From a63c943d2f60e5aad609e8e55e83d90f473bce85 Mon Sep 17 00:00:00 2001 From: Laura Fuentes Grau Date: Mon, 16 Mar 2020 17:02:51 +0100 Subject: [PATCH 1/3] dashboard grid now editable --- src/dashboard/dashboard.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/dashboard/dashboard.js b/src/dashboard/dashboard.js index ba19e56..11ac9e0 100644 --- a/src/dashboard/dashboard.js +++ b/src/dashboard/dashboard.js @@ -114,7 +114,7 @@ class Dashboard extends Component { } - + static getNewWidgetKey() { const widgetKey = this.lastWidgetKey; this.lastWidgetKey++; @@ -282,7 +282,11 @@ class Dashboard extends Component { saveEditing() { // Provide the callback so it can be called when state change is applied // TODO: Check if callback is needed - + AppDispatcher.dispatch({ + type: 'dashboards/start-edit', + data: this.state.dashboard, + token: this.state.sessionToken + }); this.state.widgetChangeData.forEach( widget => { AppDispatcher.dispatch({ @@ -317,7 +321,11 @@ class Dashboard extends Component { token: this.state.sessionToken }); }); */ - + AppDispatcher.dispatch({ + type: 'dashboards/start-load', + data: this.props.match.params.dashboard, + token: this.state.sessionToken + }); AppDispatcher.dispatch({ type: 'widgets/start-load', @@ -329,9 +337,11 @@ class Dashboard extends Component { }; setGrid(value) { - const dashboard = this.state.dashboard.set('grid', value); - + + let dashboard = this.state.dashboard; + dashboard.grid = value; this.setState({ dashboard }); + this.forceUpdate(); }; pauseData(){ From fe3c7830549ae2dadeff815d61a03ca1a0f3522b Mon Sep 17 00:00:00 2001 From: Laura Fuentes Grau Date: Mon, 16 Mar 2020 20:36:23 +0100 Subject: [PATCH 2/3] plot widget x scale now freezes if dashboard is paused --- src/widget/widget-plot/plot.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/widget/widget-plot/plot.js b/src/widget/widget-plot/plot.js index db86bfd..82c099a 100644 --- a/src/widget/widget-plot/plot.js +++ b/src/widget/widget-plot/plot.js @@ -65,7 +65,8 @@ class Plot extends React.Component { xAxis, yAxis, labelMargin, - identifier: uniqueIdentifier++ + identifier: uniqueIdentifier++, + stopTime: null, }; } @@ -86,20 +87,30 @@ class Plot extends React.Component { // check if data is invalid if (props.data == null || props.data.length === 0 || props.data[0].length === 0) { // create empty plot axes - const xScale = scaleTime().domain([Date.now() - props.time * 1000, Date.now()]).range([0, props.width - leftMargin - labelMargin - rightMargin]); + let xScale; let yScale; + let stopTime; + + if(!props.paused){ + xScale = scaleTime().domain([Date.now() - props.time * 1000, Date.now()]).range([0, props.width - leftMargin - labelMargin - rightMargin]); + stopTime = Date.now(); + }else{ + stopTime = state.stopTime; + xScale = scaleLinear().domain([state.stopTime - props.time * 1000, state.stopTime]).range([0, props.width - leftMargin - labelMargin - rightMargin]); + } if (props.yUseMinMax) { yScale = scaleLinear().domain([props.yMin, props.yMax]).range([props.height + topMargin - bottomMargin, topMargin]); } else { yScale = scaleLinear().domain([0, 10]).range([props.height + topMargin - bottomMargin, topMargin]); } - + const xAxis = axisBottom().scale(xScale).ticks(5).tickFormat(timeFormat("%M:%S")); const yAxis = axisLeft().scale(yScale).ticks(5).tickFormat(format(".3s")); return{ + stopTime: stopTime, data: null, xAxis, yAxis, From 53e0e8d4dee31ad660caf946df218b5da68a20a7 Mon Sep 17 00:00:00 2001 From: Laura Fuentes Grau Date: Wed, 18 Mar 2020 12:01:58 +0100 Subject: [PATCH 3/3] All label widget edit options now work as expected --- .../edit-widget-text-size-control.js | 2 +- src/widget/edit-widget/edit-widget.js | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/widget/edit-widget/edit-widget-text-size-control.js b/src/widget/edit-widget/edit-widget-text-size-control.js index 949b1dd..4c57f9c 100644 --- a/src/widget/edit-widget/edit-widget-text-size-control.js +++ b/src/widget/edit-widget/edit-widget-text-size-control.js @@ -29,7 +29,7 @@ class EditWidgetTextSizeControl extends React.Component { return ( Text size - this.props.handleChange(e)}> + this.props.handleChange(e)}> {sizes.map((size, index) => ( ))} diff --git a/src/widget/edit-widget/edit-widget.js b/src/widget/edit-widget/edit-widget.js index 7d34887..668454f 100644 --- a/src/widget/edit-widget/edit-widget.js +++ b/src/widget/edit-widget/edit-widget.js @@ -73,25 +73,28 @@ class EditWidgetDialog extends React.Component { // not a customProperty customProperty = false; } - + if(parts.length === 1 && customProperty){ + parts.push(parts[0]); + } + if (e.target.id === 'lockAspect') { //not a customProperty changeObject[e.target.id] = e.target.checked; // correct image aspect if turned on if (e.target.checked) { - changeObject = this.assignAspectRatio(changeObject, this.state.temporal.file); + changeObject = this.assignAspectRatio(changeObject, this.state.temporal.customProperties.file); } - } else if (e.target.id === 'file') { - //not a customProperty - changeObject.customProperties[e.target.id] = e.target.value; + } else if (parts[1] === 'file') { + //customProperty + changeObject.customProperties.parts[1] = e.target.value; // get file and update size (if it's an image) if ('lockAspect' in this.state.temporal && this.state.temporal.lockAspect) { changeObject = this.assignAspectRatio(changeObject, e.target.value); } } else if (e.target.type === 'number') { - customProperty ? changeObject.customProperties[e.target.id] = Number(e.target.value) : changeObject[e.target.id] = Number(e.target.value); + customProperty ? changeObject.customProperties.parts[1] = Number(e.target.value) : changeObject[e.target.id] = Number(e.target.value); } else if(e.target.id === 'name'){ if(changeObject[e.target.id] != null){ changeObject[e.target.id] = e.target.value; @@ -99,7 +102,7 @@ class EditWidgetDialog extends React.Component { changeObject[e.target.id] = 'default'; } } else { - customProperty ? changeObject[parts[0]][parts[1]] = e.target.value : changeObject[e.target.id] = e.target.value ; + customProperty ? changeObject.customProperties[parts[1]] = e.target.value : changeObject[e.target.id] = e.target.value ; } this.validChanges(); this.setState({ temporal: changeObject});