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 --- frontend/src/pages/App.js | 66 +++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 37 deletions(-) (limited to 'frontend/src/pages/App.js') diff --git a/frontend/src/pages/App.js b/frontend/src/pages/App.js index c2b9bd51..3034f7ff 100644 --- a/frontend/src/pages/App.js +++ b/frontend/src/pages/App.js @@ -5,7 +5,7 @@ import { connect } from 'react-redux' import { ShortcutManager } from 'react-shortcuts' import { openExperimentSucceeded } from '../actions/experiments' import { openSimulationSucceeded } from '../actions/simulations' -import { resetCurrentDatacenter } from '../actions/topology/building' +import { resetCurrentTopology } from '../actions/topology/building' import ToolPanelComponent from '../components/app/map/controls/ToolPanelComponent' import LoadingScreen from '../components/app/map/LoadingScreen' import SimulationSidebarComponent from '../components/app/sidebars/simulation/SimulationSidebarComponent' @@ -20,6 +20,8 @@ import DeleteRoomModal from '../containers/modals/DeleteRoomModal' import EditRackNameModal from '../containers/modals/EditRackNameModal' import EditRoomNameModal from '../containers/modals/EditRoomNameModal' import KeymapConfiguration from '../shortcuts/keymap' +import ChangeTopologyModal from '../containers/modals/ChangeTopologyModal' +import { openChangeTopologyModal } from '../actions/modals/topology' const shortcutManager = new ShortcutManager(KeymapConfiguration) @@ -29,18 +31,16 @@ class AppComponent extends React.Component { inSimulation: PropTypes.bool, experimentId: PropTypes.number, simulationName: PropTypes.string, + onViewTopologies: PropTypes.func, } static childContextTypes = { shortcuts: PropTypes.object.isRequired, } componentDidMount() { - this.props.resetCurrentDatacenter() + // TODO this.props.resetCurrentTopology() if (this.props.inSimulation) { - this.props.openExperimentSucceeded( - this.props.simulationId, - this.props.experimentId, - ) + this.props.openExperimentSucceeded(this.props.simulationId, this.props.experimentId) return } this.props.openSimulationSucceeded(this.props.simulationId) @@ -55,66 +55,58 @@ class AppComponent extends React.Component { render() { return (
- {this.props.datacenterIsLoading ? ( + {this.props.topologyIsLoading ? (
- +
) : (
- - - - - {this.props.inSimulation ? : undefined} - {this.props.inSimulation ? ( - - ) : ( - undefined - )} + + + + + {this.props.inSimulation ? : undefined} + {this.props.inSimulation ? : undefined}
)} - - - - - + + + + + +
) } } -const mapStateToProps = state => { +const mapStateToProps = (state) => { let simulationName = undefined - if ( - state.currentSimulationId !== -1 && - state.objects.simulation[state.currentSimulationId] - ) { + if (state.currentSimulationId !== -1 && state.objects.simulation[state.currentSimulationId]) { simulationName = state.objects.simulation[state.currentSimulationId].name } return { - datacenterIsLoading: state.currentDatacenterId === -1, + topologyIsLoading: state.currentTopologyId === -1, simulationName, } } -const mapDispatchToProps = dispatch => { +const mapDispatchToProps = (dispatch) => { return { - resetCurrentDatacenter: () => dispatch(resetCurrentDatacenter()), - openSimulationSucceeded: id => dispatch(openSimulationSucceeded(id)), + resetCurrentTopology: () => dispatch(resetCurrentTopology()), + openSimulationSucceeded: (id) => dispatch(openSimulationSucceeded(id)), + onViewTopologies: () => dispatch(openChangeTopologyModal()), openExperimentSucceeded: (simulationId, experimentId) => dispatch(openExperimentSucceeded(simulationId, experimentId)), } -- cgit v1.2.3