aboutsummaryrefslogtreecommitdiff
path: root/web/app/view
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2017-06-06 11:43:09 +0500
committerAbyss777 <abyss@fox5.ru>2017-06-06 11:43:09 +0500
commitf538963be5fcee2280b22050c8a51475c3a984f8 (patch)
tree6a08cb27c330480b60bb8fd160570e308802de0c /web/app/view
parentb6f2faab0d35d54189fefd7567b6310023c3ad7b (diff)
downloadtrackermap-web-f538963be5fcee2280b22050c8a51475c3a984f8.tar.gz
trackermap-web-f538963be5fcee2280b22050c8a51475c3a984f8.tar.bz2
trackermap-web-f538963be5fcee2280b22050c8a51475c3a984f8.zip
- 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
Diffstat (limited to 'web/app/view')
-rw-r--r--web/app/view/ReportController.js18
-rw-r--r--web/app/view/StateController.js9
-rw-r--r--web/app/view/dialog/ReportConfig.js2
-rw-r--r--web/app/view/edit/Attributes.js4
4 files changed, 28 insertions, 5 deletions
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;
}