From d240d5553bea918128471868ef0510790e0d52db Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Thu, 13 Apr 2017 10:03:30 +0200 Subject: [PATCH 01/59] Deal with undefined sim models and show notification --- src/components/widget-plot-table.js | 37 ++++++++++++--------- src/components/widget-plot.js | 38 ++++++++++++---------- src/containers/visualization.js | 20 +++++++++--- src/data-managers/notifications-factory.js | 24 ++++++++++++++ 4 files changed, 81 insertions(+), 38 deletions(-) create mode 100644 src/data-managers/notifications-factory.js diff --git a/src/components/widget-plot-table.js b/src/components/widget-plot-table.js index cbdee75..65de31e 100644 --- a/src/components/widget-plot-table.js +++ b/src/components/widget-plot-table.js @@ -58,22 +58,27 @@ class WidgetPlotTable extends Component { return (model.simulator === simulator); }); - // Create checkboxes using the signal indices from simulation model - const preselectedSignals = simulationModel.mapping.reduce( - // Loop through simulation model signals - (accum, model_signal, signal_index) => { - // Append them if they belong to the current selected type - if (nextProps.widget.preselectedSignals.indexOf(signal_index) > -1) { - accum.push( - { - index: signal_index, - name: model_signal.name - } - ) - } - return accum; - }, []); - this.setState({ preselectedSignals: preselectedSignals }); + let preselectedSignals = []; + // Proceed if a simulation model is available + if (simulationModel) { + // Create checkboxes using the signal indices from simulation model + preselectedSignals = simulationModel.mapping.reduce( + // Loop through simulation model signals + (accum, model_signal, signal_index) => { + // Append them if they belong to the current selected type + if (nextProps.widget.preselectedSignals.indexOf(signal_index) > -1) { + accum.push( + { + index: signal_index, + name: model_signal.name + } + ) + } + return accum; + }, []); + } + + this.setState({ preselectedSignals: preselectedSignals }); } updateSignalSelection(signal_index, checked) { diff --git a/src/components/widget-plot.js b/src/components/widget-plot.js index df901c9..e0c2662 100644 --- a/src/components/widget-plot.js +++ b/src/components/widget-plot.js @@ -15,25 +15,29 @@ import PlotLegend from './widget-plot/plot-legend'; class WidgetPlot extends Component { render() { - if (this.props.simulation == null) { - return (
Empty
); + + const simulator = this.props.widget.simulator; + const simulation = this.props.simulation; + let legendSignals = []; + let simulatorData = []; + + // Proceed if a simulation with models and a simulator are available + if (simulator && simulation && simulation.models.length > 0) { + + const model = simulation.models.find( (model) => model.simulator === simulator ); + const chosenSignals = this.props.widget.signals; + + simulatorData = this.props.data[simulator]; + + // Query the signals that will be displayed in the legend + legendSignals = model.mapping.reduce( (accum, model_signal, signal_index) => { + if (chosenSignals.includes(signal_index)) { + accum.push({ index: signal_index, name: model_signal.name }); + } + return accum; + }, []); } - let simulator = this.props.widget.simulator; - let simulation = this.props.simulation; - let model = simulation.models.find( (model) => model.simulator === simulator ); - let chosenSignals = this.props.widget.signals; - - let simulatorData = this.props.data[simulator]; - - // Query the signals that will be displayed in the legend - let legendSignals = model.mapping.reduce( (accum, model_signal, signal_index) => { - if (chosenSignals.includes(signal_index)) { - accum.push({ index: signal_index, name: model_signal.name }); - } - return accum; - }, []); - return (

{this.props.widget.name}

diff --git a/src/containers/visualization.js b/src/containers/visualization.js index 6085b06..c82d56d 100644 --- a/src/containers/visualization.js +++ b/src/containers/visualization.js @@ -22,6 +22,8 @@ import ProjectStore from '../stores/project-store'; import SimulationStore from '../stores/simulation-store'; import FileStore from '../stores/file-store'; import AppDispatcher from '../app-dispatcher'; +import NotificationsDataManager from '../data-managers/notifications-data-manager'; +import NotificationsFactory from '../data-managers/notifications-factory'; import WidgetSlider from '../components/widget-slider'; @@ -138,16 +140,24 @@ class Visualization extends Component { z: 0 }; + let defaultSimulator = null; + + if (this.state.simulation.models && this.state.simulation.models.length === 0) { + NotificationsDataManager.addNotification(NotificationsFactory.NO_SIM_MODEL_AVAILABLE); + } else { + defaultSimulator = this.state.simulation.models[0].simulator; + } + // set type specific properties if (item.name === 'Value') { - widget.simulator = this.state.simulation.models[0].simulator; + widget.simulator = defaultSimulator; widget.signal = 0; widget.minWidth = 70; widget.minHeight = 20; widget.width = 120; widget.height = 70; } else if (item.name === 'Plot') { - widget.simulator = this.state.simulation.models[0].simulator; + widget.simulator = defaultSimulator; widget.signals = [ 0 ]; widget.time = 60; widget.minWidth = 400; @@ -155,7 +165,7 @@ class Visualization extends Component { widget.width = 400; widget.height = 200; } else if (item.name === 'Table') { - widget.simulator = this.state.simulation.models[0].simulator; + widget.simulator = defaultSimulator; widget.minWidth = 300; widget.minHeight = 200; widget.width = 400; @@ -164,7 +174,7 @@ class Visualization extends Component { widget.minWidth = 70; widget.minHeight = 20; } else if (item.name === 'PlotTable') { - widget.simulator = this.state.simulation.models[0].simulator; + widget.simulator = defaultSimulator; widget.preselectedSignals = []; widget.signals = []; // initialize selected signals widget.minWidth = 400; @@ -194,7 +204,7 @@ class Visualization extends Component { widget.height = 50; widget.orientation = WidgetSlider.OrientationTypes.HORIZONTAL.value; // Assign default orientation } else if (item.name === 'Gauge') { - widget.simulator = this.state.simulation.models[0].simulator; + widget.simulator = defaultSimulator; widget.signal = 0; widget.minWidth = 200; widget.minHeight = 150; diff --git a/src/data-managers/notifications-factory.js b/src/data-managers/notifications-factory.js new file mode 100644 index 0000000..56c095c --- /dev/null +++ b/src/data-managers/notifications-factory.js @@ -0,0 +1,24 @@ +/** + * File: notifications-factory.js + * Description: An unique source of pre-defined notifications that are displayed + * throughout the application. + * Author: Ricardo Hernandez-Montoya + * Date: 13.04.2017 + * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC + * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. + * Unauthorized copying of this file, via any medium is strictly prohibited. + **********************************************************************************/ + +class NotificationsFactory { + + static get NO_SIM_MODEL_AVAILABLE() { + return { + title: 'No simulation model available', + message: 'Consider defining a simulation model in the simulators section.', + level: 'warning' + }; + } + +} + +export default NotificationsFactory; \ No newline at end of file From fe543dee931b8d2131d3b8386932b1772e62dae5 Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Thu, 13 Apr 2017 10:05:57 +0200 Subject: [PATCH 02/59] Extracted controls in Widget Edit model and included proper message when no sim model is available --- ...-image.js => edit-widget-image-control.js} | 6 +- src/components/dialog/edit-widget-plot.js | 85 ------------------- .../dialog/edit-widget-signals-control.js | 31 ++++--- .../dialog/edit-widget-simulator-control.js | 11 ++- .../dialog/edit-widget-time-control.js | 40 +++++++++ src/components/dialog/edit-widget-value.js | 64 -------------- src/components/dialog/edit-widget.js | 32 ++++--- 7 files changed, 87 insertions(+), 182 deletions(-) rename src/components/dialog/{edit-widget-image.js => edit-widget-image-control.js} (94%) delete mode 100644 src/components/dialog/edit-widget-plot.js create mode 100644 src/components/dialog/edit-widget-time-control.js delete mode 100644 src/components/dialog/edit-widget-value.js diff --git a/src/components/dialog/edit-widget-image.js b/src/components/dialog/edit-widget-image-control.js similarity index 94% rename from src/components/dialog/edit-widget-image.js rename to src/components/dialog/edit-widget-image-control.js index f7b06e4..d484bee 100644 --- a/src/components/dialog/edit-widget-image.js +++ b/src/components/dialog/edit-widget-image-control.js @@ -1,5 +1,5 @@ /** - * File: edit-widget-value.js + * File: edit-widget-image-control.js * Author: Markus Grigull * Date: 04.03.2017 * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC @@ -12,7 +12,7 @@ import { FormGroup, FormControl, ControlLabel, Button } from 'react-bootstrap'; import AppDispatcher from '../../app-dispatcher'; -class EditImageWidget extends Component { +class EditImageWidgetControl extends Component { constructor(props) { super(props); @@ -68,4 +68,4 @@ class EditImageWidget extends Component { } } -export default EditImageWidget; +export default EditImageWidgetControl; diff --git a/src/components/dialog/edit-widget-plot.js b/src/components/dialog/edit-widget-plot.js deleted file mode 100644 index a2371e3..0000000 --- a/src/components/dialog/edit-widget-plot.js +++ /dev/null @@ -1,85 +0,0 @@ -/** - * File: edit-widget-plot.js - * Author: Markus Grigull - * Date: 13.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ - -import React, { Component } from 'react'; -import { FormGroup, FormControl, ControlLabel, Checkbox, HelpBlock } from 'react-bootstrap'; - -class EditPlotWidget extends Component { - constructor(props) { - super(props); - - this.state = { - widget: { - simulator: '', - signals: [], - time: 0 - } - }; - } - - componentWillReceiveProps(nextProps) { - this.setState({ widget: nextProps.widget }); - } - - handleSignalChange(e, index) { - var signals = this.state.widget.signals; - - if (e.target.checked) { - // add signal - signals.push(index); - } else { - // remove signal - const pos = signals.indexOf(index); - if (pos > -1) { - signals.splice(pos, 1); - } - } - - this.props.handleChange({ target: { id: 'signals', value: signals } }); - } - - render() { - // get selected simulation model - var simulationModel = {}; - - if (this.props.simulation) { - this.props.simulation.models.forEach((model) => { - if (model.simulation === this.state.widget.simulation) { - simulationModel = model; - } - }); - } - - return ( -
- - Time - this.props.handleChange(e)} /> - Time in seconds - - - Simulator - this.props.handleChange(e)}> - {this.props.simulation.models.map((model, index) => ( - - ))} - - - - Signals - {simulationModel.mapping.map((signal, index) => ( - this.handleSignalChange(e, index)}>{signal.name} - ))} - -
- ); - } -} - -export default EditPlotWidget; diff --git a/src/components/dialog/edit-widget-signals-control.js b/src/components/dialog/edit-widget-signals-control.js index 2842618..a7fcd07 100644 --- a/src/components/dialog/edit-widget-signals-control.js +++ b/src/components/dialog/edit-widget-signals-control.js @@ -8,7 +8,7 @@ **********************************************************************************/ import React, { Component } from 'react'; -import { FormGroup, Checkbox, ControlLabel } from 'react-bootstrap'; +import { FormGroup, Checkbox, ControlLabel, FormControl } from 'react-bootstrap'; class EditWidgetSignalsControl extends Component { constructor(props) { @@ -39,27 +39,32 @@ class EditWidgetSignalsControl extends Component { new_signals = signals.filter( (idx) => idx !== index ); } - this.props.handleChange({ target: { id: 'preselectedSignals', value: new_signals } }); + this.props.handleChange({ target: { id: this.props.controlId, value: new_signals } }); } render() { - // get selected simulation model - var simulationModel = {}; + let signalsToRender = []; if (this.props.simulation) { - this.props.simulation.models.forEach((model) => { - if (model.simulation === this.state.widget.simulation) { - simulationModel = model; - } - }); - } + // get selected simulation model + const simulationModel = this.props.simulation.models.find( model => model.simulation === this.state.widget.simulation ); + // If simulation model update the signals to render + signalsToRender = simulationModel? simulationModel.mapping : []; + } + return ( Signals - {simulationModel.mapping.map((signal, index) => ( - this.handleSignalChange(e.target.checked, index)}>{signal.name} - ))} + { + signalsToRender.length === 0 ? ( + No signals available. + ) : ( + signalsToRender.map((signal, index) => ( + this.handleSignalChange(e.target.checked, index)}>{signal.name} + )) + ) + } ); } diff --git a/src/components/dialog/edit-widget-simulator-control.js b/src/components/dialog/edit-widget-simulator-control.js index baa9679..23de386 100644 --- a/src/components/dialog/edit-widget-simulator-control.js +++ b/src/components/dialog/edit-widget-simulator-control.js @@ -31,10 +31,15 @@ class EditWidgetSimulatorControl extends Component { return ( Simulator - this.props.handleChange(e)}> - {this.props.simulation.models.map((model, index) => ( + this.props.handleChange(e)}> + { + this.props.simulation.models.length === 0? ( + + ) : ( + this.props.simulation.models.map((model, index) => ( - ))} + ))) + } ); diff --git a/src/components/dialog/edit-widget-time-control.js b/src/components/dialog/edit-widget-time-control.js new file mode 100644 index 0000000..5b8e234 --- /dev/null +++ b/src/components/dialog/edit-widget-time-control.js @@ -0,0 +1,40 @@ +/** + * File: edit-widget-time-control.js + * Author: Ricardo Hernandez-Montoya + * Date: 13.04.2017 + * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC + * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. + * Unauthorized copying of this file, via any medium is strictly prohibited. + **********************************************************************************/ + +import React, { Component } from 'react'; +import { FormGroup, FormControl, ControlLabel, HelpBlock } from 'react-bootstrap'; + +class EditWidgetTimeControl extends Component { + constructor(props) { + super(props); + + this.state = { + widget: { + time: 0 + } + }; + } + + componentWillReceiveProps(nextProps) { + this.setState({ widget: nextProps.widget }); + } + + render() { + + return ( + + Time + this.props.handleChange(e)} /> + Time in seconds + + ); + } +} + +export default EditWidgetTimeControl; diff --git a/src/components/dialog/edit-widget-value.js b/src/components/dialog/edit-widget-value.js deleted file mode 100644 index 7f16a03..0000000 --- a/src/components/dialog/edit-widget-value.js +++ /dev/null @@ -1,64 +0,0 @@ -/** - * File: edit-widget-value.js - * Author: Markus Grigull - * Date: 04.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ - -import React, { Component } from 'react'; -import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap'; - -class EditValueWidget extends Component { - constructor(props) { - super(props); - - this.state = { - widget: { - simulator: '', - signal: 0 - } - }; - } - - componentWillReceiveProps(nextProps) { - this.setState({ widget: nextProps.widget }); - } - - render() { - // get selected simulation model - var simulationModel = {}; - - if (this.props.simulation) { - this.props.simulation.models.forEach((model) => { - if (model.simulation === this.state.widget.simulation) { - simulationModel = model; - } - }); - } - - return ( -
- - Simulator - this.props.handleChange(e)}> - {this.props.simulation.models.map((model, index) => ( - - ))} - - - - Signal - this.props.handleChange(e)}> - {simulationModel.mapping.map((signal, index) => ( - - ))} - - -
- ); - } -} - -export default EditValueWidget; diff --git a/src/components/dialog/edit-widget.js b/src/components/dialog/edit-widget.js index a5a2daa..b90e75c 100644 --- a/src/components/dialog/edit-widget.js +++ b/src/components/dialog/edit-widget.js @@ -12,10 +12,8 @@ import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap'; import Dialog from './dialog'; -import EditValueWidget from './edit-widget-value'; -import EditPlotWidget from './edit-widget-plot'; -import EditTableWidget from './edit-widget-table'; -import EditImageWidget from './edit-widget-image'; +import EditWidgetTimeControl from './edit-widget-time-control'; +import EditImageWidgetControl from './edit-widget-image-control'; import EditWidgetSimulatorControl from './edit-widget-simulator-control'; import EditWidgetSignalControl from './edit-widget-signal-control'; import EditWidgetSignalsControl from './edit-widget-signals-control'; @@ -53,8 +51,6 @@ class EditWidgetDialog extends Component { var update = this.state.temporal; update[e.target.id] = e.target.value; this.setState({ temporal: update }); - - //console.log(this.state.widget); } resetState() { @@ -77,20 +73,29 @@ class EditWidgetDialog extends Component { } render() { - // get widget part - var widgetDialog = null; // Use a list to concatenate the controls according to the widget type var dialogControls = []; if (this.props.widget) { if (this.props.widget.type === 'Value') { - widgetDialog = this.validateForm(id)} simulation={this.props.simulation} handleChange={(e) => this.handleChange(e)} />; + dialogControls.push( + this.validateForm(id)} simulation={this.props.simulation} handleChange={(e) => this.handleChange(e)} />, + this.validateForm(id)} simulation={this.props.simulation} handleChange={(e) => this.handleChange(e)} /> + ) } else if (this.props.widget.type === 'Plot') { - widgetDialog = this.validateForm(id)} simulation={this.props.simulation} handleChange={(e, index) => this.handleChange(e, index)} />; + dialogControls.push( + this.validateForm(id)} simulation={this.props.simulation} handleChange={(e, index) => this.handleChange(e, index)} />, + this.validateForm(id)} simulation={this.props.simulation} handleChange={(e) => this.handleChange(e)} />, + this.validateForm(id)} simulation={this.props.simulation} handleChange={(e) => this.handleChange(e)} /> + ) } else if (this.props.widget.type === 'Table') { - widgetDialog = this.validateForm(id)} simulation={this.props.simulation} handleChange={(e, index) => this.handleChange(e, index)} />; + dialogControls.push( + this.validateForm(id)} simulation={this.props.simulation} handleChange={(e) => this.handleChange(e)} /> + ) } else if (this.props.widget.type === 'Image') { - widgetDialog = this.validateForm(id)} simulation={this.props.simulation} handleChange={(e, index) => this.handleChange(e, index)} />; + dialogControls.push( + this.validateForm(id)} simulation={this.props.simulation} handleChange={(e, index) => this.handleChange(e, index)} /> + ) } else if (this.props.widget.type === 'Gauge') { dialogControls.push( this.validateForm(id)} simulation={this.props.simulation} handleChange={(e) => this.handleChange(e)} />, @@ -99,7 +104,7 @@ class EditWidgetDialog extends Component { } else if (this.props.widget.type === 'PlotTable') { dialogControls.push( this.validateForm(id)} simulation={this.props.simulation} handleChange={(e) => this.handleChange(e)} />, - this.validateForm(id)} simulation={this.props.simulation} handleChange={(e) => this.handleChange(e)} /> + this.validateForm(id)} simulation={this.props.simulation} handleChange={(e) => this.handleChange(e)} /> ) } else if (this.props.widget.type === 'Slider') { dialogControls.push( @@ -117,7 +122,6 @@ class EditWidgetDialog extends Component { { dialogControls } - {widgetDialog} ); From 279dc7b0f2e6690565b409590a87b25876d18836 Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Thu, 13 Apr 2017 10:24:01 +0200 Subject: [PATCH 03/59] Extracted widget creation to separate factory --- src/components/widget-factory.js | 108 +++++++++++++++++++++++++++++++ src/containers/visualization.js | 79 ++-------------------- 2 files changed, 112 insertions(+), 75 deletions(-) create mode 100644 src/components/widget-factory.js diff --git a/src/components/widget-factory.js b/src/components/widget-factory.js new file mode 100644 index 0000000..0f45052 --- /dev/null +++ b/src/components/widget-factory.js @@ -0,0 +1,108 @@ +/** + * File: widget-factory.js + * Description: A factory to create and pre-configure widgets + * Author: Ricardo Hernandez-Montoya + * Date: 02.03.2017 + * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC + * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. + * Unauthorized copying of this file, via any medium is strictly prohibited. + **********************************************************************************/ + +import WidgetSlider from './widget-slider'; + +class WidgetFactory { + + static createWidgetOfType(type, position, defaultSimulator = null) { + + let widget = { + name: 'Name', + type: type, + width: 100, + height: 100, + x: position.x, + y: position.y, + z: 0 + }; + + // set type specific properties + switch(type) { + case 'Value': + widget.simulator = defaultSimulator; + widget.signal = 0; + widget.minWidth = 70; + widget.minHeight = 20; + widget.width = 120; + widget.height = 70; + break; + case 'Plot': + widget.simulator = defaultSimulator; + widget.signals = [ 0 ]; + widget.time = 60; + widget.minWidth = 400; + widget.minHeight = 200; + widget.width = 400; + widget.height = 200; + break; + case 'Table': + widget.simulator = defaultSimulator; + widget.minWidth = 300; + widget.minHeight = 200; + widget.width = 400; + widget.height = 200; + break; + case 'Label': + widget.minWidth = 70; + widget.minHeight = 20; + break; + case 'PlotTable': + widget.simulator = defaultSimulator; + widget.preselectedSignals = []; + widget.signals = []; // initialize selected signals + widget.minWidth = 400; + widget.minHeight = 300; + widget.width = 500; + widget.height = 500; + widget.time = 60; + break; + case 'Image': + widget.minWidth = 100; + widget.minHeight = 100; + widget.width = 200; + widget.height = 200; + break; + case 'Button': + widget.minWidth = 100; + widget.minHeight = 50; + widget.width = 100; + widget.height = 100; + break; + case 'NumberInput': + widget.minWidth = 200; + widget.minHeight = 50; + widget.width = 200; + widget.height = 50; + break; + case 'Slider': + widget.minWidth = 380; + widget.minHeight = 30; + widget.width = 400; + widget.height = 50; + widget.orientation = WidgetSlider.OrientationTypes.HORIZONTAL.value; // Assign default orientation + break; + case 'Gauge': + widget.simulator = defaultSimulator; + widget.signal = 0; + widget.minWidth = 200; + widget.minHeight = 150; + widget.width = 200; + widget.height = 150; + break; + default: + widget.width = 100; + widget.height = 100; + } + return widget; + } +} + +export default WidgetFactory; \ No newline at end of file diff --git a/src/containers/visualization.js b/src/containers/visualization.js index c82d56d..7328205 100644 --- a/src/containers/visualization.js +++ b/src/containers/visualization.js @@ -12,6 +12,7 @@ import { Container } from 'flux/utils'; import { Button } from 'react-bootstrap'; import { ContextMenu, MenuItem } from 'react-contextmenu'; +import WidgetFactory from '../components/widget-factory'; import ToolboxItem from '../components/toolbox-item'; import Dropzone from '../components/dropzone'; import Widget from './widget'; @@ -25,8 +26,6 @@ import AppDispatcher from '../app-dispatcher'; import NotificationsDataManager from '../data-managers/notifications-data-manager'; import NotificationsFactory from '../data-managers/notifications-factory'; -import WidgetSlider from '../components/widget-slider'; - class Visualization extends Component { static getStores() { return [ VisualizationStore, ProjectStore, SimulationStore, FileStore ]; @@ -129,17 +128,8 @@ class Visualization extends Component { } handleDrop(item, position) { - // add new widget - var widget = { - name: 'Name', - type: item.name, - width: 100, - height: 100, - x: position.x, - y: position.y, - z: 0 - }; + let widget = null; let defaultSimulator = null; if (this.state.simulation.models && this.state.simulation.models.length === 0) { @@ -148,69 +138,8 @@ class Visualization extends Component { defaultSimulator = this.state.simulation.models[0].simulator; } - // set type specific properties - if (item.name === 'Value') { - widget.simulator = defaultSimulator; - widget.signal = 0; - widget.minWidth = 70; - widget.minHeight = 20; - widget.width = 120; - widget.height = 70; - } else if (item.name === 'Plot') { - widget.simulator = defaultSimulator; - widget.signals = [ 0 ]; - widget.time = 60; - widget.minWidth = 400; - widget.minHeight = 200; - widget.width = 400; - widget.height = 200; - } else if (item.name === 'Table') { - widget.simulator = defaultSimulator; - widget.minWidth = 300; - widget.minHeight = 200; - widget.width = 400; - widget.height = 200; - } else if (item.name === 'Label') { - widget.minWidth = 70; - widget.minHeight = 20; - } else if (item.name === 'PlotTable') { - widget.simulator = defaultSimulator; - widget.preselectedSignals = []; - widget.signals = []; // initialize selected signals - widget.minWidth = 400; - widget.minHeight = 300; - widget.width = 500; - widget.height = 500; - widget.time = 60 - } else if (item.name === 'Image') { - widget.minWidth = 100; - widget.minHeight = 100; - widget.width = 200; - widget.height = 200; - } else if (item.name === 'Button') { - widget.minWidth = 100; - widget.minHeight = 50; - widget.width = 100; - widget.height = 100; - } else if (item.name === 'NumberInput') { - widget.minWidth = 200; - widget.minHeight = 50; - widget.width = 200; - widget.height = 50; - } else if (item.name === 'Slider') { - widget.minWidth = 380; - widget.minHeight = 30; - widget.width = 400; - widget.height = 50; - widget.orientation = WidgetSlider.OrientationTypes.HORIZONTAL.value; // Assign default orientation - } else if (item.name === 'Gauge') { - widget.simulator = defaultSimulator; - widget.signal = 0; - widget.minWidth = 200; - widget.minHeight = 150; - widget.width = 200; - widget.height = 150; - } + // create new widget + widget = WidgetFactory.createWidgetOfType(item.name, position, defaultSimulator); var new_widgets = this.state.visualization.widgets; From 00f6739241e950dbffa63b8ea551d209c59ee31b Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Thu, 13 Apr 2017 10:39:31 +0200 Subject: [PATCH 04/59] Missing sim model handling in signal edit control --- .../dialog/edit-widget-signal-control.js | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/components/dialog/edit-widget-signal-control.js b/src/components/dialog/edit-widget-signal-control.js index fd2cd5e..879052b 100644 --- a/src/components/dialog/edit-widget-signal-control.js +++ b/src/components/dialog/edit-widget-signal-control.js @@ -27,24 +27,29 @@ class EditWidgetSignalControl extends Component { } render() { - // get selected simulation model - var simulationModel = {}; + let signalsToRender = []; if (this.props.simulation) { - this.props.simulation.models.forEach((model) => { - if (model.simulation === this.state.widget.simulation) { - simulationModel = model; - } - }); + // get selected simulation model + const simulationModel = this.props.simulation.models.find( model => model.simulation === this.state.widget.simulation ); + + // If simulation model update the signals to render + signalsToRender = simulationModel? simulationModel.mapping : []; } return ( Signal this.props.handleChange(e)}> - {simulationModel.mapping.map((signal, index) => ( - - ))} + { + signalsToRender.length === 0 ? ( + + ) : ( + signalsToRender.map((signal, index) => ( + + )) + ) + } ); From 6c28a1a77b43a23cdfbaa56fa4bf3d82c052503e Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Thu, 13 Apr 2017 13:42:26 +0200 Subject: [PATCH 05/59] outline-offset as Firefox-specific --- src/styles/widgets.css | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/styles/widgets.css b/src/styles/widgets.css index c8b5678..df4619e 100644 --- a/src/styles/widgets.css +++ b/src/styles/widgets.css @@ -19,9 +19,15 @@ background-color: #fff; } +/* Firefox-specific rules */ +@-moz-document url-prefix() { + .editing-widget:not(.border):hover { + outline-offset: -10px; + } +} + .editing-widget:not(.border):hover { outline: 1px solid lightgray; - outline-offset: -10px; } /* Area to trigger the context menu */ From ff77a43dedfec8477dd2f614bd3156199bd4b2d9 Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Thu, 13 Apr 2017 13:45:43 +0200 Subject: [PATCH 06/59] Missing classes --- src/components/widget-label.js | 4 +++- src/components/widget-value.js | 5 +++-- src/styles/widgets.css | 9 --------- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/components/widget-label.js b/src/components/widget-label.js index 2c29650..0347778 100644 --- a/src/components/widget-label.js +++ b/src/components/widget-label.js @@ -12,7 +12,9 @@ import React, { Component } from 'react'; class WidgetLabel extends Component { render() { return ( -

