diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2017-06-07 08:21:06 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-07 08:21:06 -0700 |
commit | a330ae09293c62aae381cb2c7f36cfa76b86e813 (patch) | |
tree | 26478c08fc6f7136ec8355d13af2a1bbf97207dc /web/app/view | |
parent | b6f2faab0d35d54189fefd7567b6310023c3ad7b (diff) | |
parent | e04a02921ea015d4f4fe69c1c3f1813a07be9cf4 (diff) | |
download | etbsa-traccar-web-a330ae09293c62aae381cb2c7f36cfa76b86e813.tar.gz etbsa-traccar-web-a330ae09293c62aae381cb2c7f36cfa76b86e813.tar.bz2 etbsa-traccar-web-a330ae09293c62aae381cb2c7f36cfa76b86e813.zip |
Merge pull request #501 from Abyss777/position_attributes_reports
Known position attributes for reports and charts
Diffstat (limited to 'web/app/view')
-rw-r--r-- | web/app/view/ReportController.js | 14 | ||||
-rw-r--r-- | web/app/view/StateController.js | 9 | ||||
-rw-r--r-- | web/app/view/dialog/ReportConfig.js | 2 | ||||
-rw-r--r-- | web/app/view/edit/Attributes.js | 4 |
4 files changed, 24 insertions, 5 deletions
diff --git a/web/app/view/ReportController.js b/web/app/view/ReportController.js index d83d998..3daa295 100644 --- a/web/app/view/ReportController.js +++ b/web/app/view/ReportController.js @@ -64,6 +64,20 @@ Ext.define('Traccar.view.ReportController', { return this.getView().getComponent('chart'); }, + init: function () { + var i, data, attribute; + data = Ext.getStore('PositionAttributes').getData().items; + for (i = 0; i < data.length; i++) { + attribute = data[i]; + this.routeColumns.push({ + text: attribute.get('name'), + dataIndex: 'attribute.' + attribute.get('key'), + renderer: Traccar.AttributeFormatter.getAttributeFormatter(attribute.get('key')), + hidden: true + }); + } + }, + onConfigureClick: function () { var dialog = Ext.create('Traccar.view.dialog.ReportConfig'); dialog.lookupReference('eventTypeField').setHidden(this.lookupReference('reportTypeField').getValue() !== 'events'); diff --git a/web/app/view/StateController.js b/web/app/view/StateController.js index 0723dc1..4c99a8b 100644 --- a/web/app/view/StateController.js +++ b/web/app/view/StateController.js @@ -101,7 +101,7 @@ Ext.define('Traccar.view.StateController', { }, updatePosition: function () { - var attributes, store, key, aliasIndex, name; + var attributes, store, key, aliasIndex, name, value; store = Ext.getStore('Attributes'); store.removeAll(); @@ -126,11 +126,16 @@ Ext.define('Traccar.view.StateController', { } else { name = Ext.getStore('PositionAttributes').getAttributeName(key, true); } + if (this.position.get('attribute.' + key) !== undefined) { + value = Traccar.AttributeFormatter.getAttributeFormatter(key)(this.position.get('attribute.' + key)); + } else { + value = Traccar.AttributeFormatter.defaultFormatter(attributes[key]); + } store.add(Ext.create('Traccar.model.Attribute', { priority: 1024, name: name, attribute: key, - value: Traccar.AttributeFormatter.getAttributeFormatter(key)(attributes[key]) + value: value })); } } diff --git a/web/app/view/dialog/ReportConfig.js b/web/app/view/dialog/ReportConfig.js index b8493cb..836b605 100644 --- a/web/app/view/dialog/ReportConfig.js +++ b/web/app/view/dialog/ReportConfig.js @@ -61,7 +61,7 @@ Ext.define('Traccar.view.dialog.ReportConfig', { reference: 'chartTypeField', store: 'ReportChartTypes', hidden: true, - value: 'speedConverted', + value: 'speed', valueField: 'key', displayField: 'name', queryMode: 'local' diff --git a/web/app/view/edit/Attributes.js b/web/app/view/edit/Attributes.js index b080e56..66d8bb1 100644 --- a/web/app/view/edit/Attributes.js +++ b/web/app/view/edit/Attributes.js @@ -58,9 +58,9 @@ Ext.define('Traccar.view.edit.Attributes', { attribute = Ext.getStore(this.attributesStore).getById(record.get('name')); } if (attribute && attribute.get('dataType') === 'speed') { - return Ext.getStore('SpeedUnits').formatValue(value, Traccar.app.getPreference('speedUnit', 'kn')); + return Ext.getStore('SpeedUnits').formatValue(value, Traccar.app.getPreference('speedUnit', 'kn'), true); } else if (attribute && attribute.get('dataType') === 'distance') { - return Ext.getStore('DistanceUnits').formatValue(value, Traccar.app.getPreference('distanceUnit', 'km')); + return Ext.getStore('DistanceUnits').formatValue(value, Traccar.app.getPreference('distanceUnit', 'km'), true); } else { return value; } |