summaryrefslogtreecommitdiff
path: root/src/pages/App.js
diff options
context:
space:
mode:
authorGeorgios Andreadis <G.Andreadis@student.tudelft.nl>2017-10-04 23:23:09 +0200
committerGitHub <noreply@github.com>2017-10-04 23:23:09 +0200
commitfcaaae65d34003874c76e0c01134dedf94248e09 (patch)
tree2aae1422168651e832a1904623f6f5b100fc17ec /src/pages/App.js
parent0a62dfb55c5700013d42a589b930c7448e5bff71 (diff)
parent606d1de0be09f3597165248f65d54e158a13860c (diff)
Merge pull request #42 from atlarge-research/auto-reformat
Standardize code format
Diffstat (limited to 'src/pages/App.js')
-rw-r--r--src/pages/App.js168
1 files changed, 89 insertions, 79 deletions
diff --git a/src/pages/App.js b/src/pages/App.js
index 801aefcd..ad201e7d 100644
--- a/src/pages/App.js
+++ b/src/pages/App.js
@@ -1,11 +1,11 @@
import PropTypes from "prop-types";
import React from "react";
import DocumentTitle from "react-document-title";
-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 { 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 ToolPanelComponent from "../components/app/map/controls/ToolPanelComponent";
import LoadingScreen from "../components/app/map/LoadingScreen";
import SimulationSidebarComponent from "../components/app/sidebars/simulation/SimulationSidebarComponent";
@@ -24,92 +24,102 @@ import KeymapConfiguration from "../shortcuts/keymap";
const shortcutManager = new ShortcutManager(KeymapConfiguration);
class AppComponent extends React.Component {
- static propTypes = {
- simulationId: PropTypes.number.isRequired,
- inSimulation: PropTypes.bool,
- experimentId: PropTypes.number,
- simulationName: PropTypes.string,
- };
- static childContextTypes = {
- shortcuts: PropTypes.object.isRequired
- };
+ static propTypes = {
+ simulationId: PropTypes.number.isRequired,
+ inSimulation: PropTypes.bool,
+ experimentId: PropTypes.number,
+ simulationName: PropTypes.string
+ };
+ static childContextTypes = {
+ shortcuts: PropTypes.object.isRequired
+ };
- componentDidMount() {
- this.props.resetCurrentDatacenter();
- if (this.props.inSimulation) {
- this.props.openExperimentSucceeded(this.props.simulationId, this.props.experimentId);
- return;
- }
- this.props.openSimulationSucceeded(this.props.simulationId);
+ componentDidMount() {
+ this.props.resetCurrentDatacenter();
+ if (this.props.inSimulation) {
+ this.props.openExperimentSucceeded(
+ this.props.simulationId,
+ this.props.experimentId
+ );
+ return;
}
+ this.props.openSimulationSucceeded(this.props.simulationId);
+ }
- getChildContext() {
- return {
- shortcuts: shortcutManager
- }
- }
+ getChildContext() {
+ return {
+ shortcuts: shortcutManager
+ };
+ }
- render() {
- return (
- <DocumentTitle
- title={this.props.simulationName ? this.props.simulationName + " - OpenDC" : "Simulation - OpenDC"}
- >
- <div className="page-container full-height">
- <AppNavbar simulationId={this.props.simulationId} inSimulation={true} fullWidth={true}/>
- {this.props.datacenterIsLoading ?
- <div className="full-height d-flex align-items-center justify-content-center">
- <LoadingScreen/>
- </div> :
- <div className="full-height">
- <MapStage/>
- <ScaleIndicatorContainer/>
- <ToolPanelComponent/>
- <TopologySidebar/>
- {this.props.inSimulation ?
- <TimelineContainer/> :
- undefined
- }
- {this.props.inSimulation ?
- <SimulationSidebarComponent/> :
- undefined
- }
- </div>
- }
- <EditRoomNameModal/>
- <DeleteRoomModal/>
- <EditRackNameModal/>
- <DeleteRackModal/>
- <DeleteMachineModal/>
- </div>
- </DocumentTitle>
- );
- }
+ render() {
+ return (
+ <DocumentTitle
+ title={
+ this.props.simulationName
+ ? this.props.simulationName + " - OpenDC"
+ : "Simulation - OpenDC"
+ }
+ >
+ <div className="page-container full-height">
+ <AppNavbar
+ simulationId={this.props.simulationId}
+ inSimulation={true}
+ fullWidth={true}
+ />
+ {this.props.datacenterIsLoading ? (
+ <div className="full-height d-flex align-items-center justify-content-center">
+ <LoadingScreen />
+ </div>
+ ) : (
+ <div className="full-height">
+ <MapStage />
+ <ScaleIndicatorContainer />
+ <ToolPanelComponent />
+ <TopologySidebar />
+ {this.props.inSimulation ? <TimelineContainer /> : undefined}
+ {this.props.inSimulation ? (
+ <SimulationSidebarComponent />
+ ) : (
+ undefined
+ )}
+ </div>
+ )}
+ <EditRoomNameModal />
+ <DeleteRoomModal />
+ <EditRackNameModal />
+ <DeleteRackModal />
+ <DeleteMachineModal />
+ </div>
+ </DocumentTitle>
+ );
+ }
}
const mapStateToProps = state => {
- let simulationName = undefined;
- if (state.currentSimulationId !== -1 && state.objects.simulation[state.currentSimulationId]) {
- simulationName = state.objects.simulation[state.currentSimulationId].name;
- }
+ let simulationName = undefined;
+ if (
+ state.currentSimulationId !== -1 &&
+ state.objects.simulation[state.currentSimulationId]
+ ) {
+ simulationName = state.objects.simulation[state.currentSimulationId].name;
+ }
- return {
- datacenterIsLoading: state.currentDatacenterId === -1,
- simulationName,
- };
+ return {
+ datacenterIsLoading: state.currentDatacenterId === -1,
+ simulationName
+ };
};
const mapDispatchToProps = dispatch => {
- return {
- resetCurrentDatacenter: () => dispatch(resetCurrentDatacenter()),
- openSimulationSucceeded: id => dispatch(openSimulationSucceeded(id)),
- openExperimentSucceeded: (simulationId, experimentId) =>
- dispatch(openExperimentSucceeded(simulationId, experimentId)),
- };
+ return {
+ resetCurrentDatacenter: () => dispatch(resetCurrentDatacenter()),
+ openSimulationSucceeded: id => dispatch(openSimulationSucceeded(id)),
+ openExperimentSucceeded: (simulationId, experimentId) =>
+ dispatch(openExperimentSucceeded(simulationId, experimentId))
+ };
};
-const App = connect(
- mapStateToProps,
- mapDispatchToProps
-)(AppComponent);
+const App = connect(mapStateToProps, mapDispatchToProps)(AppComponent);
export default App;