diff --git a/src/components/dialog/dialog.js b/src/components/dialog/dialog.js index 2643af9..d3bb657 100644 --- a/src/components/dialog/dialog.js +++ b/src/components/dialog/dialog.js @@ -32,12 +32,12 @@ class Dialog extends React.Component { } onKeyPress = (event) => { - if (event.key === 'Enter') { + /*if (event.key === 'Enter') { // prevent input from submitting event.preventDefault(); this.closeModal(false); - } + }*/ } render() { diff --git a/src/components/dialog/edit-widget-control-creator.js b/src/components/dialog/edit-widget-control-creator.js index 9cafc98..5b30a1e 100644 --- a/src/components/dialog/edit-widget-control-creator.js +++ b/src/components/dialog/edit-widget-control-creator.js @@ -34,6 +34,7 @@ import EditWidgetTextSizeControl from './edit-widget-text-size-control'; import EditWidgetCheckboxControl from './edit-widget-checkbox-control'; import EditWidgetColorZonesControl from './edit-widget-color-zones-control'; import EditWidgetMinMaxControl from './edit-widget-min-max-control'; +import EditWidgetHTMLContent from './edit-widget-html-content'; 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 @@ -45,11 +46,11 @@ export default function createControls(widgetType = null, widget = null, session handleChange([e, {target: {id: 'signal', value: 0}}]); } dialogControls.push( - validateForm(id)} handleChange={e => handleChange(e)} />, - validateForm(id)} simulation={simulation} handleChange={(e) => valueBoundOnChange(e)} />, - validateForm(id)} simulation={simulation} handleChange={(e) => handleChange(e)} />, - handleChange(e)} />, - handleChange(e)} /> + validateForm(id)} handleChange={e => handleChange(e)} />, + validateForm(id)} simulation={simulation} handleChange={(e) => valueBoundOnChange(e)} />, + validateForm(id)} simulation={simulation} handleChange={(e) => handleChange(e)} />, + handleChange(e)} />, + handleChange(e)} /> ); break; case 'Plot': @@ -57,22 +58,22 @@ export default function createControls(widgetType = null, widget = null, session 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)} />, - handleChange(e)} /> + 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)} />, + handleChange(e)} /> ); break; case 'Table': dialogControls.push( - validateForm(id)} simulation={simulation} handleChange={(e) => handleChange(e)} /> + validateForm(id)} simulation={simulation} handleChange={(e) => handleChange(e)} /> ); break; case 'Image': dialogControls.push( - validateForm(id)} simulation={simulation} handleChange={(e) => handleChange(e)} />, - handleChange(e)} /> + validateForm(id)} simulation={simulation} handleChange={(e) => handleChange(e)} />, + handleChange(e)} /> ); break; case 'Gauge': @@ -80,12 +81,12 @@ export default function createControls(widgetType = null, widget = null, session handleChange([e, {target: {id: 'signal', value: ''}}]); } dialogControls.push( - validateForm(id)} handleChange={e => handleChange(e)} />, - validateForm(id)} simulation={simulation} handleChange={(e) => gaugeBoundOnChange(e) } />, - validateForm(id)} simulation={simulation} handleChange={(e) => handleChange(e)} />, - handleChange(e)} />, - handleChange(e)} />, - handleChange(e)} /> + validateForm(id)} handleChange={e => handleChange(e)} />, + validateForm(id)} simulation={simulation} handleChange={(e) => gaugeBoundOnChange(e) } />, + validateForm(id)} simulation={simulation} handleChange={(e) => handleChange(e)} />, + handleChange(e)} />, + handleChange(e)} />, + handleChange(e)} /> ); break; case 'PlotTable': @@ -93,27 +94,27 @@ export default function createControls(widgetType = null, widget = null, session 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)} />, - validateForm(id)} simulation={simulation} handleChange={(e) => handleChange(e)} />, - handleChange(e)} /> + validateForm(id)} simulation={simulation} handleChange={(e) => plotTableBoundOnChange(e)} />, + validateForm(id)} simulation={simulation} handleChange={(e) => handleChange(e)} />, + handleChange(e)} />, + validateForm(id)} simulation={simulation} handleChange={(e) => handleChange(e)} />, + handleChange(e)} /> ); break; case 'Slider': dialogControls.push( - validateForm(id)} simulation={simulation} handleChange={(e) => handleChange(e)} /> + 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)} /> + validateForm(id)} handleChange={(e) => handleChange(e)} />, + validateForm(id)} handleChange={(e) => handleChange(e)} /> ); break; case 'Box': dialogControls.push( - validateForm(id)} handleChange={(e) => handleChange(e)} /> + validateForm(id)} handleChange={(e) => handleChange(e)} /> ); break; case 'Label': @@ -123,6 +124,13 @@ export default function createControls(widgetType = null, widget = null, session handleChange(e)} /> ); break; + + case 'HTML': + dialogControls.push( + handleChange(e)} /> + ); + break; + default: console.log('Non-valid widget type: ' + widgetType); } diff --git a/src/components/dialog/edit-widget-html-content.js b/src/components/dialog/edit-widget-html-content.js new file mode 100644 index 0000000..22cc10b --- /dev/null +++ b/src/components/dialog/edit-widget-html-content.js @@ -0,0 +1,47 @@ +/** + * File: edit-widget-html-content.js + * Author: Ricardo Hernandez-Montoya + * Date: 03.09.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'; +import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap'; + +class EditWidgetHTMLContent extends React.Component { + constructor(props) { + super(props); + + this.state = { + widget: {} + }; + } + + componentWillReceiveProps(nextProps) { + // Update state's widget with props + this.setState({ widget: nextProps.widget }); + } + + render() { + return + HTML Content + this.props.handleChange(e)} /> + ; + } +} + +export default EditWidgetHTMLContent; diff --git a/src/components/dialog/edit-widget.js b/src/components/dialog/edit-widget.js index 91802e0..0528938 100644 --- a/src/components/dialog/edit-widget.js +++ b/src/components/dialog/edit-widget.js @@ -140,11 +140,6 @@ class EditWidgetDialog extends React.Component { return ( this.onClose(c)} onReset={() => this.resetState()} valid={this.valid}>
- {/* - Name - this.handleChange(e)} /> - - */} { controls || '' }
diff --git a/src/components/widget-factory.js b/src/components/widget-factory.js index faed0a3..ac4bd70 100644 --- a/src/components/widget-factory.js +++ b/src/components/widget-factory.js @@ -129,6 +129,10 @@ class WidgetFactory { widget.border_color = 0; widget.z = 0; break; + case 'HTML': + widget.content = 'Hello World'; + break; + default: widget.width = 100; widget.height = 100; diff --git a/src/components/widget-html.js b/src/components/widget-html.js new file mode 100644 index 0000000..b358fea --- /dev/null +++ b/src/components/widget-html.js @@ -0,0 +1,30 @@ +/** + * File: widget-html.js + * Author: Markus Grigull + * Date: 29.08.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'; + +class WidgetHTML extends React.Component { + render() { + return
+ } +} + +export default WidgetHTML; diff --git a/src/components/widget-plot/plot.js b/src/components/widget-plot/plot.js index 9be58fa..c9cc77e 100644 --- a/src/components/widget-plot/plot.js +++ b/src/components/widget-plot/plot.js @@ -99,8 +99,6 @@ class Plot extends React.Component { } render() { - console.log(this.state); - return select(node).call(this.state.xAxis)} style={{ transform: `translateY(${this.props.height}px)` }} /> select(node).call(this.state.yAxis)} style={{ transform: `translateX(${leftMargin}px)`}} /> diff --git a/src/containers/visualization.js b/src/containers/visualization.js index e28f419..971d55a 100644 --- a/src/containers/visualization.js +++ b/src/containers/visualization.js @@ -440,6 +440,7 @@ class Visualization extends React.Component { +
} diff --git a/src/containers/widget.js b/src/containers/widget.js index 055637a..15e89b6 100644 --- a/src/containers/widget.js +++ b/src/containers/widget.js @@ -41,6 +41,7 @@ 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 WidgetHTML from '../components/widget-html'; import '../styles/widgets.css'; @@ -173,6 +174,8 @@ class Widget extends Component { element = } else if (widget.type === 'Box') { element = + } else if (widget.type === 'HTML') { + element = } const widgetClasses = classNames({