diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-09-15 12:24:13 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-09-15 12:24:13 +1200 |
commit | d2139af877194952e3d49ca882188bcebbbd927e (patch) | |
tree | f5f6c81df6f04269a0f57d83e5fce17b8c98c346 /web/app/store | |
parent | 5cf1061cfcc5baf214bce145961512fd4f672621 (diff) | |
download | traccar-server-d2139af877194952e3d49ca882188bcebbbd927e.tar.gz traccar-server-d2139af877194952e3d49ca882188bcebbbd927e.tar.bz2 traccar-server-d2139af877194952e3d49ca882188bcebbbd927e.zip |
Update and format store classes
Diffstat (limited to 'web/app/store')
-rw-r--r-- | web/app/store/CommandTypes.js | 20 | ||||
-rw-r--r-- | web/app/store/DistanceUnits.js | 36 | ||||
-rw-r--r-- | web/app/store/Languages.js | 5 | ||||
-rw-r--r-- | web/app/store/SpeedUnits.js | 32 |
4 files changed, 49 insertions, 44 deletions
diff --git a/web/app/store/CommandTypes.js b/web/app/store/CommandTypes.js index 6ce247b30..8ff78b5df 100644 --- a/web/app/store/CommandTypes.js +++ b/web/app/store/CommandTypes.js @@ -17,10 +17,18 @@ Ext.define('Traccar.store.CommandTypes', { extend: 'Ext.data.Store', fields: ['key', 'name'], - data: [ - {'key': 'positionPeriodic', 'name': strings.commandPositionPeriodic}, - {'key': 'positionStop', 'name': strings.commandPositionStop}, - {'key': 'engineStop', 'name': strings.commandEngineStop}, - {'key': 'engineResume', 'name': strings.commandEngineResume} - ] + + data: [{ + key: 'positionPeriodic', + name: strings.commandPositionPeriodic + }, { + key: 'positionStop', + name: strings.commandPositionStop + }, { + key: 'engineStop', + name: strings.commandEngineStop + }, { + key: 'engineResume', + name: strings.commandEngineResume + }] }); diff --git a/web/app/store/DistanceUnits.js b/web/app/store/DistanceUnits.js index 653bf6efb..cedff592a 100644 --- a/web/app/store/DistanceUnits.js +++ b/web/app/store/DistanceUnits.js @@ -16,27 +16,25 @@ Ext.define('Traccar.store.DistanceUnits', { extend: 'Ext.data.Store', - fields: ['key', 'name'], - data: [ - {'key': 'km', 'name': strings.sharedKm}, - {'key': 'mi', 'name': strings.sharedMi} - ], - - convert: function(value, unit) { - switch (unit) { - case 'km': - return Math.round(value * 0.1) / 100; - case 'mi': - return Math.round(value * 0.0621371) / 100; - } - return value; - }, - - getUnitName: function(unit) { + fields: ['key', 'name', 'factor'], + + data: [{ + key: 'km', + name: strings.sharedKm, + factor: 0.001 + }, { + key: 'mi', + name: strings.sharedMi, + factor: 0.00621371 + }], + + formatValue: function(value, unit) { + var model; if (unit) { - return this.findRecord('key', unit).get('name'); + model = this.findRecord('key', unit); + return Math.round(value * model.get('factor') * 100) / 100 + ' ' + model.get('name'); } else { - return ''; + return value; } } }); diff --git a/web/app/store/Languages.js b/web/app/store/Languages.js index 97a581805..360508fd1 100644 --- a/web/app/store/Languages.js +++ b/web/app/store/Languages.js @@ -17,13 +17,14 @@ Ext.define('Traccar.store.Languages', { extend: 'Ext.data.Store', fields: ['code', 'name'], + data: function() { var data = []; for (var code in availableLanguages) { if (availableLanguages.hasOwnProperty(code)) { data.push({ - 'code': code, - 'name': availableLanguages[code].name + code: code, + name: availableLanguages[code].name }); } } diff --git a/web/app/store/SpeedUnits.js b/web/app/store/SpeedUnits.js index 15c52625f..037670c8d 100644 --- a/web/app/store/SpeedUnits.js +++ b/web/app/store/SpeedUnits.js @@ -16,27 +16,25 @@ Ext.define('Traccar.store.SpeedUnits', { extend: 'Ext.data.Store', - fields: ['key', 'name'], - data: [ - {'key': 'kmh', 'name': strings.sharedKmh}, - {'key': 'mph', 'name': strings.sharedMph} - ], + fields: ['key', 'name', 'factor'], - convert: function(value, unit) { - switch (unit) { - case 'kmh': - return Math.round(value * 1.852 * 10) / 10; - case 'mph': - return Math.round(value * 1.15078 * 10) / 10; - } - return value; - }, + data: [{ + key: 'kmh', + name: strings.sharedKmh, + factor: 1.852 + }, { + key: 'mph', + name: strings.sharedMph, + factor: 1.15078 + }], - getUnitName: function(unit) { + formatValue: function(value, unit) { + var model; if (unit) { - return this.findRecord('key', unit).get('name'); + model = this.findRecord('key', unit); + return Math.round(value * model.get('factor') * 10) / 10 + ' ' + model.get('name'); } else { - return ''; + return value; } } }); |