diff options
| author | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-09-09 10:16:15 +0200 |
|---|---|---|
| committer | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-09-23 10:05:59 +0200 |
| commit | de24c69fe44df73c355a3ec481c7f146778cb4a6 (patch) | |
| tree | 3fc70b7c303453923f91dc31c67c34208b9127a0 | |
| parent | 0c15fdab70d433b6f5338176c3359e7a6ff0ff57 (diff) | |
Add a loading screen for initial datacenter fetch
| -rw-r--r-- | src/components/map/LoadingScreen.js | 11 | ||||
| -rw-r--r-- | src/pages/App.js | 22 | ||||
| -rw-r--r-- | src/sagas/topology.js | 2 |
3 files changed, 29 insertions, 6 deletions
diff --git a/src/components/map/LoadingScreen.js b/src/components/map/LoadingScreen.js new file mode 100644 index 00000000..3d5753e2 --- /dev/null +++ b/src/components/map/LoadingScreen.js @@ -0,0 +1,11 @@ +import React from 'react'; +import FontAwesome from "react-fontawesome"; + +const LoadingScreen = () => ( + <div className="display-4"> + <FontAwesome name="refresh" className="mr-4" spin/> + Loading your datacenter... + </div> +); + +export default LoadingScreen; diff --git a/src/pages/App.js b/src/pages/App.js index fc38b92d..317442f6 100644 --- a/src/pages/App.js +++ b/src/pages/App.js @@ -4,6 +4,7 @@ import {connect} from "react-redux"; import {ShortcutManager} from "react-shortcuts"; import {openSimulationSucceeded} from "../actions/simulations"; import {fetchLatestDatacenter, resetCurrentDatacenter} from "../actions/topology/building"; +import LoadingScreen from "../components/map/LoadingScreen"; import MapStage from "../components/map/MapStage"; import AppNavbar from "../components/navigation/AppNavbar"; import DeleteMachineModal from "../containers/modals/DeleteMachineModal"; @@ -40,10 +41,15 @@ class AppContainer extends React.Component { return ( <div className="page-container full-height"> <AppNavbar/> - <div className="full-height"> - <MapStage/> - <TopologySidebar/> - </div> + {this.props.datacenterIsLoading ? + <div className="full-height d-flex align-items-center justify-content-center"> + <LoadingScreen/> + </div> : + <div className="full-height"> + <MapStage/> + <TopologySidebar/> + </div> + } <EditRoomNameModal/> <DeleteRoomModal/> <EditRackNameModal/> @@ -54,6 +60,12 @@ class AppContainer extends React.Component { } } +const mapStateToProps = state => { + return { + datacenterIsLoading: state.currentDatacenterId === -1, + }; +}; + const mapDispatchToProps = dispatch => { return { storeSimulationId: id => dispatch(openSimulationSucceeded(id)), @@ -63,7 +75,7 @@ const mapDispatchToProps = dispatch => { }; const App = connect( - undefined, + mapStateToProps, mapDispatchToProps )(AppContainer); diff --git a/src/sagas/topology.js b/src/sagas/topology.js index 9c5087cc..0f1856f5 100644 --- a/src/sagas/topology.js +++ b/src/sagas/topology.js @@ -60,7 +60,7 @@ export function* onFetchLatestDatacenter(action) { } } -export function* fetchDatacenter(datacenterId) { +function* fetchDatacenter(datacenterId) { try { yield fetchAndStoreDatacenter(datacenterId); const rooms = yield fetchAndStoreRoomsOfDatacenter(datacenterId); |
