aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--web/app/Application.js4
-rw-r--r--web/app/AttributeFormatter.js47
-rw-r--r--web/app/model/KnownAttribute.js5
-rw-r--r--web/app/store/AttributeValueTypes.js33
-rw-r--r--web/app/store/DeviceAttributes.js20
-rw-r--r--web/app/store/GeofenceAttributes.js2
-rw-r--r--web/app/store/GroupAttributes.js16
-rw-r--r--web/app/store/PositionAttributes.js258
-rw-r--r--web/app/store/ServerAttributes.js14
-rw-r--r--web/app/store/UserAttributes.js24
-rw-r--r--web/app/view/CustomNumberField.js4
-rw-r--r--web/app/view/StateController.js6
-rw-r--r--web/app/view/dialog/AttributeController.js12
-rw-r--r--web/app/view/dialog/ComputedAttribute.js22
-rw-r--r--web/app/view/dialog/ComputedAttributeController.js32
-rw-r--r--web/app/view/edit/Attributes.js4
-rw-r--r--web/app/view/edit/ComputedAttributes.js20
-rw-r--r--web/app/view/permissions/DeviceAttributes.js10
-rw-r--r--web/app/view/permissions/GroupAttributes.js10
-rw-r--r--web/app/view/permissions/UserAttributes.js10
-rw-r--r--web/l10n/en.json45
21 files changed, 534 insertions, 64 deletions
diff --git a/web/app/Application.js b/web/app/Application.js
index 2a4149df..d73378c5 100644
--- a/web/app/Application.js
+++ b/web/app/Application.js
@@ -85,7 +85,9 @@ Ext.define('Traccar.Application', {
'ServerAttributes',
'UserAttributes',
'ComputedAttributes',
- 'AllComputedAttributes'
+ 'AllComputedAttributes',
+ 'PositionAttributes',
+ 'AttributeValueTypes'
],
controllers: [
diff --git a/web/app/AttributeFormatter.js b/web/app/AttributeFormatter.js
index 2142465c..ecab9fdb 100644
--- a/web/app/AttributeFormatter.js
+++ b/web/app/AttributeFormatter.js
@@ -35,6 +35,26 @@ Ext.define('Traccar.AttributeFormatter', {
return Ext.getStore('DistanceUnits').formatValue(value, Traccar.app.getPreference('distanceUnit'));
},
+ voltageFormatter: function (value) {
+ return Number(value.toFixed(Traccar.Style.numberPrecision)) + ' ' + Strings.sharedVoltAbbreviation;
+ },
+
+ percentageFormatter: function (value) {
+ return Number(value.toFixed(Traccar.Style.numberPrecision)) + ' %';
+ },
+
+ temperatureFormatter: function (value) {
+ return Number(value.toFixed(Traccar.Style.numberPrecision)) + ' °C';
+ },
+
+ volumeFormatter: function (value) {
+ return Number(value.toFixed(Traccar.Style.numberPrecision)) + ' ' + Strings.sharedLiterAbbreviation;
+ },
+
+ consumptionFormatter: function (value) {
+ return Number(value.toFixed(Traccar.Style.numberPrecision)) + ' ' + Strings.sharedLiterPerHourAbbreviation;
+ },
+
hoursFormatter: function (value) {
var hours = Math.round(value / 3600000);
return (hours + ' ' + Strings.sharedHourAbbreviation);
@@ -76,7 +96,7 @@ Ext.define('Traccar.AttributeFormatter', {
return this.speedFormatter;
} else if (key === 'course') {
return this.courseFormatter;
- } else if (key === 'distance' || key === 'odometer' || key === 'totalDistance' || key === 'accuracy') {
+ } else if (key === 'accuracy') {
return this.distanceFormatter;
} else if (key === 'hours') {
return this.hoursFormatter;
@@ -87,5 +107,30 @@ Ext.define('Traccar.AttributeFormatter', {
} else {
return this.defaultFormatter;
}
+ },
+
+ getAttributeFormatter: function (key) {
+ var dataType = Ext.getStore('PositionAttributes').getAttributeDataType(key);
+ if (!dataType) {
+ return this.defaultFormatter;
+ } else {
+ if (dataType === 'distance') {
+ return this.distanceFormatter;
+ } else if (dataType === 'speed') {
+ return this.speedFormatter;
+ } else if (dataType === 'voltage') {
+ return this.voltageFormatter;
+ } else if (dataType === 'percentage') {
+ return this.percentageFormatter;
+ } else if (dataType === 'temperature') {
+ return this.temperatureFormatter;
+ } else if (dataType === 'volume') {
+ return this.volumeFormatter;
+ } else if (dataType === 'consumption') {
+ return this.consumptionFormatter;
+ } else {
+ return this.defaultFormatter;
+ }
+ }
}
});
diff --git a/web/app/model/KnownAttribute.js b/web/app/model/KnownAttribute.js
index 9bb14dba..f6f41a73 100644
--- a/web/app/model/KnownAttribute.js
+++ b/web/app/model/KnownAttribute.js
@@ -26,7 +26,10 @@ Ext.define('Traccar.model.KnownAttribute', {
name: 'name',
type: 'string'
}, {
- name: 'type',
+ name: 'valueType',
+ type: 'string'
+ }, {
+ name: 'dataType',
type: 'string'
}]
});
diff --git a/web/app/store/AttributeValueTypes.js b/web/app/store/AttributeValueTypes.js
new file mode 100644
index 00000000..b80eba39
--- /dev/null
+++ b/web/app/store/AttributeValueTypes.js
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 Andrey Kunitsyn (andrey@traccar.org)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+Ext.define('Traccar.store.AttributeValueTypes', {
+ extend: 'Ext.data.Store',
+ fields: ['id', 'name'],
+ proxy: 'memory',
+
+ data: [{
+ id: 'string',
+ name: Strings.sharedTypeString
+ }, {
+ id: 'number',
+ name: Strings.sharedTypeNumber
+ }, {
+ id: 'boolean',
+ name: Strings.sharedTypeBoolean
+ }]
+});
diff --git a/web/app/store/DeviceAttributes.js b/web/app/store/DeviceAttributes.js
index 8f476d4e..220f9a5b 100644
--- a/web/app/store/DeviceAttributes.js
+++ b/web/app/store/DeviceAttributes.js
@@ -23,33 +23,33 @@ Ext.define('Traccar.store.DeviceAttributes', {
data: [{
key: 'speedLimit',
name: Strings.attributeSpeedLimit,
- type: 'number',
- convert: 'speed'
+ valueType: 'number',
+ dataType: 'speed'
}, {
key: 'report.ignoreOdometer',
name: Strings.attributeReportIgnoreOdometer,
- type: 'boolean'
+ valueType: 'boolean'
}, {
key: 'maintenance.start',
name: Strings.attributeMaintenanceStart,
- type: 'number',
- convert: 'distance'
+ valueType: 'number',
+ dataType: 'distance'
}, {
key: 'maintenance.interval',
name: Strings.attributeMaintenanceInterval,
- type: 'number',
- convert: 'distance'
+ valueType: 'number',
+ dataType: 'distance'
}, {
key: 'web.reportColor',
name: Strings.attributeWebReportColor,
- type: 'color'
+ valueType: 'color'
}, {
key: 'devicePassword',
name: Strings.attributeDevicePassword,
- type: 'string'
+ valueType: 'string'
}, {
key: 'processing.copyAttributes',
name: Strings.attributeProcessingCopyAttributes,
- type: 'string'
+ valueType: 'string'
}]
});
diff --git a/web/app/store/GeofenceAttributes.js b/web/app/store/GeofenceAttributes.js
index 9034b3f3..2b8d2d89 100644
--- a/web/app/store/GeofenceAttributes.js
+++ b/web/app/store/GeofenceAttributes.js
@@ -23,6 +23,6 @@ Ext.define('Traccar.store.GeofenceAttributes', {
data: [{
key: 'color',
name: Strings.attributeColor,
- type: 'color'
+ valueType: 'color'
}]
});
diff --git a/web/app/store/GroupAttributes.js b/web/app/store/GroupAttributes.js
index 95507243..2a2765f5 100644
--- a/web/app/store/GroupAttributes.js
+++ b/web/app/store/GroupAttributes.js
@@ -23,25 +23,25 @@ Ext.define('Traccar.store.GroupAttributes', {
data: [{
key: 'speedLimit',
name: Strings.attributeSpeedLimit,
- type: 'number',
- convert: 'speed'
+ valueType: 'number',
+ dataType: 'speed'
}, {
key: 'report.ignoreOdometer',
name: Strings.attributeReportIgnoreOdometer,
- type: 'boolean'
+ valueType: 'boolean'
}, {
key: 'maintenance.start',
name: Strings.attributeMaintenanceStart,
- type: 'number',
- convert: 'distance'
+ valueType: 'number',
+ dataType: 'distance'
}, {
key: 'maintenance.interval',
name: Strings.attributeMaintenanceInterval,
- type: 'number',
- convert: 'distance'
+ valueType: 'number',
+ dataType: 'distance'
}, {
key: 'processing.copyAttributes',
name: Strings.attributeProcessingCopyAttributes,
- type: 'string'
+ valueType: 'string'
}]
});
diff --git a/web/app/store/PositionAttributes.js b/web/app/store/PositionAttributes.js
new file mode 100644
index 00000000..6d6c0b71
--- /dev/null
+++ b/web/app/store/PositionAttributes.js
@@ -0,0 +1,258 @@
+/*
+ * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 Andrey Kunitsyn (andrey@traccar.org)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+Ext.define('Traccar.store.PositionAttributes', {
+ extend: 'Ext.data.Store',
+ model: 'Traccar.model.KnownAttribute',
+ proxy: 'memory',
+
+ data: [{
+ key: 'raw',
+ name: Strings.positionRaw,
+ valueType: 'string'
+ }, {
+ key: 'index',
+ name: Strings.positionIndex,
+ valueType: 'number'
+ }, {
+ key: 'hdop',
+ name: Strings.positionHdop,
+ valueType: 'number'
+ }, {
+ key: 'vdop',
+ name: Strings.positionVdop,
+ valueType: 'number'
+ }, {
+ key: 'pdop',
+ name: Strings.positionPdop,
+ valueType: 'number'
+ }, {
+ key: 'sat',
+ name: Strings.positionSat,
+ valueType: 'number'
+ }, {
+ key: 'satVisible',
+ name: Strings.positionSatVisible,
+ valueType: 'number'
+ }, {
+ key: 'rssi',
+ name: Strings.positionRssi,
+ valueType: 'number'
+ }, {
+ key: 'gps',
+ name: Strings.positionGps,
+ valueType: 'number'
+ }, {
+ key: 'event',
+ name: Strings.positionEvent,
+ valueType: 'string'
+ }, {
+ key: 'alarm',
+ name: Strings.alarm,
+ valueType: 'string'
+ }, {
+ key: 'status',
+ name: Strings.positionStatus,
+ valueType: 'string'
+ }, {
+ key: 'odometer',
+ name: Strings.positionOdometer,
+ valueType: 'number',
+ dataType: 'distance'
+ }, {
+ key: 'serviceOdometer',
+ name: Strings.positionServiceOdometer,
+ valueType: 'number',
+ dataType: 'distance'
+ }, {
+ key: 'tripOdometer',
+ name: Strings.positionTripOdometer,
+ valueType: 'number',
+ dataType: 'distance'
+ }, {
+ key: 'hours',
+ name: Strings.positionHours,
+ valueType: 'string'
+ }, {
+ key: 'input',
+ name: Strings.positionInput,
+ valueType: 'string'
+ }, {
+ key: 'output',
+ name: Strings.positionOutput,
+ valueType: 'string'
+ }, {
+ key: 'power',
+ name: Strings.positionPower,
+ valueType: 'number',
+ dataType: 'voltage'
+ }, {
+ key: 'battery',
+ name: Strings.positionBattery,
+ valueType: 'number',
+ dataType: 'voltage'
+ }, {
+ key: 'batteryLevel',
+ name: Strings.positionBatteryLevel,
+ valueType: 'number',
+ dataType: 'percentage'
+ }, {
+ key: 'fuel',
+ name: Strings.positionFuel,
+ valueType: 'number',
+ dataType: 'volume'
+ }, {
+ key: 'fuelConsumption',
+ name: Strings.positionFuelConsumption,
+ valueType: 'number',
+ dataType: 'consumption'
+ }, {
+ key: 'rfid',
+ name: Strings.positionRfid,
+ valueType: 'string'
+ }, {
+ key: 'versionFw',
+ name: Strings.positionVersionFw,
+ valueType: 'string'
+ }, {
+ key: 'versionHw',
+ name: Strings.positionVersionHw,
+ valueType: 'string'
+ }, {
+ key: 'type',
+ name: Strings.sharedType,
+ valueType: 'string'
+ }, {
+ key: 'ignition',
+ name: Strings.positionIgnition,
+ valueType: 'boolean'
+ }, {
+ key: 'flags',
+ name: Strings.positionFlags,
+ valueType: 'string'
+ }, {
+ key: 'charge',
+ name: Strings.positionCharge,
+ valueType: 'string'
+ }, {
+ key: 'ip',
+ name: Strings.positionIp,
+ valueType: 'string'
+ }, {
+ key: 'archive',
+ name: Strings.positionArchive,
+ valueType: 'boolean'
+ }, {
+ key: 'distance',
+ name: Strings.positionDistance,
+ valueType: 'number',
+ dataType: 'distance'
+ }, {
+ key: 'totalDistance',
+ name: Strings.deviceTotalDistance,
+ valueType: 'number',
+ dataType: 'distance'
+ }, {
+ key: 'rpm',
+ name: Strings.positionRpm,
+ valueType: 'number'
+ }, {
+ key: 'vin',
+ name: Strings.positionVin,
+ valueType: 'string'
+ }, {
+ key: 'approximate',
+ name: Strings.positionApproximate,
+ valueType: 'boolean'
+ }, {
+ key: 'throttle',
+ name: Strings.positionThrottle,
+ valueType: 'number'
+ }, {
+ key: 'motion',
+ name: Strings.positionMotion,
+ valueType: 'number'
+ }, {
+ key: 'armed',
+ name: Strings.positionArmed,
+ valueType: 'number'
+ }, {
+ key: 'geofence',
+ name: Strings.sharedGeofence,
+ valueType: 'string'
+ }, {
+ key: 'acceleration',
+ name: Strings.positionAcceleration,
+ valueType: 'number'
+ }, {
+ key: 'deviceTemp',
+ name: Strings.positionDeviceTemp,
+ valueType: 'number',
+ dataType: 'temperature'
+ }, {
+ key: 'operator',
+ name: Strings.positionOperator,
+ valueType: 'number',
+ dataType: 'temperature'
+ }, {
+ key: 'command',
+ name: Strings.deviceCommand,
+ valueType: 'string'
+ }, {
+ key: 'blocked',
+ name: Strings.positionBlocked,
+ valueType: 'boolean'
+ }, {
+ key: 'dtcs',
+ name: Strings.positionDtcs,
+ valueType: 'string'
+ }, {
+ key: 'obdSpeed',
+ name: Strings.positionObdSpeed,
+ valueType: 'number',
+ dataType: 'speed'
+ }, {
+ key: 'obdOdometer',
+ name: Strings.positionObdOdometer,
+ valueType: 'number',
+ dataType: 'distance'
+ }, {
+ key: 'result',
+ name: Strings.eventCommandResult,
+ valueType: 'string'
+ }],
+
+ getAttributeName: function (key) {
+ var model = this.getById(key);
+ if (model) {
+ return model.get('name');
+ } else {
+ return key.replace(/^./, function (match) {
+ return match.toUpperCase();
+ });
+ }
+ },
+
+ getAttributeDataType: function (key) {
+ var model = this.getById(key);
+ if (model && model.get('dataType')) {
+ return model.get('dataType');
+ } else {
+ return null;
+ }
+ }
+});
diff --git a/web/app/store/ServerAttributes.js b/web/app/store/ServerAttributes.js
index 602aab87..64bac240 100644
--- a/web/app/store/ServerAttributes.js
+++ b/web/app/store/ServerAttributes.js
@@ -23,22 +23,22 @@ Ext.define('Traccar.store.ServerAttributes', {
data: [{
key: 'speedLimit',
name: Strings.attributeSpeedLimit,
- type: 'number',
- convert: 'speed'
+ valueType: 'number',
+ dataType: 'speed'
}, {
key: 'maintenance.start',
name: Strings.attributeMaintenanceStart,
- type: 'number',
- convert: 'distance'
+ valueType: 'number',
+ dataType: 'distance'
}, {
key: 'maintenance.interval',
name: Strings.attributeMaintenanceInterval,
- type: 'number',
- convert: 'distance'
+ valueType: 'number',
+ dataType: 'distance'
}, {
key: 'web.liveRouteLength',
name: Strings.attributeWebLiveRouteLength,
- type: 'number',
+ valueType: 'number',
allowDecimals: false
}]
});
diff --git a/web/app/store/UserAttributes.js b/web/app/store/UserAttributes.js
index 8649eb8b..da05d5c8 100644
--- a/web/app/store/UserAttributes.js
+++ b/web/app/store/UserAttributes.js
@@ -23,54 +23,54 @@ Ext.define('Traccar.store.UserAttributes', {
data: [{
key: 'mail.smtp.host',
name: Strings.attributeMailSmtpHost,
- type: 'string'
+ valueType: 'string'
}, {
key: 'mail.smtp.port',
name: Strings.attributeMailSmtpPort,
- type: 'number',
+ valueType: 'number',
allowDecimals: false,
minValue: 1,
maxValue: 65535
}, {
key: 'mail.smtp.starttls.enable',
name: Strings.attributeMailSmtpStarttlsEnable,
- type: 'boolean'
+ valueType: 'boolean'
}, {
key: 'mail.smtp.starttls.required',
name: Strings.attributeMailSmtpStarttlsRequired,
- type: 'boolean'
+ valueType: 'boolean'
}, {
key: 'mail.smtp.ssl.enable',
name: Strings.attributeMailSmtpSslEnable,
- type: 'boolean'
+ valueType: 'boolean'
}, {
key: 'mail.smtp.ssl.trust',
name: Strings.attributeMailSmtpSslTrust,
- type: 'string'
+ valueType: 'string'
}, {
key: 'mail.smtp.ssl.protocols',
name: Strings.attributeMailSmtpSslProtocols,
- type: 'string'
+ valueType: 'string'
}, {
key: 'mail.smtp.from',
name: Strings.attributeMailSmtpFrom,
- type: 'string'
+ valueType: 'string'
}, {
key: 'mail.smtp.auth',
name: Strings.attributeMailSmtpAuth,
- type: 'boolean'
+ valueType: 'boolean'
}, {
key: 'mail.smtp.username',
name: Strings.attributeMailSmtpUsername,
- type: 'string'
+ valueType: 'string'
}, {
key: 'mail.smtp.password',
name: Strings.attributeMailSmtpPassword,
- type: 'string'
+ valueType: 'string'
}, {
key: 'web.liveRouteLength',
name: Strings.attributeWebLiveRouteLength,
- type: 'number',
+ valueType: 'number',
allowDecimals: false
}]
});
diff --git a/web/app/view/CustomNumberField.js b/web/app/view/CustomNumberField.js
index 7e2b88e9..e116e934 100644
--- a/web/app/view/CustomNumberField.js
+++ b/web/app/view/CustomNumberField.js
@@ -24,7 +24,7 @@ Ext.define('Traccar.view.CustomNumberField', {
constructor: function (config) {
var unit;
- if (config.convert === 'speed') {
+ if (config.dataType === 'speed') {
unit = Traccar.app.getPreference('speedUnit', 'kn');
config.beforeSubTpl = this.beforeEl;
config.afterSubTpl = this.unitEl + Ext.getStore('SpeedUnits').findRecord('key', unit).get('name') + '</div></div>';
@@ -34,7 +34,7 @@ Ext.define('Traccar.view.CustomNumberField', {
config.valueToRaw = function (value) {
return Ext.getStore('SpeedUnits').convertValue(value, Traccar.app.getPreference('speedUnit', 'kn'));
};
- } else if (config.convert === 'distance') {
+ } else if (config.dataType === 'distance') {
config.beforeSubTpl = this.beforeEl;
unit = Traccar.app.getPreference('distanceUnit', 'km');
config.afterSubTpl = this.unitEl + Ext.getStore('DistanceUnits').findRecord('key', unit).get('name') + '</div></div>';
diff --git a/web/app/view/StateController.js b/web/app/view/StateController.js
index f0370f96..1525db26 100644
--- a/web/app/view/StateController.js
+++ b/web/app/view/StateController.js
@@ -124,15 +124,13 @@ Ext.define('Traccar.view.StateController', {
if (aliasIndex !== -1) {
name = this.aliasesStore.getAt(aliasIndex).get('alias');
} else {
- name = key.replace(/^./, function (match) {
- return match.toUpperCase();
- });
+ name = Ext.getStore('PositionAttributes').getAttributeName(key);
}
store.add(Ext.create('Traccar.model.Attribute', {
priority: 1024,
name: name,
attribute: key,
- value: Traccar.AttributeFormatter.getFormatter(key)(attributes[key])
+ value: Traccar.AttributeFormatter.getAttributeFormatter(key)(attributes[key])
}));
}
}
diff --git a/web/app/view/dialog/AttributeController.js b/web/app/view/dialog/AttributeController.js
index afa970ad..12e31e8e 100644
--- a/web/app/view/dialog/AttributeController.js
+++ b/web/app/view/dialog/AttributeController.js
@@ -53,26 +53,26 @@ Ext.define('Traccar.view.dialog.AttributeController', {
},
onNameChange: function (combobox, newValue) {
- var type, config, attribute, valueField = this.lookupReference('valueField');
+ var valueType, config, attribute, valueField = this.lookupReference('valueField');
attribute = combobox.getStore().getById(newValue);
if (attribute) {
- type = attribute.get('type');
+ valueType = attribute.get('valueType');
config = Ext.clone(this.defaultFieldConfig);
- if (type === 'number') {
+ if (valueType === 'number') {
config.xtype = 'customNumberField';
if (attribute.get('allowDecimals') !== undefined) {
config.allowDecimals = attribute.get('allowDecimals');
} else {
config.allowDecimals = true;
}
- config.convert = attribute.get('convert');
+ config.dataType = attribute.get('dataType');
config.maxValue = attribute.get('maxValue');
config.minValue = attribute.get('minValue');
- } else if (type === 'boolean') {
+ } else if (valueType === 'boolean') {
config.xtype = 'checkboxfield';
config.inputValue = true;
config.uncheckedValue = false;
- } else if (type === 'color') {
+ } else if (valueType === 'color') {
config.xtype = 'customcolorpicker';
} else {
config.xtype = 'textfield';
diff --git a/web/app/view/dialog/ComputedAttribute.js b/web/app/view/dialog/ComputedAttribute.js
index df074919..90234b57 100644
--- a/web/app/view/dialog/ComputedAttribute.js
+++ b/web/app/view/dialog/ComputedAttribute.js
@@ -19,6 +19,11 @@
Ext.define('Traccar.view.dialog.ComputedAttribute', {
extend: 'Traccar.view.dialog.BaseEdit',
+ requires: [
+ 'Traccar.view.dialog.ComputedAttributeController'
+ ],
+
+ controller: 'computedAttribute',
title: Strings.sharedComputedAttribute,
items: {
@@ -28,20 +33,29 @@ Ext.define('Traccar.view.dialog.ComputedAttribute', {
name: 'description',
fieldLabel: Strings.sharedDescription
}, {
- xtype: 'textfield',
+ xtype: 'combobox',
name: 'attribute',
fieldLabel: Strings.sharedAttribute,
- allowBlank: false
+ store: 'PositionAttributes',
+ displayField: 'name',
+ valueField: 'key',
+ listeners: {
+ change: 'onAttributeChange'
+ }
}, {
xtype: 'textareafield',
name: 'expression',
fieldLabel: Strings.sharedExpression,
allowBlank: false
}, {
- xtype: 'textfield',
+ xtype: 'combobox',
name: 'type',
+ reference: 'typeComboField',
+ store: 'AttributeValueTypes',
fieldLabel: Strings.sharedType,
- allowBlank: false
+ displayField: 'name',
+ valueField: 'id',
+ editable: false
}]
},
diff --git a/web/app/view/dialog/ComputedAttributeController.js b/web/app/view/dialog/ComputedAttributeController.js
new file mode 100644
index 00000000..807653a6
--- /dev/null
+++ b/web/app/view/dialog/ComputedAttributeController.js
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 Andrey Kunitsyn (andrey@traccar.org)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+Ext.define('Traccar.view.dialog.ComputedAttributeController', {
+ extend: 'Traccar.view.dialog.BaseEditController',
+ alias: 'controller.computedAttribute',
+
+ onAttributeChange: function (combobox, newValue) {
+ var attribute = Ext.getStore('PositionAttributes').getById(newValue);
+ if (attribute) {
+ this.getView().lookupReference('typeComboField').setValue(attribute.get('valueType'));
+ this.getView().lookupReference('typeComboField').setReadOnly(true);
+ } else {
+ this.getView().lookupReference('typeComboField').setReadOnly(false);
+ }
+ }
+});
diff --git a/web/app/view/edit/Attributes.js b/web/app/view/edit/Attributes.js
index 7788d8c8..b080e569 100644
--- a/web/app/view/edit/Attributes.js
+++ b/web/app/view/edit/Attributes.js
@@ -57,9 +57,9 @@ Ext.define('Traccar.view.edit.Attributes', {
if (this.attributesStore) {
attribute = Ext.getStore(this.attributesStore).getById(record.get('name'));
}
- if (attribute && attribute.get('convert') === 'speed') {
+ if (attribute && attribute.get('dataType') === 'speed') {
return Ext.getStore('SpeedUnits').formatValue(value, Traccar.app.getPreference('speedUnit', 'kn'));
- } else if (attribute && attribute.get('convert') === 'distance') {
+ } else if (attribute && attribute.get('dataType') === 'distance') {
return Ext.getStore('DistanceUnits').formatValue(value, Traccar.app.getPreference('distanceUnit', 'km'));
} else {
return value;
diff --git a/web/app/view/edit/ComputedAttributes.js b/web/app/view/edit/ComputedAttributes.js
index 87d3b8da..741a1048 100644
--- a/web/app/view/edit/ComputedAttributes.js
+++ b/web/app/view/edit/ComputedAttributes.js
@@ -46,13 +46,29 @@ Ext.define('Traccar.view.edit.ComputedAttributes', {
dataIndex: 'description'
}, {
text: Strings.sharedAttribute,
- dataIndex: 'attribute'
+ dataIndex: 'attribute',
+ renderer: function (value) {
+ var attribute = Ext.getStore('PositionAttributes').getById(value);
+ if (attribute) {
+ return attribute.get('name');
+ } else {
+ return value;
+ }
+ }
}, {
text: Strings.sharedExpression,
dataIndex: 'expression'
}, {
text: Strings.sharedType,
- dataIndex: 'type'
+ dataIndex: 'type',
+ renderer: function (value) {
+ var type = Ext.getStore('AttributeValueTypes').getById(value);
+ if (type) {
+ return type.get('name');
+ } else {
+ return value;
+ }
+ }
}]
}
});
diff --git a/web/app/view/permissions/DeviceAttributes.js b/web/app/view/permissions/DeviceAttributes.js
index 2f837c42..baca9d3e 100644
--- a/web/app/view/permissions/DeviceAttributes.js
+++ b/web/app/view/permissions/DeviceAttributes.js
@@ -30,7 +30,15 @@ Ext.define('Traccar.view.permissions.DeviceAttributes', {
text: Strings.sharedAttribute,
dataIndex: 'attribute',
flex: 1,
- minWidth: Traccar.Style.columnWidthNormal
+ minWidth: Traccar.Style.columnWidthNormal,
+ renderer: function (value) {
+ var attribute = Ext.getStore('PositionAttributes').getById(value);
+ if (attribute) {
+ return attribute.get('name');
+ } else {
+ return value;
+ }
+ }
}]
}
});
diff --git a/web/app/view/permissions/GroupAttributes.js b/web/app/view/permissions/GroupAttributes.js
index a08eb78e..3972dbec 100644
--- a/web/app/view/permissions/GroupAttributes.js
+++ b/web/app/view/permissions/GroupAttributes.js
@@ -30,7 +30,15 @@ Ext.define('Traccar.view.permissions.GroupAttributes', {
text: Strings.sharedAttribute,
dataIndex: 'attribute',
flex: 1,
- minWidth: Traccar.Style.columnWidthNormal
+ minWidth: Traccar.Style.columnWidthNormal,
+ renderer: function (value) {
+ var attribute = Ext.getStore('PositionAttributes').getById(value);
+ if (attribute) {
+ return attribute.get('name');
+ } else {
+ return value;
+ }
+ }
}]
}
});
diff --git a/web/app/view/permissions/UserAttributes.js b/web/app/view/permissions/UserAttributes.js
index 056c4634..8a8a4543 100644
--- a/web/app/view/permissions/UserAttributes.js
+++ b/web/app/view/permissions/UserAttributes.js
@@ -30,7 +30,15 @@ Ext.define('Traccar.view.permissions.UserAttributes', {
text: Strings.sharedAttribute,
dataIndex: 'attribute',
flex: 1,
- minWidth: Traccar.Style.columnWidthNormal
+ minWidth: Traccar.Style.columnWidthNormal,
+ renderer: function (value) {
+ var attribute = Ext.getStore('PositionAttributes').getById(value);
+ if (attribute) {
+ return attribute.get('name');
+ } else {
+ return value;
+ }
+ }
}]
}
});
diff --git a/web/l10n/en.json b/web/l10n/en.json
index 45ddccb9..8607653b 100644
--- a/web/l10n/en.json
+++ b/web/l10n/en.json
@@ -37,6 +37,9 @@
"sharedDistance": "Distance",
"sharedHourAbbreviation": "h",
"sharedMinuteAbbreviation": "m",
+ "sharedVoltAbbreviation": "V",
+ "sharedLiterAbbreviation": "l",
+ "sharedLiterPerHourAbbreviation": "l/h",
"sharedGetMapState": "Get Map State",
"sharedAttributeAlias": "Attribute Alias",
"sharedAttributeAliases": "Attribute Aliases",
@@ -56,6 +59,9 @@
"sharedPreferences": "Preferences",
"sharedPermissions": "Permissions",
"sharedExtra": "Extra",
+ "sharedTypeString": "String",
+ "sharedTypeNumber": "Number",
+ "sharedTypeBoolean": "Boolean",
"sharedTimezone": "Timezone",
"attributeSpeedLimit": "Speed Limit",
"attributeReportIgnoreOdometer": "Report: Ignore Odometer",
@@ -146,6 +152,45 @@
"positionFuel": "Fuel",
"positionPower": "Power",
"positionBattery": "Battery",
+ "positionRaw": "Raw",
+ "positionIndex": "Index",
+ "positionHdop": "HDOP",
+ "positionVdop": "VDOP",
+ "positionPdop": "PDOP",
+ "positionSat": "Sattelites",
+ "positionSatVisible": "Visible Sattelites",
+ "positionRssi": "RSSI",
+ "positionGps": "GPS",
+ "positionEvent": "Event",
+ "positionStatus": "Status",
+ "positionOdometer": "Odometer",
+ "positionServiceOdometer": "Service Odometer",
+ "positionTripOdometer": "Trip Odometer",
+ "positionHours": "Hours",
+ "positionInput": "Input",
+ "positionOutput": "Output",
+ "positionBatteryLevel": "Battery Level",
+ "positionFuelConsumption": "Fuel Consumption",
+ "positionRfid": "RFID",
+ "positionVersionFw": "Firmware Version",
+ "positionVersionHw": "Hardware Version",
+ "positionIgnition": "Ignition",
+ "positionFlags": "Flags",
+ "positionCharge": "Charge",
+ "positionIp": "IP",
+ "positionArchive": "Archive",
+ "positionVin": "VIN",
+ "positionApproximate": "Approximate",
+ "positionThrottle": "Throttle",
+ "positionMotion": "Motion",
+ "positionArmed": "Armed",
+ "positionDeviceTemp": "Device Temperature",
+ "positionOperator": "Operator",
+ "positionCommand": "Acceleration",
+ "positionBlocked": "Blocked",
+ "positionDtcs": "DTCS",
+ "positionObdSpeed": "OBD Speed",
+ "positionObdOdometer": "OBD Odometer",
"serverTitle": "Server Settings",
"serverZoom": "Zoom",
"serverRegistration": "Registration",