From f119fc78dda4d1e828dde04f378a63a93e3a0a7e Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Thu, 2 Jul 2020 18:39:28 +0200 Subject: Add current progress on frontend port --- .../src/containers/app/map/DatacenterContainer.js | 17 ------- frontend/src/containers/app/map/MapStage.js | 6 +-- frontend/src/containers/app/map/RackContainer.js | 4 +- .../containers/app/map/RackEnergyFillContainer.js | 2 +- .../containers/app/map/RackSpaceFillContainer.js | 2 +- frontend/src/containers/app/map/TileContainer.js | 4 +- .../src/containers/app/map/TopologyContainer.js | 17 +++++++ .../containers/app/map/layers/ObjectHoverLayer.js | 2 +- .../containers/app/map/layers/RoomHoverLayer.js | 6 +-- .../simulation/ExperimentMetadataContainer.js | 12 ++--- .../app/sidebars/simulation/TaskContainer.js | 26 ---------- .../app/sidebars/simulation/TraceContainer.js | 25 ---------- .../topology/building/BuildingSidebarContainer.js | 3 +- .../topology/machine/MachineSidebarContainer.js | 2 +- .../app/sidebars/topology/machine/UnitContainer.js | 2 +- .../sidebars/topology/machine/UnitListContainer.js | 4 +- .../app/sidebars/topology/rack/MachineContainer.js | 4 +- .../sidebars/topology/rack/MachineListContainer.js | 2 +- .../sidebars/topology/rack/RackNameContainer.js | 2 +- .../sidebars/topology/rack/RackSidebarContainer.js | 2 +- .../sidebars/topology/room/EditRoomContainer.js | 5 +- .../topology/room/RackConstructionContainer.js | 5 +- .../sidebars/topology/room/RoomSidebarContainer.js | 3 +- .../sidebars/topology/room/RoomTypeContainer.js | 12 ----- .../containers/app/timeline/PlayButtonContainer.js | 5 +- .../containers/app/timeline/TimelineContainer.js | 17 +------ .../app/timeline/TimelineControlsContainer.js | 14 ------ .../experiments/ExperimentRowContainer.js | 2 +- .../src/containers/modals/ChangeTopologyModal.js | 56 ++++++++++++++++++++++ .../src/containers/modals/EditRackNameModal.js | 2 +- .../src/containers/modals/NewExperimentModal.js | 10 ++-- 31 files changed, 112 insertions(+), 163 deletions(-) delete mode 100644 frontend/src/containers/app/map/DatacenterContainer.js create mode 100644 frontend/src/containers/app/map/TopologyContainer.js delete mode 100644 frontend/src/containers/app/sidebars/simulation/TaskContainer.js delete mode 100644 frontend/src/containers/app/sidebars/simulation/TraceContainer.js delete mode 100644 frontend/src/containers/app/sidebars/topology/room/RoomTypeContainer.js create mode 100644 frontend/src/containers/modals/ChangeTopologyModal.js (limited to 'frontend/src/containers') diff --git a/frontend/src/containers/app/map/DatacenterContainer.js b/frontend/src/containers/app/map/DatacenterContainer.js deleted file mode 100644 index 9ed1d38c..00000000 --- a/frontend/src/containers/app/map/DatacenterContainer.js +++ /dev/null @@ -1,17 +0,0 @@ -import { connect } from 'react-redux' -import DatacenterGroup from '../../../components/app/map/groups/DatacenterGroup' - -const mapStateToProps = state => { - if (state.currentDatacenterId === -1) { - return {} - } - - return { - datacenter: state.objects.datacenter[state.currentDatacenterId], - interactionLevel: state.interactionLevel, - } -} - -const DatacenterContainer = connect(mapStateToProps)(DatacenterGroup) - -export default DatacenterContainer diff --git a/frontend/src/containers/app/map/MapStage.js b/frontend/src/containers/app/map/MapStage.js index e8abb86f..f749e85a 100644 --- a/frontend/src/containers/app/map/MapStage.js +++ b/frontend/src/containers/app/map/MapStage.js @@ -1,9 +1,5 @@ import { connect } from 'react-redux' -import { - setMapDimensions, - setMapPositionWithBoundsCheck, - zoomInOnPosition, -} from '../../../actions/map' +import { setMapDimensions, setMapPositionWithBoundsCheck, zoomInOnPosition } from '../../../actions/map' import MapStageComponent from '../../../components/app/map/MapStageComponent' const mapStateToProps = state => { diff --git a/frontend/src/containers/app/map/RackContainer.js b/frontend/src/containers/app/map/RackContainer.js index 614421b4..362ba2e2 100644 --- a/frontend/src/containers/app/map/RackContainer.js +++ b/frontend/src/containers/app/map/RackContainer.js @@ -9,11 +9,11 @@ const mapStateToProps = (state, ownProps) => { if (inSimulation) { if ( state.states.rack[state.currentTick] && - state.states.rack[state.currentTick][ownProps.tile.objectId] + state.states.rack[state.currentTick][ownProps.tile.rackId] ) { rackLoad = getStateLoad( state.loadMetric, - state.states.rack[state.currentTick][ownProps.tile.objectId], + state.states.rack[state.currentTick][ownProps.tile.rackId], ) } } diff --git a/frontend/src/containers/app/map/RackEnergyFillContainer.js b/frontend/src/containers/app/map/RackEnergyFillContainer.js index e25cd37d..d5989839 100644 --- a/frontend/src/containers/app/map/RackEnergyFillContainer.js +++ b/frontend/src/containers/app/map/RackEnergyFillContainer.js @@ -3,7 +3,7 @@ import RackFillBar from '../../../components/app/map/elements/RackFillBar' const mapStateToProps = (state, ownProps) => { let energyConsumptionTotal = 0 - const rack = state.objects.rack[state.objects.tile[ownProps.tileId].objectId] + const rack = state.objects.rack[state.objects.tile[ownProps.tileId].rackId] const machineIds = rack.machineIds machineIds.forEach(machineId => { if (machineId !== null) { diff --git a/frontend/src/containers/app/map/RackSpaceFillContainer.js b/frontend/src/containers/app/map/RackSpaceFillContainer.js index c43695a9..8110b1fb 100644 --- a/frontend/src/containers/app/map/RackSpaceFillContainer.js +++ b/frontend/src/containers/app/map/RackSpaceFillContainer.js @@ -3,7 +3,7 @@ import RackFillBar from '../../../components/app/map/elements/RackFillBar' const mapStateToProps = (state, ownProps) => { const machineIds = - state.objects.rack[state.objects.tile[ownProps.tileId].objectId].machineIds + state.objects.rack[state.objects.tile[ownProps.tileId].rackId].machineIds return { type: 'space', fillFraction: diff --git a/frontend/src/containers/app/map/TileContainer.js b/frontend/src/containers/app/map/TileContainer.js index 6122be96..7d9f7754 100644 --- a/frontend/src/containers/app/map/TileContainer.js +++ b/frontend/src/containers/app/map/TileContainer.js @@ -31,8 +31,8 @@ const mapStateToProps = (state, ownProps) => { const mapDispatchToProps = dispatch => { return { onClick: tile => { - if (tile.objectType) { - dispatch(goFromRoomToRack(tile.id)) + if (tile.rackId) { + dispatch(goFromRoomToRack(tile._id)) } }, } diff --git a/frontend/src/containers/app/map/TopologyContainer.js b/frontend/src/containers/app/map/TopologyContainer.js new file mode 100644 index 00000000..37cc5a06 --- /dev/null +++ b/frontend/src/containers/app/map/TopologyContainer.js @@ -0,0 +1,17 @@ +import { connect } from 'react-redux' +import TopologyGroup from '../../../components/app/map/groups/TopologyGroup' + +const mapStateToProps = state => { + if (state.currentTopologyId === -1) { + return {} + } + + return { + topology: state.objects.topology[state.currentTopologyId], + interactionLevel: state.interactionLevel, + } +} + +const TopologyContainer = connect(mapStateToProps)(TopologyGroup) + +export default TopologyContainer diff --git a/frontend/src/containers/app/map/layers/ObjectHoverLayer.js b/frontend/src/containers/app/map/layers/ObjectHoverLayer.js index dc489e82..4619c0b8 100644 --- a/frontend/src/containers/app/map/layers/ObjectHoverLayer.js +++ b/frontend/src/containers/app/map/layers/ObjectHoverLayer.js @@ -19,7 +19,7 @@ const mapStateToProps = state => { ) const tile = findTileWithPosition(tiles, x, y) - return !(tile === null || tile.objectType) + return !(tile === null || tile.rackId) }, } } diff --git a/frontend/src/containers/app/map/layers/RoomHoverLayer.js b/frontend/src/containers/app/map/layers/RoomHoverLayer.js index b5a891ce..c05627ea 100644 --- a/frontend/src/containers/app/map/layers/RoomHoverLayer.js +++ b/frontend/src/containers/app/map/layers/RoomHoverLayer.js @@ -21,9 +21,9 @@ const mapStateToProps = state => { .map(id => Object.assign({}, state.objects.room[id])) .filter( room => - state.objects.datacenter[state.currentDatacenterId].roomIds.indexOf( - room.id, - ) !== -1 && room.id !== state.construction.currentRoomInConstruction, + state.objects.topology[state.currentTopologyId].roomIds.indexOf( + room._id, + ) !== -1 && room._id !== state.construction.currentRoomInConstruction, ); [...oldRooms, newRoom].forEach(room => { diff --git a/frontend/src/containers/app/sidebars/simulation/ExperimentMetadataContainer.js b/frontend/src/containers/app/sidebars/simulation/ExperimentMetadataContainer.js index 06d0b88a..0dc20ea7 100644 --- a/frontend/src/containers/app/sidebars/simulation/ExperimentMetadataContainer.js +++ b/frontend/src/containers/app/sidebars/simulation/ExperimentMetadataContainer.js @@ -5,21 +5,21 @@ const mapStateToProps = state => { if (!state.objects.experiment[state.currentExperimentId]) { return { experimentName: 'Loading experiment', - pathName: '', + topologyName: '', traceName: '', schedulerName: '', } } - const path = - state.objects.path[ - state.objects.experiment[state.currentExperimentId].pathId + const topology = + state.objects.topology[ + state.objects.experiment[state.currentExperimentId].topologyId ] - const pathName = path.name ? path.name : 'Path ' + path.id + const topologyName = topology.name return { experimentName: state.objects.experiment[state.currentExperimentId].name, - pathName, + topologyName, traceName: state.objects.trace[ state.objects.experiment[state.currentExperimentId].traceId diff --git a/frontend/src/containers/app/sidebars/simulation/TaskContainer.js b/frontend/src/containers/app/sidebars/simulation/TaskContainer.js deleted file mode 100644 index c4c86284..00000000 --- a/frontend/src/containers/app/sidebars/simulation/TaskContainer.js +++ /dev/null @@ -1,26 +0,0 @@ -import { connect } from 'react-redux' -import TaskComponent from '../../../../components/app/sidebars/simulation/TaskComponent' - -const mapStateToProps = (state, ownProps) => { - let flopsLeft = state.objects.task[ownProps.taskId].totalFlopCount - - if ( - state.states.task[state.currentTick] && - state.states.task[state.currentTick][ownProps.taskId] - ) { - flopsLeft = state.states.task[state.currentTick][ownProps.taskId].flopsLeft - } else if ( - state.objects.task[ownProps.taskId].startTick < state.currentTick - ) { - flopsLeft = 0 - } - - return { - task: state.objects.task[ownProps.taskId], - flopsLeft, - } -} - -const TaskContainer = connect(mapStateToProps)(TaskComponent) - -export default TaskContainer diff --git a/frontend/src/containers/app/sidebars/simulation/TraceContainer.js b/frontend/src/containers/app/sidebars/simulation/TraceContainer.js deleted file mode 100644 index 907c8874..00000000 --- a/frontend/src/containers/app/sidebars/simulation/TraceContainer.js +++ /dev/null @@ -1,25 +0,0 @@ -import { connect } from 'react-redux' -import TraceComponent from '../../../../components/app/sidebars/simulation/TraceComponent' - -const mapStateToProps = state => { - if ( - !state.objects.experiment[state.currentExperimentId] || - !state.objects.trace[ - state.objects.experiment[state.currentExperimentId].traceId - ].jobIds - ) { - return { - jobs: [], - } - } - - return { - jobs: state.objects.trace[ - state.objects.experiment[state.currentExperimentId].traceId - ].jobIds.map(id => state.objects.job[id]), - } -} - -const TraceContainer = connect(mapStateToProps)(TraceComponent) - -export default TraceContainer diff --git a/frontend/src/containers/app/sidebars/topology/building/BuildingSidebarContainer.js b/frontend/src/containers/app/sidebars/topology/building/BuildingSidebarContainer.js index 711b2b82..1869705a 100644 --- a/frontend/src/containers/app/sidebars/topology/building/BuildingSidebarContainer.js +++ b/frontend/src/containers/app/sidebars/topology/building/BuildingSidebarContainer.js @@ -1,6 +1,5 @@ import { connect } from 'react-redux' -import BuildingSidebarComponent - from '../../../../../components/app/sidebars/topology/building/BuildingSidebarComponent' +import BuildingSidebarComponent from '../../../../../components/app/sidebars/topology/building/BuildingSidebarComponent' const mapStateToProps = state => { return { diff --git a/frontend/src/containers/app/sidebars/topology/machine/MachineSidebarContainer.js b/frontend/src/containers/app/sidebars/topology/machine/MachineSidebarContainer.js index f5baee44..a39bd2d6 100644 --- a/frontend/src/containers/app/sidebars/topology/machine/MachineSidebarContainer.js +++ b/frontend/src/containers/app/sidebars/topology/machine/MachineSidebarContainer.js @@ -6,7 +6,7 @@ const mapStateToProps = state => { inSimulation: state.currentExperimentId !== -1, machineId: state.objects.rack[ - state.objects.tile[state.interactionLevel.tileId].objectId + state.objects.tile[state.interactionLevel.tileId].rackId ].machineIds[state.interactionLevel.position - 1], } } diff --git a/frontend/src/containers/app/sidebars/topology/machine/UnitContainer.js b/frontend/src/containers/app/sidebars/topology/machine/UnitContainer.js index 1a01cad0..d8e549a7 100644 --- a/frontend/src/containers/app/sidebars/topology/machine/UnitContainer.js +++ b/frontend/src/containers/app/sidebars/topology/machine/UnitContainer.js @@ -4,8 +4,8 @@ import UnitComponent from '../../../../../components/app/sidebars/topology/machi const mapStateToProps = (state, ownProps) => { return { - unit: state.objects[ownProps.unitType][ownProps.unitId], inSimulation: state.currentExperimentId !== -1, + unit: state.objects[ownProps.unitType][ownProps.unitId], } } diff --git a/frontend/src/containers/app/sidebars/topology/machine/UnitListContainer.js b/frontend/src/containers/app/sidebars/topology/machine/UnitListContainer.js index fce657d4..2f11a22f 100644 --- a/frontend/src/containers/app/sidebars/topology/machine/UnitListContainer.js +++ b/frontend/src/containers/app/sidebars/topology/machine/UnitListContainer.js @@ -3,13 +3,13 @@ import UnitListComponent from '../../../../../components/app/sidebars/topology/m const mapStateToProps = (state, ownProps) => { return { + inSimulation: state.currentExperimentId !== -1, unitIds: state.objects.machine[ state.objects.rack[ - state.objects.tile[state.interactionLevel.tileId].objectId + state.objects.tile[state.interactionLevel.tileId].rackId ].machineIds[state.interactionLevel.position - 1] ][ownProps.unitType + 'Ids'], - inSimulation: state.currentExperimentId !== -1, } } diff --git a/frontend/src/containers/app/sidebars/topology/rack/MachineContainer.js b/frontend/src/containers/app/sidebars/topology/rack/MachineContainer.js index f205257e..89818f1d 100644 --- a/frontend/src/containers/app/sidebars/topology/rack/MachineContainer.js +++ b/frontend/src/containers/app/sidebars/topology/rack/MachineContainer.js @@ -11,11 +11,11 @@ const mapStateToProps = (state, ownProps) => { if (inSimulation) { if ( state.states.machine[state.currentTick] && - state.states.machine[state.currentTick][machine.id] + state.states.machine[state.currentTick][machine._id] ) { machineLoad = getStateLoad( state.loadMetric, - state.states.machine[state.currentTick][machine.id], + state.states.machine[state.currentTick][machine._id], ) } } diff --git a/frontend/src/containers/app/sidebars/topology/rack/MachineListContainer.js b/frontend/src/containers/app/sidebars/topology/rack/MachineListContainer.js index 3a797ed5..3898d119 100644 --- a/frontend/src/containers/app/sidebars/topology/rack/MachineListContainer.js +++ b/frontend/src/containers/app/sidebars/topology/rack/MachineListContainer.js @@ -5,7 +5,7 @@ const mapStateToProps = state => { return { machineIds: state.objects.rack[ - state.objects.tile[state.interactionLevel.tileId].objectId + state.objects.tile[state.interactionLevel.tileId].rackId ].machineIds, } } diff --git a/frontend/src/containers/app/sidebars/topology/rack/RackNameContainer.js b/frontend/src/containers/app/sidebars/topology/rack/RackNameContainer.js index 11173b82..1eb885fc 100644 --- a/frontend/src/containers/app/sidebars/topology/rack/RackNameContainer.js +++ b/frontend/src/containers/app/sidebars/topology/rack/RackNameContainer.js @@ -6,7 +6,7 @@ const mapStateToProps = state => { return { rackName: state.objects.rack[ - state.objects.tile[state.interactionLevel.tileId].objectId + state.objects.tile[state.interactionLevel.tileId].rackId ].name, } } diff --git a/frontend/src/containers/app/sidebars/topology/rack/RackSidebarContainer.js b/frontend/src/containers/app/sidebars/topology/rack/RackSidebarContainer.js index 89382ef0..21745b1d 100644 --- a/frontend/src/containers/app/sidebars/topology/rack/RackSidebarContainer.js +++ b/frontend/src/containers/app/sidebars/topology/rack/RackSidebarContainer.js @@ -3,7 +3,7 @@ import RackSidebarComponent from '../../../../../components/app/sidebars/topolog const mapStateToProps = state => { return { - rackId: state.objects.tile[state.interactionLevel.tileId].objectId, + rackId: state.objects.tile[state.interactionLevel.tileId].rackId, inSimulation: state.currentExperimentId !== -1, } } diff --git a/frontend/src/containers/app/sidebars/topology/room/EditRoomContainer.js b/frontend/src/containers/app/sidebars/topology/room/EditRoomContainer.js index 29014022..87470bfe 100644 --- a/frontend/src/containers/app/sidebars/topology/room/EditRoomContainer.js +++ b/frontend/src/containers/app/sidebars/topology/room/EditRoomContainer.js @@ -1,8 +1,5 @@ import { connect } from 'react-redux' -import { - finishRoomEdit, - startRoomEdit, -} from '../../../../../actions/topology/building' +import { finishRoomEdit, startRoomEdit } from '../../../../../actions/topology/building' import EditRoomComponent from '../../../../../components/app/sidebars/topology/room/EditRoomComponent' const mapStateToProps = state => { diff --git a/frontend/src/containers/app/sidebars/topology/room/RackConstructionContainer.js b/frontend/src/containers/app/sidebars/topology/room/RackConstructionContainer.js index fe42647c..30f7a688 100644 --- a/frontend/src/containers/app/sidebars/topology/room/RackConstructionContainer.js +++ b/frontend/src/containers/app/sidebars/topology/room/RackConstructionContainer.js @@ -1,8 +1,5 @@ import { connect } from 'react-redux' -import { - startRackConstruction, - stopRackConstruction, -} from '../../../../../actions/topology/room' +import { startRackConstruction, stopRackConstruction } from '../../../../../actions/topology/room' import RackConstructionComponent from '../../../../../components/app/sidebars/topology/room/RackConstructionComponent' const mapStateToProps = state => { diff --git a/frontend/src/containers/app/sidebars/topology/room/RoomSidebarContainer.js b/frontend/src/containers/app/sidebars/topology/room/RoomSidebarContainer.js index f940b282..443495de 100644 --- a/frontend/src/containers/app/sidebars/topology/room/RoomSidebarContainer.js +++ b/frontend/src/containers/app/sidebars/topology/room/RoomSidebarContainer.js @@ -3,9 +3,8 @@ import RoomSidebarComponent from '../../../../../components/app/sidebars/topolog const mapStateToProps = state => { return { - roomId: state.interactionLevel.roomId, - roomType: state.objects.room[state.interactionLevel.roomId].roomType, inSimulation: state.currentExperimentId !== -1, + roomId: state.interactionLevel.roomId, } } diff --git a/frontend/src/containers/app/sidebars/topology/room/RoomTypeContainer.js b/frontend/src/containers/app/sidebars/topology/room/RoomTypeContainer.js deleted file mode 100644 index de4c8c85..00000000 --- a/frontend/src/containers/app/sidebars/topology/room/RoomTypeContainer.js +++ /dev/null @@ -1,12 +0,0 @@ -import { connect } from 'react-redux' -import RoomTypeComponent from '../../../../../components/app/sidebars/topology/room/RoomTypeComponent' - -const mapStateToProps = state => { - return { - roomType: state.objects.room[state.interactionLevel.roomId].roomType, - } -} - -const RoomNameContainer = connect(mapStateToProps)(RoomTypeComponent) - -export default RoomNameContainer diff --git a/frontend/src/containers/app/timeline/PlayButtonContainer.js b/frontend/src/containers/app/timeline/PlayButtonContainer.js index e332f08b..9662d753 100644 --- a/frontend/src/containers/app/timeline/PlayButtonContainer.js +++ b/frontend/src/containers/app/timeline/PlayButtonContainer.js @@ -1,8 +1,5 @@ import { connect } from 'react-redux' -import { - pauseSimulation, - playSimulation, -} from '../../../actions/simulation/playback' +import { pauseSimulation, playSimulation } from '../../../actions/simulation/playback' import PlayButtonComponent from '../../../components/app/timeline/PlayButtonComponent' const mapStateToProps = state => { diff --git a/frontend/src/containers/app/timeline/TimelineContainer.js b/frontend/src/containers/app/timeline/TimelineContainer.js index 4fcaaaaf..9b196a1b 100644 --- a/frontend/src/containers/app/timeline/TimelineContainer.js +++ b/frontend/src/containers/app/timeline/TimelineContainer.js @@ -1,28 +1,14 @@ import { connect } from 'react-redux' import { pauseSimulation } from '../../../actions/simulation/playback' import { incrementTick } from '../../../actions/simulation/tick' -import { setCurrentDatacenter } from '../../../actions/topology/building' import TimelineComponent from '../../../components/app/timeline/TimelineComponent' const mapStateToProps = state => { - let sections = [] - if (state.currentExperimentId !== -1) { - const sectionIds = - state.objects.path[ - state.objects.experiment[state.currentExperimentId].pathId - ].sectionIds - - if (sectionIds) { - sections = sectionIds.map(sectionId => state.objects.section[sectionId]) - } - } - return { isPlaying: state.isPlaying, currentTick: state.currentTick, lastSimulatedTick: state.lastSimulatedTick, - currentDatacenterId: state.currentDatacenterId, - sections, + currentTopologyId: state.currentTopologyId, } } @@ -30,7 +16,6 @@ const mapDispatchToProps = dispatch => { return { incrementTick: () => dispatch(incrementTick()), pauseSimulation: () => dispatch(pauseSimulation()), - setCurrentDatacenter: id => dispatch(setCurrentDatacenter(id)), } } diff --git a/frontend/src/containers/app/timeline/TimelineControlsContainer.js b/frontend/src/containers/app/timeline/TimelineControlsContainer.js index 92e03e6a..91aba98d 100644 --- a/frontend/src/containers/app/timeline/TimelineControlsContainer.js +++ b/frontend/src/containers/app/timeline/TimelineControlsContainer.js @@ -3,23 +3,9 @@ import { goToTick } from '../../../actions/simulation/tick' import TimelineControlsComponent from '../../../components/app/timeline/TimelineControlsComponent' const mapStateToProps = state => { - let sectionTicks = [] - if (state.currentExperimentId !== -1) { - const sectionIds = - state.objects.path[ - state.objects.experiment[state.currentExperimentId].pathId - ].sectionIds - if (sectionIds) { - sectionTicks = sectionIds - .filter(sectionId => state.objects.section[sectionId].startTick !== 0) - .map(sectionId => state.objects.section[sectionId].startTick) - } - } - return { currentTick: state.currentTick, lastSimulatedTick: state.lastSimulatedTick, - sectionTicks, } } diff --git a/frontend/src/containers/experiments/ExperimentRowContainer.js b/frontend/src/containers/experiments/ExperimentRowContainer.js index bec32617..523c0747 100644 --- a/frontend/src/containers/experiments/ExperimentRowContainer.js +++ b/frontend/src/containers/experiments/ExperimentRowContainer.js @@ -9,7 +9,7 @@ const mapStateToProps = (state, ownProps) => { ) experiment.trace = state.objects.trace[experiment.traceId] experiment.scheduler = state.objects.scheduler[experiment.schedulerName] - experiment.path = state.objects.path[experiment.pathId] + experiment.topology = state.objects.topology[experiment.topologyId] return { experiment, diff --git a/frontend/src/containers/modals/ChangeTopologyModal.js b/frontend/src/containers/modals/ChangeTopologyModal.js new file mode 100644 index 00000000..bd364194 --- /dev/null +++ b/frontend/src/containers/modals/ChangeTopologyModal.js @@ -0,0 +1,56 @@ +import { connect } from 'react-redux' +import ChangeTopologyModalComponent from '../../components/modals/custom-components/ChangeTopologyModalComponent' +import { closeChangeTopologyModal } from '../../actions/modals/topology' +import { addTopology, deleteTopology } from '../../actions/topologies' + +const mapStateToProps = state => { + let topologies = state.objects.simulation[state.currentSimulationId] ? state.objects.simulation[state.currentSimulationId].topologyIds.map(t => ( + state.objects.topology[t] + )) : [] + if (topologies.filter(t => !t).length > 0) { + topologies = [] + } + + return { + show: state.modals.newExperimentModalVisible, + topologies, + } +} + +const mapDispatchToProps = dispatch => { + return { + onCreateTopology: (name) => { + if (name) { + dispatch( + addTopology({name}) + ) + } + dispatch(closeChangeTopologyModal()) + }, + onDuplicateTopology: (name) => { + if (name) { + // TODO different handling here + dispatch( + addTopology({name}) + ) + } + dispatch(closeChangeTopologyModal()) + }, + onDeleteTopology: (id) => { + if (id) { + dispatch( + deleteTopology(id) + ) + } + }, + onCancel: () => { + dispatch(closeChangeTopologyModal()) + }, + } +} + +const ChangeTopologyModal = connect(mapStateToProps, mapDispatchToProps)( + ChangeTopologyModalComponent, +) + +export default ChangeTopologyModal diff --git a/frontend/src/containers/modals/EditRackNameModal.js b/frontend/src/containers/modals/EditRackNameModal.js index e5c87e35..495c107b 100644 --- a/frontend/src/containers/modals/EditRackNameModal.js +++ b/frontend/src/containers/modals/EditRackNameModal.js @@ -20,7 +20,7 @@ const mapStateToProps = state => { previousName: state.interactionLevel.mode === 'RACK' ? state.objects.rack[ - state.objects.tile[state.interactionLevel.tileId].objectId + state.objects.tile[state.interactionLevel.tileId].rackId ].name : '', } diff --git a/frontend/src/containers/modals/NewExperimentModal.js b/frontend/src/containers/modals/NewExperimentModal.js index db60f088..2ac5a4b8 100644 --- a/frontend/src/containers/modals/NewExperimentModal.js +++ b/frontend/src/containers/modals/NewExperimentModal.js @@ -6,9 +6,9 @@ import NewExperimentModalComponent from '../../components/modals/custom-componen const mapStateToProps = state => { return { show: state.modals.newExperimentModalVisible, - paths: Object.values(state.objects.path).filter( - path => path.simulationId === state.currentSimulationId, - ), + topologies: state.objects.simulation[state.currentSimulationId].topologyIds.map(t => ( + state.objects.topology[t] + )), traces: Object.values(state.objects.trace), schedulers: Object.values(state.objects.scheduler), } @@ -16,12 +16,12 @@ const mapStateToProps = state => { const mapDispatchToProps = dispatch => { return { - callback: (name, pathId, traceId, schedulerName) => { + callback: (name, topologyId, traceId, schedulerName) => { if (name) { dispatch( addExperiment({ name, - pathId, + topologyId, traceId, schedulerName, }), -- cgit v1.2.3