1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/web/ synced 2025-03-09 00:00:01 +01:00

Change widget table data

This commit is contained in:
Markus Grigull 2017-07-11 21:09:19 +02:00
parent 6a535a5338
commit 101caf15c0
4 changed files with 14 additions and 10 deletions

View file

@ -71,7 +71,12 @@ class EditWidgetDialog extends Component {
this.setState({ temporal: Object.assign({}, this.state.temporal, changes ) });
} else {
let changeObject = {};
changeObject[e.target.id] = e.target.value;
if (e.target.id === 'simulator') {
changeObject[e.target.id] = JSON.parse(e.target.value);
} else {
changeObject[e.target.id] = e.target.value;
}
this.setState({ temporal: Object.assign({}, this.state.temporal, changeObject ) });
}
}

View file

@ -38,33 +38,33 @@ class WidgetTable extends Component {
// check data
const simulator = nextProps.widget.simulator;
if (nextProps.simulation == null || nextProps.data == null || nextProps.data[simulator] == null || nextProps.data[simulator].length === 0 || nextProps.data[simulator].values[0].length === 0) {
if (nextProps.simulation == null || nextProps.data == null || nextProps.data[simulator.node][simulator.simulator] == null || nextProps.data[simulator.node][simulator.simulator].length === 0 || nextProps.data[simulator.node][simulator.simulator].values.length === 0 || nextProps.data[simulator.node][simulator.simulator].values[0].length === 0) {
// clear values
this.setState({ rows: [], sequence: null });
return;
}
// check if new data, otherwise skip
if (this.state.sequence >= nextProps.data[simulator].sequence) {
/*if (this.state.sequence >= nextProps.data[simulator.node][simulator.simulator].sequence) {
return;
}
}*/
// get simulation model
const simulationModel = nextProps.simulation.models.find((model) => {
return (model.simulator === simulator);
return (model.simulator.node === simulator.node && model.simulator.simulator === simulator.simulator);
});
// get rows
var rows = [];
nextProps.data[simulator].values.forEach((signal, index) => {
nextProps.data[simulator.node][simulator.simulator].values.forEach((signal, index) => {
rows.push({
name: simulationModel.mapping[index].name,
value: signal[signal.length - 1].y.toFixed(3)
})
});
this.setState({ rows: rows, sequence: nextProps.data[simulator].sequence });
this.setState({ rows: rows, sequence: nextProps.data[simulator.node][simulator.simulator].sequence });
}
render() {

View file

@ -44,7 +44,7 @@ class WidgetValue extends Component {
// check if value has changed
const signal = nextProps.data[node][simulator].values[nextProps.widget.signal];
if (this.state.value !== signal[signal.length - 1].y) {
if (signal != null && this.state.value !== signal[signal.length - 1].y) {
this.setState({ value: signal[signal.length - 1].y });
}
}

View file

@ -154,7 +154,6 @@ class Visualization extends Component {
NotificationsDataManager.addNotification(NotificationsFactory.NO_SIM_MODEL_AVAILABLE);
} else {
defaultSimulator = this.state.simulation.models[0].simulator;
console.log(defaultSimulator);
}
// create new widget
@ -236,7 +235,7 @@ class Visualization extends Component {
if (data) {
// save changes temporarily
var widgets_update = {};
widgets_update[this.state.modalIndex] = data;
widgets_update[this.state.modalIndex] = data;
var new_widgets = Object.assign({}, this.state.visualization.widgets, widgets_update);