1313//
1414// You should have received a copy of the GNU Affero General Public License
1515// along with this program. If not, see <http://www.gnu.org/licenses/>.
16-
1716import React from "react" ;
1817import { Theme } from "@mui/material/styles" ;
1918import createStyles from "@mui/styles/createStyles" ;
@@ -25,18 +24,15 @@ import { Card, CardHeader } from "@mui/material";
2524import { CircleIcon , VersionIcon } from "../../../../icons" ;
2625import get from "lodash/get" ;
2726import { commonDashboardInfocard } from "../../Common/FormComponents/common/styleLibrary" ;
28-
2927const styles = ( theme : Theme ) =>
3028 createStyles ( {
3129 ...commonDashboardInfocard ,
3230 } ) ;
33-
3431interface ICardProps {
3532 classes : any ;
3633 server : ServerInfo ;
3734 index : number ;
3835}
39-
4036const ServerInfoCard = ( { classes, server, index } : ICardProps ) => {
4137 const serverStatusToClass = ( health_status : string ) => {
4238 switch ( health_status ) {
@@ -48,24 +44,19 @@ const ServerInfoCard = ({ classes, server, index }: ICardProps) => {
4844 return classes . greyState ;
4945 }
5046 } ;
51-
5247 const networkKeys = Object . keys ( get ( server , "network" , { } ) ) ;
53-
5448 const networkTotal = networkKeys . length ;
5549 const totalDrives = server . drives ? server . drives . length : 0 ;
56-
5750 const activeNetwork = networkKeys . reduce ( ( acc : number , currValue : string ) => {
5851 const item = server . network [ currValue ] ;
5952 if ( item === "online" ) {
6053 return acc + 1 ;
6154 }
6255 return acc ;
6356 } , 0 ) ;
64-
6557 const activeDisks = server . drives
6658 ? server . drives . filter ( ( element ) => element . state === "ok" ) . length
6759 : 0 ;
68-
6960 return (
7061 < Card className = { classes . cardContainer } >
7162 < CardHeader
@@ -89,9 +80,10 @@ const ServerInfoCard = ({ classes, server, index }: ICardProps) => {
8980 < span
9081 className = { `${ classes . innerState } ${
9182 activeDisks <= totalDrives / 2 && classes . redState
92- } ${
93- activeDisks === totalDrives / 2 + 1 && classes . yellowState
94- } ${ activeDisks === totalDrives && classes . greenState } `}
83+ } ${
84+ totalDrives != 2 && activeDisks === totalDrives / 2 + 1 && classes . yellowState
85+ } ${
86+ activeDisks === totalDrives && classes . greenState } `}
9587 >
9688 < CircleIcon />
9789 </ span >
@@ -122,5 +114,4 @@ const ServerInfoCard = ({ classes, server, index }: ICardProps) => {
122114 </ Card >
123115 ) ;
124116} ;
125-
126- export default withStyles ( styles ) ( ServerInfoCard ) ;
117+ export default withStyles ( styles ) ( ServerInfoCard ) ;
0 commit comments