From f8f617c97fcb2df3dbefc9527d974151e367cb60 Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Mon, 18 Sep 2017 16:52:11 +0200 Subject: Implement basic experiment mode with timeline The timeline doesn't trigger anything yet, but the visual element is in place and connected. --- src/pages/App.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'src/pages/App.js') diff --git a/src/pages/App.js b/src/pages/App.js index e70c7e48..87c139ec 100644 --- a/src/pages/App.js +++ b/src/pages/App.js @@ -2,10 +2,12 @@ import PropTypes from "prop-types"; import React from "react"; import {connect} from "react-redux"; import {ShortcutManager} from "react-shortcuts"; +import {openExperimentSucceeded} from "../actions/experiments"; import {openSimulationSucceeded} from "../actions/simulations"; -import {fetchLatestDatacenter, resetCurrentDatacenter} from "../actions/topology/building"; +import {resetCurrentDatacenter} from "../actions/topology/building"; import LoadingScreen from "../components/map/LoadingScreen"; import AppNavbar from "../components/navigation/AppNavbar"; +import Timeline from "../components/timeline/Timeline"; import MapStage from "../containers/map/MapStage"; import DeleteMachineModal from "../containers/modals/DeleteMachineModal"; import DeleteRackModal from "../containers/modals/DeleteRackModal"; @@ -20,15 +22,20 @@ const shortcutManager = new ShortcutManager(KeymapConfiguration); class AppComponent extends React.Component { static propTypes = { simulationId: PropTypes.number.isRequired, + inSimulation: PropTypes.bool, + experimentId: PropTypes.number, }; static childContextTypes = { shortcuts: PropTypes.object.isRequired }; componentDidMount() { - this.props.storeSimulationId(this.props.simulationId); this.props.resetCurrentDatacenter(); - this.props.fetchLatestDatacenter(); + if (this.props.inSimulation) { + this.props.openExperimentSucceeded(this.props.simulationId, this.props.experimentId); + return; + } + this.props.openSimulationSucceeded(this.props.simulationId); } getChildContext() { @@ -48,6 +55,10 @@ class AppComponent extends React.Component {
+ {this.props.inSimulation ? + : + undefined + }
} @@ -68,9 +79,10 @@ const mapStateToProps = state => { const mapDispatchToProps = dispatch => { return { - storeSimulationId: id => dispatch(openSimulationSucceeded(id)), resetCurrentDatacenter: () => dispatch(resetCurrentDatacenter()), - fetchLatestDatacenter: () => dispatch(fetchLatestDatacenter()), + openSimulationSucceeded: id => dispatch(openSimulationSucceeded(id)), + openExperimentSucceeded: (simulationId, experimentId) => + dispatch(openExperimentSucceeded(simulationId, experimentId)), }; }; -- cgit v1.2.3