diff options
Diffstat (limited to 'src/components/sidebars/topology/rack/MachineComponent.js')
| -rw-r--r-- | src/components/sidebars/topology/rack/MachineComponent.js | 80 |
1 files changed, 45 insertions, 35 deletions
diff --git a/src/components/sidebars/topology/rack/MachineComponent.js b/src/components/sidebars/topology/rack/MachineComponent.js index 4854456c..b6e9791d 100644 --- a/src/components/sidebars/topology/rack/MachineComponent.js +++ b/src/components/sidebars/topology/rack/MachineComponent.js @@ -1,5 +1,6 @@ import React from "react"; import Shapes from "../../../../shapes"; +import {convertLoadToSimulationColor} from "../../../../util/simulation-load"; const UnitIcon = ({id, type}) => ( <div> @@ -12,41 +13,50 @@ const UnitIcon = ({id, type}) => ( </div> ); -const MachineComponent = ({position, machine, onClick}) => ( - <li - className="d-flex list-group-item list-group-item-action justify-content-between align-items-center" - onClick={onClick} - > - <span className="badge badge-default badge-info mr-1"> - {position} - </span> - <div className="d-inline-flex"> - {machine.cpuIds.length > 0 ? - <UnitIcon id="cpu" type="CPU"/> : - undefined - } - {machine.gpuIds.length > 0 ? - <UnitIcon id="gpu" type="GPU"/> : - undefined - } - {machine.memoryIds.length > 0 ? - <UnitIcon id="memory" type="memory"/> : - undefined - } - {machine.storageIds.length > 0 ? - <UnitIcon id="storage" type="storage"/> : - undefined - } - {machine.cpuIds.length + machine.gpuIds.length + machine.memoryIds.length - + machine.storageIds.length === 0 ? - <span className="badge badge-default badge-warning"> - Machine with no units - </span> : - undefined - } - </div> - </li> -); +const MachineComponent = ({position, machine, inSimulation, machineLoad, onClick}) => { + let color = "white"; + if (inSimulation) { + color = convertLoadToSimulationColor(machineLoad); + } + const hasNoUnits = machine.cpuIds.length + machine.gpuIds.length + machine.memoryIds.length + + machine.storageIds.length === 0; + + return ( + <li + className="d-flex list-group-item list-group-item-action justify-content-between align-items-center" + onClick={onClick} + style={{backgroundColor: color}} + > + <span className="badge badge-default badge-info mr-1"> + {position} + </span> + <div className="d-inline-flex"> + {machine.cpuIds.length > 0 ? + <UnitIcon id="cpu" type="CPU"/> : + undefined + } + {machine.gpuIds.length > 0 ? + <UnitIcon id="gpu" type="GPU"/> : + undefined + } + {machine.memoryIds.length > 0 ? + <UnitIcon id="memory" type="memory"/> : + undefined + } + {machine.storageIds.length > 0 ? + <UnitIcon id="storage" type="storage"/> : + undefined + } + {hasNoUnits ? + <span className="badge badge-default badge-warning"> + Machine with no units + </span> : + undefined + } + </div> + </li> + ); +}; MachineComponent.propTypes = { machine: Shapes.Machine |
