From d0d156b42eeba86d6a043be051470f05cd022919 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Wed, 12 Jul 2017 12:20:08 +0500 Subject: Implement Drivers --- web/app/store/AllDrivers.js | 30 ++++++++++++++++++++++++++++++ web/app/store/Drivers.js | 30 ++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 web/app/store/AllDrivers.js create mode 100644 web/app/store/Drivers.js (limited to 'web/app/store') diff --git a/web/app/store/AllDrivers.js b/web/app/store/AllDrivers.js new file mode 100644 index 0000000..9d72388 --- /dev/null +++ b/web/app/store/AllDrivers.js @@ -0,0 +1,30 @@ +/* + * 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 . + */ + +Ext.define('Traccar.store.AllDrivers', { + extend: 'Ext.data.Store', + model: 'Traccar.model.Driver', + + proxy: { + type: 'rest', + url: 'api/drivers', + extraParams: { + all: true + } + } +}); diff --git a/web/app/store/Drivers.js b/web/app/store/Drivers.js new file mode 100644 index 0000000..fd4ca20 --- /dev/null +++ b/web/app/store/Drivers.js @@ -0,0 +1,30 @@ +/* + * 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 . + */ + +Ext.define('Traccar.store.Drivers', { + extend: 'Ext.data.Store', + model: 'Traccar.model.Driver', + + proxy: { + type: 'rest', + url: 'api/drivers', + writer: { + writeAllFields: true + } + } +}); -- cgit v1.2.3 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 ++++++++++++++ web/app/model/Event.js | 3 +++ web/app/model/ReportTrip.js | 3 +++ web/app/store/PositionAttributes.js | 5 +++++ web/app/view/ReportController.js | 4 ++++ web/l10n/en.json | 3 +++ 6 files changed, 32 insertions(+) (limited to 'web/app/store') diff --git a/web/app/AttributeFormatter.js b/web/app/AttributeFormatter.js index e63cf89..464314a 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') { diff --git a/web/app/model/Event.js b/web/app/model/Event.js index 70fab17..da866b4 100644 --- a/web/app/model/Event.js +++ b/web/app/model/Event.js @@ -51,6 +51,9 @@ Ext.define('Traccar.model.Event', { text = Strings[alarmKey] || alarmKey; } else if (rec.get('type') === 'textMessage') { text = Strings.eventTextMessage + ': ' + rec.get('attributes')['message']; + } else if (rec.get('type') === 'driverUnauthorized') { + text = Strings.eventDriverUnauthorized + ': ' + Traccar.AttributeFormatter.driverUniqueIdFormatter( + rec.get('attributes')['driverUniqueId']); } else { text = Traccar.app.getEventString(rec.get('type')); } diff --git a/web/app/model/ReportTrip.js b/web/app/model/ReportTrip.js index d243a8a..107008e 100644 --- a/web/app/model/ReportTrip.js +++ b/web/app/model/ReportTrip.js @@ -55,5 +55,8 @@ Ext.define('Traccar.model.ReportTrip', { }, { name: 'endAddress', type: 'string' + }, { + name: 'driverName', + type: 'string' }] }); diff --git a/web/app/store/PositionAttributes.js b/web/app/store/PositionAttributes.js index 0a6572d..44bfa92 100644 --- a/web/app/store/PositionAttributes.js +++ b/web/app/store/PositionAttributes.js @@ -233,6 +233,11 @@ Ext.define('Traccar.store.PositionAttributes', { key: 'result', name: Strings.eventCommandResult, valueType: 'string' + }, { + key: 'driverUniqueId', + name: Strings.positionDriverUniqueId, + valueType: 'string', + dataType: 'driverUniqueId' }], getAttributeName: function (key, capitalize) { diff --git a/web/app/view/ReportController.js b/web/app/view/ReportController.js index e048c06..b478ae9 100644 --- a/web/app/view/ReportController.js +++ b/web/app/view/ReportController.js @@ -531,6 +531,10 @@ Ext.define('Traccar.view.ReportController', { text: Strings.reportSpentFuel, dataIndex: 'spentFuel', renderer: Traccar.AttributeFormatter.getFormatter('spentFuel') + }, { + text: Strings.reportDriverName, + dataIndex: 'driverName', + renderer: Traccar.AttributeFormatter.getFormatter('driverName') }], stopsColumns: [{ diff --git a/web/l10n/en.json b/web/l10n/en.json index e9ac17f..823066d 100644 --- a/web/l10n/en.json +++ b/web/l10n/en.json @@ -198,6 +198,7 @@ "positionDtcs": "DTCs", "positionObdSpeed": "OBD Speed", "positionObdOdometer": "OBD Odometer", + "positionDriverUniqueId": "Driver Unique Id", "serverTitle": "Server Settings", "serverZoom": "Zoom", "serverRegistration": "Registration", @@ -271,6 +272,7 @@ "eventIgnitionOff": "Ignition is OFF", "eventMaintenance": "Maintenance required", "eventTextMessage": "Text message received", + "eventDriverUnauthorized": "Driver Unauthorized", "eventsScrollToLast": "Scroll To Last", "alarmSos": "SOS Alarm", "alarmVibration": "Vibration Alarm", @@ -328,6 +330,7 @@ "reportEndTime": "End Time", "reportEndAddress": "End Address", "reportSpentFuel": "Spent Fuel", + "reportDriverName": "Driver Name", "statisticsTitle": "Statistics", "statisticsCaptureTime": "Capture Time", "statisticsActiveUsers": "Active Users", -- cgit v1.2.3 From d40b862b56075e1544d3ed117576e05354b398a1 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Fri, 14 Jul 2017 12:39:04 +0500 Subject: Implement driverChanged event instead of driverUnauthorized --- web/app/model/Event.js | 4 ++-- web/app/store/PositionAttributes.js | 4 ---- web/l10n/en.json | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) (limited to 'web/app/store') diff --git a/web/app/model/Event.js b/web/app/model/Event.js index da866b4..9455b0d 100644 --- a/web/app/model/Event.js +++ b/web/app/model/Event.js @@ -51,8 +51,8 @@ Ext.define('Traccar.model.Event', { text = Strings[alarmKey] || alarmKey; } else if (rec.get('type') === 'textMessage') { text = Strings.eventTextMessage + ': ' + rec.get('attributes')['message']; - } else if (rec.get('type') === 'driverUnauthorized') { - text = Strings.eventDriverUnauthorized + ': ' + Traccar.AttributeFormatter.driverUniqueIdFormatter( + } else if (rec.get('type') === 'driverChanged') { + text = Strings.eventDriverChanged + ': ' + Traccar.AttributeFormatter.driverUniqueIdFormatter( rec.get('attributes')['driverUniqueId']); } else { text = Traccar.app.getEventString(rec.get('type')); diff --git a/web/app/store/PositionAttributes.js b/web/app/store/PositionAttributes.js index 44bfa92..c3d6d18 100644 --- a/web/app/store/PositionAttributes.js +++ b/web/app/store/PositionAttributes.js @@ -120,10 +120,6 @@ Ext.define('Traccar.store.PositionAttributes', { name: Strings.positionFuelConsumption, valueType: 'number', dataType: 'consumption' - }, { - key: 'rfid', - name: Strings.positionRfid, - valueType: 'string' }, { key: 'versionFw', name: Strings.positionVersionFw, diff --git a/web/l10n/en.json b/web/l10n/en.json index 404b26f..ba34d06 100644 --- a/web/l10n/en.json +++ b/web/l10n/en.json @@ -272,7 +272,7 @@ "eventIgnitionOff": "Ignition is OFF", "eventMaintenance": "Maintenance required", "eventTextMessage": "Text message received", - "eventDriverUnauthorized": "Driver Unauthorized", + "eventDriverChanged": "Driver has changed", "eventsScrollToLast": "Scroll To Last", "alarmSos": "SOS Alarm", "alarmVibration": "Vibration Alarm", -- cgit v1.2.3