From 805d50ac020dec042bfc94a1f17869372f7eff0e Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Wed, 12 Jul 2017 16:37:06 +0500 Subject: Implement Driver Unauthorized event and driverName field in Trip report --- web/app/AttributeFormatter.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'web/app/AttributeFormatter.js') diff --git a/web/app/AttributeFormatter.js b/web/app/AttributeFormatter.js index e63cf890..464314ad 100644 --- a/web/app/AttributeFormatter.js +++ b/web/app/AttributeFormatter.js @@ -74,6 +74,18 @@ Ext.define('Traccar.AttributeFormatter', { } }, + driverUniqueIdFormatter: function (value) { + var driver, store; + if (value !== 0) { + store = Ext.getStore('AllDrivers'); + if (store.getTotalCount() === 0) { + store = Ext.getStore('Drivers'); + } + driver = store.findRecord('uniqueId', value, 0, false, true, true); + return driver ? value + ' (' + driver.get('name') + ')' : value; + } + }, + lastUpdateFormatter: function (value) { var seconds, interval; @@ -157,6 +169,8 @@ Ext.define('Traccar.AttributeFormatter', { return this.distanceFormatter; } else if (dataType === 'speed') { return this.speedFormatter; + } else if (dataType === 'driverUniqueId') { + return this.driverUniqueIdFormatter; } else if (dataType === 'voltage') { return this.numberFormatterFactory(Traccar.Style.numberPrecision, Strings.sharedVoltAbbreviation); } else if (dataType === 'percentage') { -- cgit v1.2.3 From 4c5cfa14db69d4f7687c7187c81a36b959a0f415 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Thu, 13 Jul 2017 10:02:44 +0500 Subject: Use driverUniqueId for trips --- web/.jshintrc | 2 +- web/app/AttributeFormatter.js | 2 ++ web/app/model/ReportTrip.js | 3 +++ web/app/view/ReportController.js | 6 +++--- web/l10n/en.json | 1 - 5 files changed, 9 insertions(+), 5 deletions(-) (limited to 'web/app/AttributeFormatter.js') diff --git a/web/.jshintrc b/web/.jshintrc index cc0cdd4c..67329cd0 100644 --- a/web/.jshintrc +++ b/web/.jshintrc @@ -55,7 +55,7 @@ "proto" : false, // true: Tolerate using the `__proto__` property "scripturl" : false, // true: Tolerate script-targeted URLs "shadow" : false, // true: Allows re-define variables later in code e.g. `var x=1; x=2;` - "sub" : true, // true: Tolerate using `[]` notation when it can still be expressed in dot notation + "sub" : true, // true: Tolerate using `[]` notation when it can still be expressed in dot notation "supernew" : false, // true: Tolerate `new function () { ... };` and `new Object;` "validthis" : false, // true: Tolerate using this in a non-constructor function diff --git a/web/app/AttributeFormatter.js b/web/app/AttributeFormatter.js index 464314ad..3e6758ac 100644 --- a/web/app/AttributeFormatter.js +++ b/web/app/AttributeFormatter.js @@ -143,6 +143,8 @@ Ext.define('Traccar.AttributeFormatter', { return this.lastUpdateFormatter; } else if (key === 'spentFuel') { return this.numberFormatterFactory(Traccar.Style.numberPrecision, Strings.sharedLiterAbbreviation); + } else if (key === 'driverUniqueId') { + return this.driverUniqueIdFormatter; } else { return this.defaultFormatter; } diff --git a/web/app/model/ReportTrip.js b/web/app/model/ReportTrip.js index 107008eb..edff02b5 100644 --- a/web/app/model/ReportTrip.js +++ b/web/app/model/ReportTrip.js @@ -55,6 +55,9 @@ Ext.define('Traccar.model.ReportTrip', { }, { name: 'endAddress', type: 'string' + }, { + name: 'driverUniqueId', + type: 'string' }, { name: 'driverName', type: 'string' diff --git a/web/app/view/ReportController.js b/web/app/view/ReportController.js index b478ae98..7dfeaf3f 100644 --- a/web/app/view/ReportController.js +++ b/web/app/view/ReportController.js @@ -532,9 +532,9 @@ Ext.define('Traccar.view.ReportController', { dataIndex: 'spentFuel', renderer: Traccar.AttributeFormatter.getFormatter('spentFuel') }, { - text: Strings.reportDriverName, - dataIndex: 'driverName', - renderer: Traccar.AttributeFormatter.getFormatter('driverName') + text: Strings.sharedDriver, + dataIndex: 'driverUniqueId', + renderer: Traccar.AttributeFormatter.getFormatter('driverUniqueId') }], stopsColumns: [{ diff --git a/web/l10n/en.json b/web/l10n/en.json index 823066d6..404b26f7 100644 --- a/web/l10n/en.json +++ b/web/l10n/en.json @@ -330,7 +330,6 @@ "reportEndTime": "End Time", "reportEndAddress": "End Address", "reportSpentFuel": "Spent Fuel", - "reportDriverName": "Driver Name", "statisticsTitle": "Statistics", "statisticsCaptureTime": "Capture Time", "statisticsActiveUsers": "Active Users", -- cgit v1.2.3