diff --git a/package-lock.json b/package-lock.json index 3e6f31cba2658c2d4d48546718a28bce8af484f9..8fec080b4db8eb3bad7954ba1de1f41bfcb3adf0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6939,6 +6939,11 @@ "resolved": "https://registry.npmjs.org/flatten/-/flatten-1.0.3.tgz", "integrity": "sha512-dVsPA/UwQ8+2uoFe5GHtiBMu48dWLTdsuEd7CKGlZlD78r1TTWBvDuFaFGKCo/ZfEr95Uk56vZoX86OsHkUeIg==" }, + "flexlayout-react": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/flexlayout-react/-/flexlayout-react-0.5.5.tgz", + "integrity": "sha512-y8fQQ1nfBdSmBELoD/nEplEIxRZfDtHT1Lg50M4iXkvlF9blnkQktmngiYR2tO/wr6fy2+2cV+tX0HXoeHY8cQ==" + }, "flush-write-stream": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/flush-write-stream/-/flush-write-stream-1.1.1.tgz", diff --git a/package.json b/package.json index fef55b15322cae2989d9ebf1206936db583ca439..32c471e8f5c6c6afe3b9f0e59fff1aa6a240e8fe 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "private": true, "dependencies": { "bootstrap": "4.5", + "flexlayout-react": "0.5.5", "jszip": "3.2.0", "react": "^17.0.1", "react-bootstrap": "1.4.0", diff --git a/src/App.js b/src/App.js index cf98ecd9cb8154553af02cf6946e1b355f49c6bc..096f392f8a5c1ad32cca31e62b9446b59507f119 100644 --- a/src/App.js +++ b/src/App.js @@ -2,20 +2,18 @@ import React from 'react'; import { HashRouter, Switch, Route } from 'react-router-dom'; -import EntryPage from './components/entry-page/entry-page.js'; -import ExperimentOverview from './components/experiment-overview/experiment-overview.js'; +import EntryPage from './components/entry-page/entry-page'; +import ExperimentOverview from './components/experiment-overview/experiment-overview'; +import SimulationView from './components/simulation-view/simulation-view'; class App extends React.Component { render() { return ( <HashRouter> <Switch> - <Route path='/experiments-overview'> - <ExperimentOverview /> - </Route> - <Route path='/'> - <EntryPage /> - </Route> + <Route path='/experiments-overview' component={ExperimentOverview} /> + <Route path='/simulation-view/:simID' component={SimulationView} /> + <Route path='/' component={EntryPage} /> </Switch> </HashRouter> ); diff --git a/src/components/experiment-list/simulation-details.js b/src/components/experiment-list/simulation-details.js index bd8ccb8c05557a249a82b13508afee12c0e791c6..26107c7af29098abf9cce6c77b6526e3a6a3db9f 100644 --- a/src/components/experiment-list/simulation-details.js +++ b/src/components/experiment-list/simulation-details.js @@ -1,6 +1,7 @@ import React from 'react'; import { FaStop, FaStopCircle } from 'react-icons/fa'; import { ImEnter } from 'react-icons/im'; +import { withRouter } from 'react-router-dom'; import timeDDHHMMSS from '../../utility/time-filter.js'; import { EXPERIMENT_STATE } from '../../services/experiments/experiment-constants.js'; @@ -8,7 +9,7 @@ import ExperimentExecutionService from '../../services/experiments/execution/exp import './simulation-details.css'; -export default class SimulationDetails extends React.Component { +class SimulationDetails extends React.Component { constructor() { super(); @@ -78,7 +79,13 @@ export default class SimulationDetails extends React.Component { ng-click="(simulation.runningSimulation.state === STATE.CREATED) || simulation.stopping || joinExperiment(simulation, exp);"*/ type="button" className='nrp-btn btn-default' - disabled={this.isJoinDisabled(simulation)}> + disabled={this.isJoinDisabled(simulation)} + onClick={() => { + console.info(simulation); + this.props.history.push({ + pathname: '/simulation-view/' + simulation.runningSimulation.simulationID + }); + }}> <ImEnter className='icon' />Join </button> {/* Stop button enabled provided simulation state is consistent */} @@ -106,3 +113,4 @@ export default class SimulationDetails extends React.Component { ); } } +export default withRouter(SimulationDetails); diff --git a/src/components/simulation-view/simulation-view.js b/src/components/simulation-view/simulation-view.js new file mode 100644 index 0000000000000000000000000000000000000000..8c82d3f6db534b953a5943d4769aaf1b9fe0f15b --- /dev/null +++ b/src/components/simulation-view/simulation-view.js @@ -0,0 +1,65 @@ +import React from 'react'; +import FlexLayout from 'flexlayout-react'; + +import '../../../node_modules/flexlayout-react/style/light.css'; + +const jsonBaseLayout = { + global: {}, + borders: [], + layout:{ + 'type': 'row', + 'weight': 100, + 'children': [ + { + 'type': 'tabset', + 'weight': 50, + 'selected': 0, + 'children': [ + { + 'type': 'tab', + 'name': 'FX', + 'component':'grid' + } + ] + }, + { + 'type': 'tabset', + 'weight': 50, + 'selected': 0, + 'children': [ + { + 'type': 'tab', + 'name': 'FI', + 'component':'grid' + } + ] + } + ] + } +}; + +export default class SimulationView extends React.Component { + constructor(props) { + super(props); + console.info(this.state); + console.info(this.props); + + this.state = {model: FlexLayout.Model.fromJson(jsonBaseLayout)}; + console.info(this.state); + } + + factory = (node) => { + var component = node.getComponent(); + if (component === 'button') { + return <button>{node.getName()}</button>; + } + } + + render() { + return ( + <div> + <FlexLayout.Layout model={this.state.model} factory={this.factory}/> + </div> + ); + } +}