diff options
| author | jc0b <j@jc0b.computer> | 2020-07-07 16:55:22 +0200 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2020-08-24 19:47:51 +0200 |
| commit | 223e916997eb641a1662110b6de630a4cdfdf479 (patch) | |
| tree | 90ca4364461f676db45f25e03d8f22fc32f9fdd8 /frontend/src/pages | |
| parent | 9ff1e3c6bae253372a468dbdc9b8369ab8dd2c6f (diff) | |
| parent | b810c4413079bf5aeb5374f1cd20e151a83530d0 (diff) | |
Merge branch 'feature/mongodb-migration' of github.com:atlarge-research/opendc-dev into feature/mongodb-migration
Diffstat (limited to 'frontend/src/pages')
| -rw-r--r-- | frontend/src/pages/App.js | 75 | ||||
| -rw-r--r-- | frontend/src/pages/Experiments.js | 65 | ||||
| -rw-r--r-- | frontend/src/pages/Home.js | 22 | ||||
| -rw-r--r-- | frontend/src/pages/NotFound.js | 2 | ||||
| -rw-r--r-- | frontend/src/pages/Profile.js | 8 | ||||
| -rw-r--r-- | frontend/src/pages/Projects.js | 43 | ||||
| -rw-r--r-- | frontend/src/pages/Simulations.js | 43 |
7 files changed, 90 insertions, 168 deletions
diff --git a/frontend/src/pages/App.js b/frontend/src/pages/App.js index 89d1fa32..8f99d1bd 100644 --- a/frontend/src/pages/App.js +++ b/frontend/src/pages/App.js @@ -4,33 +4,31 @@ 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 { openProjectSucceeded } from '../actions/projects' import { resetCurrentTopology } 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' -import AppNavbar from '../components/navigation/AppNavbar' import ScaleIndicatorContainer from '../containers/app/map/controls/ScaleIndicatorContainer' import MapStage from '../containers/app/map/MapStage' -import TopologySidebar from '../containers/app/sidebars/topology/TopologySidebar' -import TimelineContainer from '../containers/app/timeline/TimelineContainer' +import TopologySidebarContainer from '../containers/app/sidebars/topology/TopologySidebarContainer' import DeleteMachineModal from '../containers/modals/DeleteMachineModal' import DeleteRackModal from '../containers/modals/DeleteRackModal' import DeleteRoomModal from '../containers/modals/DeleteRoomModal' import EditRackNameModal from '../containers/modals/EditRackNameModal' import EditRoomNameModal from '../containers/modals/EditRoomNameModal' import KeymapConfiguration from '../shortcuts/keymap' -import ChangeTopologyModal from '../containers/modals/ChangeTopologyModal' -import { openChangeTopologyModal } from '../actions/modals/topology' +import NewTopologyModal from '../containers/modals/NewTopologyModal' +import { openNewTopologyModal } from '../actions/modals/topology' +import AppNavbarContainer from '../containers/navigation/AppNavbarContainer' +import ProjectSidebarContainer from '../containers/app/sidebars/project/ProjectSidebarContainer' const shortcutManager = new ShortcutManager(KeymapConfiguration) class AppComponent extends React.Component { static propTypes = { - simulationId: PropTypes.string.isRequired, - inSimulation: PropTypes.bool, + projectId: PropTypes.string.isRequired, experimentId: PropTypes.number, - simulationName: PropTypes.string, + projectName: PropTypes.string, onViewTopologies: PropTypes.func, } static childContextTypes = { @@ -38,12 +36,7 @@ class AppComponent extends React.Component { } componentDidMount() { - // TODO this.props.resetCurrentTopology() - if (this.props.inSimulation) { - this.props.openExperimentSucceeded(this.props.simulationId, this.props.experimentId) - return - } - this.props.openSimulationSucceeded(this.props.simulationId) + this.props.openProjectSucceeded(this.props.projectId) } getChildContext() { @@ -55,35 +48,29 @@ class AppComponent extends React.Component { render() { return ( <DocumentTitle - title={this.props.simulationName ? this.props.simulationName + ' - OpenDC' : 'Simulation - OpenDC'} + title={this.props.projectName ? this.props.projectName + ' - OpenDC' : 'Simulation - OpenDC'} > <div className="page-container full-height"> - <AppNavbar - simulationId={this.props.simulationId} - inSimulation={true} - fullWidth={true} - onViewTopologies={this.props.onViewTopologies} - /> + <AppNavbarContainer fullWidth={true} /> {this.props.topologyIsLoading ? ( <div className="full-height d-flex align-items-center justify-content-center"> - <LoadingScreen /> + <LoadingScreen/> </div> ) : ( <div className="full-height"> - <MapStage /> - <ScaleIndicatorContainer /> - <ToolPanelComponent /> - <TopologySidebar /> - {this.props.inSimulation ? <TimelineContainer /> : undefined} - {this.props.inSimulation ? <SimulationSidebarComponent /> : undefined} + <MapStage/> + <ScaleIndicatorContainer/> + <ToolPanelComponent/> + <ProjectSidebarContainer/> + <TopologySidebarContainer/> </div> )} - <ChangeTopologyModal /> - <EditRoomNameModal /> - <DeleteRoomModal /> - <EditRackNameModal /> - <DeleteRackModal /> - <DeleteMachineModal /> + <NewTopologyModal/> + <EditRoomNameModal/> + <DeleteRoomModal/> + <EditRackNameModal/> + <DeleteRackModal/> + <DeleteMachineModal/> </div> </DocumentTitle> ) @@ -91,24 +78,24 @@ class AppComponent extends React.Component { } const mapStateToProps = (state) => { - let simulationName = undefined - if (state.currentSimulationId !== '-1' && state.objects.simulation[state.currentSimulationId]) { - simulationName = state.objects.simulation[state.currentSimulationId].name + let projectName = undefined + if (state.currentProjectId !== '-1' && state.objects.project[state.currentProjectId]) { + projectName = state.objects.project[state.currentProjectId].name } return { topologyIsLoading: state.currentTopologyId === '-1', - simulationName, + projectName, } } const mapDispatchToProps = (dispatch) => { return { resetCurrentTopology: () => dispatch(resetCurrentTopology()), - openSimulationSucceeded: (id) => dispatch(openSimulationSucceeded(id)), - onViewTopologies: () => dispatch(openChangeTopologyModal()), - openExperimentSucceeded: (simulationId, experimentId) => - dispatch(openExperimentSucceeded(simulationId, experimentId)), + openProjectSucceeded: (id) => dispatch(openProjectSucceeded(id)), + onViewTopologies: () => dispatch(openNewTopologyModal()), + openExperimentSucceeded: (projectId, experimentId) => + dispatch(openExperimentSucceeded(projectId, experimentId)), } } diff --git a/frontend/src/pages/Experiments.js b/frontend/src/pages/Experiments.js deleted file mode 100644 index 43bd15be..00000000 --- a/frontend/src/pages/Experiments.js +++ /dev/null @@ -1,65 +0,0 @@ -import PropTypes from 'prop-types' -import React from 'react' -import DocumentTitle from 'react-document-title' -import { connect } from 'react-redux' -import { fetchExperimentsOfSimulation } from '../actions/experiments' -import { openSimulationSucceeded } from '../actions/simulations' -import AppNavbar from '../components/navigation/AppNavbar' -import ExperimentListContainer from '../containers/experiments/ExperimentListContainer' -import NewExperimentButtonContainer from '../containers/experiments/NewExperimentButtonContainer' -import NewExperimentModal from '../containers/modals/NewExperimentModal' - -class ExperimentsComponent extends React.Component { - static propTypes = { - simulationId: PropTypes.string.isRequired, - simulationName: PropTypes.string, - } - - componentDidMount() { - this.props.storeSimulationId(this.props.simulationId) - this.props.fetchExperimentsOfSimulation(this.props.simulationId) - } - - render() { - return ( - <DocumentTitle - title={ - this.props.simulationName - ? 'Experiments - ' + this.props.simulationName + ' - OpenDC' - : 'Experiments - OpenDC' - } - > - <div className="full-height"> - <AppNavbar simulationId={this.props.simulationId} inSimulation={true} fullWidth={true} /> - <div className="container text-page-container full-height"> - <ExperimentListContainer /> - <NewExperimentButtonContainer /> - </div> - <NewExperimentModal /> - </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 { - simulationName, - } -} - -const mapDispatchToProps = (dispatch) => { - return { - storeSimulationId: (id) => dispatch(openSimulationSucceeded(id)), - fetchExperimentsOfSimulation: (id) => dispatch(fetchExperimentsOfSimulation(id)), - } -} - -const Experiments = connect(mapStateToProps, mapDispatchToProps)(ExperimentsComponent) - -export default Experiments diff --git a/frontend/src/pages/Home.js b/frontend/src/pages/Home.js index 1bdfc5c7..e69c2049 100644 --- a/frontend/src/pages/Home.js +++ b/frontend/src/pages/Home.js @@ -21,7 +21,7 @@ class Home extends React.Component { const scrollOffset = 60 jQuery('#navbar') .find('li a') - .click(function (e) { + .click(function(e) { if (jQuery(e.target).parents('.auth-links').length > 0) { return } @@ -42,17 +42,17 @@ class Home extends React.Component { render() { return ( <div> - <HomeNavbar /> + <HomeNavbar/> <div className="body-wrapper page-container"> - <JumbotronHeader /> - <IntroSection /> - <StakeholderSection /> - <ModelingSection /> - <SimulationSection /> - <TechnologiesSection /> - <TeamSection /> - <ContactSection /> - <DocumentTitle title="OpenDC" /> + <JumbotronHeader/> + <IntroSection/> + <StakeholderSection/> + <ModelingSection/> + <SimulationSection/> + <TechnologiesSection/> + <TeamSection/> + <ContactSection/> + <DocumentTitle title="OpenDC"/> </div> </div> ) diff --git a/frontend/src/pages/NotFound.js b/frontend/src/pages/NotFound.js index f72c7d01..959cceec 100644 --- a/frontend/src/pages/NotFound.js +++ b/frontend/src/pages/NotFound.js @@ -6,7 +6,7 @@ import './NotFound.css' const NotFound = () => ( <DocumentTitle title="Page Not Found - OpenDC"> <div className="not-found-backdrop"> - <TerminalWindow /> + <TerminalWindow/> </div> </DocumentTitle> ) diff --git a/frontend/src/pages/Profile.js b/frontend/src/pages/Profile.js index 45b48247..527dc721 100644 --- a/frontend/src/pages/Profile.js +++ b/frontend/src/pages/Profile.js @@ -2,24 +2,24 @@ import React from 'react' import DocumentTitle from 'react-document-title' import { connect } from 'react-redux' import { openDeleteProfileModal } from '../actions/modals/profile' -import AppNavbar from '../components/navigation/AppNavbar' import DeleteProfileModal from '../containers/modals/DeleteProfileModal' +import AppNavbarContainer from '../containers/navigation/AppNavbarContainer' const ProfileContainer = ({ onDelete }) => ( <DocumentTitle title="My Profile - OpenDC"> <div className="full-height"> - <AppNavbar inSimulation={false} fullWidth={false} /> + <AppNavbarContainer fullWidth={false}/> <div className="container text-page-container full-height"> <button className="btn btn-danger mb-2 ml-auto mr-auto" style={{ maxWidth: 300 }} onClick={onDelete}> Delete my account on OpenDC </button> <p className="text-muted text-center"> This does not delete your Google account, but simply disconnects it from the OpenDC platform and - deletes any simulation info that is associated with you (simulations you own and any authorizations + deletes any project info that is associated with you (projects you own and any authorizations you may have on other projects). </p> </div> - <DeleteProfileModal /> + <DeleteProfileModal/> </div> </DocumentTitle> ) diff --git a/frontend/src/pages/Projects.js b/frontend/src/pages/Projects.js new file mode 100644 index 00000000..f4af10c3 --- /dev/null +++ b/frontend/src/pages/Projects.js @@ -0,0 +1,43 @@ +import React from 'react' +import DocumentTitle from 'react-document-title' +import { connect } from 'react-redux' +import { openNewProjectModal } from '../actions/modals/projects' +import { fetchAuthorizationsOfCurrentUser } from '../actions/users' +import ProjectFilterPanel from '../components/projects/FilterPanel' +import NewProjectModal from '../containers/modals/NewProjectModal' +import NewProjectButtonContainer from '../containers/projects/NewProjectButtonContainer' +import VisibleProjectList from '../containers/projects/VisibleProjectAuthList' +import AppNavbarContainer from '../containers/navigation/AppNavbarContainer' + +class ProjectsContainer extends React.Component { + componentDidMount() { + this.props.fetchAuthorizationsOfCurrentUser() + } + + render() { + return ( + <DocumentTitle title="My Projects - OpenDC"> + <div className="full-height"> + <AppNavbarContainer fullWidth={false}/> + <div className="container text-page-container full-height"> + <ProjectFilterPanel/> + <VisibleProjectList/> + <NewProjectButtonContainer/> + </div> + <NewProjectModal/> + </div> + </DocumentTitle> + ) + } +} + +const mapDispatchToProps = (dispatch) => { + return { + fetchAuthorizationsOfCurrentUser: () => dispatch(fetchAuthorizationsOfCurrentUser()), + openNewProjectModal: () => dispatch(openNewProjectModal()), + } +} + +const Projects = connect(undefined, mapDispatchToProps)(ProjectsContainer) + +export default Projects diff --git a/frontend/src/pages/Simulations.js b/frontend/src/pages/Simulations.js deleted file mode 100644 index ce2386fd..00000000 --- a/frontend/src/pages/Simulations.js +++ /dev/null @@ -1,43 +0,0 @@ -import React from 'react' -import DocumentTitle from 'react-document-title' -import { connect } from 'react-redux' -import { openNewSimulationModal } from '../actions/modals/simulations' -import { fetchAuthorizationsOfCurrentUser } from '../actions/users' -import AppNavbar from '../components/navigation/AppNavbar' -import SimulationFilterPanel from '../components/simulations/FilterPanel' -import NewSimulationModal from '../containers/modals/NewSimulationModal' -import NewSimulationButtonContainer from '../containers/simulations/NewSimulationButtonContainer' -import VisibleSimulationList from '../containers/simulations/VisibleSimulationAuthList' - -class SimulationsContainer extends React.Component { - componentDidMount() { - this.props.fetchAuthorizationsOfCurrentUser() - } - - render() { - return ( - <DocumentTitle title="My Simulations - OpenDC"> - <div className="full-height"> - <AppNavbar inSimulation={false} fullWidth={false} /> - <div className="container text-page-container full-height"> - <SimulationFilterPanel /> - <VisibleSimulationList /> - <NewSimulationButtonContainer /> - </div> - <NewSimulationModal /> - </div> - </DocumentTitle> - ) - } -} - -const mapDispatchToProps = (dispatch) => { - return { - fetchAuthorizationsOfCurrentUser: () => dispatch(fetchAuthorizationsOfCurrentUser()), - openNewSimulationModal: () => dispatch(openNewSimulationModal()), - } -} - -const Simulations = connect(undefined, mapDispatchToProps)(SimulationsContainer) - -export default Simulations |
