diff --git a/app/adapters/application.js b/app/adapters/application.js index 98724cb..9515f11 100644 --- a/app/adapters/application.js +++ b/app/adapters/application.js @@ -13,8 +13,10 @@ export default DS.RESTAdapter.extend({ entities: [ { type: 'ElectricalGridMonitoring', - isPattern: true, - id: 'S?_ElectricalGrid' + /*isPattern: true, + id: 'S?_ElectricalGrid'*/ + isPattern: false, + id: 'S3_ElectricalGrid' } ] }; @@ -41,6 +43,6 @@ export default DS.RESTAdapter.extend({ }, updateRecord: function(store, type, snapshot) { - + } }); diff --git a/app/components/line-chart.js b/app/components/line-chart.js index f0a0d64..8b2d61f 100644 --- a/app/components/line-chart.js +++ b/app/components/line-chart.js @@ -44,10 +44,24 @@ export default Ember.Component.extend({ }, });*/ + var firstTimestamp = this.data[0][0]; + var lastTimestamp = this.data[this.data.length - 1][0]; + + var diff = lastTimestamp - firstTimestamp; + var diffValue = this.xaxisLength * 100; + + if (diff > diffValue) { + firstTimestamp = lastTimestamp - diffValue; + } else { + lastTimestamp = +firstTimestamp + +diffValue; + } + $.plot('#' + element.id, [this.data], { xaxis: { mode: 'time', - timeformat: '%H:%M:%S' + timeformat: '%M:%S', + min: firstTimestamp, + max: lastTimestamp } }); diff --git a/app/models/property.js b/app/models/property.js index 73c4d08..d7dc082 100644 --- a/app/models/property.js +++ b/app/models/property.js @@ -2,10 +2,9 @@ import DS from 'ember-data'; export default DS.Model.extend({ name: DS.attr('string'), - value: DS.attr('number'), type: DS.attr('string'), + values: DS.attr(), timestamp: DS.attr('date'), - history: DS.attr(), visible: DS.attr('boolean', { defaultValue: false }), entity: DS.belongsTo('entity'), category: DS.belongsTo('category') diff --git a/app/serializers/application.js b/app/serializers/application.js index aa148a0..9a38933 100644 --- a/app/serializers/application.js +++ b/app/serializers/application.js @@ -80,7 +80,7 @@ export default DS.RESTSerializer.extend({ if (item.contextElement.attributes) { item.contextElement.attributes.forEach(function(attribute) { if (attribute.type !== 'category') { - // find timestamp + // find timestamp data var timestamp = 0; attribute.metadatas.forEach(function(metadata) { @@ -96,10 +96,9 @@ export default DS.RESTSerializer.extend({ attributes: { name: attribute.name, type: attribute.type, - value: attribute.value, - timestamp: timestamp, + date: timestamp, visible: false, - history: [[timestamp, attribute.value]] + values: [] }, relationships: { entity: { @@ -108,6 +107,13 @@ export default DS.RESTSerializer.extend({ } } + // add values + if (attribute.value) { + attribute.value.forEach(function (value) { + property.attributes.values.push(value); + }); + } + entity.relationships.properties.data.push({ type: 'property', id: property.id }); handleItem(property); @@ -145,8 +151,10 @@ export default DS.RESTSerializer.extend({ var record = this.store.peekRecord('property', item.id); if (record) { if (record.timestamp !== item.attributes.timestamp) { - record.get('history').push([record.get('timestamp'), record.get('value')]); - record.set('value', item.attributes.value); + item.attributes.values.forEach(function (value) { + record.get('values').push(value); + }); + record.set('timestamp', item.attributes.timestamp); } } else { diff --git a/app/templates/lab-mashup/entity/property.hbs b/app/templates/lab-mashup/entity/property.hbs index 76d3e37..c045921 100644 --- a/app/templates/lab-mashup/entity/property.hbs +++ b/app/templates/lab-mashup/entity/property.hbs @@ -1 +1 @@ -{{line-chart data=model.history xaxisLength=600}} +{{line-chart data=model.values xaxisLength=600}} diff --git a/ember-cli-build.js b/ember-cli-build.js index 9898f53..a8d7780 100644 --- a/ember-cli-build.js +++ b/ember-cli-build.js @@ -19,7 +19,7 @@ module.exports = function(defaults) { // please specify an object with the list of modules as keys // along with the exports of each module as its value. - app.import('bower_components/flot/jquery.flot.time.js') + app.import('bower_components/flot/jquery.flot.time.js'); return app.toTree(); };