diff options
| author | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-09-17 17:55:04 +0200 |
|---|---|---|
| committer | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-09-23 10:06:03 +0200 |
| commit | eb208a7e2fd020ab5d07d11cc6d52d1e3dcfcc7c (patch) | |
| tree | d2ec8a20408b7b2880e62feaa70fe95a78c484dd /src/components/sidebars/topology/rack | |
| parent | 326b74fc39f63f47c71359276601ea93f7345dc6 (diff) | |
Add simulation mode framework
Includes object states in the store (by tick), charting, and progress bars.
Diffstat (limited to 'src/components/sidebars/topology/rack')
| -rw-r--r-- | src/components/sidebars/topology/rack/MachineComponent.js | 80 | ||||
| -rw-r--r-- | src/components/sidebars/topology/rack/RackSidebarComponent.js | 14 |
2 files changed, 57 insertions, 37 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 diff --git a/src/components/sidebars/topology/rack/RackSidebarComponent.js b/src/components/sidebars/topology/rack/RackSidebarComponent.js index 007add6e..bfcc7e32 100644 --- a/src/components/sidebars/topology/rack/RackSidebarComponent.js +++ b/src/components/sidebars/topology/rack/RackSidebarComponent.js @@ -1,14 +1,24 @@ import React from "react"; +import LoadBarContainer from "../../../../containers/sidebars/elements/LoadBarContainer"; +import LoadChartContainer from "../../../../containers/sidebars/elements/LoadChartContainer"; import DeleteRackContainer from "../../../../containers/sidebars/topology/rack/DeleteRackContainer"; import MachineListContainer from "../../../../containers/sidebars/topology/rack/MachineListContainer"; import RackNameContainer from "../../../../containers/sidebars/topology/rack/RackNameContainer"; import "./RackSidebarComponent.css"; -const RackSidebarComponent = () => { +const RackSidebarComponent = ({inSimulation, rackId}) => { return ( <div className="rack-sidebar-container flex-column"> <RackNameContainer/> - <DeleteRackContainer/> + {inSimulation ? + <div> + <LoadBarContainer objectType="rack" objectId={rackId}/> + <LoadChartContainer objectType="rack" objectId={rackId}/> + </div> : + <div> + <DeleteRackContainer/> + </div> + } <div className="machine-list-container mt-2"> <MachineListContainer/> </div> |
