diff --git a/src/app.js b/src/app.js index 5f0cadc..d77e02f 100644 --- a/src/app.js +++ b/src/app.js @@ -44,7 +44,6 @@ import Simulators from './simulator/simulators'; import Dashboard from './dashboard/dashboard'; import Scenarios from './scenario/scenarios'; import Scenario from './scenario/scenario'; -import SimulationModel from './simulationmodel/simulation-model'; import Users from './user/users'; import User from './user/user'; @@ -137,7 +136,6 @@ class App extends React.Component { - diff --git a/src/common/editable-header.js b/src/common/editable-header.js index 47aba96..b5e6a2f 100644 --- a/src/common/editable-header.js +++ b/src/common/editable-header.js @@ -18,7 +18,7 @@ * You should have received a copy of the GNU General Public License * along with VILLASweb. If not, see . ******************************************************************************/ - +// TODO remove this file (not used!) import React from 'react'; import PropTypes from 'prop-types'; import { FormControl, Button } from 'react-bootstrap'; diff --git a/src/simulationmodel/simulation-model.js b/src/simulationmodel/simulation-model.js deleted file mode 100644 index b1e6fea..0000000 --- a/src/simulationmodel/simulation-model.js +++ /dev/null @@ -1,243 +0,0 @@ -/** - * File: simulationModel.js - * Author: Markus Grigull - * Date: 10.05.2018 - * - * This file is part of VILLASweb. - * - * VILLASweb is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * VILLASweb is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with VILLASweb. If not, see . - ******************************************************************************/ - -import React from 'react'; -import { Container } from 'flux/utils'; -import { Button, Col, Form, FormLabel, FormGroup } from 'react-bootstrap'; - -import SimulationModelStore from './simulation-model-store'; -import LoginStore from '../user/login-store'; -import AppDispatcher from '../common/app-dispatcher'; - -import SelectFile from '../file/select-file'; -import EditSignalMapping from '../signal/edit-signal-mapping'; -import EditableHeader from '../common/editable-header'; -import ParametersEditor from '../common/parameters-editor'; -import SimulatorStore from "../simulator/simulator-store"; -import SignalStore from "../signal/signal-store"; -import FileStore from "../file/file-store" - - -class SimulationModel extends React.Component { - static getStores() { - return [ SimulationModelStore, LoginStore ]; - } - - static calculateState(prevState, props) { - - // get selected simulation model - const sessionToken = LoginStore.getState().token; - - let simulationModel = SimulationModelStore.getState().find(m => m.id === parseInt(props.match.params.simulationModel, 10)); - if (simulationModel == null) { - AppDispatcher.dispatch({ - type: 'simulationModels/start-load', - data: props.match.params.simulationModel, - token: sessionToken - }); - } - - // signals and files of simulation model - // TODO add direction of signals to find operation - let inputSignals = SignalStore.getState().find(sig => sig.simulationModelID === parseInt(props.match.params.simulationModel, 10)); - let outputSignals = SignalStore.getState().find(sig => sig.simulationModelID === parseInt(props.match.params.simulationModel, 10)); - - - let files = FileStore.getState().find(f => f.simulationModelID === parseInt(props.match.params.simulationModel, 10)); - - - return { - simulationModel, - inputSignals, - outputSignals, - files, - sessionToken, - signals: SignalStore.getState(), - simulators: SimulatorStore.getState(), - selectedFile: null, - - }; - } - - componentDidMount() { - //load selected simulationModel - AppDispatcher.dispatch({ - type: 'simulationModels/start-load', - data: this.state.simulationModel.id, - token: this.state.sessionToken - }); - - // load input signals for selected simulation model - // AppDispatcher.dispatch({ - // type: 'signals/start-load', - // token: this.state.sessionToken, - // param: '?direction=in&modelID=' + this.state.simulationModel.id, - // }); - // - // // load output signals for selected simulation model - // AppDispatcher.dispatch({ - // type: 'signals/start-load', - // token: this.state.sessionToken, - // param: '?direction=out&modelID=' + this.state.simulationModel.id, - // }); - - // load files for selected simulation model - // AppDispatcher.dispatch({ - // type: 'files/start-load', - // token: this.state.sessionToken, - // param: '?objectType=model&objectID=' + this.state.simulationModel.id, - // }); - - // load simulators - AppDispatcher.dispatch({ - type: 'simulators/start-load', - token: this.state.sessionToken, - }); - } - - submitForm = event => { - event.preventDefault(); - } - - saveChanges = () => { - AppDispatcher.dispatch({ - type: 'simulationModels/start-edit', - data: this.state.simulationModel, - token: this.state.sessionToken - }); - - this.props.history.push('/scenarios/' + this.state.simulationModel.scenarioID); - } - - discardChanges = () => { - this.props.history.push('/scenarios/' + this.state.simulationModel.scenarioID); - } - - handleSimulatorChange = simulator => { - const simulationModel = this.state.simulationModel; - - simulationModel.simulator = simulator; - - this.setState({ simulationModel }); - } - - handleModelChange = file => { - console.log(file); - } - - handleConfigurationChange = file => { - console.log(file); - } - - handleOutputMappingChange = (length, signals) => { - const simulationModel = this.state.simulationModel; - - simulationModel.outputMapping = signals; - simulationModel.outputLength = length; - - this.setState({ simulationModel }); - } - - handleInputMappingChange = (length, signals) => { - const simulationModel = this.state.simulationModel; - - simulationModel.inputMapping = signals; - simulationModel.inputLength = length; - - this.setState({ simulationModel }); - } - - handleTitleChange = title => { - const simulationModel = this.state.simulationModel; - - simulationModel.name = title; - - this.setState({ simulationModel }); - } - - handleStartParametersChange = startParameters => { - const simulationModel = this.state.simulationModel; - - simulationModel.startParameters = startParameters; - - this.setState({ simulationModel }); - } - - render() { - const buttonStyle = { - marginRight: '10px' - }; - console.log("OutputSignals: ", this.state.outputSignals); - let outputSignals = null; - if (this.state.outputSignals != null){ - outputSignals = Object.keys(this.state.outputSignals).map(key => {return this.state.outputSignals[key]}); - console.log("OutputSignals Array", outputSignals); - } - let inputSignals = null; - console.log("InputSignals: ", this.state.inputSignals); - if (this.state.inputSignals != null){ - inputSignals = Object.keys(this.state.inputSignals).map(key => {return this.state.inputSignals[key]}); - console.log("InputSignals Array", inputSignals); - } - - console.log("All SIGNALS: ", this.state.signals); - - return
- - -
- - - - - - -
- - Start Parameters - - - - - -
- -
- - - - - - - - - -
- - - - -
; - } -} - -let fluxContainerConverter = require('../common/FluxContainerConverter'); -export default Container.create(fluxContainerConverter.convert(SimulationModel), { withProps: true });