From f538963be5fcee2280b22050c8a51475c3a984f8 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Tue, 6 Jun 2017 11:43:09 +0500 Subject: - Reworked fields and attributes formatting - Convert position and reports fields in the model - Add hidden columns to Route report - Add Number attributes to possible chart types --- web/app/view/ReportController.js | 18 ++++++++++++++++++ web/app/view/StateController.js | 9 +++++++-- web/app/view/dialog/ReportConfig.js | 2 +- web/app/view/edit/Attributes.js | 4 ++-- 4 files changed, 28 insertions(+), 5 deletions(-) (limited to 'web/app/view') diff --git a/web/app/view/ReportController.js b/web/app/view/ReportController.js index d83d9986..8631b7ca 100644 --- a/web/app/view/ReportController.js +++ b/web/app/view/ReportController.js @@ -64,6 +64,10 @@ Ext.define('Traccar.view.ReportController', { return this.getView().getComponent('chart'); }, + init: function () { + this.addAttributeColumns(); + }, + onConfigureClick: function () { var dialog = Ext.create('Traccar.view.dialog.ReportConfig'); dialog.lookupReference('eventTypeField').setHidden(this.lookupReference('reportTypeField').getValue() !== 'events'); @@ -383,6 +387,20 @@ Ext.define('Traccar.view.ReportController', { this.updateButtons(); }, + addAttributeColumns: 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 + }); + } + }, + routeColumns: [{ text: Strings.reportDeviceName, dataIndex: 'deviceId', diff --git a/web/app/view/StateController.js b/web/app/view/StateController.js index 0723dc13..4c99a8be 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 b8493cbb..836b6050 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 b080e569..0d16e1e8 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').convertAndFormat(value, Traccar.app.getPreference('speedUnit', 'kn')); } else if (attribute && attribute.get('dataType') === 'distance') { - return Ext.getStore('DistanceUnits').formatValue(value, Traccar.app.getPreference('distanceUnit', 'km')); + return Ext.getStore('DistanceUnits').convertAndFormat(value, Traccar.app.getPreference('distanceUnit', 'km')); } else { return value; } -- cgit v1.2.3