{this.props.widget.name}

+
+

{this.props.widget.name}

+
); } } diff --git a/src/components/widget-value.js b/src/components/widget-value.js index c096695..0eb7a9d 100644 --- a/src/components/widget-value.js +++ b/src/components/widget-value.js @@ -35,9 +35,10 @@ class WidgetValue extends Component { } render() { + var value_to_render = Number(this.state.value); return ( -
- {this.props.widget.name}: {this.state.value} +
+ {this.props.widget.name} { Number.isNaN(value_to_render)? NaN : value_to_render.toFixed(3) }
); } diff --git a/src/styles/widgets.css b/src/styles/widgets.css index df4619e..e69fae9 100644 --- a/src/styles/widgets.css +++ b/src/styles/widgets.css @@ -248,15 +248,6 @@ div[class*="-widget"] .btn[disabled], .btn.disabled, div[class*="-widget"] input /* End Plots */ -/*.single-value-widget { - position: absolute; - top: 50%; - left: 50%; - transform: translate(-50%, -50%); - width: 95%; - height: 95%; -}*/ - .single-value-widget { width: 100%; height: 100%; From be0fa587ab6f3fa3523f5e20050d2fdaa37234bd Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Thu, 13 Apr 2017 14:39:01 +0200 Subject: [PATCH 07/59] Meaningful hint --- src/components/widget-plot-table.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/widget-plot-table.js b/src/components/widget-plot-table.js index cbdee75..a985221 100644 --- a/src/components/widget-plot-table.js +++ b/src/components/widget-plot-table.js @@ -126,7 +126,7 @@ class WidgetPlotTable extends Component { { checkBoxes } - ) : ( No signal found, select a different signal type. ) + ) : ( No signal has been pre-selected. ) }
From e980245be59fd923e24acf396f1d9b90666ccadd Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Thu, 13 Apr 2017 14:39:32 +0200 Subject: [PATCH 08/59] No overflow --- src/styles/widgets.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/styles/widgets.css b/src/styles/widgets.css index e69fae9..0a4f286 100644 --- a/src/styles/widgets.css +++ b/src/styles/widgets.css @@ -237,7 +237,7 @@ div[class*="-widget"] .btn[disabled], .btn.disabled, div[class*="-widget"] input .signal-legend { font-size: 0.8em; font-weight: 700; - overflow-x: hidden; + overflow: hidden; } .legend-color { From fed600d2e90db083fe354951cdc54f2f9e4afc4b Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Thu, 13 Apr 2017 15:46:54 +0200 Subject: [PATCH 09/59] Dropped use of height percentage in column-oriented flex child (not supported by Chrome) --- src/styles/widgets.css | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/styles/widgets.css b/src/styles/widgets.css index 0a4f286..c449bf6 100644 --- a/src/styles/widgets.css +++ b/src/styles/widgets.css @@ -200,11 +200,6 @@ div[class*="-widget"] .btn[disabled], .btn.disabled, div[class*="-widget"] input .plot-table-widget input[type="checkbox"] { display: none; } - -.plot-table-widget .widget-plot { - -webkit-flex: 1 1 auto; - flex: 1 1 auto; -} /* End PlotTable Widget */ /* Plot Widget */ @@ -213,16 +208,17 @@ div[class*="-widget"] .btn[disabled], .btn.disabled, div[class*="-widget"] input display: flex; flex-direction: column; } - -.plot-widget .widget-plot { - -webkit-flex: 1 1 auto; - flex: 1 1 auto; -} /* End Plot Widget */ /* Plots */ +/* The plot container, in order to avoid 100% height/width */ +.widget-plot { + display: flex; + -webkit-flex: 1 1 auto; + flex: 1 1 auto; +} + .chart-wrapper { - height: 100%; width: 100%; } From 7eed1cdc54c537ee08a12c00d4d355c14a1c1f54 Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Tue, 18 Apr 2017 14:03:33 +0200 Subject: [PATCH 10/59] let visualization area expand and shrink with new widgets --- src/containers/visualization.js | 68 ++++++++++++++++++++++++--------- src/styles/app.css | 18 ++++----- 2 files changed, 57 insertions(+), 29 deletions(-) diff --git a/src/containers/visualization.js b/src/containers/visualization.js index 6085b06..813dae5 100644 --- a/src/containers/visualization.js +++ b/src/containers/visualization.js @@ -50,11 +50,13 @@ class Visualization extends Component { editModal: prevState.editModal || false, modalData: prevState.modalData || null, modalIndex: prevState.modalIndex || null, - + + maxWidgetHeight: prevState.maxWidgetHeight || 0, + dropZoneHeight: prevState.dropZoneHeight || 0, last_widget_key: prevState.last_widget_key || 0 }; } - + componentWillMount() { AppDispatcher.dispatch({ type: 'visualizations/start-load' @@ -116,6 +118,8 @@ class Visualization extends Component { widgets: tempVisualization.widgets? this.transformToWidgetsDict(tempVisualization.widgets) : {} }); + this.computeHeightWithWidgets(visualization.widgets); + this.setState({ visualization: visualization, project: null }); AppDispatcher.dispatch({ @@ -210,6 +214,8 @@ class Visualization extends Component { var visualization = Object.assign({}, this.state.visualization, { widgets: new_widgets }); + + this.increaseHeightWithWidget(widget); this.setState({ visualization: visualization }); } @@ -227,9 +233,48 @@ class Visualization extends Component { var visualization = Object.assign({}, this.state.visualization, { widgets: new_widgets }); + + // Check if the height needs to be increased, the section may have shrunk if not + if (!this.increaseHeightWithWidget(updated_widget)) { + this.computeHeightWithWidgets(visualization.widgets); + } this.setState({ visualization: visualization }, callback); } + /* + * Set the initial height state based on the existing widgets + */ + computeHeightWithWidgets(widgets) { + // Compute max height from widgets + let maxHeight = Object.keys(widgets).reduce( (maxHeightSoFar, widgetKey) => { + let thisWidget = widgets[widgetKey]; + let thisWidgetHeight = thisWidget.y + thisWidget.height; + + return thisWidgetHeight > maxHeightSoFar? thisWidgetHeight : maxHeightSoFar; + }, 0); + + this.setState({ + maxWidgetHeight: maxHeight, + dropZoneHeight: maxHeight + 40 + }); + } + /* + * Adapt the area's height with the position of the new widget. + * Return true if the height increased, otherwise false. + */ + increaseHeightWithWidget(widget) { + let increased = false; + let thisWidgetHeight = widget.y + widget.height; + if (thisWidgetHeight > this.state.maxWidgetHeight) { + increased = true; + this.setState({ + maxWidgetHeight: thisWidgetHeight, + dropZoneHeight: thisWidgetHeight + 40 + }); + } + return increased; + } + editWidget(e, data) { this.setState({ editModal: true, modalData: this.state.visualization.widgets[data.key], modalIndex: data.key }); } @@ -324,25 +369,10 @@ class Visualization extends Component { } render() { - // calculate widget area height - var height = 0; - var current_widgets = this.state.visualization.widgets; - if (current_widgets) { - Object.keys(current_widgets).forEach( (widget_key) => { - var widget = current_widgets[widget_key]; - if (widget.y + widget.height > height) { - height = widget.y + widget.height; - } - }); - - // add padding - height += 40; - } - return ( -
+
@@ -383,7 +413,7 @@ class Visualization extends Component {
} - this.handleDrop(item, position)} editing={this.state.editing}> + this.handleDrop(item, position)} editing={this.state.editing}> {current_widgets != null && Object.keys(current_widgets).map( (widget_key) => ( this.widgetChange(w, k)} onWidgetStatusChange={(w, k) => this.widgetStatusChange(w, k)} editing={this.state.editing} index={widget_key} grid={this.state.grid} /> diff --git a/src/styles/app.css b/src/styles/app.css index f1972a0..a22bcaa 100644 --- a/src/styles/app.css +++ b/src/styles/app.css @@ -47,8 +47,7 @@ body { .app-footer { width: 100%; height: 60px; - position: absolute; - bottom: 0px; + float: right; padding-top: 20px; text-align: center; @@ -57,14 +56,12 @@ body { } .app-content { - position: absolute; - bottom: 0px; - top: 60px; - right: 0px; - left: 200px; - min-height: 400px; + display: flex; + float: right; + min-height: calc(100vh - 140px); + width: calc(100% - 220px); - margin: 20px 20px 60px 20px; + margin: 20px 20px 0px 20px; padding: 15px 20px; background-color: #fff; @@ -207,7 +204,8 @@ body { } .section { - height: 100%; + min-height: 100%; + width: 100%; } .section-header div { From 8e08dcf4e781496adea45687bdc8b8bc9d2abca4 Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Tue, 18 Apr 2017 14:04:47 +0200 Subject: [PATCH 11/59] Update sections with css layout --- src/containers/project.js | 2 +- src/containers/projects.js | 2 +- src/containers/simulation.js | 2 +- src/containers/simulations.js | 2 +- src/containers/simulators.js | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/containers/project.js b/src/containers/project.js index 910eebe..48c42ba 100644 --- a/src/containers/project.js +++ b/src/containers/project.js @@ -136,7 +136,7 @@ class Visualizations extends Component { } return ( -
+

{this.state.project.name}

diff --git a/src/containers/projects.js b/src/containers/projects.js index 4e6a4b6..84931f0 100644 --- a/src/containers/projects.js +++ b/src/containers/projects.js @@ -90,7 +90,7 @@ class Projects extends Component { render() { return ( -
+

Projects

diff --git a/src/containers/simulation.js b/src/containers/simulation.js index b6f6c97..75c5877 100644 --- a/src/containers/simulation.js +++ b/src/containers/simulation.js @@ -119,7 +119,7 @@ class Simulation extends Component { render() { return ( -
+

{this.state.simulation.name}

diff --git a/src/containers/simulations.js b/src/containers/simulations.js index dd80a71..f21c3cd 100644 --- a/src/containers/simulations.js +++ b/src/containers/simulations.js @@ -100,7 +100,7 @@ class Simulations extends Component { render() { return ( -
+

Simulations

diff --git a/src/containers/simulators.js b/src/containers/simulators.js index a913f73..620ecc1 100644 --- a/src/containers/simulators.js +++ b/src/containers/simulators.js @@ -84,7 +84,7 @@ class Simulators extends Component { render() { return ( -
+

Simulators

From 94bb086d5674de15b5a4971ff7062994c25b36d2 Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Tue, 18 Apr 2017 16:20:01 +0200 Subject: [PATCH 12/59] more consisting widget sizes (handle overflow) --- src/styles/widgets.css | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/styles/widgets.css b/src/styles/widgets.css index c449bf6..6c8987a 100644 --- a/src/styles/widgets.css +++ b/src/styles/widgets.css @@ -9,6 +9,7 @@ .widget { background-color: #fff; + overflow: auto; } .border { @@ -37,7 +38,7 @@ position: absolute; top: 0px; left: 0px; - padding: 3px 6px; + overflow: auto; } .react-contextmenu { @@ -281,6 +282,10 @@ div[class*="-widget"] .btn[disabled], .btn.disabled, div[class*="-widget"] input div[class*="-widget"] label { cursor: inherit; } + +.number-input-widget .form-horizontal .form-group { + margin: 0px; +} /* End number input widget */ /* Slider widget */ @@ -339,7 +344,7 @@ input[type=range]::-ms-thumb { .gauge-widget canvas { width: 100%; - height: 90%; + height: 87%; } .gauge-name { From 3c60a4800c4fb68bda620b5c1e6627ac4084e3b4 Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Wed, 19 Apr 2017 09:12:16 +0200 Subject: [PATCH 13/59] Allow locking aspect ratio (gauge) --- src/containers/visualization.js | 5 +++-- src/containers/widget.js | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/containers/visualization.js b/src/containers/visualization.js index 813dae5..ec9dc1e 100644 --- a/src/containers/visualization.js +++ b/src/containers/visualization.js @@ -200,10 +200,11 @@ class Visualization extends Component { } else if (item.name === 'Gauge') { widget.simulator = this.state.simulation.models[0].simulator; widget.signal = 0; - widget.minWidth = 200; + widget.minWidth = 150; widget.minHeight = 150; widget.width = 200; - widget.height = 150; + widget.height = 200; + widget.lockedAspectRatio = true; } var new_widgets = this.state.visualization.widgets; diff --git a/src/containers/widget.js b/src/containers/widget.js index 8f17940..d8c9e00 100644 --- a/src/containers/widget.js +++ b/src/containers/widget.js @@ -161,6 +161,7 @@ class Widget extends Component { initial={{ x: Number(widget.x), y: Number(widget.y), width: widget.width, height: widget.height }} minWidth={ widget.minWidth } minHeight={ widget.minHeight } + lockAspectRatio={ widget.lockedAspectRatio } bounds={'parent'} className={ widgetClasses } onResizeStart={ (direction, styleSize, clientSize, event) => this.borderWasClicked(event) } From 02011d6067389a372412e574371658eecfabb803 Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Wed, 19 Apr 2017 15:46:23 +0200 Subject: [PATCH 14/59] Included slider library. Slider adapts to orientation changes --- package.json | 3 +- src/components/widget-slider.js | 63 +++++++++++++++------- src/containers/visualization.js | 7 ++- src/containers/widget.js | 2 +- src/styles/widgets.css | 92 ++++++++++++++++++++------------- 5 files changed, 108 insertions(+), 59 deletions(-) diff --git a/package.json b/package.json index 7d9df16..1e6f8b1 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,8 @@ "react-router": "^3.0.2", "superagent": "^3.5.0", "gaugeJS": "^1.3.2", - "d3-scale": "^1.0.5" + "d3-scale": "^1.0.5", + "rc-slider": "^7.0.1" }, "devDependencies": { "react-scripts": "0.9.3" diff --git a/src/components/widget-slider.js b/src/components/widget-slider.js index 40f890f..2ea720c 100644 --- a/src/components/widget-slider.js +++ b/src/components/widget-slider.js @@ -9,6 +9,8 @@ import React, { Component } from 'react'; import classNames from 'classnames'; +import Slider from 'rc-slider'; +import 'rc-slider/assets/index.css'; class WidgetSlider extends Component { @@ -27,43 +29,68 @@ class WidgetSlider extends Component { }; } - valueChanged(e) { - this.setState({ value: e.target.value }); + componentWillReceiveProps(nextProps) { + // Update value + if (nextProps.widget.value && this.state.value !== nextProps.widget.value) { + this.setState({ value: nextProps.widget.value }) + } + // Check if the orientation changed, update the size if it did + if (this.props.widget.orientation !== nextProps.widget.orientation) { + let baseWidget = nextProps.widget; + // Exchange dimensions and constraints + let newWidget = Object.assign({}, baseWidget, { + width: baseWidget.height, + height: baseWidget.width, + minWidth: baseWidget.minHeight, + minHeight: baseWidget.minWidth, + maxWidth: baseWidget.maxHeight, + maxHeight: baseWidget.maxWidth + }); + nextProps.onWidgetChange(newWidget); + } + } + + valueIsChanging(newValue) { + this.setState({ value: newValue }); + } + + valueChanged(newValue) { + // Enable to propagate action + // let newWidget = Object.assign({}, this.props.widget, { + // value: newValue + // }); + // this.props.onWidgetChange(newWidget); } render() { + + let isVertical = this.props.widget.orientation === WidgetSlider.OrientationTypes.VERTICAL.value; + let fields = { 'name': this.props.widget.name, - 'control': this.valueChanged(e) } defaultValue={ this.state.value }/>, + 'control': this.valueIsChanging(v) } onAfterChange={ (v) => this.valueChanged(v) }/>, 'value': this.state.value } - let vertical = this.props.widget.orientation === WidgetSlider.OrientationTypes.VERTICAL.value; var widgetClasses = classNames({ 'slider-widget': true, 'full': true, - 'vertical': vertical, - 'horizontal': !vertical + 'vertical': isVertical, + 'horizontal': !isVertical }); return ( this.props.widget.orientation === WidgetSlider.OrientationTypes.HORIZONTAL.value? (
-
- -
-
- { fields.control } - { fields.value } -
+ +
{ fields.control }
+ { fields.value }
) : (
-
- - { fields.value } -
-
{ fields.control }
+ + { fields.control } + { fields.value }
) ); diff --git a/src/containers/visualization.js b/src/containers/visualization.js index ec9dc1e..84be870 100644 --- a/src/containers/visualization.js +++ b/src/containers/visualization.js @@ -192,8 +192,11 @@ class Visualization extends Component { widget.width = 200; widget.height = 50; } else if (item.name === 'Slider') { - widget.minWidth = 380; - widget.minHeight = 30; + // Set dimensions and constraints as Horizontal + widget.minWidth = 150; + widget.minHeight = 50; + widget.maxHeight = 51; + widget.maxWidth = 1000; widget.width = 400; widget.height = 50; widget.orientation = WidgetSlider.OrientationTypes.HORIZONTAL.value; // Assign default orientation diff --git a/src/containers/widget.js b/src/containers/widget.js index d8c9e00..1b55f94 100644 --- a/src/containers/widget.js +++ b/src/containers/widget.js @@ -143,7 +143,7 @@ class Widget extends Component { } else if (widget.type === 'NumberInput') { element = } else if (widget.type === 'Slider') { - element = + element = this.props.onWidgetStatusChange(w, this.props.index) } /> } else if (widget.type === 'Gauge') { element = } diff --git a/src/styles/widgets.css b/src/styles/widgets.css index 6c8987a..aa57d12 100644 --- a/src/styles/widgets.css +++ b/src/styles/widgets.css @@ -288,52 +288,70 @@ div[class*="-widget"] label { } /* End number input widget */ -/* Slider widget */ -.slider-widget.vertical input[type="range"] { - position: absolute; - top: 40%; - left: 50%; - transform: rotate(270deg); - /*margin-left: 20px;*/ - width: 150px; -} - -input[type=range]::-moz-range-thumb { - background: #ffffff; -} - -input[type=range]::-webkit-slider-thumb { - background: #ffffff; -} - -input[type=range]::-ms-thumb { - background: #ffffff; -} - -.slider-widget.horizontal div { - width: 50%; - display: inline-block; - text-align: center; - vertical-align: top; -} - -.slider-widget.horizontal span { - display: block; - margin: 5px; -} - -.slider-widget.vertical div { - width: 50%; +/* Begin Slider widget */ +.slider-widget { display: flex; - flex-direction: column; align-items: center; justify-content: space-around; } +.slider-widget label { + flex: 0 0 auto; + text-align: center; +} + .slider-widget span { + text-align: center; font-size: 1.5em; font-weight: 600; } + +.slider-widget.horizontal .slider { + flex: 1 1 auto; +} + +.slider-widget.horizontal span { + flex: 0 0 50pt; +} + +.slider-widget.horizontal label { + padding-right: 10px; +} + +.slider-widget.vertical { + flex-direction: column; +} + +.slider-widget.vertical span { + padding-top: 10px; +} + +.slider-widget.vertical label { + padding-bottom: 10px; +} + +/* Begin Slider customization */ +.rc-slider-track { + background-color: #6EA2B0; +} + +.rc-slider-handle, .rc-slider-handle:hover { + border-color: #6EA2B0; +} + +.rc-slider-disabled { + background-color: inherit; +} + +.rc-slider-disabled .rc-slider-handle { + cursor: inherit; +} + +.rc-slider-disabled .rc-slider-handle:hover { + border-color:#ccc; +} +/* End Slider customization */ + /* End slider widget */ /* Gauge widget */ From 3859aa887bff2bb98262e427bee977709c93431a Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Wed, 19 Apr 2017 16:04:28 +0200 Subject: [PATCH 15/59] Center label widget content --- src/styles/widgets.css | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/styles/widgets.css b/src/styles/widgets.css index aa57d12..04dd7f3 100644 --- a/src/styles/widgets.css +++ b/src/styles/widgets.css @@ -388,4 +388,10 @@ div[class*="-widget"] label { bottom: 10%; text-align: center; } -/* End gauge widget */ \ No newline at end of file +/* End gauge widget */ + +/* Begin label widget */ +.label-widget { + text-align: center; +} +/* End label widget */ \ No newline at end of file From 67d0e159bf1323e88116b790511ff9f83443fa39 Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Wed, 19 Apr 2017 16:14:42 +0200 Subject: [PATCH 16/59] Center content in table widget --- src/components/widget-table.js | 2 +- src/styles/widgets.css | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/widget-table.js b/src/components/widget-table.js index 91e59de..e8862f3 100644 --- a/src/components/widget-table.js +++ b/src/components/widget-table.js @@ -57,7 +57,7 @@ class WidgetTable extends Component { render() { return ( -
+

{this.props.widget.name}

diff --git a/src/styles/widgets.css b/src/styles/widgets.css index 04dd7f3..8752db5 100644 --- a/src/styles/widgets.css +++ b/src/styles/widgets.css @@ -394,4 +394,10 @@ div[class*="-widget"] label { .label-widget { text-align: center; } -/* End label widget */ \ No newline at end of file +/* End label widget */ + +/* Begin table widget */ +.table-widget td, .table-widget th { + text-align: center; +} +/* End table widget*/ \ No newline at end of file From d163d93cd05fd9a7669eb3b185f12006f1d36ff9 Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Thu, 20 Apr 2017 15:06:17 +0200 Subject: [PATCH 17/59] Gauge: restrict updates to value changes, gauge updated directly. --- src/components/widget-gauge.js | 29 +++++++++++++++++++---------- src/containers/widget.js | 2 +- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/components/widget-gauge.js b/src/components/widget-gauge.js index a61c3e8..b4365fe 100644 --- a/src/components/widget-gauge.js +++ b/src/components/widget-gauge.js @@ -23,7 +23,7 @@ class WidgetGauge extends Component { } staticLabels(widget_height) { - var label_font_size = widget_height * 0.055; // font scaling factor + let label_font_size = Math.floor(widget_height * 0.055); // font scaling factor, integer for performance return { font: label_font_size + 'px "Helvetica Neue"', labels: [0.0, 0.1, 0.5, 0.9, 1.0], @@ -58,17 +58,18 @@ class WidgetGauge extends Component { this.gauge.set(this.state.value); } - componentWillUpdate() { - // Update labels after possible resize - this.gauge.setOptions({ staticLabels: this.staticLabels(this.props.widget.height) }); + shouldComponentUpdate(nextProps, nextState) { + + // Check if size changed, resize labels if it did (the canvas itself is scaled with css) + if (this.props.widget.height !== nextProps.widget.height) { + this.updateAfterResize(nextProps.widget.height); + } + + // signal component update only if the value changed + return this.state.value !== nextState.value; } - componentDidUpdate() { - // update gauge's value - this.gauge.set(this.state.value); - } - - componentWillReceiveProps(nextProps) { + componentWillReceiveProps(nextProps) { // update value const simulator = nextProps.widget.simulator; @@ -84,9 +85,17 @@ class WidgetGauge extends Component { const new_value = Math.round( signal[signal.length - 1].y * 1e3 ) / 1e3; if (this.state.value !== new_value) { this.setState({ value: new_value }); + + // update gauge's value + this.gauge.set(new_value); } } + updateAfterResize(newHeight) { + // Update labels after resize + this.gauge.setOptions({ staticLabels: this.staticLabels(newHeight) }); + } + render() { var componentClass = this.props.editing ? "gauge-widget editing" : "gauge-widget"; var signalType = null; diff --git a/src/containers/widget.js b/src/containers/widget.js index 1b55f94..89323b1 100644 --- a/src/containers/widget.js +++ b/src/containers/widget.js @@ -77,7 +77,7 @@ class Widget extends Component { resizeStop(direction, styleSize, clientSize, delta) { // update widget - var widget = this.props.data; + let widget = Object.assign({}, this.props.data); // resize depends on direction if (direction === 'left' || direction === 'topLeft' || direction === 'bottomLeft') { From fe1c9248367acec218da535c4dad5b18010af3b5 Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Thu, 20 Apr 2017 16:30:12 +0200 Subject: [PATCH 18/59] correct highlight in selected plot table widget buttons --- src/styles/widgets.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/styles/widgets.css b/src/styles/widgets.css index 8752db5..b327871 100644 --- a/src/styles/widgets.css +++ b/src/styles/widgets.css @@ -115,7 +115,7 @@ div[class*="-widget"] .btn[disabled], .btn.disabled, div[class*="-widget"] input pointer-events: none; } -.editing-widget .btn-default.disabled { +.editing-widget .btn-default.active { background-color: #abcfd8; border-color: #ccc; } From 3be7fdcd35a829fb2d331b5952a840c374904166 Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Fri, 21 Apr 2017 11:54:41 +0200 Subject: [PATCH 19/59] Initial blank plot and allocate fixed initial height to legend (avoid resizing) --- src/components/widget-plot/plot.js | 59 +++++++++++++++++++++--------- src/styles/widgets.css | 5 +++ 2 files changed, 47 insertions(+), 17 deletions(-) diff --git a/src/components/widget-plot/plot.js b/src/components/widget-plot/plot.js index bb5ff01..cb9aba8 100644 --- a/src/components/widget-plot/plot.js +++ b/src/components/widget-plot/plot.js @@ -17,13 +17,26 @@ class Plot extends Component { this.chartWrapper = null; - this.state = { - size: { w: 0, h: 0 }, - firstTimestamp: 0, - latestTimestamp: 0, - sequence: null, - values: [] - }; + // Initialize plot size and data + this.state = Object.assign( + { size: { w: 0, h: 0 } }, + this.getPlotInitData(true) + ); + } + + // Get an object with 'invisible' init data for the last minute. + // Include start/end timestamps if required. + getPlotInitData(withRangeTimestamps = false) { + + const initSecondTime = Date.now(); + const initFirstTime = initSecondTime - 1000 * 60; // Decrease 1 min + const values = [{ values: [{x: initFirstTime, y: 0}], strokeWidth: 0 }]; + + let output = withRangeTimestamps? + { sequence: 0, values: values, firstTimestamp: initFirstTime, latestTimestamp: initSecondTime, } : + { sequence: 0, values: values }; + + return output; } componentWillReceiveProps(nextProps) { @@ -37,22 +50,34 @@ class Plot extends Component { this.setState({size: { w, h } }); } + // If signals were cleared, clear the plot (triggers a new state) + if (this.signalsWereJustCleared(nextProps)) { this.clearPlot(); return; } + + // If no signals have been selected, just leave + if (nextProps.signals == null || nextProps.signals.length === 0) { return; } + // Identify simulation reset - if (nextData == null || nextData.length === 0 || nextData.values[0].length === 0) { - // clear values - this.setState({ values: [], sequence: null }); - return; - } + if (nextData == null || nextData.length === 0 || nextData.values[0].length === 0) { this.clearPlot(); return; } // check if new data, otherwise skip - if (this.state.sequence >= nextData.sequence) { - return; - } - + if (this.state.sequence >= nextData.sequence) { return; } + this.updatePlotData(nextProps); } + signalsWereJustCleared(nextProps) { + + return this.props.signals && + nextProps.signals && + this.props.signals.length > 0 && + nextProps.signals.length === 0; + } + + clearPlot() { + this.setState( this.getPlotInitData(false) ); + } + updatePlotData(nextProps) { let nextData = nextProps.simulatorData; @@ -91,7 +116,7 @@ class Plot extends Component { return (
this.chartWrapper = domNode }> - {this.state.sequence && + {this.state.sequence != null && Date: Fri, 21 Apr 2017 15:10:36 +0200 Subject: [PATCH 20/59] fixed signals control generic controlId --- src/components/dialog/edit-widget-signals-control.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/components/dialog/edit-widget-signals-control.js b/src/components/dialog/edit-widget-signals-control.js index a7fcd07..b84d930 100644 --- a/src/components/dialog/edit-widget-signals-control.js +++ b/src/components/dialog/edit-widget-signals-control.js @@ -16,8 +16,7 @@ class EditWidgetSignalsControl extends Component { this.state = { widget: { - simulator: '', - preselectedSignals: [] + simulator: '' } }; } @@ -28,7 +27,7 @@ class EditWidgetSignalsControl extends Component { } handleSignalChange(checked, index) { - var signals = this.state.widget.preselectedSignals; + var signals = this.state.widget[this.props.controlId]; var new_signals; if (checked) { @@ -57,11 +56,11 @@ class EditWidgetSignalsControl extends Component { Signals { - signalsToRender.length === 0 ? ( + signalsToRender.length === 0 || !this.state.widget.hasOwnProperty(this.props.controlId)? ( No signals available. ) : ( signalsToRender.map((signal, index) => ( - this.handleSignalChange(e.target.checked, index)}>{signal.name} + this.handleSignalChange(e.target.checked, index)}>{signal.name} )) ) } From dd068b919d08d89a68f29b33803360d0d6541b2e Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Fri, 21 Apr 2017 16:13:07 +0200 Subject: [PATCH 21/59] Plots' Y-axis label can be edited --- .../dialog/edit-widget-text-control.js | 39 +++++++++++++++++++ src/components/dialog/edit-widget.js | 7 +++- src/components/widget-factory.js | 2 + src/components/widget-plot-table.js | 2 +- src/components/widget-plot.js | 2 +- src/components/widget-plot/plot.js | 1 + src/styles/widgets.css | 1 + 7 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 src/components/dialog/edit-widget-text-control.js diff --git a/src/components/dialog/edit-widget-text-control.js b/src/components/dialog/edit-widget-text-control.js new file mode 100644 index 0000000..d4196b4 --- /dev/null +++ b/src/components/dialog/edit-widget-text-control.js @@ -0,0 +1,39 @@ +/** + * File: edit-widget-text-control.js + * Author: Ricardo Hernandez-Montoya + * Date: 21.04.2017 + * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC + * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. + * Unauthorized copying of this file, via any medium is strictly prohibited. + **********************************************************************************/ + +import React, { Component } from 'react'; +import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap'; + +class EditWidgetTextControl extends Component { + constructor(props) { + super(props); + + this.state = { + widget: {} + }; + } + + componentWillReceiveProps(nextProps) { + // Update state's widget with props + this.setState({ widget: nextProps.widget }); + } + + render() { + + return ( + + { this.props.label } + this.props.handleChange(e)} /> + + + ); + } +} + +export default EditWidgetTextControl; \ No newline at end of file diff --git a/src/components/dialog/edit-widget.js b/src/components/dialog/edit-widget.js index b90e75c..a7fc542 100644 --- a/src/components/dialog/edit-widget.js +++ b/src/components/dialog/edit-widget.js @@ -12,6 +12,7 @@ import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap'; import Dialog from './dialog'; +import EditWidgetTextControl from './edit-widget-text-control'; import EditWidgetTimeControl from './edit-widget-time-control'; import EditImageWidgetControl from './edit-widget-image-control'; import EditWidgetSimulatorControl from './edit-widget-simulator-control'; @@ -86,7 +87,8 @@ class EditWidgetDialog extends Component { dialogControls.push( this.validateForm(id)} simulation={this.props.simulation} handleChange={(e, index) => this.handleChange(e, index)} />, this.validateForm(id)} simulation={this.props.simulation} handleChange={(e) => this.handleChange(e)} />, - this.validateForm(id)} simulation={this.props.simulation} handleChange={(e) => this.handleChange(e)} /> + this.validateForm(id)} simulation={this.props.simulation} handleChange={(e) => this.handleChange(e)} />, + this.handleChange(e)} /> ) } else if (this.props.widget.type === 'Table') { dialogControls.push( @@ -104,7 +106,8 @@ class EditWidgetDialog extends Component { } else if (this.props.widget.type === 'PlotTable') { dialogControls.push( this.validateForm(id)} simulation={this.props.simulation} handleChange={(e) => this.handleChange(e)} />, - this.validateForm(id)} simulation={this.props.simulation} handleChange={(e) => this.handleChange(e)} /> + this.validateForm(id)} simulation={this.props.simulation} handleChange={(e) => this.handleChange(e)} />, + this.handleChange(e)} /> ) } else if (this.props.widget.type === 'Slider') { dialogControls.push( diff --git a/src/components/widget-factory.js b/src/components/widget-factory.js index 0f45052..b22faa3 100644 --- a/src/components/widget-factory.js +++ b/src/components/widget-factory.js @@ -37,6 +37,7 @@ class WidgetFactory { case 'Plot': widget.simulator = defaultSimulator; widget.signals = [ 0 ]; + widget.ylabel = ''; widget.time = 60; widget.minWidth = 400; widget.minHeight = 200; @@ -58,6 +59,7 @@ class WidgetFactory { widget.simulator = defaultSimulator; widget.preselectedSignals = []; widget.signals = []; // initialize selected signals + widget.ylabel = ''; widget.minWidth = 400; widget.minHeight = 300; widget.width = 500; diff --git a/src/components/widget-plot-table.js b/src/components/widget-plot-table.js index 4041c8f..43eaf03 100644 --- a/src/components/widget-plot-table.js +++ b/src/components/widget-plot-table.js @@ -136,7 +136,7 @@ class WidgetPlotTable extends Component {
- +
diff --git a/src/components/widget-plot.js b/src/components/widget-plot.js index e0c2662..1c05d58 100644 --- a/src/components/widget-plot.js +++ b/src/components/widget-plot.js @@ -43,7 +43,7 @@ class WidgetPlot extends Component {

{this.props.widget.name}

- +
diff --git a/src/components/widget-plot/plot.js b/src/components/widget-plot/plot.js index cb9aba8..6bae9d0 100644 --- a/src/components/widget-plot/plot.js +++ b/src/components/widget-plot/plot.js @@ -126,6 +126,7 @@ class Plot extends Component { gridHorizontal={true} xAccessor={(d) => { if (d != null) { return new Date(d.x); } }} xAxisTickCount={ tickCount } + yAxisLabel={ this.props.yAxisLabel } hoverAnimation={false} circleRadius={0} domain={{ x: [this.state.firstTimestamp, this.state.latestTimestamp] }} diff --git a/src/styles/widgets.css b/src/styles/widgets.css index b031497..93c40e4 100644 --- a/src/styles/widgets.css +++ b/src/styles/widgets.css @@ -221,6 +221,7 @@ div[class*="-widget"] .btn[disabled], .btn.disabled, div[class*="-widget"] input .chart-wrapper { width: 100%; + padding-left: 10px; } .plot-legend { From 9d229a828ce48314f81a475d7fd82472fbf9ec80 Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Mon, 24 Apr 2017 14:41:23 +0200 Subject: [PATCH 22/59] Button color selection --- .../dialog/edit-widget-color-control.js | 70 +++++++++++++++++++ src/components/dialog/edit-widget.js | 6 ++ src/components/widget-button.js | 15 +++- src/components/widget-factory.js | 2 + src/styles/widgets.css | 37 +++++++++- 5 files changed, 127 insertions(+), 3 deletions(-) create mode 100644 src/components/dialog/edit-widget-color-control.js diff --git a/src/components/dialog/edit-widget-color-control.js b/src/components/dialog/edit-widget-color-control.js new file mode 100644 index 0000000..1b50f44 --- /dev/null +++ b/src/components/dialog/edit-widget-color-control.js @@ -0,0 +1,70 @@ +/** + * File: edit-widget-color-control.js + * Author: Ricardo Hernandez-Montoya + * Date: 24.04.2017 + * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC + * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. + * Unauthorized copying of this file, via any medium is strictly prohibited. + **********************************************************************************/ + +import React, { Component } from 'react'; +import { FormGroup, Col, Row, Radio, ControlLabel } from 'react-bootstrap'; +import classNames from 'classnames'; +import { scaleOrdinal, schemeCategory20 } from 'd3-scale'; + +class EditWidgetColorControl extends Component { + + static get ColorPalette() { + let colorCount = 0; + const colors = []; + const colorScale = scaleOrdinal(schemeCategory20); + while (colorCount < 20) { colors.push(colorScale(colorCount)); colorCount++; } + colors.unshift('#000', '#FFF'); // include black and white + + return colors; + } + + constructor(props) { + super(props); + + this.state = { + widget: {} + }; + } + + componentWillReceiveProps(nextProps) { + // Update state's widget with props + this.setState({ widget: nextProps.widget }); + } + + render() { + + return ( + + +
+ { this.props.label } + + + { + EditWidgetColorControl.ColorPalette.map( (color, idx ) => { + let colorStyle = { + background: color, + borderColor: color + }; + + let checkedClass = classNames({ + 'checked': idx === this.state.widget[this.props.controlId] + }); + + return ( this.props.handleChange({target: { id: this.props.controlId, value: idx}})} />) + } + ) + } + + + ) + } +} + +export default EditWidgetColorControl; \ No newline at end of file diff --git a/src/components/dialog/edit-widget.js b/src/components/dialog/edit-widget.js index a7fc542..d23c3a5 100644 --- a/src/components/dialog/edit-widget.js +++ b/src/components/dialog/edit-widget.js @@ -13,6 +13,7 @@ import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap'; import Dialog from './dialog'; import EditWidgetTextControl from './edit-widget-text-control'; +import EditWidgetColorControl from './edit-widget-color-control'; import EditWidgetTimeControl from './edit-widget-time-control'; import EditImageWidgetControl from './edit-widget-image-control'; import EditWidgetSimulatorControl from './edit-widget-simulator-control'; @@ -113,6 +114,11 @@ class EditWidgetDialog extends Component { dialogControls.push( this.validateForm(id)} simulation={this.props.simulation} handleChange={(e) => this.handleChange(e)} />, ) + } else if (this.props.widget.type === 'Button') { + dialogControls.push( + this.validateForm(id)} handleChange={(e, index) => this.handleChange(e, index)} />, + this.validateForm(id)} handleChange={(e, index) => this.handleChange(e, index)} /> + ) } } diff --git a/src/components/widget-button.js b/src/components/widget-button.js index 72f33fa..98ced0d 100644 --- a/src/components/widget-button.js +++ b/src/components/widget-button.js @@ -9,6 +9,8 @@ import React, { Component } from 'react'; +import EditWidgetColorControl from './dialog/edit-widget-color-control'; + class WidgetButton extends Component { action(e) { @@ -17,12 +19,21 @@ class WidgetButton extends Component { } render() { + + let colors = EditWidgetColorControl.ColorPalette; + + let colorStyle = { + background: colors[this.props.widget.background_color], + color: colors[this.props.widget.font_color], + borderColor: colors[this.props.widget.font_color] + } + return (
{ this.props.editing ? ( - + ) : ( - + ) }
diff --git a/src/components/widget-factory.js b/src/components/widget-factory.js index b22faa3..6414180 100644 --- a/src/components/widget-factory.js +++ b/src/components/widget-factory.js @@ -77,6 +77,8 @@ class WidgetFactory { widget.minHeight = 50; widget.width = 100; widget.height = 100; + widget.background_color = 1; + widget.font_color = 0; break; case 'NumberInput': widget.minWidth = 200; diff --git a/src/styles/widgets.css b/src/styles/widgets.css index 93c40e4..394b3d0 100644 --- a/src/styles/widgets.css +++ b/src/styles/widgets.css @@ -145,6 +145,39 @@ div[class*="-widget"] .btn[disabled], .btn.disabled, div[class*="-widget"] input } /* End match */ +/* Begin edit menu: Colors */ +.color-control input[type="radio"] { + display: none; +} + +.color-control .radio-inline.checked { + border-color: #000 !important; +} + +.color-control .radio-inline { + height: 24px; + flex: 1 1 auto; + border: 2px solid; + /* Reset bootstrap padding */ + padding-left: 0px; +} + +.color-control .radio-inline + .radio-inline { + /* Reset bootstrap margin */ + margin-left: 0px; +} + +.color-control .radio-inline:hover { + border-color: #444 !important; +} + +.color-control div[class*="colors-column-"] { + display: flex; + padding: 2px 20px; +} + +/* End edit menu: Colors */ + /* PlotTable widget */ .plot-table-widget, .plot-widget, .value-widget, .image-widget, .label-widget { width: 100%; @@ -270,8 +303,10 @@ div[class*="-widget"] .btn[disabled], .btn.disabled, div[class*="-widget"] input .button-widget button { border-radius: 25px; border-style: double; - border-width: 5px; + border-width: 4px; overflow-x: hidden; + font-weight: 500; + font-size: 1.2em; } .button-widget button:hover { From 1ded5755d8c4a8799d38180e8300db74c51aaac2 Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Tue, 25 Apr 2017 14:31:28 +0200 Subject: [PATCH 23/59] Box to group widgets --- src/components/dialog/edit-widget.js | 4 ++++ src/components/widget-box.js | 33 ++++++++++++++++++++++++++++ src/components/widget-factory.js | 8 +++++++ src/containers/visualization.js | 1 + src/containers/widget.js | 3 +++ src/styles/widgets.css | 10 ++++++++- 6 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 src/components/widget-box.js diff --git a/src/components/dialog/edit-widget.js b/src/components/dialog/edit-widget.js index d23c3a5..696675b 100644 --- a/src/components/dialog/edit-widget.js +++ b/src/components/dialog/edit-widget.js @@ -119,6 +119,10 @@ class EditWidgetDialog extends Component { this.validateForm(id)} handleChange={(e, index) => this.handleChange(e, index)} />, this.validateForm(id)} handleChange={(e, index) => this.handleChange(e, index)} /> ) + } else if (this.props.widget.type === 'Box') { + dialogControls.push( + this.validateForm(id)} handleChange={(e, index) => this.handleChange(e, index)} /> + ) } } diff --git a/src/components/widget-box.js b/src/components/widget-box.js new file mode 100644 index 0000000..b917b65 --- /dev/null +++ b/src/components/widget-box.js @@ -0,0 +1,33 @@ +/** + * File: widget-box.js + * Author: Ricardo Hernandez-Montoya + * Date: 25.04.2017 + * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC + * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. + * Unauthorized copying of this file, via any medium is strictly prohibited. + **********************************************************************************/ + +import React, { Component } from 'react'; + +import EditWidgetColorControl from './dialog/edit-widget-color-control'; + +class WidgetBox extends Component { + render() { + + let colors = EditWidgetColorControl.ColorPalette; + + let colorStyle = { + borderColor: colors[this.props.widget.border_color] + } + + return ( +
+
+ { } +
+
+ ); + } +} + +export default WidgetBox; diff --git a/src/components/widget-factory.js b/src/components/widget-factory.js index 6414180..59c49d6 100644 --- a/src/components/widget-factory.js +++ b/src/components/widget-factory.js @@ -101,6 +101,14 @@ class WidgetFactory { widget.width = 200; widget.height = 150; break; + case 'Box': + widget.minWidth = 50; + widget.minHeight = 50; + widget.width = 100; + widget.height = 100; + widget.border_color = 0; + widget.z = 0; + break; default: widget.width = 100; widget.height = 100; diff --git a/src/containers/visualization.js b/src/containers/visualization.js index 7766c05..8490f95 100644 --- a/src/containers/visualization.js +++ b/src/containers/visualization.js @@ -349,6 +349,7 @@ class Visualization extends Component { + } diff --git a/src/containers/widget.js b/src/containers/widget.js index 89323b1..b72311c 100644 --- a/src/containers/widget.js +++ b/src/containers/widget.js @@ -27,6 +27,7 @@ import WidgetButton from '../components/widget-button'; import WidgetNumberInput from '../components/widget-number-input'; import WidgetSlider from '../components/widget-slider'; import WidgetGauge from '../components/widget-gauge'; +import WidgetBox from '../components/widget-box'; import '../styles/widgets.css'; @@ -146,6 +147,8 @@ class Widget extends Component { element = this.props.onWidgetStatusChange(w, this.props.index) } /> } else if (widget.type === 'Gauge') { element = + } else if (widget.type === 'Box') { + element = } let widgetClasses = classNames({ diff --git a/src/styles/widgets.css b/src/styles/widgets.css index 394b3d0..19ce5f4 100644 --- a/src/styles/widgets.css +++ b/src/styles/widgets.css @@ -441,4 +441,12 @@ div[class*="-widget"] label { .table-widget td, .table-widget th { text-align: center; } -/* End table widget*/ \ No newline at end of file +/* End table widget*/ + +/* Begin box widget */ +.box-widget .border { + width: 100%; + height: 100%; + border: 2px solid; +} +/* End box widget */ \ No newline at end of file From e7660ceace55c5d3c209f3963f4c965b54bec59e Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Tue, 25 Apr 2017 15:41:20 +0200 Subject: [PATCH 24/59] Place new widgets always on top of the existing ones --- src/components/dropzone.js | 13 +++++++++++++ src/components/widget-factory.js | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/components/dropzone.js b/src/components/dropzone.js index 18815e2..dea4398 100644 --- a/src/components/dropzone.js +++ b/src/components/dropzone.js @@ -19,6 +19,19 @@ const dropzoneTarget = { position.x -= dropzoneRect.left; position.y -= dropzoneRect.top; + // Z-Index is one more the top most children + let foundZ = props.children.reduce( (maxZ, currentChildren) => { + // Is there a simpler way? Is not easy to expose a getter in a Container.create(Component) + let widget = currentChildren.props.data; + if (widget && widget.z) { + if (widget.z > maxZ) { + return widget.z; + } + } + return maxZ; + }, 0); + position.z = foundZ >= 100? foundZ : ++foundZ; + props.onDrop(monitor.getItem(), position); } }; diff --git a/src/components/widget-factory.js b/src/components/widget-factory.js index 59c49d6..364562a 100644 --- a/src/components/widget-factory.js +++ b/src/components/widget-factory.js @@ -21,7 +21,7 @@ class WidgetFactory { height: 100, x: position.x, y: position.y, - z: 0 + z: position.z }; // set type specific properties From 6e130accc15aecb2ae9e456d0ae4b55c52f907b0 Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Tue, 25 Apr 2017 15:47:30 +0200 Subject: [PATCH 25/59] center number input widget vertically --- src/styles/widgets.css | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/styles/widgets.css b/src/styles/widgets.css index 19ce5f4..8745a2c 100644 --- a/src/styles/widgets.css +++ b/src/styles/widgets.css @@ -324,6 +324,12 @@ div[class*="-widget"] label { cursor: inherit; } +.number-input-widget { + display: flex; + flex-direction: column; + justify-content: center; +} + .number-input-widget .form-horizontal .form-group { margin: 0px; } From 6a33dc33c07fbce247837fe865b722063b29f1a1 Mon Sep 17 00:00:00 2001 From: Markus Grigull Date: Thu, 27 Apr 2017 14:41:44 +0200 Subject: [PATCH 26/59] Add GPLv3 License --- COPYING.md | 675 ++++++++++++++++++ src/api/rest-api.js | 20 +- src/api/websocket-api.js | 20 +- src/app-dispatcher.js | 20 +- src/components/dialog/dialog.js | 20 +- src/components/dialog/edit-project.js | 20 +- .../dialog/edit-simulation-model.js | 22 +- src/components/dialog/edit-simulation.js | 20 +- src/components/dialog/edit-simulator.js | 20 +- src/components/dialog/edit-visualization.js | 20 +- src/components/dialog/edit-widget-image.js | 20 +- src/components/dialog/edit-widget-plot.js | 20 +- src/components/dialog/edit-widget-table.js | 20 +- src/components/dialog/edit-widget-value.js | 20 +- src/components/dialog/edit-widget.js | 20 +- src/components/dialog/new-project.js | 20 +- src/components/dialog/new-simulation-model.js | 22 +- src/components/dialog/new-simulation.js | 20 +- src/components/dialog/new-simulator.js | 20 +- src/components/dialog/new-visualization.js | 20 +- src/components/dropzone.js | 20 +- src/components/footer.js | 20 +- src/components/header.js | 20 +- src/components/login-form.js | 20 +- src/components/menu-sidebar.js | 20 +- src/components/table-column.js | 20 +- src/components/table.js | 20 +- src/components/toolbox-item.js | 20 +- src/components/widget-image.js | 20 +- src/components/widget-label.js | 20 +- src/components/widget-plot-table.js | 22 +- src/components/widget-plot.js | 20 +- src/components/widget-table.js | 20 +- src/components/widget-value.js | 20 +- src/containers/app.js | 22 +- src/containers/home.js | 20 +- src/containers/login.js | 20 +- src/containers/logout.js | 20 +- src/containers/project.js | 26 +- src/containers/projects.js | 20 +- src/containers/simulation.js | 20 +- src/containers/simulations.js | 20 +- src/containers/simulators.js | 20 +- src/containers/visualization.js | 30 +- src/containers/widget.js | 28 +- src/data-managers/files-data-manager.js | 20 +- .../notifications-data-manager.js | 20 +- src/data-managers/projects-data-manager.js | 20 +- src/data-managers/rest-data-manager.js | 20 +- src/data-managers/simulations-data-manager.js | 20 +- .../simulator-data-data-manager.js | 20 +- src/data-managers/simulators-data-manager.js | 20 +- src/data-managers/users-data-manager.js | 20 +- .../visualizations-data-manager.js | 20 +- src/index.js | 20 +- src/router.js | 20 +- src/stores/array-store.js | 20 +- src/stores/file-store.js | 20 +- src/stores/project-store.js | 20 +- src/stores/simulation-store.js | 20 +- src/stores/simulator-data-store.js | 20 +- src/stores/simulator-store.js | 24 +- src/stores/user-store.js | 20 +- src/stores/villas-store.js | 20 +- src/stores/visualization-store.js | 20 +- src/styles/app.css | 22 +- src/styles/index.css | 21 + src/styles/widgets.css | 24 +- 68 files changed, 1773 insertions(+), 285 deletions(-) create mode 100644 COPYING.md diff --git a/COPYING.md b/COPYING.md new file mode 100644 index 0000000..5f8b06f --- /dev/null +++ b/COPYING.md @@ -0,0 +1,675 @@ +### GNU GENERAL PUBLIC LICENSE + +Version 3, 29 June 2007 + +Copyright (C) 2007 Free Software Foundation, Inc. + + +Everyone is permitted to copy and distribute verbatim copies of this +license document, but changing it is not allowed. + +### Preamble + +The GNU General Public License is a free, copyleft license for +software and other kinds of works. + +The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom +to share and change all versions of a program--to make sure it remains +free software for all its users. We, the Free Software Foundation, use +the GNU General Public License for most of our software; it applies +also to any other work released this way by its authors. You can apply +it to your programs, too. + +When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + +To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you +have certain responsibilities if you distribute copies of the +software, or if you modify it: responsibilities to respect the freedom +of others. + +For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + +Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + +For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + +Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the +manufacturer can do so. This is fundamentally incompatible with the +aim of protecting users' freedom to change the software. The +systematic pattern of such abuse occurs in the area of products for +individuals to use, which is precisely where it is most unacceptable. +Therefore, we have designed this version of the GPL to prohibit the +practice for those products. If such problems arise substantially in +other domains, we stand ready to extend this provision to those +domains in future versions of the GPL, as needed to protect the +freedom of users. + +Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish +to avoid the special danger that patents applied to a free program +could make it effectively proprietary. To prevent this, the GPL +assures that patents cannot be used to render the program non-free. + +The precise terms and conditions for copying, distribution and +modification follow. + +### TERMS AND CONDITIONS + +#### 0. Definitions. + +"This License" refers to version 3 of the GNU General Public License. + +"Copyright" also means copyright-like laws that apply to other kinds +of works, such as semiconductor masks. + +"The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + +To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of +an exact copy. The resulting work is called a "modified version" of +the earlier work or a work "based on" the earlier work. + +A "covered work" means either the unmodified Program or a work based +on the Program. + +To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + +To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user +through a computer network, with no transfer of a copy, is not +conveying. + +An interactive user interface displays "Appropriate Legal Notices" to +the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + +#### 1. Source Code. + +The "source code" for a work means the preferred form of the work for +making modifications to it. "Object code" means any non-source form of +a work. + +A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + +The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + +The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + +The Corresponding Source need not include anything that users can +regenerate automatically from other parts of the Corresponding Source. + +The Corresponding Source for a work in source code form is that same +work. + +#### 2. Basic Permissions. + +All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + +You may make, run and propagate covered works that you do not convey, +without conditions so long as your license otherwise remains in force. +You may convey covered works to others for the sole purpose of having +them make modifications exclusively for you, or provide you with +facilities for running those works, provided that you comply with the +terms of this License in conveying all material for which you do not +control copyright. Those thus making or running the covered works for +you must do so exclusively on your behalf, under your direction and +control, on terms that prohibit them from making any copies of your +copyrighted material outside their relationship with you. + +Conveying under any other circumstances is permitted solely under the +conditions stated below. Sublicensing is not allowed; section 10 makes +it unnecessary. + +#### 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + +No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + +When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such +circumvention is effected by exercising rights under this License with +respect to the covered work, and you disclaim any intention to limit +operation or modification of the work as a means of enforcing, against +the work's users, your or third parties' legal rights to forbid +circumvention of technological measures. + +#### 4. Conveying Verbatim Copies. + +You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + +You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + +#### 5. Conveying Modified Source Versions. + +You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these +conditions: + +- a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. +- b) The work must carry prominent notices stating that it is + released under this License and any conditions added under + section 7. This requirement modifies the requirement in section 4 + to "keep intact all notices". +- c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. +- d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + +A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + +#### 6. Conveying Non-Source Forms. + +You may convey a covered work in object code form under the terms of +sections 4 and 5, provided that you also convey the machine-readable +Corresponding Source under the terms of this License, in one of these +ways: + +- a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. +- b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the Corresponding + Source from a network server at no charge. +- c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. +- d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. +- e) Convey the object code using peer-to-peer transmission, + provided you inform other peers where the object code and + Corresponding Source of the work are being offered to the general + public at no charge under subsection 6d. + +A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + +A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, +family, or household purposes, or (2) anything designed or sold for +incorporation into a dwelling. In determining whether a product is a +consumer product, doubtful cases shall be resolved in favor of +coverage. For a particular product received by a particular user, +"normally used" refers to a typical or common use of that class of +product, regardless of the status of the particular user or of the way +in which the particular user actually uses, or expects or is expected +to use, the product. A product is a consumer product regardless of +whether the product has substantial commercial, industrial or +non-consumer uses, unless such uses represent the only significant +mode of use of the product. + +"Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to +install and execute modified versions of a covered work in that User +Product from a modified version of its Corresponding Source. The +information must suffice to ensure that the continued functioning of +the modified object code is in no case prevented or interfered with +solely because modification has been made. + +If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + +The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or +updates for a work that has been modified or installed by the +recipient, or for the User Product in which it has been modified or +installed. Access to a network may be denied when the modification +itself materially and adversely affects the operation of the network +or violates the rules and protocols for communication across the +network. + +Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + +#### 7. Additional Terms. + +"Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + +When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + +Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders +of that material) supplement the terms of this License with terms: + +- a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or +- b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or +- c) Prohibiting misrepresentation of the origin of that material, + or requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or +- d) Limiting the use for publicity purposes of names of licensors + or authors of the material; or +- e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or +- f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions + of it) with contractual assumptions of liability to the recipient, + for any liability that these contractual assumptions directly + impose on those licensors and authors. + +All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + +If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + +Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; the +above requirements apply either way. + +#### 8. Termination. + +You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + +However, if you cease all violation of this License, then your license +from a particular copyright holder is reinstated (a) provisionally, +unless and until the copyright holder explicitly and finally +terminates your license, and (b) permanently, if the copyright holder +fails to notify you of the violation by some reasonable means prior to +60 days after the cessation. + +Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + +Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + +#### 9. Acceptance Not Required for Having Copies. + +You are not required to accept this License in order to receive or run +a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + +#### 10. Automatic Licensing of Downstream Recipients. + +Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + +An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + +You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + +#### 11. Patents. + +A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + +A contributor's "essential patent claims" are all patent claims owned +or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + +Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + +In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + +If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + +If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + +A patent license is "discriminatory" if it does not include within the +scope of its coverage, prohibits the exercise of, or is conditioned on +the non-exercise of one or more of the rights that are specifically +granted under this License. You may not convey a covered work if you +are a party to an arrangement with a third party that is in the +business of distributing software, under which you make payment to the +third party based on the extent of your activity of conveying the +work, and under which the third party grants, to any of the parties +who would receive the covered work from you, a discriminatory patent +license (a) in connection with copies of the covered work conveyed by +you (or copies made from those copies), or (b) primarily for and in +connection with specific products or compilations that contain the +covered work, unless you entered into that arrangement, or that patent +license was granted, prior to 28 March 2007. + +Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + +#### 12. No Surrender of Others' Freedom. + +If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under +this License and any other pertinent obligations, then as a +consequence you may not convey it at all. For example, if you agree to +terms that obligate you to collect a royalty for further conveying +from those to whom you convey the Program, the only way you could +satisfy both those terms and this License would be to refrain entirely +from conveying the Program. + +#### 13. Use with the GNU Affero General Public License. + +Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + +#### 14. Revised Versions of this License. + +The Free Software Foundation may publish revised and/or new versions +of the GNU General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in +detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies that a certain numbered version of the GNU General Public +License "or any later version" applies to it, you have the option of +following the terms and conditions either of that numbered version or +of any later version published by the Free Software Foundation. If the +Program does not specify a version number of the GNU General Public +License, you may choose any version ever published by the Free +Software Foundation. + +If the Program specifies that a proxy can decide which future versions +of the GNU General Public License can be used, that proxy's public +statement of acceptance of a version permanently authorizes you to +choose that version for the Program. + +Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + +#### 15. Disclaimer of Warranty. + +THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT +WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND +PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE +DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR +CORRECTION. + +#### 16. Limitation of Liability. + +IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR +CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES +ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT +NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR +LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM +TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER +PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +#### 17. Interpretation of Sections 15 and 16. + +If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + +END OF TERMS AND CONDITIONS + +### How to Apply These Terms to Your New Programs + +If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these +terms. + +To do so, attach the following notices to the program. It is safest to +attach them to the start of each source file to most effectively state +the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program 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. + + This program 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 this program. If not, see . + +Also add information on how to contact you by electronic and paper +mail. + +If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands \`show w' and \`show c' should show the +appropriate parts of the General Public License. Of course, your +program's commands might be different; for a GUI interface, you would +use an "about box". + +You should also get your employer (if you work as a programmer) or +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. For more information on this, and how to apply and follow +the GNU GPL, see . + +The GNU General Public License does not permit incorporating your +program into proprietary programs. If your program is a subroutine +library, you may consider it more useful to permit linking proprietary +applications with the library. If this is what you want to do, use the +GNU Lesser General Public License instead of this License. But first, +please read . diff --git a/src/api/rest-api.js b/src/api/rest-api.js index be14376..66e8211 100644 --- a/src/api/rest-api.js +++ b/src/api/rest-api.js @@ -2,10 +2,22 @@ * File: rest-api.js * Author: Markus Grigull * Date: 02.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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 request from 'superagent/lib/client'; import Promise from 'es6-promise'; diff --git a/src/api/websocket-api.js b/src/api/websocket-api.js index c5cad2c..ff866e2 100644 --- a/src/api/websocket-api.js +++ b/src/api/websocket-api.js @@ -2,10 +2,22 @@ * File: websocket-api.js * Author: Markus Grigull * Date: 03.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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 . + ******************************************************************************/ class WebsocketAPI { addSocket(endpoint, callbacks) { diff --git a/src/app-dispatcher.js b/src/app-dispatcher.js index 52ba2af..ee54eb5 100644 --- a/src/app-dispatcher.js +++ b/src/app-dispatcher.js @@ -2,10 +2,22 @@ * File: app-dispatcher.js * Author: Markus Grigull * Date: 02.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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 { Dispatcher } from 'flux'; diff --git a/src/components/dialog/dialog.js b/src/components/dialog/dialog.js index e3c774d..b0dff93 100644 --- a/src/components/dialog/dialog.js +++ b/src/components/dialog/dialog.js @@ -2,10 +2,22 @@ * File: dialog.js * Author: Markus Grigull * Date: 03.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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, { Component, PropTypes } from 'react'; import { Modal, Button } from 'react-bootstrap'; diff --git a/src/components/dialog/edit-project.js b/src/components/dialog/edit-project.js index b4facfb..74391f5 100644 --- a/src/components/dialog/edit-project.js +++ b/src/components/dialog/edit-project.js @@ -2,10 +2,22 @@ * File: edit-project.js * Author: Markus Grigull * Date: 07.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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, { Component, PropTypes } from 'react'; import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap'; diff --git a/src/components/dialog/edit-simulation-model.js b/src/components/dialog/edit-simulation-model.js index e51380c..3de81dd 100644 --- a/src/components/dialog/edit-simulation-model.js +++ b/src/components/dialog/edit-simulation-model.js @@ -2,10 +2,22 @@ * File: edit-simulation-model.js * Author: Markus Grigull * Date: 04.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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, { Component, PropTypes } from 'react'; import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap'; @@ -58,7 +70,7 @@ class EditSimulationModelDialog extends Component { this.setState({ [e.target.id]: e.target.value }); } - + handleMappingChange(event, row, column) { var mapping = this.state.mapping; diff --git a/src/components/dialog/edit-simulation.js b/src/components/dialog/edit-simulation.js index af9dfa4..b12699c 100644 --- a/src/components/dialog/edit-simulation.js +++ b/src/components/dialog/edit-simulation.js @@ -2,10 +2,22 @@ * File: new-simulation.js * Author: Markus Grigull * Date: 04.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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, { Component, PropTypes } from 'react'; import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap'; diff --git a/src/components/dialog/edit-simulator.js b/src/components/dialog/edit-simulator.js index 2ed14fb..1fdcc09 100644 --- a/src/components/dialog/edit-simulator.js +++ b/src/components/dialog/edit-simulator.js @@ -2,10 +2,22 @@ * File: new-simulator.js * Author: Markus Grigull * Date: 02.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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, { Component, PropTypes } from 'react'; import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap'; diff --git a/src/components/dialog/edit-visualization.js b/src/components/dialog/edit-visualization.js index e31f96a..d9520d4 100644 --- a/src/components/dialog/edit-visualization.js +++ b/src/components/dialog/edit-visualization.js @@ -2,10 +2,22 @@ * File: new-visualization.js * Author: Markus Grigull * Date: 03.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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, { Component, PropTypes } from 'react'; import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap'; diff --git a/src/components/dialog/edit-widget-image.js b/src/components/dialog/edit-widget-image.js index f7b06e4..20f61e7 100644 --- a/src/components/dialog/edit-widget-image.js +++ b/src/components/dialog/edit-widget-image.js @@ -2,10 +2,22 @@ * File: edit-widget-value.js * Author: Markus Grigull * Date: 04.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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, { Component } from 'react'; import { FormGroup, FormControl, ControlLabel, Button } from 'react-bootstrap'; diff --git a/src/components/dialog/edit-widget-plot.js b/src/components/dialog/edit-widget-plot.js index a2371e3..9ff53a2 100644 --- a/src/components/dialog/edit-widget-plot.js +++ b/src/components/dialog/edit-widget-plot.js @@ -2,10 +2,22 @@ * File: edit-widget-plot.js * Author: Markus Grigull * Date: 13.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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, { Component } from 'react'; import { FormGroup, FormControl, ControlLabel, Checkbox, HelpBlock } from 'react-bootstrap'; diff --git a/src/components/dialog/edit-widget-table.js b/src/components/dialog/edit-widget-table.js index 0388ebd..05b17c2 100644 --- a/src/components/dialog/edit-widget-table.js +++ b/src/components/dialog/edit-widget-table.js @@ -2,10 +2,22 @@ * File: edit-widget-table.js * Author: Markus Grigull * Date: 14.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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, { Component } from 'react'; import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap'; diff --git a/src/components/dialog/edit-widget-value.js b/src/components/dialog/edit-widget-value.js index 7f16a03..7061fc9 100644 --- a/src/components/dialog/edit-widget-value.js +++ b/src/components/dialog/edit-widget-value.js @@ -2,10 +2,22 @@ * File: edit-widget-value.js * Author: Markus Grigull * Date: 04.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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, { Component } from 'react'; import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap'; diff --git a/src/components/dialog/edit-widget.js b/src/components/dialog/edit-widget.js index 2b7a21e..561d387 100644 --- a/src/components/dialog/edit-widget.js +++ b/src/components/dialog/edit-widget.js @@ -2,10 +2,22 @@ * File: edit-widget.js * Author: Markus Grigull * Date: 08.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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, { Component, PropTypes } from 'react'; import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap'; diff --git a/src/components/dialog/new-project.js b/src/components/dialog/new-project.js index ae08024..02c1550 100644 --- a/src/components/dialog/new-project.js +++ b/src/components/dialog/new-project.js @@ -2,10 +2,22 @@ * File: new-project.js * Author: Markus Grigull * Date: 07.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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, { Component, PropTypes } from 'react'; import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap'; diff --git a/src/components/dialog/new-simulation-model.js b/src/components/dialog/new-simulation-model.js index e8cf8aa..5789e51 100644 --- a/src/components/dialog/new-simulation-model.js +++ b/src/components/dialog/new-simulation-model.js @@ -2,10 +2,22 @@ * File: new-simulation-model.js * Author: Markus Grigull * Date: 04.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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, { Component, PropTypes } from 'react'; import { FormGroup, FormControl, ControlLabel, HelpBlock } from 'react-bootstrap'; @@ -74,7 +86,7 @@ class NewSimulationModelDialog extends Component { resetState() { this.setState({ name: '', - simulator: this.props.simulators[0] != null ? this.props.simulators[0]._id : '', + simulator: this.props.simulators[0] != null ? this.props.simulators[0]._id : '', length: '1', mapping: [ { name: 'Signal', type: 'Type' } ] }); diff --git a/src/components/dialog/new-simulation.js b/src/components/dialog/new-simulation.js index 617f00b..e0d6313 100644 --- a/src/components/dialog/new-simulation.js +++ b/src/components/dialog/new-simulation.js @@ -2,10 +2,22 @@ * File: new-simulation.js * Author: Markus Grigull * Date: 04.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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, { Component, PropTypes } from 'react'; import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap'; diff --git a/src/components/dialog/new-simulator.js b/src/components/dialog/new-simulator.js index 7726e85..395cf9e 100644 --- a/src/components/dialog/new-simulator.js +++ b/src/components/dialog/new-simulator.js @@ -2,10 +2,22 @@ * File: new-simulator.js * Author: Markus Grigull * Date: 02.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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, { Component, PropTypes } from 'react'; import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap'; diff --git a/src/components/dialog/new-visualization.js b/src/components/dialog/new-visualization.js index 06b3c73..5d04baf 100644 --- a/src/components/dialog/new-visualization.js +++ b/src/components/dialog/new-visualization.js @@ -2,10 +2,22 @@ * File: new-visualization.js * Author: Markus Grigull * Date: 03.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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, { Component, PropTypes } from 'react'; import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap'; diff --git a/src/components/dropzone.js b/src/components/dropzone.js index 18815e2..2c3172c 100644 --- a/src/components/dropzone.js +++ b/src/components/dropzone.js @@ -2,10 +2,22 @@ * File: dropzone.js * Author: Markus Grigull * Date: 02.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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, { Component, PropTypes } from 'react'; import { DropTarget } from 'react-dnd'; diff --git a/src/components/footer.js b/src/components/footer.js index 77b7136..31d29ed 100644 --- a/src/components/footer.js +++ b/src/components/footer.js @@ -2,10 +2,22 @@ * File: footer.js * Author: Markus Grigull * Date: 02.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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, { Component } from 'react'; diff --git a/src/components/header.js b/src/components/header.js index b246f9d..2268cb5 100644 --- a/src/components/header.js +++ b/src/components/header.js @@ -2,10 +2,22 @@ * File: header.js * Author: Markus Grigull * Date: 02.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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, { Component } from 'react'; diff --git a/src/components/login-form.js b/src/components/login-form.js index e4e329f..62840d4 100644 --- a/src/components/login-form.js +++ b/src/components/login-form.js @@ -2,10 +2,22 @@ * File: login-form.js * Author: Markus Grigull * Date: 15.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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, { Component } from 'react'; import { Form, Button, FormGroup, FormControl, ControlLabel, Col } from 'react-bootstrap'; diff --git a/src/components/menu-sidebar.js b/src/components/menu-sidebar.js index 12ed741..120065d 100644 --- a/src/components/menu-sidebar.js +++ b/src/components/menu-sidebar.js @@ -2,10 +2,22 @@ * File: menu-sidebar.js * Author: Markus Grigull * Date: 02.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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, { Component } from 'react'; import { Link } from 'react-router'; diff --git a/src/components/table-column.js b/src/components/table-column.js index 634910d..2867754 100644 --- a/src/components/table-column.js +++ b/src/components/table-column.js @@ -2,10 +2,22 @@ * File: table-column.js * Author: Markus Grigull * Date: 06.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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, { Component } from 'react'; diff --git a/src/components/table.js b/src/components/table.js index 26bec32..f0b94d1 100644 --- a/src/components/table.js +++ b/src/components/table.js @@ -2,10 +2,22 @@ * File: table.js * Author: Markus Grigull * Date: 02.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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, { Component } from 'react'; import { Table, Button, Glyphicon, FormControl, Label } from 'react-bootstrap'; diff --git a/src/components/toolbox-item.js b/src/components/toolbox-item.js index 4cc0144..8d253f3 100644 --- a/src/components/toolbox-item.js +++ b/src/components/toolbox-item.js @@ -2,10 +2,22 @@ * File: toolbox-item.js * Author: Markus Grigull * Date: 02.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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, { Component, PropTypes } from 'react'; import { DragSource } from 'react-dnd'; diff --git a/src/components/widget-image.js b/src/components/widget-image.js index c04a4a1..aeb9642 100644 --- a/src/components/widget-image.js +++ b/src/components/widget-image.js @@ -2,10 +2,22 @@ * File: widget-image.js * Author: Markus Grigull * Date: 14.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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, { Component } from 'react'; diff --git a/src/components/widget-label.js b/src/components/widget-label.js index 2c29650..d9cd5cc 100644 --- a/src/components/widget-label.js +++ b/src/components/widget-label.js @@ -2,10 +2,22 @@ * File: widget-label.js * Author: Markus Grigull * Date: 14.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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, { Component } from 'react'; diff --git a/src/components/widget-plot-table.js b/src/components/widget-plot-table.js index 5305ff8..71ea8bf 100644 --- a/src/components/widget-plot-table.js +++ b/src/components/widget-plot-table.js @@ -2,10 +2,22 @@ * File: widget-plot-table.js * Author: Markus Grigull * Date: 15.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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, { Component } from 'react'; import { LineChart } from 'rd3'; @@ -80,7 +92,7 @@ class WidgetPlotTable extends Component { this.setState({ values: values, firstTimestamp: firstTimestamp, latestTimestamp: latestTimestamp, sequence: nextProps.data[simulator].sequence, rows: rows }); } - + render() { console.log("Signal: " + this.state.signal); return ( diff --git a/src/components/widget-plot.js b/src/components/widget-plot.js index 96de856..aa455a6 100644 --- a/src/components/widget-plot.js +++ b/src/components/widget-plot.js @@ -2,10 +2,22 @@ * File: widget-plot.js * Author: Markus Grigull * Date: 08.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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, { Component } from 'react'; import { LineChart } from 'rd3'; diff --git a/src/components/widget-table.js b/src/components/widget-table.js index 071c084..9de95d7 100644 --- a/src/components/widget-table.js +++ b/src/components/widget-table.js @@ -2,10 +2,22 @@ * File: widget-table.js * Author: Markus Grigull * Date: 14.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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, { Component } from 'react'; diff --git a/src/components/widget-value.js b/src/components/widget-value.js index c096695..f4b9ac4 100644 --- a/src/components/widget-value.js +++ b/src/components/widget-value.js @@ -2,10 +2,22 @@ * File: widget-value.js * Author: Markus Grigull * Date: 04.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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, { Component } from 'react'; diff --git a/src/containers/app.js b/src/containers/app.js index 61f4d16..4e90442 100644 --- a/src/containers/app.js +++ b/src/containers/app.js @@ -2,10 +2,22 @@ * File: app.js * Author: Markus Grigull * Date: 02.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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, { Component } from 'react'; import { Container } from 'flux/utils'; @@ -108,7 +120,7 @@ class App extends Component { localStorage.setItem('token', ''); this.props.router.push('/login'); - + return; } diff --git a/src/containers/home.js b/src/containers/home.js index ae74541..22e6782 100644 --- a/src/containers/home.js +++ b/src/containers/home.js @@ -2,10 +2,22 @@ * File: home.js * Author: Markus Grigull * Date: 02.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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, { Component } from 'react'; import { Container } from 'flux/utils'; diff --git a/src/containers/login.js b/src/containers/login.js index 9453900..d568bc7 100644 --- a/src/containers/login.js +++ b/src/containers/login.js @@ -2,10 +2,22 @@ * File: login.js * Author: Markus Grigull * Date: 15.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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, { Component } from 'react'; import { Container } from 'flux/utils'; diff --git a/src/containers/logout.js b/src/containers/logout.js index 91dc617..5e246bb 100644 --- a/src/containers/logout.js +++ b/src/containers/logout.js @@ -2,10 +2,22 @@ * File: logout.js * Author: Markus Grigull * Date: 15.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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, { Component } from 'react'; import { Container } from 'flux/utils'; diff --git a/src/containers/project.js b/src/containers/project.js index 5ba98bd..988dbdf 100644 --- a/src/containers/project.js +++ b/src/containers/project.js @@ -2,10 +2,22 @@ * File: project.js * Author: Markus Grigull * Date: 03.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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, { Component } from 'react'; import { Container } from 'flux/utils'; @@ -29,7 +41,7 @@ class Visualizations extends Component { let currentProjects = ProjectStore.getState(); let currentVisualizations = VisualizationStore.getState(); - + if (prevState) { var projectUpdate = prevState.project; @@ -62,7 +74,7 @@ class Visualizations extends Component { if (initialProject && (!currentVisualizations || currentVisualizations.length === 0)) { Visualizations.loadVisualizations(initialProject.visualizations); } - + return { projects: currentProjects, visualizations: currentVisualizations, @@ -136,7 +148,7 @@ class Visualizations extends Component { // get visualizations for this project var visualizations = []; if (this.state.visualizations && this.state.project.visualizations) { - visualizations = this.state.visualizations.filter( + visualizations = this.state.visualizations.filter( (visualization) => this.state.project.visualizations.includes(visualization._id) ).sort( (visA, visB) => visA.name.localeCompare(visB.name) diff --git a/src/containers/projects.js b/src/containers/projects.js index 4e6a4b6..e04d34f 100644 --- a/src/containers/projects.js +++ b/src/containers/projects.js @@ -2,10 +2,22 @@ * File: projects.js * Author: Markus Grigull * Date: 02.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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, { Component } from 'react'; import { Container } from 'flux/utils'; diff --git a/src/containers/simulation.js b/src/containers/simulation.js index b6f6c97..20f17bd 100644 --- a/src/containers/simulation.js +++ b/src/containers/simulation.js @@ -2,10 +2,22 @@ * File: simulation.js * Author: Markus Grigull * Date: 04.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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, { Component } from 'react'; import { Container } from 'flux/utils'; diff --git a/src/containers/simulations.js b/src/containers/simulations.js index dd80a71..62ef433 100644 --- a/src/containers/simulations.js +++ b/src/containers/simulations.js @@ -2,10 +2,22 @@ * File: simulations.js * Author: Markus Grigull * Date: 04.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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, { Component } from 'react'; import { Container } from 'flux/utils'; diff --git a/src/containers/simulators.js b/src/containers/simulators.js index a913f73..489aac4 100644 --- a/src/containers/simulators.js +++ b/src/containers/simulators.js @@ -2,10 +2,22 @@ * File: simulators.js * Author: Markus Grigull * Date: 02.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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, { Component } from 'react'; import { Container } from 'flux/utils'; diff --git a/src/containers/visualization.js b/src/containers/visualization.js index 9d108fa..3f9ea9c 100644 --- a/src/containers/visualization.js +++ b/src/containers/visualization.js @@ -2,10 +2,22 @@ * File: visualization.js * Author: Markus Grigull * Date: 02.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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, { Component } from 'react'; import { Container } from 'flux/utils'; @@ -87,7 +99,7 @@ class Visualization extends Component { }); } } - + getNewWidgetKey() { // Increase the counter and update the state return this.state.last_widget_key++; @@ -185,7 +197,7 @@ class Visualization extends Component { } widgetChange(updated_widget, key) { - + var widgets_update = {}; widgets_update[key] = updated_widget; var new_widgets = Object.assign({}, this.state.visualization.widgets, widgets_update); @@ -205,7 +217,7 @@ class Visualization extends Component { // save changes temporarily var widgets_update = {}; widgets_update[this.state.modalIndex] = data; - + var new_widgets = Object.assign({}, this.state.visualization.widgets, widgets_update); var visualization = Object.assign({}, this.state.visualization, { @@ -227,7 +239,7 @@ class Visualization extends Component { } saveChanges() { - // Transform to a list + // Transform to a list var visualization = Object.assign({}, this.state.visualization, { widgets: this.transformToWidgetsList(this.state.visualization.widgets) }); @@ -349,7 +361,7 @@ class Visualization extends Component { ))} - {current_widgets != null && + {current_widgets != null && Object.keys(current_widgets).map( (widget_key) => ( this.editWidget(e, data)}>Edit diff --git a/src/containers/widget.js b/src/containers/widget.js index 7aa540f..e14a47b 100644 --- a/src/containers/widget.js +++ b/src/containers/widget.js @@ -2,10 +2,22 @@ * File: widget.js * Author: Markus Grigull * Date: 04.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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, { Component } from 'react'; import { Container } from 'flux/utils'; @@ -100,8 +112,8 @@ class Widget extends Component { } render() { - - + + //console.log('render widget ' + this.props.data.z + this.props.data.type); @@ -129,7 +141,7 @@ class Widget extends Component { } else if (widget.type === 'Image') { element = } - + if (this.props.editing) { return ( this.borderWasClicked(event) } + onResizeStart={ (direction, styleSize, clientSize, event) => this.borderWasClicked(event) } onResizeStop={(direction, styleSize, clientSize, delta) => this.resizeStop(direction, styleSize, clientSize, delta)} onDragStop={(event, ui) => this.dragStop(event, ui)} moveGrid={grid} diff --git a/src/data-managers/files-data-manager.js b/src/data-managers/files-data-manager.js index 385c778..5f7e1c0 100644 --- a/src/data-managers/files-data-manager.js +++ b/src/data-managers/files-data-manager.js @@ -2,10 +2,22 @@ * File: files-data-manager.js * Author: Markus Grigull * Date: 16.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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 RestDataManager from './rest-data-manager'; import RestAPI from '../api/rest-api'; diff --git a/src/data-managers/notifications-data-manager.js b/src/data-managers/notifications-data-manager.js index b5798bb..f463fcd 100644 --- a/src/data-managers/notifications-data-manager.js +++ b/src/data-managers/notifications-data-manager.js @@ -2,10 +2,22 @@ * File: notifications-data-manager.js * Author: Markus Grigull * Date: 21.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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 . + ******************************************************************************/ class NotificationsDataManager { _notificationSystem = null; diff --git a/src/data-managers/projects-data-manager.js b/src/data-managers/projects-data-manager.js index a85801d..e1b8167 100644 --- a/src/data-managers/projects-data-manager.js +++ b/src/data-managers/projects-data-manager.js @@ -2,10 +2,22 @@ * File: projects-data-manager.js * Author: Markus Grigull * Date: 07.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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 RestDataManager from './rest-data-manager'; diff --git a/src/data-managers/rest-data-manager.js b/src/data-managers/rest-data-manager.js index 655815c..10fb65a 100644 --- a/src/data-managers/rest-data-manager.js +++ b/src/data-managers/rest-data-manager.js @@ -2,10 +2,22 @@ * File: rest-data-manager.js * Author: Markus Grigull * Date: 03.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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 RestAPI from '../api/rest-api'; import AppDispatcher from '../app-dispatcher'; diff --git a/src/data-managers/simulations-data-manager.js b/src/data-managers/simulations-data-manager.js index d5a606e..d5756cb 100644 --- a/src/data-managers/simulations-data-manager.js +++ b/src/data-managers/simulations-data-manager.js @@ -2,10 +2,22 @@ * File: simulation-data-manager.js * Author: Markus Grigull * Date: 04.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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 RestDataManager from './rest-data-manager'; diff --git a/src/data-managers/simulator-data-data-manager.js b/src/data-managers/simulator-data-data-manager.js index 57dc126..d311af4 100644 --- a/src/data-managers/simulator-data-data-manager.js +++ b/src/data-managers/simulator-data-data-manager.js @@ -2,10 +2,22 @@ * File: simulator-data-data-manager.js * Author: Markus Grigull * Date: 03.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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 WebsocketAPI from '../api/websocket-api'; import AppDispatcher from '../app-dispatcher'; diff --git a/src/data-managers/simulators-data-manager.js b/src/data-managers/simulators-data-manager.js index f9c2c97..9bee488 100644 --- a/src/data-managers/simulators-data-manager.js +++ b/src/data-managers/simulators-data-manager.js @@ -2,10 +2,22 @@ * File: simulators-data-manager.js * Author: Markus Grigull * Date: 02.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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 RestDataManager from './rest-data-manager'; import RestAPI from '../api/rest-api'; diff --git a/src/data-managers/users-data-manager.js b/src/data-managers/users-data-manager.js index 7ba1723..711c68d 100644 --- a/src/data-managers/users-data-manager.js +++ b/src/data-managers/users-data-manager.js @@ -2,10 +2,22 @@ * File: users-data-manager.js * Author: Markus Grigull * Date: 15.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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 RestDataManager from './rest-data-manager'; import RestAPI from '../api/rest-api'; diff --git a/src/data-managers/visualizations-data-manager.js b/src/data-managers/visualizations-data-manager.js index 10210bc..b141880 100644 --- a/src/data-managers/visualizations-data-manager.js +++ b/src/data-managers/visualizations-data-manager.js @@ -2,10 +2,22 @@ * File: visualizations-data-manager.js * Author: Markus Grigull * Date: 03.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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 RestDataManager from './rest-data-manager'; diff --git a/src/index.js b/src/index.js index c7cccd4..a853c12 100644 --- a/src/index.js +++ b/src/index.js @@ -2,10 +2,22 @@ * File: index.js * Author: Markus Grigull * Date: 02.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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 ReactDOM from 'react-dom'; diff --git a/src/router.js b/src/router.js index aff704e..a74a7eb 100644 --- a/src/router.js +++ b/src/router.js @@ -2,10 +2,22 @@ * File: router.js * Author: Markus Grigull * Date: 02.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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, { Component } from 'react'; import { Router, Route, hashHistory } from 'react-router'; diff --git a/src/stores/array-store.js b/src/stores/array-store.js index 20c006b..9ff162e 100644 --- a/src/stores/array-store.js +++ b/src/stores/array-store.js @@ -2,10 +2,22 @@ * File: array-store.js * Author: Markus Grigull * Date: 03.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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 { ReduceStore } from 'flux/utils'; diff --git a/src/stores/file-store.js b/src/stores/file-store.js index 57bf1c9..104d16b 100644 --- a/src/stores/file-store.js +++ b/src/stores/file-store.js @@ -2,10 +2,22 @@ * File: file-store.js * Author: Markus Grigull * Date: 16.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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 ArrayStore from './array-store'; import FilesDataManager from '../data-managers/files-data-manager'; diff --git a/src/stores/project-store.js b/src/stores/project-store.js index 405820f..0df9380 100644 --- a/src/stores/project-store.js +++ b/src/stores/project-store.js @@ -2,10 +2,22 @@ * File: project-store.js * Author: Markus Grigull * Date: 07.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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 ArrayStore from './array-store'; import ProjectsDataManager from '../data-managers/projects-data-manager'; diff --git a/src/stores/simulation-store.js b/src/stores/simulation-store.js index 89854f5..87f4676 100644 --- a/src/stores/simulation-store.js +++ b/src/stores/simulation-store.js @@ -2,10 +2,22 @@ * File: simulation-store.js * Author: Markus Grigull * Date: 04.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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 ArrayStore from './array-store'; import SimulationsDataManager from '../data-managers/simulations-data-manager'; diff --git a/src/stores/simulator-data-store.js b/src/stores/simulator-data-store.js index 741c339..d52ac1d 100644 --- a/src/stores/simulator-data-store.js +++ b/src/stores/simulator-data-store.js @@ -2,10 +2,22 @@ * File: simulator-data-store.js * Author: Markus Grigull * Date: 03.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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 { ReduceStore } from 'flux/utils'; diff --git a/src/stores/simulator-store.js b/src/stores/simulator-store.js index 9f430ef..4f8d6bd 100644 --- a/src/stores/simulator-store.js +++ b/src/stores/simulator-store.js @@ -2,10 +2,22 @@ * File: villas-store.js * Author: Markus Grigull * Date: 02.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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 ArrayStore from './array-store'; import SimulatorsDataManager from '../data-managers/simulators-data-manager'; @@ -28,7 +40,7 @@ class SimulatorStore extends ArrayStore { case 'simulators/removed': SimulatorsDataManager.stopRunningDetection(action.original); - + return super.reduce(state, action); case 'simulators/start-edit': @@ -40,7 +52,7 @@ class SimulatorStore extends ArrayStore { case 'simulators/edited': // The update was done, resume the 'runningDetection' SimulatorsDataManager.startRunningDetection(action.data); - + return super.reduce(state, action); case 'simulators/loaded': diff --git a/src/stores/user-store.js b/src/stores/user-store.js index c3467d2..37fc363 100644 --- a/src/stores/user-store.js +++ b/src/stores/user-store.js @@ -2,10 +2,22 @@ * File: user-store.js * Author: Markus Grigull * Date: 15.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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 { ReduceStore } from 'flux/utils'; diff --git a/src/stores/villas-store.js b/src/stores/villas-store.js index 3fc05bf..b553101 100644 --- a/src/stores/villas-store.js +++ b/src/stores/villas-store.js @@ -2,10 +2,22 @@ * File: villas-store.js * Author: Markus Grigull * Date: 02.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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 { ReduceStore } from 'flux/utils'; diff --git a/src/stores/visualization-store.js b/src/stores/visualization-store.js index 5b5c83f..ba69682 100644 --- a/src/stores/visualization-store.js +++ b/src/stores/visualization-store.js @@ -2,10 +2,22 @@ * File: visualization-store.js * Author: Markus Grigull * Date: 02.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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 ArrayStore from './array-store'; import VisualizationsDataManager from '../data-managers/visualizations-data-manager'; diff --git a/src/styles/app.css b/src/styles/app.css index f1972a0..f5a12fd 100644 --- a/src/styles/app.css +++ b/src/styles/app.css @@ -2,10 +2,22 @@ * File: app.css * Author: Markus Grigull * Date: 02.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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 . + ******************************************************************************/ /** * Application container @@ -236,4 +248,4 @@ body { .section-header .glyphicon { font-size: 0.8em; -} \ No newline at end of file +} diff --git a/src/styles/index.css b/src/styles/index.css index 830576d..dde0352 100644 --- a/src/styles/index.css +++ b/src/styles/index.css @@ -1,3 +1,24 @@ +/** + * File: index.css + * Author: Markus Grigull + * Date: 17.03.2017 + * + * 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 . + ******************************************************************************/ + * { margin: 0; padding: 0; diff --git a/src/styles/widgets.css b/src/styles/widgets.css index c6a9c91..dcf9957 100644 --- a/src/styles/widgets.css +++ b/src/styles/widgets.css @@ -2,10 +2,22 @@ * File: widgets.css * Author: Markus Grigull * Date: 02.03.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ + * + * 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 . + ******************************************************************************/ .widget { border: 1px solid lightgray; @@ -123,8 +135,8 @@ border-color: #adadad; } /* End reset */ - + .plot-table-widget .widget-plot { -webkit-flex: 1 0 auto; flex: 1 0 auto; -} \ No newline at end of file +} From 5d70a737737d63c0767e6db95e14f0a00834ac39 Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Fri, 28 Apr 2017 11:43:15 +0200 Subject: [PATCH 27/59] issues #42 and #43 --- src/api/rest-api.js | 37 +++++++++++++++++++++++++++++++++++-- src/stores/user-store.js | 18 ++++++++++++------ 2 files changed, 47 insertions(+), 8 deletions(-) diff --git a/src/api/rest-api.js b/src/api/rest-api.js index 66e8211..6a79598 100644 --- a/src/api/rest-api.js +++ b/src/api/rest-api.js @@ -21,6 +21,36 @@ import request from 'superagent/lib/client'; import Promise from 'es6-promise'; +import NotificationsDataManager from '../data-managers/notifications-data-manager'; + + +// TODO: Add this to a central pool of notifications +const SERVER_NOT_REACHABLE_NOTIFICATION = { + title: 'Server not reachable', + message: 'The server could not be reached. Please try again later.', + level: 'error' + }; + +const REQUEST_TIMEOUT_NOTIFICATION = { + title: 'Request timeout', + message: 'Request timed out. Please try again later.', + level: 'error' + }; + +// Check if the error was due to network failure, timeouts, etc. +// Can be used for the rest of requests +function isNetworkError(err) { + let result = false; + + // If not status nor response fields, it is a network error. TODO: Handle timeouts + if (err.status == null || err.response == null) { + result = true; + + let notification = err.timeout? REQUEST_TIMEOUT_NOTIFICATION : SERVER_NOT_REACHABLE_NOTIFICATION; + NotificationsDataManager.addNotification(notification); + } + return result; +} class RestAPI { get(url, token) { @@ -43,14 +73,17 @@ class RestAPI { post(url, body, token) { return new Promise(function (resolve, reject) { - var req = request.post(url).send(body); + var req = request.post(url).send(body).timeout({ response: 5000 }); // Simple response start timeout (3s) if (token != null) { req.set('x-access-token', token); } - + req.end(function (error, res) { if (res == null || res.status !== 200) { + + error.handled = isNetworkError(error); + reject(error); } else { resolve(JSON.parse(res.text)); diff --git a/src/stores/user-store.js b/src/stores/user-store.js index 37fc363..aeed56f 100644 --- a/src/stores/user-store.js +++ b/src/stores/user-store.js @@ -67,12 +67,18 @@ class UserStore extends ReduceStore { return Object.assign({}, state, { currentUser: null, token: null }); case 'users/login-error': - // server offline - NotificationsDataManager.addNotification({ - title: 'Server offline', - message: 'The server is offline. Please try again later.', - level: 'error' - }); + + if (action.error && !action.error.handled) { + // If it was an error and hasn't been handled, the credentials must have been wrong. + const WRONG_CREDENTIALS_NOTIFICATION = { + title: 'Incorrect credentials', + message: 'Please modify and try again.', + level: 'error' + } + NotificationsDataManager.addNotification(WRONG_CREDENTIALS_NOTIFICATION); + + } + return state; default: From 560713e90184e1cf37de56ed34acbdf6de84cff1 Mon Sep 17 00:00:00 2001 From: Markus Grigull Date: Thu, 27 Apr 2017 17:39:44 +0200 Subject: [PATCH 28/59] Add backend environment support Add proxy for development --- docker-compose.yml | 7 ++++--- nginx/villas.conf | 6 +++--- package.json | 1 + src/data-managers/rest-data-manager.js | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index afdd7a7..1f3a63e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,9 +16,10 @@ services: image: villasweb-backend links: - database + environment: + - NODE_ENV=production database: image: mongo:latest - volumes: - - /opt/database:/data/db - +# volumes: +# - /opt/database:/data/db diff --git a/nginx/villas.conf b/nginx/villas.conf index f3417de..7fd9ee9 100644 --- a/nginx/villas.conf +++ b/nginx/villas.conf @@ -7,10 +7,10 @@ server { proxy_redirect off; proxy_set_header Host $http_host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - + # rewrite url to exclude /api on context broker side - rewrite ^/api/?(.*) /api/v1/$1 break; - + rewrite ^/api/?(.*) /api/$1 break; + proxy_pass http://backend:4000/; } diff --git a/package.json b/package.json index 0116f0a..81c7ea6 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "villasweb-frontend", "version": "0.1.0", "private": true, + "proxy": "http://localhost:4000", "dependencies": { "bootstrap": "^3.3.7", "classnames": "^2.2.5", diff --git a/src/data-managers/rest-data-manager.js b/src/data-managers/rest-data-manager.js index 10fb65a..f4fd82f 100644 --- a/src/data-managers/rest-data-manager.js +++ b/src/data-managers/rest-data-manager.js @@ -22,7 +22,7 @@ import RestAPI from '../api/rest-api'; import AppDispatcher from '../app-dispatcher'; -const API_URL = 'http://localhost:4000/api/v1'; +const API_URL = '/api/v1'; class RestDataManager { constructor(type, url, keyFilter) { From 2fbd71f28f62aaf63a30ad85ef72902ceb3b354e Mon Sep 17 00:00:00 2001 From: Markus Grigull Date: Fri, 28 Apr 2017 12:37:16 +0200 Subject: [PATCH 29/59] Add automated react build to docker-compose --- .dockerignore | 4 ++++ Dockerfile | 10 ++++++++++ docker-compose.yml | 21 +++++++++++++++++---- 3 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..84eb9b1 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +node_modules/ +nginx/ +doc/ +build/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b014976 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM node:latest + +RUN mkdir /react +RUN mkdir /result + +VOLUME /result + +WORKDIR /react + +CMD npm install && npm run build && cp -R /react/build/* /result/ diff --git a/docker-compose.yml b/docker-compose.yml index 1f3a63e..c41ab1f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,16 +1,23 @@ version: "2" services: - frontend: + webserver: image: nginx:stable volumes: - ./nginx:/etc/nginx/conf.d/ - - ./build:/www + - website-volume:/www links: - backend ports: - "80:80" - "443:443" + restart: always + + frontend: + build: . + volumes: + - ./:/react + - website-volume:/result backend: image: villasweb-backend @@ -18,8 +25,14 @@ services: - database environment: - NODE_ENV=production + restart: always database: image: mongo:latest -# volumes: -# - /opt/database:/data/db + volumes: + - data-volume:/data/db + restart: always + +volumes: + data-volume: + website-volume: From b2728b31be7e3432789bfb325767f4cdb4bc8380 Mon Sep 17 00:00:00 2001 From: Markus Grigull Date: Fri, 28 Apr 2017 12:53:01 +0200 Subject: [PATCH 30/59] Fix for mongodb on linux --- docker-compose.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docker-compose.yml b/docker-compose.yml index c41ab1f..579c30b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -32,6 +32,7 @@ services: volumes: - data-volume:/data/db restart: always + user: mongodb volumes: data-volume: From 56f49da1bb014c68ad25947b2c230b1db5c38694 Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Tue, 2 May 2017 11:38:48 +0200 Subject: [PATCH 31/59] Issue #56: tab jump in tables --- src/components/table.js | 70 +++++++++++++++++++++++++++++++---------- 1 file changed, 53 insertions(+), 17 deletions(-) diff --git a/src/components/table.js b/src/components/table.js index f0b94d1..f0798c5 100644 --- a/src/components/table.js +++ b/src/components/table.js @@ -29,6 +29,7 @@ class CustomTable extends Component { constructor(props) { super(props); + this.activeInput = null; this.state = { rows: [], editCell: [ -1, -1 ] @@ -125,6 +126,23 @@ class CustomTable extends Component { this.setState({ rows: rows }); } + componentDidUpdate() { + // A cell will not be selected at initial render, hence no need to call this in 'componentDidMount' + if (this.activeInput) { + this.activeInput.focus(); + } + } + + onCellFocus(index) { + // When a cell focus is detected, update the current state in order to uncover the input element + this.setState({ editCell: [ index.cell, index.row ]}); + } + + cellLostFocus() { + // Reset cell selection state + this.setState({ editCell: [ -1, -1 ] }); + } + render() { // get children var children = this.props.children; @@ -140,23 +158,41 @@ class CustomTable extends Component {
- {this.state.rows.map((row, rowIndex) => ( - - {row.map((cell, cellIndex) => ( - - ))} - - ))} + { + this.state.rows.map((row, rowIndex) => ( + + { + row.map((cell, cellIndex) => { + + let isCellInlineEditable = children[cellIndex].props.inlineEditable === true; + + let tabIndex = isCellInlineEditable? 0 : -1; + + let evtHdls = isCellInlineEditable ? { + onCellClick: (event) => this.onClick(event, rowIndex, cellIndex), + onCellFocus: () => this.onCellFocus({cell: cellIndex, row: rowIndex}), + onCellBlur: () => this.cellLostFocus() + } : { + onCellClick: () => {}, + onCellFocus: () => {}, + onCellBlur: () => {} + }; + + return () + }) + } + )) + }
this.onClick(event, rowIndex, cellIndex) : () => {}}> - {(this.state.editCell[0] === cellIndex && this.state.editCell[1] === rowIndex ) ? ( - children[cellIndex].props.onInlineChange(event, rowIndex, cellIndex)} /> - ) : ( - - {cell.map((element, elementIndex) => ( - {element} - ))} - - )} -
+ {(this.state.editCell[0] === cellIndex && this.state.editCell[1] === rowIndex ) ? ( + children[cellIndex].props.onInlineChange(event, rowIndex, cellIndex)} inputRef={ref => { this.activeInput = ref; }} /> + ) : ( + + {cell.map((element, elementIndex) => ( + {element} + ))} + + )} +
); From 80bd1f102eb39c7ec026af4fa14992b0986fa443 Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Tue, 2 May 2017 14:23:09 +0200 Subject: [PATCH 32/59] list users --- src/components/menu-sidebar.js | 1 + src/containers/users.js | 136 ++++++++++++++++++++++++ src/data-managers/users-data-manager.js | 14 +++ src/router.js | 3 + src/stores/user-store.js | 14 +++ 5 files changed, 168 insertions(+) create mode 100644 src/containers/users.js diff --git a/src/components/menu-sidebar.js b/src/components/menu-sidebar.js index 120065d..1782304 100644 --- a/src/components/menu-sidebar.js +++ b/src/components/menu-sidebar.js @@ -33,6 +33,7 @@ class SidebarMenu extends Component {
  • Projects
  • Simulations
  • Simulators
  • +
  • User Management
  • Logout
  • diff --git a/src/containers/users.js b/src/containers/users.js new file mode 100644 index 0000000..531f112 --- /dev/null +++ b/src/containers/users.js @@ -0,0 +1,136 @@ +/** + * File: users.js + * Author: Ricardo Hernandez-Montoya + * Date: 02.05.2017 + * + * 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, { Component } from 'react'; +import { Container } from 'flux/utils'; +import { Button, Modal, Glyphicon } from 'react-bootstrap'; + +import AppDispatcher from '../app-dispatcher'; +import UserStore from '../stores/user-store'; + +import Table from '../components/table'; +import TableColumn from '../components/table-column'; +import NewProjectDialog from '../components/dialog/new-project'; +import EditProjectDialog from '../components/dialog/edit-project'; + +class Projects extends Component { + static getStores() { + return [ UserStore ]; + } + + static calculateState() { + return { + users: UserStore.getState().users, + + newModal: false, + editModal: false, + deleteModal: false, + modalData: {} + }; + } + + componentWillMount() { + AppDispatcher.dispatch({ + type: 'users/start-load' + }); + } + + // closeNewModal(data) { + // this.setState({ newModal: false }); + + // if (data) { + // AppDispatcher.dispatch({ + // type: 'projects/start-add', + // data: data + // }); + // } + // } + + // confirmDeleteModal() { + // this.setState({ deleteModal: false }); + + // AppDispatcher.dispatch({ + // type: 'projects/start-remove', + // data: this.state.modalData + // }); + // } + + // closeEditModal(data) { + // this.setState({ editModal: false }); + + // if (data) { + // AppDispatcher.dispatch({ + // type: 'projects/start-edit', + // data: data + // }); + // } + // } + + // getSimulationName(id) { + // for (var i = 0; i < this.state.simulations.length; i++) { + // if (this.state.simulations[i]._id === id) { + // return this.state.simulations[i].name; + // } + // } + + // return id; + // } + + render() { + + this.state.users.map( (user) => console.log('User: %o', user)); + + return ( +
    +

    Users

    + + + + + this.setState({ editModal: true, modalData: this.state.users[index] })} onDelete={index => this.setState({ deleteModal: true, modalData: this.state.users[index] })} /> +
    + + {/* + + this.closeNewModal(data)} simulations={this.state.simulations} /> + + this.closeEditModal(data)} project={this.state.modalData} simulations={this.state.simulations} /> + + + + Delete Project + + + + Are you sure you want to delete the project '{this.state.modalData.name}'? + + + + + + + */} +
    + ); + } +} + +export default Container.create(Projects); diff --git a/src/data-managers/users-data-manager.js b/src/data-managers/users-data-manager.js index 711c68d..08c3138 100644 --- a/src/data-managers/users-data-manager.js +++ b/src/data-managers/users-data-manager.js @@ -55,6 +55,20 @@ class UsersDataManager extends RestDataManager { }); }); } + + getUsers(token) { + RestAPI.get(this.makeURL('/users'), token).then(response => { + AppDispatcher.dispatch({ + type: 'users/users-loaded', + users: response.users + }); + }).catch(error => { + AppDispatcher.dispatch({ + type: 'users/users-load-error', + error: error + }); + }); + } } export default new UsersDataManager(); diff --git a/src/router.js b/src/router.js index a74a7eb..85bbe78 100644 --- a/src/router.js +++ b/src/router.js @@ -30,6 +30,7 @@ import Simulators from './containers/simulators'; import Visualization from './containers/visualization'; import Simulations from './containers/simulations'; import Simulation from './containers/simulation'; +import Users from './containers/users'; import Login from './containers/login'; import Logout from './containers/logout'; @@ -50,6 +51,8 @@ class Root extends Component { + + diff --git a/src/stores/user-store.js b/src/stores/user-store.js index aeed56f..9acf4d2 100644 --- a/src/stores/user-store.js +++ b/src/stores/user-store.js @@ -80,6 +80,20 @@ class UserStore extends ReduceStore { } return state; + + case 'users/start-load': + console.log('Sending request'); + UsersDataManager.getUsers(state.token); + + return state; + + case 'users/users-loaded': + + return Object.assign({}, state, { users: action.users }); + + case 'users/users-load-error': + // Users couldn't be loaded. Keep same state + return state; default: return state; From 6a4c31baef0570900242468dc42c9d6df45608dc Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Tue, 2 May 2017 16:29:11 +0200 Subject: [PATCH 33/59] List users reusing array-store --- src/containers/users.js | 43 ++++++++++++----------- src/data-managers/users-data-manager.js | 6 ++-- src/stores/user-store.js | 16 +-------- src/stores/users-store.js | 45 +++++++++++++++++++++++++ 4 files changed, 73 insertions(+), 37 deletions(-) create mode 100644 src/stores/users-store.js diff --git a/src/containers/users.js b/src/containers/users.js index 531f112..b8773be 100644 --- a/src/containers/users.js +++ b/src/containers/users.js @@ -25,20 +25,33 @@ import { Button, Modal, Glyphicon } from 'react-bootstrap'; import AppDispatcher from '../app-dispatcher'; import UserStore from '../stores/user-store'; +import UsersStore from '../stores/users-store'; import Table from '../components/table'; import TableColumn from '../components/table-column'; -import NewProjectDialog from '../components/dialog/new-project'; -import EditProjectDialog from '../components/dialog/edit-project'; +// import NewUserDialog from '../components/dialog/new-user'; +// import EditUserDialog from '../components/dialog/edit-user'; -class Projects extends Component { +class Users extends Component { static getStores() { - return [ UserStore ]; + return [ UserStore, UsersStore ]; } - static calculateState() { + static calculateState(prevState, props) { + + let tokenState = UserStore.getState().token; + + // If there is a token available and this method was called as a result of loading users + if (!prevState && tokenState) { + AppDispatcher.dispatch({ + type: 'users/start-load', + token: tokenState + }); + } + return { - users: UserStore.getState().users, + token: tokenState, + users: UsersStore.getState(), newModal: false, editModal: false, @@ -47,18 +60,12 @@ class Projects extends Component { }; } - componentWillMount() { - AppDispatcher.dispatch({ - type: 'users/start-load' - }); - } - // closeNewModal(data) { // this.setState({ newModal: false }); // if (data) { // AppDispatcher.dispatch({ - // type: 'projects/start-add', + // type: 'users/start-add', // data: data // }); // } @@ -95,8 +102,6 @@ class Projects extends Component { // } render() { - - this.state.users.map( (user) => console.log('User: %o', user)); return (
    @@ -108,11 +113,11 @@ class Projects extends Component { this.setState({ editModal: true, modalData: this.state.users[index] })} onDelete={index => this.setState({ deleteModal: true, modalData: this.state.users[index] })} /> - {/* + - this.closeNewModal(data)} simulations={this.state.simulations} /> + {/* this.closeNewModal(data)} />*/} - this.closeEditModal(data)} project={this.state.modalData} simulations={this.state.simulations} /> + {/* this.closeEditModal(data)} project={this.state.modalData} simulations={this.state.simulations} /> @@ -133,4 +138,4 @@ class Projects extends Component { } } -export default Container.create(Projects); +export default Container.create(Users); diff --git a/src/data-managers/users-data-manager.js b/src/data-managers/users-data-manager.js index 08c3138..b20c3c2 100644 --- a/src/data-managers/users-data-manager.js +++ b/src/data-managers/users-data-manager.js @@ -59,12 +59,12 @@ class UsersDataManager extends RestDataManager { getUsers(token) { RestAPI.get(this.makeURL('/users'), token).then(response => { AppDispatcher.dispatch({ - type: 'users/users-loaded', - users: response.users + type: 'users/loaded', + data: response.users }); }).catch(error => { AppDispatcher.dispatch({ - type: 'users/users-load-error', + type: 'users/load-error', error: error }); }); diff --git a/src/stores/user-store.js b/src/stores/user-store.js index 9acf4d2..0c3a70a 100644 --- a/src/stores/user-store.js +++ b/src/stores/user-store.js @@ -79,21 +79,7 @@ class UserStore extends ReduceStore { } - return state; - - case 'users/start-load': - console.log('Sending request'); - UsersDataManager.getUsers(state.token); - - return state; - - case 'users/users-loaded': - - return Object.assign({}, state, { users: action.users }); - - case 'users/users-load-error': - // Users couldn't be loaded. Keep same state - return state; + return state; default: return state; diff --git a/src/stores/users-store.js b/src/stores/users-store.js new file mode 100644 index 0000000..3eb1595 --- /dev/null +++ b/src/stores/users-store.js @@ -0,0 +1,45 @@ +/** + * File: users-store.js + * Author: Markus Grigull + * Date: 15.03.2017 + * + * 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 ArrayStore from './array-store'; +import UsersDataManager from '../data-managers/users-data-manager'; + +class UsersStore extends ArrayStore { + constructor() { + super('users', UsersDataManager); + } + + reduce(state, action) { + switch (action.type) { + + // Override ArrayStore's start-load to pass token + case 'users/start-load': + UsersDataManager.getUsers(action.token); + return state; + + default: + return super.reduce(state, action); + } + } + +} + +export default new UsersStore(); From 1a54ae09a21183a2fea3ee11ee9f11c9eeabad3e Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Tue, 2 May 2017 17:26:47 +0200 Subject: [PATCH 34/59] Allow optional token inclusion in REST API calls --- src/data-managers/rest-data-manager.js | 18 +++++++++--------- src/data-managers/users-data-manager.js | 15 +-------------- src/stores/array-store.js | 11 ++++++----- src/stores/users-store.js | 5 ----- 4 files changed, 16 insertions(+), 33 deletions(-) diff --git a/src/data-managers/rest-data-manager.js b/src/data-managers/rest-data-manager.js index f4fd82f..99dbd04 100644 --- a/src/data-managers/rest-data-manager.js +++ b/src/data-managers/rest-data-manager.js @@ -51,10 +51,10 @@ class RestDataManager { return object; } - load(id) { + load(id, token = null) { if (id != null) { // load single object - RestAPI.get(this.makeURL(this.url + '/' + id)).then(response => { + RestAPI.get(this.makeURL(this.url + '/' + id), token).then(response => { const data = this.filterKeys(response[this.type]); AppDispatcher.dispatch({ @@ -69,7 +69,7 @@ class RestDataManager { }); } else { // load all objects - RestAPI.get(this.makeURL(this.url)).then(response => { + RestAPI.get(this.makeURL(this.url), token).then(response => { const data = response[this.type + 's'].map(element => { return this.filterKeys(element); }); @@ -87,11 +87,11 @@ class RestDataManager { } } - add(object) { + add(object, token = null) { var obj = {}; obj[this.type] = this.filterKeys(object); - RestAPI.post(this.makeURL(this.url), obj).then(response => { + RestAPI.post(this.makeURL(this.url), obj, token).then(response => { AppDispatcher.dispatch({ type: this.type + 's/added', data: response[this.type] @@ -104,8 +104,8 @@ class RestDataManager { }); } - remove(object) { - RestAPI.delete(this.makeURL(this.url + '/' + object._id)).then(response => { + remove(object, token = null) { + RestAPI.delete(this.makeURL(this.url + '/' + object._id), token).then(response => { AppDispatcher.dispatch({ type: this.type + 's/removed', data: response[this.type], @@ -119,11 +119,11 @@ class RestDataManager { }); } - update(object) { + update(object, token = null) { var obj = {}; obj[this.type] = this.filterKeys(object); - RestAPI.put(this.makeURL(this.url + '/' + object._id), obj).then(response => { + RestAPI.put(this.makeURL(this.url + '/' + object._id, token), obj).then(response => { AppDispatcher.dispatch({ type: this.type + 's/edited', data: response[this.type] diff --git a/src/data-managers/users-data-manager.js b/src/data-managers/users-data-manager.js index b20c3c2..bd60534 100644 --- a/src/data-managers/users-data-manager.js +++ b/src/data-managers/users-data-manager.js @@ -55,20 +55,7 @@ class UsersDataManager extends RestDataManager { }); }); } - - getUsers(token) { - RestAPI.get(this.makeURL('/users'), token).then(response => { - AppDispatcher.dispatch({ - type: 'users/loaded', - data: response.users - }); - }).catch(error => { - AppDispatcher.dispatch({ - type: 'users/load-error', - error: error - }); - }); - } + } export default new UsersDataManager(); diff --git a/src/stores/array-store.js b/src/stores/array-store.js index 9ff162e..b7cfbee 100644 --- a/src/stores/array-store.js +++ b/src/stores/array-store.js @@ -69,10 +69,10 @@ class ArrayStore extends ReduceStore { case this.type + '/start-load': if (Array.isArray(action.data)) { action.data.forEach((id) => { - this.dataManager.load(id); + this.dataManager.load(id, action.token); }); } else { - this.dataManager.load(action.data); + this.dataManager.load(action.data, action.token); } return state; @@ -88,18 +88,19 @@ class ArrayStore extends ReduceStore { return state; case this.type + '/start-add': - this.dataManager.add(action.data); + this.dataManager.add(action.data, action.token); return state; case this.type + '/added': return this.updateElements(state, [action.data]); case this.type + '/add-error': + console.log('something happened'); // TODO: Add error message return state; case this.type + '/start-remove': - this.dataManager.remove(action.data); + this.dataManager.remove(action.data, action.token); return state; case this.type + '/removed': @@ -112,7 +113,7 @@ class ArrayStore extends ReduceStore { return state; case this.type + '/start-edit': - this.dataManager.update(action.data); + this.dataManager.update(action.data, action.token); return state; case this.type + '/edited': diff --git a/src/stores/users-store.js b/src/stores/users-store.js index 3eb1595..0b38e69 100644 --- a/src/stores/users-store.js +++ b/src/stores/users-store.js @@ -30,11 +30,6 @@ class UsersStore extends ArrayStore { reduce(state, action) { switch (action.type) { - // Override ArrayStore's start-load to pass token - case 'users/start-load': - UsersDataManager.getUsers(action.token); - return state; - default: return super.reduce(state, action); } From a4ea7af42933f62faca799e25ad68fecad379516 Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Tue, 2 May 2017 17:27:04 +0200 Subject: [PATCH 35/59] add users with fixed password --- src/components/dialog/new-user.js | 101 ++++++++++++++++++++++++++++++ src/containers/users.js | 35 ++++++----- 2 files changed, 120 insertions(+), 16 deletions(-) create mode 100644 src/components/dialog/new-user.js diff --git a/src/components/dialog/new-user.js b/src/components/dialog/new-user.js new file mode 100644 index 0000000..60f845d --- /dev/null +++ b/src/components/dialog/new-user.js @@ -0,0 +1,101 @@ +/** + * File: new-user.js + * Author: Ricardo Hernandez-Montoya + * Date: 02.05.2017 + * + * 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, { Component, PropTypes } from 'react'; +import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap'; + +import Dialog from './dialog'; + +class NewUserDialog extends Component { + static propTypes = { + show: PropTypes.bool.isRequired, + onClose: PropTypes.func.isRequired + }; + + valid: false; + + constructor(props) { + super(props); + + this.state = { + username: '', + role: 'admin', + password: '1234' + }; + } + + onClose(canceled) { + if (canceled === false) { + this.props.onClose(this.state); + } else { + this.props.onClose(); + } + } + + handleChange(e) { + this.setState({ [e.target.id]: e.target.value }); + } + + resetState() { + this.setState({ + username: '', + role: 'admin', + password: '1234' + }); + } + + validateForm(target) { + // check all controls + var username = true; + + if (this.state.username === '') { + username = false; + } + + this.valid = username; + + // return state to control + if (target === 'username') return username ? "success" : "error"; + } + + render() { + return ( + this.onClose(c)} onReset={() => this.resetState()} valid={this.valid}> +
    + + Username + this.handleChange(e)} /> + + + + Simulation + this.handleChange(e)}> + + + + +
    +
    + ); + } +} + +export default NewUserDialog; diff --git a/src/containers/users.js b/src/containers/users.js index b8773be..4ab17eb 100644 --- a/src/containers/users.js +++ b/src/containers/users.js @@ -21,7 +21,8 @@ import React, { Component } from 'react'; import { Container } from 'flux/utils'; -import { Button, Modal, Glyphicon } from 'react-bootstrap'; +// import { Button, Modal, Glyphicon } from 'react-bootstrap'; +import { Button, Glyphicon } from 'react-bootstrap'; import AppDispatcher from '../app-dispatcher'; import UserStore from '../stores/user-store'; @@ -29,7 +30,7 @@ import UsersStore from '../stores/users-store'; import Table from '../components/table'; import TableColumn from '../components/table-column'; -// import NewUserDialog from '../components/dialog/new-user'; +import NewUserDialog from '../components/dialog/new-user'; // import EditUserDialog from '../components/dialog/edit-user'; class Users extends Component { @@ -60,16 +61,17 @@ class Users extends Component { }; } - // closeNewModal(data) { - // this.setState({ newModal: false }); + closeNewModal(data) { + this.setState({ newModal: false }); - // if (data) { - // AppDispatcher.dispatch({ - // type: 'users/start-add', - // data: data - // }); - // } - // } + if (data) { + AppDispatcher.dispatch({ + type: 'users/start-add', + data: data, + token: this.state.token + }); + } + } // confirmDeleteModal() { // this.setState({ deleteModal: false }); @@ -85,8 +87,9 @@ class Users extends Component { // if (data) { // AppDispatcher.dispatch({ - // type: 'projects/start-edit', - // data: data + // type: 'users/start-edit', + // data: data, + // token: this.state.token // }); // } // } @@ -115,11 +118,11 @@ class Users extends Component { - {/* this.closeNewModal(data)} />*/} + this.closeNewModal(data)} /> - {/* this.closeEditModal(data)} project={this.state.modalData} simulations={this.state.simulations} /> + {/* this.closeEditModal(data)} project={this.state.modalData} />*/} - + {/* Delete Project From fbe3576892cbd95bbe723688e4d5d5ac19ced423 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Tue, 2 May 2017 18:21:47 +0200 Subject: [PATCH 36/59] use new API of VILLASnode to detect running simulators --- src/data-managers/simulators-data-manager.js | 22 +++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/data-managers/simulators-data-manager.js b/src/data-managers/simulators-data-manager.js index 9bee488..f9dfaa6 100644 --- a/src/data-managers/simulators-data-manager.js +++ b/src/data-managers/simulators-data-manager.js @@ -26,20 +26,26 @@ import AppDispatcher from '../app-dispatcher'; function isRunning(simulator) { // get path to nodes.json and simulator name var path = simulator.endpoint.substring(0, simulator.endpoint.lastIndexOf('/')); - path += '/nodes.json'; - var name = simulator.endpoint.substring(simulator.endpoint.lastIndexOf('/') + 1); + var url = 'http://' + path + '/api/v1'; + var body = { + action: 'nodes', + id: '1234' /// @todo use random generated id + }; + // send request - RestAPI.get('http://' + path).then(response => { + RestAPI.post(url, body).then(response => { // check if simulator is running simulator.running = false; - response.forEach(sim => { - if (sim.name === name) { - simulator.running = true; - } - }); + if (response.id == body.id) { + response.response.forEach(sim => { + if (sim.name === name) { + simulator.running = true; + } + }); + } AppDispatcher.dispatch({ type: 'simulators/running', From 56fbaca6802893b18118978cd952360ee87c2b05 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Tue, 2 May 2017 18:22:41 +0200 Subject: [PATCH 37/59] remove endian flag from websocket packets --- src/data-managers/simulator-data-data-manager.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/data-managers/simulator-data-data-manager.js b/src/data-managers/simulator-data-data-manager.js index d311af4..22f443b 100644 --- a/src/data-managers/simulator-data-data-manager.js +++ b/src/data-managers/simulator-data-data-manager.js @@ -90,23 +90,20 @@ class SimulatorDataDataManager { // parse incoming message into usable data var data = new DataView(blob); - let OFFSET_ENDIAN = 1; let OFFSET_TYPE = 2; let OFFSET_VERSION = 4; var bits = data.getUint8(0); - var endian = (bits >> OFFSET_ENDIAN) & 0x1 ? 0 : 1; - var length = data.getUint16(0x02, endian); + var length = data.getUint16(0x02, 1); var values = new Float32Array(data.buffer, data.byteOffset + 0x10, length); return { - endian: endian, version: (bits >> OFFSET_VERSION) & 0xF, type: (bits >> OFFSET_TYPE) & 0x3, length: length, - sequence: data.getUint32(0x04, endian), - timestamp: data.getUint32(0x08, endian) * 1e3 + data.getUint32(0x0C, endian) * 1e-6, + sequence: data.getUint32(0x04, 1), + timestamp: data.getUint32(0x08, 1) * 1e3 + data.getUint32(0x0C, 1) * 1e-6, values: values }; } From 9ec1d54a9389ba029512161cfd4ac6e85587c9be Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Tue, 2 May 2017 18:26:04 +0200 Subject: [PATCH 38/59] add note about default user and password --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d05a9a5..172ff40 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,8 @@ Additional libraries are used, for a complete list see package.json. To start the website locally run `npm start`. This will open a local webserver serving the _frontend_. To make the website work, you still need to start at least the VILLASweb-backend (See repository for information). +The default user and password are configured in the `config.js` file of the _backend_. By default they are: __admin__ / __admin__. + ## Copyright 2017, Institute for Automation of Complex Power Systems, EONERC @@ -55,4 +57,4 @@ For other licensing options please consult [Prof. Antonello Monti](mailto:amonti [Institute for Automation of Complex Power Systems (ACS)](http://www.acs.eonerc.rwth-aachen.de) [EON Energy Research Center (EONERC)](http://www.eonerc.rwth-aachen.de) -[RWTH University Aachen, Germany](http://www.rwth-aachen.de) \ No newline at end of file +[RWTH University Aachen, Germany](http://www.rwth-aachen.de) From 8f6e1fc4399e09581781e08d55d6f24a4b478e89 Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Wed, 3 May 2017 11:05:22 +0200 Subject: [PATCH 39/59] User edit and remove --- src/components/dialog/edit-user.js | 104 +++++++++++++++++++++++++ src/containers/users.js | 60 ++++++-------- src/data-managers/rest-data-manager.js | 2 +- 3 files changed, 130 insertions(+), 36 deletions(-) create mode 100644 src/components/dialog/edit-user.js diff --git a/src/components/dialog/edit-user.js b/src/components/dialog/edit-user.js new file mode 100644 index 0000000..9485c29 --- /dev/null +++ b/src/components/dialog/edit-user.js @@ -0,0 +1,104 @@ +/** + * File: edit-user.js + * Author: Ricardo Hernandez-Montoya + * Date: 02.05.2017 + * + * 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, { Component, PropTypes } from 'react'; +import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap'; + +import Dialog from './dialog'; + +class EditUserDialog extends Component { + static propTypes = { + show: PropTypes.bool.isRequired, + onClose: PropTypes.func.isRequired, + user: PropTypes.object.isRequired + }; + + valid: true; + + constructor(props) { + super(props); + + this.state = { + username: '', + role: '', + _id: '' + } + } + + onClose(canceled) { + if (canceled === false) { + this.props.onClose(this.state); + } else { + this.props.onClose(); + } + } + + handleChange(e) { + this.setState({ [e.target.id]: e.target.value }); + } + + resetState() { + this.setState({ + username: this.props.user.username, + role: this.props.user.role, + _id: this.props.user._id + }); + } + + validateForm(target) { + // check all controls + var username = true; + + if (this.state.username === '') { + username = false; + } + + this.valid = username; + + // return state to control + if (target === 'username') return username ? "success" : "error"; + + return "success"; + } + + render() { + return ( + this.onClose(c)} onReset={() => this.resetState()} valid={this.valid}> +
    + + Username + this.handleChange(e)} /> + + + + Simulation + this.handleChange(e)}> + + + + +
    +
    + ); + } +} + +export default EditUserDialog; diff --git a/src/containers/users.js b/src/containers/users.js index 4ab17eb..b1f573f 100644 --- a/src/containers/users.js +++ b/src/containers/users.js @@ -21,8 +21,7 @@ import React, { Component } from 'react'; import { Container } from 'flux/utils'; -// import { Button, Modal, Glyphicon } from 'react-bootstrap'; -import { Button, Glyphicon } from 'react-bootstrap'; +import { Button, Modal, Glyphicon } from 'react-bootstrap'; import AppDispatcher from '../app-dispatcher'; import UserStore from '../stores/user-store'; @@ -31,7 +30,7 @@ import UsersStore from '../stores/users-store'; import Table from '../components/table'; import TableColumn from '../components/table-column'; import NewUserDialog from '../components/dialog/new-user'; -// import EditUserDialog from '../components/dialog/edit-user'; +import EditUserDialog from '../components/dialog/edit-user'; class Users extends Component { static getStores() { @@ -73,36 +72,27 @@ class Users extends Component { } } - // confirmDeleteModal() { - // this.setState({ deleteModal: false }); + confirmDeleteModal() { + this.setState({ deleteModal: false }); - // AppDispatcher.dispatch({ - // type: 'projects/start-remove', - // data: this.state.modalData - // }); - // } + AppDispatcher.dispatch({ + type: 'users/start-remove', + data: this.state.modalData, + token: this.state.token + }); + } - // closeEditModal(data) { - // this.setState({ editModal: false }); + closeEditModal(data) { + this.setState({ editModal: false }); - // if (data) { - // AppDispatcher.dispatch({ - // type: 'users/start-edit', - // data: data, - // token: this.state.token - // }); - // } - // } - - // getSimulationName(id) { - // for (var i = 0; i < this.state.simulations.length; i++) { - // if (this.state.simulations[i]._id === id) { - // return this.state.simulations[i].name; - // } - // } - - // return id; - // } + if (data) { + AppDispatcher.dispatch({ + type: 'users/start-edit', + data: data, + token: this.state.token + }); + } + } render() { @@ -120,22 +110,22 @@ class Users extends Component { this.closeNewModal(data)} /> - {/* this.closeEditModal(data)} project={this.state.modalData} />*/} + this.closeEditModal(data)} user={this.state.modalData} /> - {/* + - Delete Project + Delete user - Are you sure you want to delete the project '{this.state.modalData.name}'? + Are you sure you want to delete the user '{this.state.modalData.username}'? - */} +
    ); } diff --git a/src/data-managers/rest-data-manager.js b/src/data-managers/rest-data-manager.js index 99dbd04..2ae0a46 100644 --- a/src/data-managers/rest-data-manager.js +++ b/src/data-managers/rest-data-manager.js @@ -123,7 +123,7 @@ class RestDataManager { var obj = {}; obj[this.type] = this.filterKeys(object); - RestAPI.put(this.makeURL(this.url + '/' + object._id, token), obj).then(response => { + RestAPI.put(this.makeURL(this.url + '/' + object._id), obj, token).then(response => { AppDispatcher.dispatch({ type: this.type + 's/edited', data: response[this.type] From 703fa92d2fb9142599f5952db999e90cdd339949 Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Wed, 3 May 2017 11:26:11 +0200 Subject: [PATCH 40/59] include user e-mail --- src/components/dialog/edit-user.js | 9 ++++++++- src/components/dialog/new-user.js | 9 ++++++++- src/containers/users.js | 3 ++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/components/dialog/edit-user.js b/src/components/dialog/edit-user.js index 9485c29..a779725 100644 --- a/src/components/dialog/edit-user.js +++ b/src/components/dialog/edit-user.js @@ -38,6 +38,7 @@ class EditUserDialog extends Component { this.state = { username: '', + mail: '', role: '', _id: '' } @@ -58,6 +59,7 @@ class EditUserDialog extends Component { resetState() { this.setState({ username: this.props.user.username, + mail: this.props.user.mail, role: this.props.user.role, _id: this.props.user._id }); @@ -88,8 +90,13 @@ class EditUserDialog extends Component { this.handleChange(e)} /> + + E-mail + this.handleChange(e)} /> + + - Simulation + Role this.handleChange(e)}> diff --git a/src/components/dialog/new-user.js b/src/components/dialog/new-user.js index 60f845d..690f17d 100644 --- a/src/components/dialog/new-user.js +++ b/src/components/dialog/new-user.js @@ -37,6 +37,7 @@ class NewUserDialog extends Component { this.state = { username: '', + mail: '', role: 'admin', password: '1234' }; @@ -57,6 +58,7 @@ class NewUserDialog extends Component { resetState() { this.setState({ username: '', + mail: '', role: 'admin', password: '1234' }); @@ -85,8 +87,13 @@ class NewUserDialog extends Component { this.handleChange(e)} /> + + E-mail + this.handleChange(e)} /> + + - Simulation + Role this.handleChange(e)}> diff --git a/src/containers/users.js b/src/containers/users.js index b1f573f..91f720c 100644 --- a/src/containers/users.js +++ b/src/containers/users.js @@ -101,7 +101,8 @@ class Users extends Component {

    Users

    - + + this.setState({ editModal: true, modalData: this.state.users[index] })} onDelete={index => this.setState({ deleteModal: true, modalData: this.state.users[index] })} />
    From 8fb0166059b61eeb1fe52d8b16352224409f8876 Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Wed, 3 May 2017 11:44:08 +0200 Subject: [PATCH 41/59] human names and consisting roles with back-end --- src/components/dialog/edit-user.js | 5 +++-- src/components/dialog/new-user.js | 5 +++-- src/containers/users.js | 8 +++++++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/components/dialog/edit-user.js b/src/components/dialog/edit-user.js index a779725..c8bb203 100644 --- a/src/components/dialog/edit-user.js +++ b/src/components/dialog/edit-user.js @@ -98,8 +98,9 @@ class EditUserDialog extends Component { Role this.handleChange(e)}> - - + + + diff --git a/src/components/dialog/new-user.js b/src/components/dialog/new-user.js index 690f17d..f666e31 100644 --- a/src/components/dialog/new-user.js +++ b/src/components/dialog/new-user.js @@ -95,8 +95,9 @@ class NewUserDialog extends Component { Role this.handleChange(e)}> - - + + + diff --git a/src/containers/users.js b/src/containers/users.js index 91f720c..288c4f4 100644 --- a/src/containers/users.js +++ b/src/containers/users.js @@ -94,6 +94,12 @@ class Users extends Component { } } + getHumanRoleName(role_key) { + const HUMAN_ROLE_NAMES = {admin: 'Administrator', user: 'User', guest: 'Guest'}; + + return HUMAN_ROLE_NAMES.hasOwnProperty(role_key)? HUMAN_ROLE_NAMES[role_key] : ''; + } + render() { return ( @@ -103,7 +109,7 @@ class Users extends Component { - + this.getHumanRoleName(role)} /> this.setState({ editModal: true, modalData: this.state.users[index] })} onDelete={index => this.setState({ deleteModal: true, modalData: this.state.users[index] })} />
    From d218c1854d466bcd8db80de9c0ee42f4dd5daba8 Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Wed, 3 May 2017 12:46:53 +0200 Subject: [PATCH 42/59] hide user management section for non-admins --- src/components/menu-sidebar.js | 4 +++- src/containers/app.js | 6 ++++-- src/data-managers/users-data-manager.js | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/components/menu-sidebar.js b/src/components/menu-sidebar.js index 1782304..882ab56 100644 --- a/src/components/menu-sidebar.js +++ b/src/components/menu-sidebar.js @@ -33,7 +33,9 @@ class SidebarMenu extends Component {
  • Projects
  • Simulations
  • Simulators
  • -
  • User Management
  • + { this.props.currentRole === 'admin' ? +
  • User Management
  • : '' + }
  • Logout
  • diff --git a/src/containers/app.js b/src/containers/app.js index 4e90442..9e6eaf0 100644 --- a/src/containers/app.js +++ b/src/containers/app.js @@ -76,9 +76,11 @@ class App extends Component { } } + let currentUser = UserStore.getState().currentUser; + return { simulations: SimulationStore.getState(), - currentUser: UserStore.getState().currentUser, + currentRole: currentUser? currentUser.role : '', token: UserStore.getState().token, runningSimulators: simulators @@ -183,7 +185,7 @@ class App extends Component {
    - +
    {children} diff --git a/src/data-managers/users-data-manager.js b/src/data-managers/users-data-manager.js index bd60534..f5db8f8 100644 --- a/src/data-managers/users-data-manager.js +++ b/src/data-managers/users-data-manager.js @@ -46,7 +46,7 @@ class UsersDataManager extends RestDataManager { RestAPI.get(this.makeURL('/users/me'), token).then(response => { AppDispatcher.dispatch({ type: 'users/current-user', - user: response + user: response.user }); }).catch(error => { AppDispatcher.dispatch({ From 39c8a2518a14f659fabafaa6e3563ceefa45880e Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Wed, 3 May 2017 15:58:58 +0200 Subject: [PATCH 43/59] sidebar menu items no wrap and grow --- src/components/menu-sidebar.js | 12 ++++----- src/containers/app.js | 10 ++++--- src/styles/app.css | 49 +++++++++++++++++++++++++--------- 3 files changed, 48 insertions(+), 23 deletions(-) diff --git a/src/components/menu-sidebar.js b/src/components/menu-sidebar.js index 882ab56..152644a 100644 --- a/src/components/menu-sidebar.js +++ b/src/components/menu-sidebar.js @@ -29,14 +29,14 @@ class SidebarMenu extends Component {

    Menu

      -
    • Home
    • -
    • Projects
    • -
    • Simulations
    • -
    • Simulators
    • +
    • Home
    • +
    • Projects
    • +
    • Simulations
    • +
    • Simulators
    • { this.props.currentRole === 'admin' ? -
    • User Management
    • : '' +
    • User Management
    • : '' } -
    • Logout
    • +
    • Logout
    ); diff --git a/src/containers/app.js b/src/containers/app.js index 9e6eaf0..2af248e 100644 --- a/src/containers/app.js +++ b/src/containers/app.js @@ -77,7 +77,7 @@ class App extends Component { } let currentUser = UserStore.getState().currentUser; - + return { simulations: SimulationStore.getState(), currentRole: currentUser? currentUser.role : '', @@ -185,10 +185,12 @@ class App extends Component {
    - -
    - {children} +
    + +
    + {children} +
    diff --git a/src/styles/app.css b/src/styles/app.css index f5a12fd..d02e36f 100644 --- a/src/styles/app.css +++ b/src/styles/app.css @@ -41,7 +41,6 @@ body { .app-header { width: 100%; height: 60px; - padding: 10px 0 0 0; color: #527984; @@ -50,7 +49,6 @@ body { .app-header h1 { width: 100%; - margin: 0; text-align: center; @@ -68,15 +66,27 @@ body { clear: both; } -.app-content { +.app-body { + /* Let sidebar grow and content occupy rest of the space */ + display: flex; position: absolute; - bottom: 0px; top: 60px; + bottom: 60px; right: 0px; - left: 200px; - min-height: 400px; + left: 0px; - margin: 20px 20px 60px 20px; + padding: 15px 5px 0px 5px; +} + +.app-body div { + margin-left: 7px; + margin-right: 7px; +} + +.app-content { + flex: 1 1 auto; + min-height: 400px; + height: 100%; padding: 15px 20px; background-color: #fff; @@ -88,11 +98,7 @@ body { * Menus */ .menu-sidebar { - float: left; - - width: 160px; - - margin: 20px 0 0 20px; + display: inline-table; padding: 20px 25px 20px 25px; background-color: #fff; @@ -102,18 +108,35 @@ body { .menu-sidebar a { color: #4d4d4d; + text-decoration:none; +} + +.menu-sidebar a:hover, .menu-sidebar a:focus { + text-decoration:none; } .active { font-weight: bold; + /*text-decoration:none;*/ } .menu-sidebar ul { padding-top: 10px; - list-style: none; + white-space: nowrap; } +.menu-sidebar a::after { + /* Trick to make menu items to be as wide as in bold */ + display:block; + content:attr(title); + font-weight:bold; + height:1px; + color:transparent; + overflow:hidden; + visibility:hidden; + margin-bottom:-1px; +} /** * Login form */ From 1c20d0c87ddf00ac346389cdcfb9ec96a4c51d56 Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Wed, 3 May 2017 17:30:00 +0200 Subject: [PATCH 44/59] add/edit user simple validation --- src/components/dialog/edit-user.js | 3 +-- src/components/dialog/new-user.js | 32 ++++++++++++++++++++---------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/components/dialog/edit-user.js b/src/components/dialog/edit-user.js index c8bb203..594492a 100644 --- a/src/components/dialog/edit-user.js +++ b/src/components/dialog/edit-user.js @@ -90,10 +90,9 @@ class EditUserDialog extends Component { this.handleChange(e)} /> - + E-mail this.handleChange(e)} /> - Role diff --git a/src/components/dialog/new-user.js b/src/components/dialog/new-user.js index f666e31..fd01f99 100644 --- a/src/components/dialog/new-user.js +++ b/src/components/dialog/new-user.js @@ -20,7 +20,7 @@ ******************************************************************************/ import React, { Component, PropTypes } from 'react'; -import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap'; +import { FormGroup, FormControl, ControlLabel, HelpBlock } from 'react-bootstrap'; import Dialog from './dialog'; @@ -39,7 +39,7 @@ class NewUserDialog extends Component { username: '', mail: '', role: 'admin', - password: '1234' + password: '' }; } @@ -60,22 +60,26 @@ class NewUserDialog extends Component { username: '', mail: '', role: 'admin', - password: '1234' + password: '' }); } validateForm(target) { // check all controls - var username = true; + let username = this.state.username !== '' && this.state.username.length >= 3; + let password = this.state.password !== ''; - if (this.state.username === '') { - username = false; - } - - this.valid = username; + this.valid = username && password; // return state to control - if (target === 'username') return username ? "success" : "error"; + switch(target) { + case 'username': + return username ? "success" : "error"; + case 'password': + return password ? "success" : "error"; + default: + return "success"; + } } render() { @@ -86,12 +90,18 @@ class NewUserDialog extends Component { Username this.handleChange(e)} /> + Min 3 characters. - + E-mail this.handleChange(e)} /> + + Password + this.handleChange(e)} /> + + Role this.handleChange(e)}> From 059512333fc4bb12a7930eb2184d23d0b3e17c4e Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Wed, 3 May 2017 17:30:40 +0200 Subject: [PATCH 45/59] handle taken usernames add/edit user --- src/stores/array-store.js | 1 - src/stores/users-store.js | 27 +++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/stores/array-store.js b/src/stores/array-store.js index b7cfbee..ccd9689 100644 --- a/src/stores/array-store.js +++ b/src/stores/array-store.js @@ -95,7 +95,6 @@ class ArrayStore extends ReduceStore { return this.updateElements(state, [action.data]); case this.type + '/add-error': - console.log('something happened'); // TODO: Add error message return state; diff --git a/src/stores/users-store.js b/src/stores/users-store.js index 0b38e69..e42b1ed 100644 --- a/src/stores/users-store.js +++ b/src/stores/users-store.js @@ -21,6 +21,7 @@ import ArrayStore from './array-store'; import UsersDataManager from '../data-managers/users-data-manager'; +import NotificationsDataManager from '../data-managers/notifications-data-manager'; class UsersStore extends ArrayStore { constructor() { @@ -30,6 +31,32 @@ class UsersStore extends ArrayStore { reduce(state, action) { switch (action.type) { + case this.type + '/add-error': + if (action.error && !action.error.handled && action.error.response) { + // If it was an error and hasn't been handled, user could not be added + const USER_ADD_ERROR_NOTIFICATION = { + title: 'Failed to add new user', + message: action.error.response.body.message, + level: 'error' + } + NotificationsDataManager.addNotification(USER_ADD_ERROR_NOTIFICATION); + + } + return super.reduce(state, action); + + case this.type + '/edit-error': + if (action.error && !action.error.handled && action.error.response) { + // If it was an error and hasn't been handled, user couldn't not be updated + const USER_EDIT_ERROR_NOTIFICATION = { + title: 'Failed to edit user', + message: action.error.response.body.message, + level: 'error' + } + NotificationsDataManager.addNotification(USER_EDIT_ERROR_NOTIFICATION); + + } + return super.reduce(state, action); + default: return super.reduce(state, action); } From 2340850b40667a21c3f7a474457627bcc6ecbdfc Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Fri, 5 May 2017 09:07:22 +0200 Subject: [PATCH 46/59] adapt layout to previous changes --- src/styles/app.css | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/styles/app.css b/src/styles/app.css index 4029992..41b2bbb 100644 --- a/src/styles/app.css +++ b/src/styles/app.css @@ -57,6 +57,7 @@ body { .app-footer { width: 100%; height: 60px; + /* Float below body */ float: right; padding-top: 20px; @@ -68,24 +69,21 @@ body { .app-body { /* Let sidebar grow and content occupy rest of the space */ display: flex; - position: absolute; - top: 60px; - bottom: 60px; - right: 0px; - left: 0px; + float: right; + width: 100%; + /* Fit between header and footer */ + min-height: calc(100vh - 140px); padding: 15px 5px 0px 5px; } -.app-body div { +.app-body > div { margin-left: 7px; margin-right: 7px; } .app-content { flex: 1 1 auto; - min-height: 400px; - height: 100%; padding: 15px 20px; background-color: #fff; From fa09f9eef75547fe09630ca092b7c79bed5e1d4d Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Fri, 5 May 2017 09:08:43 +0200 Subject: [PATCH 47/59] removed commented rules --- src/styles/app.css | 1 - 1 file changed, 1 deletion(-) diff --git a/src/styles/app.css b/src/styles/app.css index 41b2bbb..33b3280 100644 --- a/src/styles/app.css +++ b/src/styles/app.css @@ -114,7 +114,6 @@ body { .active { font-weight: bold; - /*text-decoration:none;*/ } .menu-sidebar ul { From a4884bd0fba029bfbf66fe8438e5d3efdd9b90c1 Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Fri, 5 May 2017 09:42:39 +0200 Subject: [PATCH 48/59] issue #60: site's title --- public/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/index.html b/public/index.html index aab5e3b..2775a2d 100644 --- a/public/index.html +++ b/public/index.html @@ -13,7 +13,7 @@ work correctly both with client-side routing and a non-root public URL. Learn how to configure a non-root public URL by running `npm run build`. --> - React App + VILLASweb
    From e2be97dcd382a69c76eab322eac8cded1719fcae Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Mon, 8 May 2017 10:55:21 +0200 Subject: [PATCH 49/59] default edit image option and no images msg --- .../dialog/edit-widget-image-control.js | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/components/dialog/edit-widget-image-control.js b/src/components/dialog/edit-widget-image-control.js index 199a331..56ae8f0 100644 --- a/src/components/dialog/edit-widget-image-control.js +++ b/src/components/dialog/edit-widget-image-control.js @@ -49,11 +49,12 @@ class EditImageWidgetControl extends Component { formData.append(key, this.state.fileList[key]); } } - + // upload files AppDispatcher.dispatch({ type: 'files/start-upload', - data: formData + data: formData, + token: this.props.sessionToken }); } @@ -63,9 +64,18 @@ class EditImageWidgetControl extends Component { Image this.props.handleChange(e)}> - {this.props.files.map((file, index) => ( - - ))} + { + this.props.files.length === 0? ( + + ) : ( + this.props.files.reduce( (entries, file, index) => { + entries.push(); + return entries; + }, [ + + ]) + ) + } From e0c5ffbd8fb158959ee46a18c14244232af1df5c Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Mon, 8 May 2017 12:24:52 +0200 Subject: [PATCH 50/59] authenticated upload --- src/components/dialog/edit-widget.js | 3 ++- src/containers/visualization.js | 6 ++++-- src/data-managers/files-data-manager.js | 11 +++++++---- src/stores/file-store.js | 2 +- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/components/dialog/edit-widget.js b/src/components/dialog/edit-widget.js index a6a1523..eeabba3 100644 --- a/src/components/dialog/edit-widget.js +++ b/src/components/dialog/edit-widget.js @@ -35,6 +35,7 @@ import EditWidgetOrientation from './edit-widget-orientation'; class EditWidgetDialog extends Component { static propTypes = { + sessionToken: PropTypes.string.isRequired, show: PropTypes.bool.isRequired, onClose: PropTypes.func.isRequired }; @@ -109,7 +110,7 @@ class EditWidgetDialog extends Component { ) } else if (this.props.widget.type === 'Image') { dialogControls.push( - this.validateForm(id)} simulation={this.props.simulation} handleChange={(e, index) => this.handleChange(e, index)} /> + this.validateForm(id)} simulation={this.props.simulation} handleChange={(e, index) => this.handleChange(e, index)} /> ) } else if (this.props.widget.type === 'Gauge') { dialogControls.push( diff --git a/src/containers/visualization.js b/src/containers/visualization.js index 00fc336..a526df3 100644 --- a/src/containers/visualization.js +++ b/src/containers/visualization.js @@ -30,6 +30,7 @@ import Dropzone from '../components/dropzone'; import Widget from './widget'; import EditWidget from '../components/dialog/edit-widget'; +import UserStore from '../stores/user-store'; import VisualizationStore from '../stores/visualization-store'; import ProjectStore from '../stores/project-store'; import SimulationStore from '../stores/simulation-store'; @@ -40,7 +41,7 @@ import NotificationsFactory from '../data-managers/notifications-factory'; class Visualization extends Component { static getStores() { - return [ VisualizationStore, ProjectStore, SimulationStore, FileStore ]; + return [ VisualizationStore, ProjectStore, SimulationStore, FileStore, UserStore ]; } static calculateState(prevState) { @@ -49,6 +50,7 @@ class Visualization extends Component { } return { + sessionToken: UserStore.getState().token, visualizations: VisualizationStore.getState(), projects: ProjectStore.getState(), simulations: SimulationStore.getState(), @@ -384,7 +386,7 @@ class Visualization extends Component { ))} - this.closeEdit(data)} widget={this.state.modalData} simulation={this.state.simulation} files={this.state.files} /> + this.closeEdit(data)} widget={this.state.modalData} simulation={this.state.simulation} files={this.state.files} />
    ); diff --git a/src/data-managers/files-data-manager.js b/src/data-managers/files-data-manager.js index 5f7e1c0..f5edb37 100644 --- a/src/data-managers/files-data-manager.js +++ b/src/data-managers/files-data-manager.js @@ -28,13 +28,16 @@ class FilesDataManager extends RestDataManager { super('file', '/files'); } - upload(file) { - RestAPI.upload(this.makeURL('/upload'), file).then(response => { + upload(file, token = null) { + RestAPI.upload(this.makeURL('/upload'), file, token).then(response => { AppDispatcher.dispatch({ type: 'files/uploaded' }); - - console.log(response); + // Trigger a files reload + AppDispatcher.dispatch({ + type: 'files/start-load', + token: token + }); }).catch(error => { AppDispatcher.dispatch({ type: 'files/upload-error', diff --git a/src/stores/file-store.js b/src/stores/file-store.js index 104d16b..09266dd 100644 --- a/src/stores/file-store.js +++ b/src/stores/file-store.js @@ -30,7 +30,7 @@ class FileStore extends ArrayStore { reduce(state, action) { switch (action.type) { case 'files/start-upload': - FilesDataManager.upload(action.data); + FilesDataManager.upload(action.data, action.token); return state; case 'files/uploaded': From e395b65fc17547c5c8a416ae7033e1d2628c0bb1 Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Mon, 8 May 2017 12:27:36 +0200 Subject: [PATCH 51/59] fixed imaged widget, load image by id --- src/components/widget-image.js | 40 +++++++++++++++------------------- src/config.js | 6 +++++ 2 files changed, 24 insertions(+), 22 deletions(-) create mode 100644 src/config.js diff --git a/src/components/widget-image.js b/src/components/widget-image.js index aeb9642..2bbba8c 100644 --- a/src/components/widget-image.js +++ b/src/components/widget-image.js @@ -21,37 +21,33 @@ import React, { Component } from 'react'; -const API_URL = 'http://localhost:4000/'; +import AppDispatcher from '../app-dispatcher'; +import config from '../config'; class WidgetImage extends Component { - constructor(props) { - super(props); - - this.state = { - file: null - }; - } componentWillReceiveProps(nextProps) { - // check if file is set - if (nextProps.widget.file == null) { - this.setState({ file: null }); - return; - } - // get file by id - nextProps.files.forEach(file => { - if (file._id === nextProps.widget.file) { - this.setState({ file: file }); - } - }); + // Query the image referenced by the widget (public request, no token required) + let widgetFile = nextProps.widget.file; + if (widgetFile && !nextProps.files.find( file => file._id === widgetFile ) ) { + + AppDispatcher.dispatch({ + type: 'files/start-load', + data: widgetFile + }); + + } } render() { + + let file = this.props.files.find( (file) => file._id === this.props.widget.file ); + return ( -
    - {this.state.file && - {this.state.file.name} +
    + {file && + {file.name} e.preventDefault() } /> }
    ); diff --git a/src/config.js b/src/config.js new file mode 100644 index 0000000..4ade8ce --- /dev/null +++ b/src/config.js @@ -0,0 +1,6 @@ + +const config = { + publicPathBase: 'public/' +} + +export default config \ No newline at end of file From 503560dbbee562b66da28ac67eb73e0c3d48f3a7 Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Mon, 8 May 2017 12:28:16 +0200 Subject: [PATCH 52/59] authenticated (all) files query --- src/containers/widget.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/containers/widget.js b/src/containers/widget.js index 1f61e9b..18e3d12 100644 --- a/src/containers/widget.js +++ b/src/containers/widget.js @@ -26,6 +26,7 @@ import Rnd from 'react-rnd'; import classNames from 'classnames'; import AppDispatcher from '../app-dispatcher'; +import UserStore from '../stores/user-store'; import SimulatorDataStore from '../stores/simulator-data-store'; import FileStore from '../stores/file-store'; @@ -45,12 +46,16 @@ import '../styles/widgets.css'; class Widget extends Component { static getStores() { - return [ SimulatorDataStore, FileStore ]; + return [ SimulatorDataStore, FileStore, UserStore ]; } static calculateState(prevState) { + + let tokenState = UserStore.getState().token; + if (prevState) { return { + sessionToken: tokenState, simulatorData: SimulatorDataStore.getState(), files: FileStore.getState(), @@ -58,6 +63,7 @@ class Widget extends Component { } } else { return { + sessionToken: tokenState, simulatorData: SimulatorDataStore.getState(), files: FileStore.getState(), @@ -72,11 +78,15 @@ class Widget extends Component { // Reference to the context menu element this.contextMenuTriggerViaDraggable = null; } - + componentWillMount() { - AppDispatcher.dispatch({ - type: 'files/start-load' - }); + // If loading for the first time + if (this.state.sessionToken) { + AppDispatcher.dispatch({ + type: 'files/start-load', + token: this.state.sessionToken + }); + } } dragStop(event, ui) { @@ -150,7 +160,6 @@ class Widget extends Component { borderedWidget = true; } else if (widget.type === 'Image') { element = - borderedWidget = true; } else if (widget.type === 'Button') { element = } else if (widget.type === 'NumberInput') { From b076db8b7b72833d62081212f91110ccc051de35 Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Tue, 23 May 2017 10:50:03 +0200 Subject: [PATCH 53/59] fixed simulator property --- src/components/dialog/edit-widget-signal-control.js | 2 +- src/components/dialog/edit-widget-signals-control.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/dialog/edit-widget-signal-control.js b/src/components/dialog/edit-widget-signal-control.js index 879052b..b31dab6 100644 --- a/src/components/dialog/edit-widget-signal-control.js +++ b/src/components/dialog/edit-widget-signal-control.js @@ -31,7 +31,7 @@ class EditWidgetSignalControl extends Component { if (this.props.simulation) { // get selected simulation model - const simulationModel = this.props.simulation.models.find( model => model.simulation === this.state.widget.simulation ); + const simulationModel = this.props.simulation.models.find( model => model.simulator === this.state.widget.simulator ); // If simulation model update the signals to render signalsToRender = simulationModel? simulationModel.mapping : []; diff --git a/src/components/dialog/edit-widget-signals-control.js b/src/components/dialog/edit-widget-signals-control.js index b84d930..8bd9bb9 100644 --- a/src/components/dialog/edit-widget-signals-control.js +++ b/src/components/dialog/edit-widget-signals-control.js @@ -46,7 +46,7 @@ class EditWidgetSignalsControl extends Component { if (this.props.simulation) { // get selected simulation model - const simulationModel = this.props.simulation.models.find( model => model.simulation === this.state.widget.simulation ); + const simulationModel = this.props.simulation.models.find( model => model.simulator === this.state.widget.simulator ); // If simulation model update the signals to render signalsToRender = simulationModel? simulationModel.mapping : []; From 72ffd6cd96641aa1356ae795f75364a8e6bf5c56 Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Tue, 23 May 2017 10:50:30 +0200 Subject: [PATCH 54/59] refactoring: extracted control creation --- .../dialog/edit-widget-control-creator.js | 90 +++++++++++++++++++ src/components/dialog/edit-widget.js | 83 +++++------------ 2 files changed, 112 insertions(+), 61 deletions(-) create mode 100644 src/components/dialog/edit-widget-control-creator.js diff --git a/src/components/dialog/edit-widget-control-creator.js b/src/components/dialog/edit-widget-control-creator.js new file mode 100644 index 0000000..9b430e0 --- /dev/null +++ b/src/components/dialog/edit-widget-control-creator.js @@ -0,0 +1,90 @@ + + +import React from 'react'; + +import EditWidgetTextControl from './edit-widget-text-control'; +import EditWidgetColorControl from './edit-widget-color-control'; +import EditWidgetTimeControl from './edit-widget-time-control'; +import EditImageWidgetControl from './edit-widget-image-control'; +import EditWidgetSimulatorControl from './edit-widget-simulator-control'; +import EditWidgetSignalControl from './edit-widget-signal-control'; +import EditWidgetSignalsControl from './edit-widget-signals-control'; +import EditWidgetOrientation from './edit-widget-orientation'; + +export default function createControls(widgetType = null, widget = null, sessionToken = null, files = null, validateForm, simulation, handleChange) { + // Use a list to concatenate the controls according to the widget type + var dialogControls = []; + + switch(widgetType) { + case 'Value': { + let valueBoundOnChange = (e) => { + handleChange([e, {target: {id: 'signal', value: 0}}]); + } + dialogControls.push( + validateForm(id)} simulation={simulation} handleChange={(e) => valueBoundOnChange(e)} />, + validateForm(id)} simulation={simulation} handleChange={(e) => handleChange(e)} /> + ) + } + break; + case 'Plot': { + let plotBoundOnChange = (e) => { + handleChange([e, {target: {id: 'signals', value: []}}]); + } + dialogControls.push( + validateForm(id)} simulation={simulation} handleChange={(e) => handleChange(e)} />, + validateForm(id)} simulation={simulation} handleChange={(e) => plotBoundOnChange(e)} />, + validateForm(id)} simulation={simulation} handleChange={(e) => handleChange(e)} />, + handleChange(e)} />) + } + break; + case 'Table': { + dialogControls.push( + validateForm(id)} simulation={simulation} handleChange={(e) => handleChange(e)} />) + } + break; + case 'Image': { + dialogControls.push( + validateForm(id)} simulation={simulation} handleChange={(e) => handleChange(e)} />) + } + break; + case 'Gauge': { + let gaugeBoundOnChange = (e) => { + handleChange([e, {target: {id: 'signal', value: ''}}]); + } + dialogControls.push( + validateForm(id)} simulation={simulation} handleChange={(e) => gaugeBoundOnChange(e) } />, + validateForm(id)} simulation={simulation} handleChange={(e) => handleChange(e)} />) + } + break; + case 'PlotTable': { + let plotTableBoundOnChange = (e) => { + handleChange([e, {target: {id: 'preselectedSignals', value: []}}]); + } + dialogControls.push( + validateForm(id)} simulation={simulation} handleChange={(e) => plotTableBoundOnChange(e)} />, + validateForm(id)} simulation={simulation} handleChange={(e) => handleChange(e)} />, + handleChange(e)} />) + } + break; + case 'Slider': { + dialogControls.push( + validateForm(id)} simulation={simulation} handleChange={(e) => handleChange(e)} />) + } + break; + case 'Button': { + dialogControls.push( + validateForm(id)} handleChange={(e) => handleChange(e)} />, + validateForm(id)} handleChange={(e) => handleChange(e)} />) + } + break; + case 'Box': { + dialogControls.push( + validateForm(id)} handleChange={(e) => handleChange(e)} />) + } + break; + default: + console.log('Non-valid widget type'); + } + + return dialogControls; +} \ No newline at end of file diff --git a/src/components/dialog/edit-widget.js b/src/components/dialog/edit-widget.js index eeabba3..8c2277f 100644 --- a/src/components/dialog/edit-widget.js +++ b/src/components/dialog/edit-widget.js @@ -24,14 +24,7 @@ import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap'; import Dialog from './dialog'; -import EditWidgetTextControl from './edit-widget-text-control'; -import EditWidgetColorControl from './edit-widget-color-control'; -import EditWidgetTimeControl from './edit-widget-time-control'; -import EditImageWidgetControl from './edit-widget-image-control'; -import EditWidgetSimulatorControl from './edit-widget-simulator-control'; -import EditWidgetSignalControl from './edit-widget-signal-control'; -import EditWidgetSignalsControl from './edit-widget-signals-control'; -import EditWidgetOrientation from './edit-widget-orientation'; +import createControls from './edit-widget-control-creator'; class EditWidgetDialog extends Component { static propTypes = { @@ -62,10 +55,16 @@ class EditWidgetDialog extends Component { } } - handleChange(e, index) { - var update = this.state.temporal; - update[e.target.id] = e.target.value; - this.setState({ temporal: update }); + handleChange(e) { + if (e.constructor === Array) { + // Every property in the array will be updated + let changes = e.reduce( (changesObject, event) => { changesObject[event.target.id] = event.target.value; return changesObject }, {}); + this.setState({ temporal: Object.assign({}, this.state.temporal, changes ) }); + } else { + let changeObject = {}; + changeObject[e.target.id] = e.target.value; + this.setState({ temporal: Object.assign({}, this.state.temporal, changeObject ) }); + } } resetState() { @@ -88,55 +87,17 @@ class EditWidgetDialog extends Component { } render() { - // Use a list to concatenate the controls according to the widget type - var dialogControls = []; - + + let controls = null; if (this.props.widget) { - if (this.props.widget.type === 'Value') { - dialogControls.push( - this.validateForm(id)} simulation={this.props.simulation} handleChange={(e) => this.handleChange(e)} />, - this.validateForm(id)} simulation={this.props.simulation} handleChange={(e) => this.handleChange(e)} /> - ) - } else if (this.props.widget.type === 'Plot') { - dialogControls.push( - this.validateForm(id)} simulation={this.props.simulation} handleChange={(e, index) => this.handleChange(e, index)} />, - this.validateForm(id)} simulation={this.props.simulation} handleChange={(e) => this.handleChange(e)} />, - this.validateForm(id)} simulation={this.props.simulation} handleChange={(e) => this.handleChange(e)} />, - this.handleChange(e)} /> - ) - } else if (this.props.widget.type === 'Table') { - dialogControls.push( - this.validateForm(id)} simulation={this.props.simulation} handleChange={(e) => this.handleChange(e)} /> - ) - } else if (this.props.widget.type === 'Image') { - dialogControls.push( - this.validateForm(id)} simulation={this.props.simulation} handleChange={(e, index) => this.handleChange(e, index)} /> - ) - } else if (this.props.widget.type === 'Gauge') { - dialogControls.push( - this.validateForm(id)} simulation={this.props.simulation} handleChange={(e) => this.handleChange(e)} />, - this.validateForm(id)} simulation={this.props.simulation} handleChange={(e) => this.handleChange(e)} /> - ) - } else if (this.props.widget.type === 'PlotTable') { - dialogControls.push( - this.validateForm(id)} simulation={this.props.simulation} handleChange={(e) => this.handleChange(e)} />, - this.validateForm(id)} simulation={this.props.simulation} handleChange={(e) => this.handleChange(e)} />, - this.handleChange(e)} /> - ) - } else if (this.props.widget.type === 'Slider') { - dialogControls.push( - this.validateForm(id)} simulation={this.props.simulation} handleChange={(e) => this.handleChange(e)} />, - ) - } else if (this.props.widget.type === 'Button') { - dialogControls.push( - this.validateForm(id)} handleChange={(e, index) => this.handleChange(e, index)} />, - this.validateForm(id)} handleChange={(e, index) => this.handleChange(e, index)} /> - ) - } else if (this.props.widget.type === 'Box') { - dialogControls.push( - this.validateForm(id)} handleChange={(e, index) => this.handleChange(e, index)} /> - ) - } + controls = createControls( + this.props.widget.type, + this.state.temporal, + this.props.sessionToken, + this.props.files, + (id) => this.validateForm(id), + this.props.simulation, + (e) => this.handleChange(e)); } return ( @@ -147,7 +108,7 @@ class EditWidgetDialog extends Component { this.handleChange(e)} /> - { dialogControls } + { controls || '' } ); From 0e7ce1aff064a6753557dca5a32dc107e1d1e1c1 Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Tue, 23 May 2017 10:57:28 +0200 Subject: [PATCH 55/59] removed unused js module --- .../dialog/edit-widget-signal-type-control.js | 64 ------------------- 1 file changed, 64 deletions(-) delete mode 100644 src/components/dialog/edit-widget-signal-type-control.js diff --git a/src/components/dialog/edit-widget-signal-type-control.js b/src/components/dialog/edit-widget-signal-type-control.js deleted file mode 100644 index 8978186..0000000 --- a/src/components/dialog/edit-widget-signal-type-control.js +++ /dev/null @@ -1,64 +0,0 @@ -/** - * File: edit-widget-signal-type-control.js - * Author: Ricardo Hernandez-Montoya - * Date: 03.04.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. - **********************************************************************************/ - -import React, { Component } from 'react'; -import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap'; - -class EditWidgetSignalTypeControl extends Component { - constructor(props) { - super(props); - - this.state = { - widget: {} - }; - } - - componentWillReceiveProps(nextProps) { - // Update state's widget with props - this.setState({ widget: nextProps.widget }); - } - - render() { - // get selected simulation model - var simulationModel = {}; - - if (this.props.simulation) { - this.props.simulation.models.forEach((model) => { - if (model.simulation === this.state.widget.simulation) { - simulationModel = model; - } - }); - } - - // Obtain unique signal types with the help of dictionary keys - var signalTypes = Object.keys(simulationModel.mapping.reduce( (collection, signal) => { - var lower = signal.type.toLowerCase(); - collection[lower] = ''; - return collection; - }, {})); - - var capitalize = (str) => { return str.charAt(0).toUpperCase() + str.slice(1); } - - var selectedValue = signalTypes.includes(this.state.widget.signalType) ? this.state.widget.signalType : ''; - - return ( - - Signal type - this.props.handleChange(e)}> - - {signalTypes.map((type, index) => ( - - ))} - - - ); - } -} - -export default EditWidgetSignalTypeControl; \ No newline at end of file From 2a5c164ace4d88f7671f01ba31d45bb36ea32ca1 Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Tue, 23 May 2017 10:59:01 +0200 Subject: [PATCH 56/59] updated licenses in edit control modules --- .../dialog/edit-widget-control-creator.js | 21 ++++++++++++++++++- .../dialog/edit-widget-orientation.js | 18 +++++++++++++--- .../dialog/edit-widget-signal-control.js | 18 +++++++++++++--- .../dialog/edit-widget-signals-control.js | 18 +++++++++++++--- .../dialog/edit-widget-simulator-control.js | 18 +++++++++++++--- .../dialog/edit-widget-text-control.js | 18 +++++++++++++--- .../dialog/edit-widget-time-control.js | 18 +++++++++++++--- 7 files changed, 110 insertions(+), 19 deletions(-) diff --git a/src/components/dialog/edit-widget-control-creator.js b/src/components/dialog/edit-widget-control-creator.js index 9b430e0..455ca2f 100644 --- a/src/components/dialog/edit-widget-control-creator.js +++ b/src/components/dialog/edit-widget-control-creator.js @@ -1,4 +1,23 @@ - +/** + * File: edit-widget-control-creator.js + * Author: Ricardo Hernandez-Montoya + * Date: 23.05.2017 + * + * 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'; diff --git a/src/components/dialog/edit-widget-orientation.js b/src/components/dialog/edit-widget-orientation.js index 76aa874..9f3e67f 100644 --- a/src/components/dialog/edit-widget-orientation.js +++ b/src/components/dialog/edit-widget-orientation.js @@ -2,9 +2,21 @@ * File: edit-widget-orientation.js * Author: Ricardo Hernandez-Montoya * Date: 10.04.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. + * + * 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, { Component } from 'react'; diff --git a/src/components/dialog/edit-widget-signal-control.js b/src/components/dialog/edit-widget-signal-control.js index b31dab6..623b416 100644 --- a/src/components/dialog/edit-widget-signal-control.js +++ b/src/components/dialog/edit-widget-signal-control.js @@ -2,9 +2,21 @@ * File: edit-widget-signal-control.js * Author: Ricardo Hernandez-Montoya * Date: 03.04.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. + * + * 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, { Component } from 'react'; diff --git a/src/components/dialog/edit-widget-signals-control.js b/src/components/dialog/edit-widget-signals-control.js index 8bd9bb9..76b832b 100644 --- a/src/components/dialog/edit-widget-signals-control.js +++ b/src/components/dialog/edit-widget-signals-control.js @@ -2,9 +2,21 @@ * File: edit-widget-signals-control.js * Author: Ricardo Hernandez-Montoya * Date: 03.04.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. + * + * 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, { Component } from 'react'; diff --git a/src/components/dialog/edit-widget-simulator-control.js b/src/components/dialog/edit-widget-simulator-control.js index 23de386..48186ef 100644 --- a/src/components/dialog/edit-widget-simulator-control.js +++ b/src/components/dialog/edit-widget-simulator-control.js @@ -2,9 +2,21 @@ * File: edit-widget-simulator-control.js * Author: Ricardo Hernandez-Montoya * Date: 03.04.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. + * + * 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, { Component } from 'react'; diff --git a/src/components/dialog/edit-widget-text-control.js b/src/components/dialog/edit-widget-text-control.js index d4196b4..b9eef66 100644 --- a/src/components/dialog/edit-widget-text-control.js +++ b/src/components/dialog/edit-widget-text-control.js @@ -2,9 +2,21 @@ * File: edit-widget-text-control.js * Author: Ricardo Hernandez-Montoya * Date: 21.04.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. + * + * 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, { Component } from 'react'; diff --git a/src/components/dialog/edit-widget-time-control.js b/src/components/dialog/edit-widget-time-control.js index 5b8e234..8f6434d 100644 --- a/src/components/dialog/edit-widget-time-control.js +++ b/src/components/dialog/edit-widget-time-control.js @@ -2,9 +2,21 @@ * File: edit-widget-time-control.js * Author: Ricardo Hernandez-Montoya * Date: 13.04.2017 - * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC - * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited. + * + * 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, { Component } from 'react'; From ea119f52e08ad8eeaa4f04ea929e6408ea53c218 Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Tue, 23 May 2017 12:57:48 +0200 Subject: [PATCH 57/59] test edit control creator --- .../dialog/edit-widget-control-creator.js | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/__tests__/components/dialog/edit-widget-control-creator.js diff --git a/src/__tests__/components/dialog/edit-widget-control-creator.js b/src/__tests__/components/dialog/edit-widget-control-creator.js new file mode 100644 index 0000000..fea0b2a --- /dev/null +++ b/src/__tests__/components/dialog/edit-widget-control-creator.js @@ -0,0 +1,42 @@ + +import { expect } from 'chai'; + +import createControls from '../../../components/dialog/edit-widget-control-creator'; +import EditWidgetTextControl from '../../../components/dialog/edit-widget-text-control'; +import EditWidgetColorControl from '../../../components/dialog/edit-widget-color-control'; +import EditWidgetTimeControl from '../../../components/dialog/edit-widget-time-control'; +import EditImageWidgetControl from '../../../components/dialog/edit-widget-image-control'; +import EditWidgetSimulatorControl from '../../../components/dialog/edit-widget-simulator-control'; +import EditWidgetSignalControl from '../../../components/dialog/edit-widget-signal-control'; +import EditWidgetSignalsControl from '../../../components/dialog/edit-widget-signals-control'; +import EditWidgetOrientation from '../../../components/dialog/edit-widget-orientation'; + +describe('edit widget control creator', () => { + it('should not return null', () => { + let controls = createControls('Value', null, null, null, null, null, null); + expect(controls).to.be.defined; + }); + + var runs = [ + { args: { widgetType: 'Value' }, result: { controlNumber: 2, controlTypes: [EditWidgetSimulatorControl, EditWidgetSignalControl] } }, + { args: { widgetType: 'Plot' }, result: { controlNumber: 4, controlTypes: [EditWidgetTimeControl, EditWidgetSimulatorControl, EditWidgetSignalsControl, EditWidgetTextControl] } }, + { args: { widgetType: 'Table' }, result: { controlNumber: 1, controlTypes: [EditWidgetSimulatorControl] } }, + { args: { widgetType: 'Image' }, result: { controlNumber: 1, controlTypes: [EditImageWidgetControl] } }, + { args: { widgetType: 'Gauge' }, result: { controlNumber: 2, controlTypes: [EditWidgetSimulatorControl, EditWidgetSignalControl] } }, + { args: { widgetType: 'PlotTable' }, result: { controlNumber: 3, controlTypes: [EditWidgetSimulatorControl, EditWidgetSignalsControl, EditWidgetTextControl] } }, + { args: { widgetType: 'Slider' }, result: { controlNumber: 1, controlTypes: [EditWidgetOrientation] } }, + { args: { widgetType: 'Button' }, result: { controlNumber: 2, controlTypes: [EditWidgetColorControl] } }, + { args: { widgetType: 'Box' }, result: { controlNumber: 1, controlTypes: [EditWidgetColorControl] } }, + ]; + + runs.forEach( (run) => { + let itMsg = run.args.widgetType + ' widget edit model should have correct controls'; + it(itMsg, () => { + let controls = createControls(run.args.widgetType, null, null, null, null, null, null); + + expect(controls).to.have.lengthOf(run.result.controlNumber); + + controls.forEach( (control) => expect(control.type).to.be.oneOf(run.result.controlTypes)) + }); + }); +}); \ No newline at end of file From 125e936e26e1200e1d4815158ada842981e60433 Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Tue, 23 May 2017 12:59:13 +0200 Subject: [PATCH 58/59] chai dependency for tests --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 8977188..aa1e73c 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "rc-slider": "^7.0.1" }, "devDependencies": { + "chai": "^3.5.0", "react-scripts": "0.9.3" }, "scripts": { From ec7efbd11c35f6e66818623bd65d8798399a5d42 Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Wed, 24 May 2017 14:41:47 +0200 Subject: [PATCH 59/59] removed unused code --- src/components/dialog/edit-widget-plot.js | 97 ---------------------- src/components/dialog/edit-widget-table.js | 56 ------------- src/components/dialog/edit-widget-value.js | 76 ----------------- 3 files changed, 229 deletions(-) delete mode 100644 src/components/dialog/edit-widget-plot.js delete mode 100644 src/components/dialog/edit-widget-table.js delete mode 100644 src/components/dialog/edit-widget-value.js diff --git a/src/components/dialog/edit-widget-plot.js b/src/components/dialog/edit-widget-plot.js deleted file mode 100644 index 9ff53a2..0000000 --- a/src/components/dialog/edit-widget-plot.js +++ /dev/null @@ -1,97 +0,0 @@ -/** - * File: edit-widget-plot.js - * Author: Markus Grigull - * Date: 13.03.2017 - * - * 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, { Component } from 'react'; -import { FormGroup, FormControl, ControlLabel, Checkbox, HelpBlock } from 'react-bootstrap'; - -class EditPlotWidget extends Component { - constructor(props) { - super(props); - - this.state = { - widget: { - simulator: '', - signals: [], - time: 0 - } - }; - } - - componentWillReceiveProps(nextProps) { - this.setState({ widget: nextProps.widget }); - } - - handleSignalChange(e, index) { - var signals = this.state.widget.signals; - - if (e.target.checked) { - // add signal - signals.push(index); - } else { - // remove signal - const pos = signals.indexOf(index); - if (pos > -1) { - signals.splice(pos, 1); - } - } - - this.props.handleChange({ target: { id: 'signals', value: signals } }); - } - - render() { - // get selected simulation model - var simulationModel = {}; - - if (this.props.simulation) { - this.props.simulation.models.forEach((model) => { - if (model.simulation === this.state.widget.simulation) { - simulationModel = model; - } - }); - } - - return ( -
    - - Time - this.props.handleChange(e)} /> - Time in seconds - - - Simulator - this.props.handleChange(e)}> - {this.props.simulation.models.map((model, index) => ( - - ))} - - - - Signals - {simulationModel.mapping.map((signal, index) => ( - this.handleSignalChange(e, index)}>{signal.name} - ))} - -
    - ); - } -} - -export default EditPlotWidget; diff --git a/src/components/dialog/edit-widget-table.js b/src/components/dialog/edit-widget-table.js deleted file mode 100644 index 05b17c2..0000000 --- a/src/components/dialog/edit-widget-table.js +++ /dev/null @@ -1,56 +0,0 @@ -/** - * File: edit-widget-table.js - * Author: Markus Grigull - * Date: 14.03.2017 - * - * 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, { Component } from 'react'; - import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap'; - - class EditTableWidget extends Component { - constructor(props) { - super(props); - - this.state = { - widget: { - simulator: '' - } - }; - } - - componentWillReceiveProps(nextProps) { - this.setState({ widget: nextProps.widget }); - } - - render() { - return ( -
    - - Simulator - this.props.handleChange(e)}> - {this.props.simulation.models.map((model, index) => ( - - ))} - - -
    - ); - } - } - - export default EditTableWidget; diff --git a/src/components/dialog/edit-widget-value.js b/src/components/dialog/edit-widget-value.js deleted file mode 100644 index 7061fc9..0000000 --- a/src/components/dialog/edit-widget-value.js +++ /dev/null @@ -1,76 +0,0 @@ -/** - * File: edit-widget-value.js - * Author: Markus Grigull - * Date: 04.03.2017 - * - * 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, { Component } from 'react'; -import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap'; - -class EditValueWidget extends Component { - constructor(props) { - super(props); - - this.state = { - widget: { - simulator: '', - signal: 0 - } - }; - } - - componentWillReceiveProps(nextProps) { - this.setState({ widget: nextProps.widget }); - } - - render() { - // get selected simulation model - var simulationModel = {}; - - if (this.props.simulation) { - this.props.simulation.models.forEach((model) => { - if (model.simulation === this.state.widget.simulation) { - simulationModel = model; - } - }); - } - - return ( -
    - - Simulator - this.props.handleChange(e)}> - {this.props.simulation.models.map((model, index) => ( - - ))} - - - - Signal - this.props.handleChange(e)}> - {simulationModel.mapping.map((signal, index) => ( - - ))} - - -
    - ); - } -} - -export default EditValueWidget;