summaryrefslogtreecommitdiff
path: root/src/pages/App.js
diff options
context:
space:
mode:
authorGeorgios Andreadis <g.andreadis@student.tudelft.nl>2017-09-22 13:39:50 +0200
committerGeorgios Andreadis <g.andreadis@student.tudelft.nl>2017-09-23 10:06:07 +0200
commitd628e0ac5162bb1baeb16fcf21b688d37bbff758 (patch)
treea26163a319e60e2a99893aadfe7f1cd6fad9363f /src/pages/App.js
parent5633c36d49c4ffd61688b0d05182934973fdd3ce (diff)
Implement dynamic web page document title change
Diffstat (limited to 'src/pages/App.js')
-rw-r--r--src/pages/App.js66
1 files changed, 39 insertions, 27 deletions
diff --git a/src/pages/App.js b/src/pages/App.js
index 8e74bfa5..8f46156b 100644
--- a/src/pages/App.js
+++ b/src/pages/App.js
@@ -1,5 +1,6 @@
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";
@@ -27,6 +28,7 @@ class AppComponent extends React.Component {
simulationId: PropTypes.number.isRequired,
inSimulation: PropTypes.bool,
experimentId: PropTypes.number,
+ simulationName: PropTypes.string,
};
static childContextTypes = {
shortcuts: PropTypes.object.isRequired
@@ -49,40 +51,50 @@ class AppComponent extends React.Component {
render() {
return (
- <div className="page-container full-height">
- <AppNavbar simulationId={this.props.simulationId} inSimulation={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
+ title={this.props.simulationName ? this.props.simulationName + " - OpenDC" : "Simulation - OpenDC"}
+ >
+ <div className="page-container full-height">
+ <AppNavbar simulationId={this.props.simulationId} inSimulation={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;
+ }
+
return {
datacenterIsLoading: state.currentDatacenterId === -1,
+ simulationName,
};
};