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

Move visualization data to mixin

Add live data to edit visualization
Fix stylesheet files
This commit is contained in:
Markus Grigull 2016-10-12 09:10:41 +02:00
parent 59c9438ce1
commit f8028d88b7
13 changed files with 94 additions and 71 deletions

View file

@ -21,7 +21,7 @@ export default Ember.Component.extend(Resizable, Draggable, {
grid: false,
data: null,
simulator: 0
simulator: 0,
disabled_resize: false,
autoHide_resize: false,

View file

@ -8,8 +8,9 @@
**********************************************************************************/
import Ember from 'ember';
import FetchLiveDataMixin from '../../mixins/fetch-live-data';
export default Ember.Controller.extend({
export default Ember.Controller.extend(FetchLiveDataMixin, {
actions: {
addPlot(name) {
var plot = null;

View file

@ -8,67 +8,8 @@
**********************************************************************************/
import Ember from 'ember';
import FetchLiveDataMixin from '../../mixins/fetch-live-data';
export default Ember.Controller.extend({
data: {},
export default Ember.Controller.extend(FetchLiveDataMixin, {
/*values: function() {
console.log('update');
return this.get('data');
}.property('data.2.values'),*/
_getData: function() {
// check if simulation is running
let self = this;
this.get('model.project').then((project) => {
project.get('simulation').then((simulation) => {
if (simulation.get('running')) {
// get all models to access data
simulation.get('models').then((simulationModels) => {
simulationModels.forEach(function(simulationModel) {
// get simulator
simulationModel.get('simulator').then((simulator) => {
let simulatorID = simulator.get('simulatorid');
if (simulatorID) {
// add simulation data to list
self._loadDataForSimulator(simulatorID);
} else {
Ember.debug('undefined simulator id');
}
});
});
});
} else {
// clear simulation data
this.set('data', {});
//Ember.debug('Simulation not running');
// check again if simulation is running
Ember.run.later(this, function() {
// trigger _getData observer
this.notifyPropertyChange('model');
}, 1000);
}
});
});
}.observes('model'),
_loadDataForSimulator(simulatorID) {
// get data by simulator id
let simulationData = this.store.peekRecord('simulation-data', simulatorID);
if (simulationData) {
// add data to list
this.get('data')[simulatorID] = simulationData;
// notify object for property changes
this.notifyPropertyChange('data.' + simulatorID + '.values');
} else {
// try to load data later
Ember.run.later(this, function() {
this._loadDataForSimulator(simulatorID);
}, 1000);
}
}
});

View file

@ -0,0 +1,69 @@
/**
* File: fetch-live-data.js
* Author: Markus Grigull <mgrigull@eonerc.rwth-aachen.de>
* Date: 12.10.2016
* Copyright: 2016, 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 Ember from 'ember';
export default Ember.Mixin.create({
data: {},
_getData: function() {
// check if simulation is running
let self = this;
this.get('model.project').then((project) => {
project.get('simulation').then((simulation) => {
if (simulation.get('running')) {
// get all models to access data
simulation.get('models').then((simulationModels) => {
simulationModels.forEach(function(simulationModel) {
// get simulator
simulationModel.get('simulator').then((simulator) => {
let simulatorID = simulator.get('simulatorid');
if (simulatorID) {
// add simulation data to list
self._loadDataForSimulator(simulatorID);
} else {
Ember.debug('undefined simulator id');
}
});
});
});
} else {
// clear simulation data
this.set('data', {});
//Ember.debug('Simulation not running');
// check again if simulation is running
Ember.run.later(this, function() {
// trigger _getData observer
this.notifyPropertyChange('model');
}, 1000);
}
});
});
}.observes('model'),
_loadDataForSimulator(simulatorID) {
// get data by simulator id
let simulationData = this.store.peekRecord('simulation-data', simulatorID);
if (simulationData) {
// add data to list
this.get('data')[simulatorID] = simulationData;
// notify object for property changes
this.notifyPropertyChange('data.' + simulatorID + '.values');
} else {
// try to load data later
Ember.run.later(this, function() {
this._loadDataForSimulator(simulatorID);
}, 1000);
}
}
});

View file

@ -29,7 +29,7 @@ export default Ember.Mixin.create({
setInterval((function(self) {
return function() {
self._fetchRunningSimulations();
}
};
})(this), this.INTERVAL);
},

View file

@ -7,11 +7,11 @@
* Unauthorized copying of this file, via any medium is strictly prohibited.
**********************************************************************************/
@import 'plots.css';
@import 'models.css';
@import 'simulations.css';
@import 'projects.css';
@import 'simulators.css';
@import 'plots';
@import 'models';
@import 'simulations';
@import 'projects';
@import 'simulators';
@import "ember-modal-dialog/ember-modal-structure";
@import "ember-modal-dialog/ember-modal-appearance";

View file

@ -38,7 +38,7 @@
}
.project-index-row-controls a {
margin:left: 10px;
margin-left: 10px;
}
.project-index-new-visualization {

View file

@ -16,7 +16,7 @@
</div>
{{#draggable-dropzone dropped='addPlot'}}
{{plot-container plots=model.plots editing=true}}
{{plot-container plots=model.plots editing=true data=data}}
{{/draggable-dropzone}}
<p>

View file

@ -0,0 +1,12 @@
import Ember from 'ember';
import FetchLiveDataMixin from 'villasweb-frontend/mixins/fetch-live-data';
import { module, test } from 'qunit';
module('Unit | Mixin | fetch live data');
// Replace this with your real tests.
test('it works', function(assert) {
let FetchLiveDataObject = Ember.Object.extend(FetchLiveDataMixin);
let subject = FetchLiveDataObject.create();
assert.ok(subject);
});