diff options
author | Abyss777 <abyss@fox5.ru> | 2017-04-19 14:17:11 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2017-04-19 14:17:11 +0500 |
commit | 3810a8be84b010f6c26f7541be22ecd6a973af58 (patch) | |
tree | a266c3fad333c50d0c1361ccc358fd685625ea01 /web/app/view/edit | |
parent | 648d5fe1e4a0d92b79410572d386dac45b4e8d36 (diff) | |
download | etbsa-traccar-web-3810a8be84b010f6c26f7541be22ecd6a973af58.tar.gz etbsa-traccar-web-3810a8be84b010f6c26f7541be22ecd6a973af58.tar.bz2 etbsa-traccar-web-3810a8be84b010f6c26f7541be22ecd6a973af58.zip |
Convert speed and distance for known attributes
Diffstat (limited to 'web/app/view/edit')
-rw-r--r-- | web/app/view/edit/Attributes.js | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/web/app/view/edit/Attributes.js b/web/app/view/edit/Attributes.js index 8008319..981d539 100644 --- a/web/app/view/edit/Attributes.js +++ b/web/app/view/edit/Attributes.js @@ -43,15 +43,31 @@ Ext.define('Traccar.view.edit.Attributes', { text: Strings.sharedName, dataIndex: 'name', renderer: function (value, metaData) { - var result; + var attribute; if (this.attributesStore) { - result = Ext.getStore(this.attributesStore).getById(value); + attribute = Ext.getStore(this.attributesStore).getById(value); } - return result && result.get('name') ? result.get('name') : value; + return attribute && attribute.get('name') ? attribute.get('name') : value; } }, { text: Strings.stateValue, - dataIndex: 'value' + dataIndex: 'value', + renderer: function (value, metaData, record) { + var attribute; + if (this.attributesStore) { + attribute = Ext.getStore(this.attributesStore).getById(record.get('name')); + } + if (attribute && attribute.get('convert') === 'speed') { + return Ext.getStore('SpeedUnits').formatValue(value, Traccar.app.getPreference('speedUnit', 'kn')); + } else if (attribute && attribute.get('convert') === 'distance') { + return Ext.getStore('DistanceUnits').formatValue(value, Traccar.app.getPreference('distanceUnit', 'km')); + } else if (attribute && attribute.get('type') === 'color') { + metaData.tdStyle = 'background-color:' + value; + return value; + } else { + return value; + } + } }] } }); |