mirror of
https://git.rwth-aachen.de/acs/public/villas/web/
synced 2025-03-16 00:00:03 +01:00
Change live data observer
Fix last extend prototype changes
This commit is contained in:
parent
846a0a73ee
commit
68d33e0b18
6 changed files with 21 additions and 48 deletions
app
components
controllers
mixins
models
|
@ -16,37 +16,18 @@ export default PlotAbstract.extend({
|
|||
minWidth_resize: 50,
|
||||
minHeight_resize: 20,
|
||||
|
||||
value: Ember.computed('data.2.values', 'plot.simulator', 'plot.signal', function() {
|
||||
// get all values for the choosen simulator
|
||||
let values = this.get('data.' + this.get('plot.simulator') + '.values');
|
||||
if (values) {
|
||||
return values[this.get('plot.signal')];
|
||||
}
|
||||
|
||||
// values is null, try to reload later
|
||||
Ember.run.later(this, function() {
|
||||
this.notifyPropertyChange('data.' + this.get('plot.simulator') + '.values');
|
||||
}, 1000);
|
||||
}),
|
||||
|
||||
/*_updateValue() {
|
||||
let values = this.get('data.' + this.get('plot.simulator') + '.values');
|
||||
if (values) {
|
||||
console.log('update value');
|
||||
return;
|
||||
}
|
||||
|
||||
// values is null, try to reload later
|
||||
Ember.run.later(this, this._updateValue, 1000);
|
||||
|
||||
console.log('update later');
|
||||
},
|
||||
|
||||
_updateDataObserver: function() {
|
||||
let query = 'data.' + this.get('plot.simulator') + '.values';
|
||||
this.addObserver(query, this, this._updateValue);
|
||||
console.log('Add observer: ' + query);
|
||||
}.observes('plot.simulator', 'plot.signal').on('init'),*/
|
||||
_updateDataObserver: Ember.on('init', Ember.observer('plot.simulator', 'plot.signal', function() {
|
||||
let query = 'data.' + this.get('plot.simulator') + '.sequence';
|
||||
this.addObserver(query, function() {
|
||||
// get value from array
|
||||
let values = this.get('data.' + this.get('plot.simulator') + '.values');
|
||||
if (values) {
|
||||
this.set('value', values[this.get('plot.signal')]);
|
||||
} else {
|
||||
this.set('value', null);
|
||||
}
|
||||
});
|
||||
})),
|
||||
|
||||
doubleClick() {
|
||||
if (this.get('editing') === true) {
|
||||
|
|
|
@ -19,12 +19,12 @@ export default Ember.Controller.extend({
|
|||
simulationModel: null,
|
||||
simulatorName: null,
|
||||
|
||||
_updateSimulators: function() {
|
||||
_updateSimulators: Ember.observer('model', function() {
|
||||
if (this.get('model.simulators') != null && this.get('model.simulators.length') > 0) {
|
||||
let simulators = this.get('model.simulators');
|
||||
this.set('simulatorName', simulators.toArray()[0].get('name'));
|
||||
}
|
||||
}.observes('model'),
|
||||
}),
|
||||
|
||||
actions: {
|
||||
showNewModal() {
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
users: function() {
|
||||
users: Ember.computed('model.@each', function() {
|
||||
var filteredUsers = this.get('model');
|
||||
filteredUsers.forEach(function(user) {
|
||||
// catch undefined user
|
||||
|
@ -22,5 +22,5 @@ export default Ember.Controller.extend({
|
|||
});
|
||||
|
||||
return filteredUsers;
|
||||
}.property('model.@each')
|
||||
})
|
||||
});
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Mixin.create({
|
||||
data: {},
|
||||
data: Ember.Object.create(),
|
||||
|
||||
_getData: Ember.observer('model', function() {
|
||||
// check if simulation is running
|
||||
|
@ -35,11 +35,6 @@ export default Ember.Mixin.create({
|
|||
});
|
||||
});
|
||||
} 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
|
||||
|
@ -55,10 +50,7 @@ export default Ember.Mixin.create({
|
|||
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');
|
||||
this.set('data.' + simulatorID, simulationData);
|
||||
} else {
|
||||
// try to load data later
|
||||
Ember.run.later(this, function() {
|
||||
|
|
|
@ -17,7 +17,7 @@ export default Model.extend({
|
|||
sequence: attr('number'),
|
||||
values: attr('array'),
|
||||
|
||||
historyValues() {
|
||||
/*historyValues() {
|
||||
return this._history;
|
||||
},
|
||||
|
||||
|
@ -28,5 +28,5 @@ export default Model.extend({
|
|||
while (this._history.length > 5) {
|
||||
this._history.shift();
|
||||
}
|
||||
})
|
||||
})*/
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue