summaryrefslogtreecommitdiff
path: root/src/pages/App.js
blob: 4f973ab7386e7af94f8fba053da428cbcbe3955a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import PropTypes from "prop-types";
import React from 'react';
import {connect} from "react-redux";
import {openSimulationSucceeded} from "../actions/simulations";
import {fetchLatestDatacenter} from "../actions/topology";
import MapStage from "../components/map/MapStage";
import AppNavbar from "../components/navigation/AppNavbar";
import TopologySidebar from "../containers/sidebars/TopologySidebar";

class AppContainer extends React.Component {
    static propTypes = {
        simulationId: PropTypes.number.isRequired,
    };

    componentDidMount() {
        this.props.storeSimulationId(this.props.simulationId);
        this.props.fetchLatestDatacenter();
    }

    render() {
        return (
            <div className="page-container full-height">
                <AppNavbar/>
                <div className="full-height">
                    <MapStage/>
                    <TopologySidebar/>
                </div>
            </div>
        );
    }
}

const mapDispatchToProps = dispatch => {
    return {
        storeSimulationId: id => dispatch(openSimulationSucceeded(id)),
        fetchLatestDatacenter: () => dispatch(fetchLatestDatacenter()),
    };
};

const App = connect(
    undefined,
    mapDispatchToProps
)(AppContainer);

export default App;