diff --git a/app/components/plot-abstract.js b/app/components/plot-abstract.js index 5df157f..2ec8964 100644 --- a/app/components/plot-abstract.js +++ b/app/components/plot-abstract.js @@ -30,13 +30,13 @@ export default Ember.Component.extend(Resizable, Draggable, { grid_drag: [ 10, 10 ], scroll_drag: true, - style: function() { + style: Ember.computed('plot', function() { return Ember.String.htmlSafe('width: ' + this.get('plot.width') + 'px; height: ' + this.get('plot.height') + 'px; left: ' + this.get('plot.x') + 'px; top: ' + this.get('plot.y') + 'px;'); - }.property('plot'), + }), - name: function() { + name: Ember.computed('plot', function() { return this.get('plot.name'); - }.property('plot'), + }), stop_resize(event, ui) { var width = ui.size.width; @@ -59,7 +59,7 @@ export default Ember.Component.extend(Resizable, Draggable, { }, - _updateUI: function() { + _updateUI: Ember.on('init', Ember.observer('editing', 'grid', function() { if (this.get('editing') === true) { this.set('disabled_resize', false); this.set('autoHide_resize', false); @@ -77,7 +77,7 @@ export default Ember.Component.extend(Resizable, Draggable, { this.set('grid_resize', false); this.set('grid_drag', false); } - }.observes('editing', 'grid').on('init'), + })), /*doubleClick() { if (this.get('editing')) { diff --git a/app/components/plot-container.js b/app/components/plot-container.js index 5f758c3..d2fdc0c 100644 --- a/app/components/plot-container.js +++ b/app/components/plot-container.js @@ -19,18 +19,18 @@ export default Ember.Component.extend({ grid: true, data: null, - style: function() { + style: Ember.computed('plots.@each.height', 'plots.@each.y', function() { var height = this._calculateHeight(); if (this.get('editing') === true && height < 400) { height = 400; } return Ember.String.htmlSafe('height: ' + height + 'px;'); - }.property('plots.@each.height', 'plots.@each.y'), + }), - _value: function() { + _value: Ember.computed('data.2.values.@each', function() { console.log(this.get('data')); - }.property('data.2.values.@each'), + }), _calculateHeight() { var maxHeight = 0; diff --git a/app/components/plot-value.js b/app/components/plot-value.js index b526080..d5f0ac2 100644 --- a/app/components/plot-value.js +++ b/app/components/plot-value.js @@ -8,6 +8,7 @@ **********************************************************************************/ import PlotAbstract from './plot-abstract'; +import Ember from 'ember'; export default PlotAbstract.extend({ classNames: [ 'plotValue' ], @@ -15,7 +16,7 @@ export default PlotAbstract.extend({ minWidth_resize: 50, minHeight_resize: 20, - value: function() { + 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) { @@ -26,7 +27,26 @@ export default PlotAbstract.extend({ Ember.run.later(this, function() { this.notifyPropertyChange('data.' + this.get('plot.simulator') + '.values'); }, 1000); - }.property('data.2.values', 'plot.simulator', 'plot.signal'), + }), + + /*_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'),*/ doubleClick() { if (this.get('editing') === true) { @@ -124,7 +144,6 @@ export default PlotAbstract.extend({ // get signal mapping for simulation model let self = this; - let simulatorid = this.get('plot.simulator'); this.get('plot.visualization').then((visualization) => { visualization.get('project').then((project) => { diff --git a/app/controllers/me.js b/app/controllers/me.js index 0374c40..8897e12 100644 --- a/app/controllers/me.js +++ b/app/controllers/me.js @@ -10,10 +10,10 @@ import Ember from 'ember'; export default Ember.Controller.extend({ - isAdmin: function() { + isAdmin: Ember.computed('model', function() { var level = this.get('model.adminLevel'); return level >= 1; - }.property('model'), + }), actions: { changeUser() { diff --git a/app/controllers/projects.js b/app/controllers/projects.js index c77ae2e..337bc46 100644 --- a/app/controllers/projects.js +++ b/app/controllers/projects.js @@ -21,12 +21,12 @@ export default Ember.Controller.extend({ project: null, projectSimulation: null, - _updateSimulations: function() { + _updateSimulations: Ember.observer('model', function() { if (this.get('model.simulations') != null && this.get('model.simulations.length') > 0) { var simulations = this.get('model.simulations'); this.set('projectSimulation', simulations.toArray()[0]); } - }.observes('model'), + }), actions: { showNewModal() { diff --git a/app/controllers/visualization/edit.js b/app/controllers/visualization/edit.js index a7c1845..8062829 100644 --- a/app/controllers/visualization/edit.js +++ b/app/controllers/visualization/edit.js @@ -21,12 +21,12 @@ export default Ember.Controller.extend(FetchLiveDataMixin, { simulatorName: null, signal: 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: { addPlot(name) { diff --git a/app/mixins/fetch-live-data.js b/app/mixins/fetch-live-data.js index 811f104..0398f6d 100644 --- a/app/mixins/fetch-live-data.js +++ b/app/mixins/fetch-live-data.js @@ -12,7 +12,7 @@ import Ember from 'ember'; export default Ember.Mixin.create({ data: {}, - _getData: function() { + _getData: Ember.observer('model', function() { // check if simulation is running let self = this; @@ -48,7 +48,7 @@ export default Ember.Mixin.create({ } }); }); - }.observes('model'), + }), _loadDataForSimulator(simulatorID) { // get data by simulator id diff --git a/app/models/simulation-data.js b/app/models/simulation-data.js index f4825db..6764464 100644 --- a/app/models/simulation-data.js +++ b/app/models/simulation-data.js @@ -23,10 +23,10 @@ export default Model.extend({ _history: [], - _updateHistory: function() { + _updateHistory: Ember.observer('values', function() { this._history.unshift(this.get('values')); while (this._history.length > 5) { this._history.shift(); } - }.observes('values') + }) }); diff --git a/config/environment.js b/config/environment.js index f359e20..a6feb08 100644 --- a/config/environment.js +++ b/config/environment.js @@ -10,6 +10,9 @@ module.exports = function(environment) { FEATURES: { // Here you can enable experimental features on an ember canary build // e.g. 'with-controller': true + }, + EXTEND_PROTOTYPES: { + Date: false, } },