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/Application.js | 7 ++-- web/app/controller/Root.js | 1 + web/app/model/Driver.js | 35 +++++++++++++++++++ web/app/store/AllDrivers.js | 30 ++++++++++++++++ web/app/store/Drivers.js | 30 ++++++++++++++++ web/app/view/SettingsMenu.js | 6 ++++ web/app/view/SettingsMenuController.js | 11 ++++++ web/app/view/dialog/Driver.js | 42 +++++++++++++++++++++++ web/app/view/edit/Devices.js | 8 +++++ web/app/view/edit/DevicesController.js | 17 +++++++++ web/app/view/edit/Drivers.js | 57 +++++++++++++++++++++++++++++++ web/app/view/edit/DriversController.js | 32 +++++++++++++++++ web/app/view/edit/Groups.js | 8 +++++ web/app/view/edit/GroupsController.js | 19 +++++++++++ web/app/view/edit/Users.js | 7 ++++ web/app/view/edit/UsersController.js | 18 ++++++++++ web/app/view/permissions/DeviceDrivers.js | 44 ++++++++++++++++++++++++ web/app/view/permissions/GroupDrivers.js | 44 ++++++++++++++++++++++++ web/app/view/permissions/UserDrivers.js | 44 ++++++++++++++++++++++++ 19 files changed, 458 insertions(+), 2 deletions(-) create mode 100644 web/app/model/Driver.js create mode 100644 web/app/store/AllDrivers.js create mode 100644 web/app/store/Drivers.js create mode 100644 web/app/view/dialog/Driver.js create mode 100644 web/app/view/edit/Drivers.js create mode 100644 web/app/view/edit/DriversController.js create mode 100644 web/app/view/permissions/DeviceDrivers.js create mode 100644 web/app/view/permissions/GroupDrivers.js create mode 100644 web/app/view/permissions/UserDrivers.js (limited to 'web/app') diff --git a/web/app/Application.js b/web/app/Application.js index c0a69457..b4ce10ad 100644 --- a/web/app/Application.js +++ b/web/app/Application.js @@ -40,7 +40,8 @@ Ext.define('Traccar.Application', { 'ReportTrip', 'ReportStop', 'Calendar', - 'KnownAttribute' + 'KnownAttribute', + 'Driver' ], stores: [ @@ -89,7 +90,9 @@ Ext.define('Traccar.Application', { 'ComputedAttributes', 'AllComputedAttributes', 'PositionAttributes', - 'AttributeValueTypes' + 'AttributeValueTypes', + 'Drivers', + 'AllDrivers' ], controllers: [ diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js index e389266e..337ec4c5 100644 --- a/web/app/controller/Root.js +++ b/web/app/controller/Root.js @@ -105,6 +105,7 @@ Ext.define('Traccar.controller.Root', { loadApp: function () { var attribution, eventId; Ext.getStore('Groups').load(); + Ext.getStore('Drivers').load(); Ext.getStore('Geofences').load(); Ext.getStore('Calendars').load(); Ext.getStore('AttributeAliases').load(); diff --git a/web/app/model/Driver.js b/web/app/model/Driver.js new file mode 100644 index 00000000..3c3b30e5 --- /dev/null +++ b/web/app/model/Driver.js @@ -0,0 +1,35 @@ +/* + * 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.model.Driver', { + extend: 'Ext.data.Model', + identifier: 'negative', + + fields: [{ + name: 'id', + type: 'int' + }, { + name: 'name', + type: 'string' + }, { + name: 'uniqueId', + type: 'string' + }, { + name: 'attributes' + }] +}); diff --git a/web/app/store/AllDrivers.js b/web/app/store/AllDrivers.js new file mode 100644 index 00000000..9d723885 --- /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 00000000..fd4ca203 --- /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 + } + } +}); diff --git a/web/app/view/SettingsMenu.js b/web/app/view/SettingsMenu.js index db426bbe..f893a157 100644 --- a/web/app/view/SettingsMenu.js +++ b/web/app/view/SettingsMenu.js @@ -42,6 +42,12 @@ Ext.define('Traccar.view.SettingsMenu', { glyph: 'xf247@FontAwesome', handler: 'onGroupsClick', reference: 'settingsGroupsButton' + }, { + hidden: true, + text: Strings.sharedDrivers, + glyph: 'xf2c2@FontAwesome', + handler: 'onDriversClick', + reference: 'settingsDriversButton' }, { hidden: true, text: Strings.sharedGeofences, diff --git a/web/app/view/SettingsMenuController.js b/web/app/view/SettingsMenuController.js index a1883a61..102120d8 100644 --- a/web/app/view/SettingsMenuController.js +++ b/web/app/view/SettingsMenuController.js @@ -26,6 +26,7 @@ Ext.define('Traccar.view.SettingsMenuController', { 'Traccar.view.edit.Users', 'Traccar.view.edit.Groups', 'Traccar.view.edit.Geofences', + 'Traccar.view.edit.Drivers', 'Traccar.view.Notifications', 'Traccar.view.edit.AttributeAliases', 'Traccar.view.edit.ComputedAttributes', @@ -55,6 +56,7 @@ Ext.define('Traccar.view.SettingsMenuController', { this.lookupReference('settingsGeofencesButton').setHidden(false); this.lookupReference('settingsNotificationsButton').setHidden(false); this.lookupReference('settingsCalendarsButton').setHidden(false); + this.lookupReference('settingsDriversButton').setHidden(false); } if (admin || (!deviceReadonly && !readonly)) { this.lookupReference('settingsAttributeAliasesButton').setHidden(false); @@ -156,6 +158,15 @@ Ext.define('Traccar.view.SettingsMenuController', { }).show(); }, + onDriversClick: function () { + Ext.create('Traccar.view.BaseWindow', { + title: Strings.sharedDrivers, + items: { + xtype: 'driversView' + } + }).show(); + }, + onLogoutClick: function () { Ext.create('Traccar.view.dialog.LoginController').logout(); } diff --git a/web/app/view/dialog/Driver.js b/web/app/view/dialog/Driver.js new file mode 100644 index 00000000..437ef666 --- /dev/null +++ b/web/app/view/dialog/Driver.js @@ -0,0 +1,42 @@ +/* + * 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.view.dialog.Driver', { + extend: 'Traccar.view.dialog.BaseEdit', + + title: Strings.sharedDevice, + + items: { + xtype: 'form', + items: [{ + xtype: 'fieldset', + title: Strings.sharedRequired, + items: [{ + xtype: 'textfield', + name: 'name', + fieldLabel: Strings.sharedName, + allowBlank: false + }, { + xtype: 'textfield', + name: 'uniqueId', + fieldLabel: Strings.deviceIdentifier, + allowBlank: false + }] + }] + } +}); diff --git a/web/app/view/edit/Devices.js b/web/app/view/edit/Devices.js index 267a38be..97cbba2b 100644 --- a/web/app/view/edit/Devices.js +++ b/web/app/view/edit/Devices.js @@ -82,6 +82,14 @@ Ext.define('Traccar.view.edit.Devices', { glyph: 'xf0ae@FontAwesome', tooltip: Strings.sharedComputedAttributes, tooltipType: 'title' + }, { + xtype: 'button', + disabled: true, + handler: 'onDriversClick', + reference: 'toolbarDriversButton', + glyph: 'xf2c2@FontAwesome', + tooltip: Strings.sharedDrivers, + tooltipType: 'title' }, { disabled: true, handler: 'onCommandClick', diff --git a/web/app/view/edit/DevicesController.js b/web/app/view/edit/DevicesController.js index 2457d5cb..0cdf18ac 100644 --- a/web/app/view/edit/DevicesController.js +++ b/web/app/view/edit/DevicesController.js @@ -24,6 +24,7 @@ Ext.define('Traccar.view.edit.DevicesController', { 'Traccar.view.dialog.Device', 'Traccar.view.permissions.DeviceGeofences', 'Traccar.view.permissions.DeviceAttributes', + 'Traccar.view.permissions.DeviceDrivers', 'Traccar.view.BaseWindow', 'Traccar.model.Device', 'Traccar.model.Command' @@ -93,6 +94,21 @@ Ext.define('Traccar.view.edit.DevicesController', { }).show(); }, + onDriversClick: function () { + var device = this.getView().getSelectionModel().getSelection()[0]; + Ext.create('Traccar.view.BaseWindow', { + title: Strings.sharedDrivers, + items: { + xtype: 'deviceDriversView', + baseObjectName: 'deviceId', + linkObjectName: 'driverId', + storeName: 'Drivers', + urlApi: 'api/devices/drivers', + baseObject: device.getId() + } + }).show(); + }, + onCommandClick: function () { var device, deviceId, command, dialog, typesStore, online; device = this.getView().getSelectionModel().getSelection()[0]; @@ -122,6 +138,7 @@ Ext.define('Traccar.view.edit.DevicesController', { this.lookupReference('toolbarRemoveButton').setDisabled(empty || readonly || deviceReadonly); this.lookupReference('toolbarGeofencesButton').setDisabled(empty || readonly); this.lookupReference('toolbarAttributesButton').setDisabled(empty || readonly); + this.lookupReference('toolbarDriversButton').setDisabled(empty || readonly); this.lookupReference('deviceCommandButton').setDisabled(empty || readonly); }, diff --git a/web/app/view/edit/Drivers.js b/web/app/view/edit/Drivers.js new file mode 100644 index 00000000..59d8d2c4 --- /dev/null +++ b/web/app/view/edit/Drivers.js @@ -0,0 +1,57 @@ +/* + * 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.view.edit.Drivers', { + extend: 'Ext.grid.Panel', + xtype: 'driversView', + + requires: [ + 'Ext.grid.filters.Filters', + 'Traccar.view.edit.DriversController', + 'Traccar.view.edit.Toolbar' + ], + + plugins: 'gridfilters', + + controller: 'drivers', + store: 'Drivers', + + tbar: { + xtype: 'editToolbar' + }, + + listeners: { + selectionchange: 'onSelectionChange' + }, + + columns: { + defaults: { + flex: 1, + minWidth: Traccar.Style.columnWidthNormal + }, + items: [{ + text: Strings.sharedName, + dataIndex: 'name', + filter: 'string' + }, { + text: Strings.sharedDescription, + dataIndex: 'uniqueId', + filter: 'string' + }] + } +}); diff --git a/web/app/view/edit/DriversController.js b/web/app/view/edit/DriversController.js new file mode 100644 index 00000000..2840c2a7 --- /dev/null +++ b/web/app/view/edit/DriversController.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 . + */ + +Ext.define('Traccar.view.edit.DriversController', { + extend: 'Traccar.view.edit.ToolbarController', + alias: 'controller.drivers', + + requires: [ + 'Traccar.view.dialog.Driver', + 'Traccar.model.Driver' + ], + + objectModel: 'Traccar.model.Driver', + objectDialog: 'Traccar.view.dialog.Driver', + removeTitle: Strings.sharedDriver + +}); diff --git a/web/app/view/edit/Groups.js b/web/app/view/edit/Groups.js index d4d08305..deb797f1 100644 --- a/web/app/view/edit/Groups.js +++ b/web/app/view/edit/Groups.js @@ -49,6 +49,14 @@ Ext.define('Traccar.view.edit.Groups', { glyph: 'xf0ae@FontAwesome', tooltip: Strings.sharedComputedAttributes, tooltipType: 'title' + }, { + xtype: 'button', + disabled: true, + handler: 'onDriversClick', + reference: 'toolbarDriversButton', + glyph: 'xf2c2@FontAwesome', + tooltip: Strings.sharedDrivers, + tooltipType: 'title' }] }, diff --git a/web/app/view/edit/GroupsController.js b/web/app/view/edit/GroupsController.js index 602bb095..a170b3e9 100644 --- a/web/app/view/edit/GroupsController.js +++ b/web/app/view/edit/GroupsController.js @@ -23,6 +23,7 @@ Ext.define('Traccar.view.edit.GroupsController', { 'Traccar.view.dialog.Group', 'Traccar.view.permissions.GroupGeofences', 'Traccar.view.permissions.GroupAttributes', + 'Traccar.view.permissions.GroupDrivers', 'Traccar.view.BaseWindow', 'Traccar.model.Group' ], @@ -65,10 +66,28 @@ Ext.define('Traccar.view.edit.GroupsController', { }).show(); }, + onDriversClick: function () { + var admin, group; + admin = Traccar.app.getUser().get('admin'); + group = this.getView().getSelectionModel().getSelection()[0]; + Ext.create('Traccar.view.BaseWindow', { + title: Strings.sharedDrivers, + items: { + xtype: 'groupDriversView', + baseObjectName: 'groupId', + linkObjectName: 'driverId', + storeName: admin ? 'AllDrivers' : 'Drivers', + urlApi: 'api/groups/drivers', + baseObject: group.getId() + } + }).show(); + }, + onSelectionChange: function (selected) { var disabled = selected.length > 0; this.lookupReference('toolbarGeofencesButton').setDisabled(disabled); this.lookupReference('toolbarAttributesButton').setDisabled(disabled); + this.lookupReference('toolbarDriversButton').setDisabled(disabled); this.callParent(arguments); } }); diff --git a/web/app/view/edit/Users.js b/web/app/view/edit/Users.js index 0aafb3dd..5c1c8efe 100644 --- a/web/app/view/edit/Users.js +++ b/web/app/view/edit/Users.js @@ -82,6 +82,13 @@ Ext.define('Traccar.view.edit.Users', { glyph: 'xf0ae@FontAwesome', tooltip: Strings.sharedComputedAttributes, tooltipType: 'title' + }, { + disabled: true, + handler: 'onDriversClick', + reference: 'userDriversButton', + glyph: 'xf2c2@FontAwesome', + tooltip: Strings.sharedDrivers, + tooltipType: 'title' }] }, diff --git a/web/app/view/edit/UsersController.js b/web/app/view/edit/UsersController.js index a6f150be..1fa17dfe 100644 --- a/web/app/view/edit/UsersController.js +++ b/web/app/view/edit/UsersController.js @@ -28,6 +28,7 @@ Ext.define('Traccar.view.edit.UsersController', { 'Traccar.view.permissions.UserCalendars', 'Traccar.view.permissions.UserUsers', 'Traccar.view.permissions.UserAttributes', + 'Traccar.view.permissions.UserDrivers', 'Traccar.view.Notifications', 'Traccar.view.BaseWindow', 'Traccar.model.User' @@ -172,6 +173,22 @@ Ext.define('Traccar.view.edit.UsersController', { }).show(); }, + onDriversClick: function () { + var user = this.getView().getSelectionModel().getSelection()[0]; + Ext.create('Traccar.view.BaseWindow', { + title: Strings.sharedDrivers, + items: { + xtype: 'userDriversView', + baseObjectName: 'userId', + linkObjectName: 'driverId', + storeName: 'AllDrivers', + linkStoreName: 'Drivers', + urlApi: 'api/permissions/drivers', + baseObject: user.getId() + } + }).show(); + }, + onSelectionChange: function (selection, selected) { var disabled = selected.length === 0; @@ -181,6 +198,7 @@ Ext.define('Traccar.view.edit.UsersController', { this.lookupReference('userNotificationsButton').setDisabled(disabled); this.lookupReference('userCalendarsButton').setDisabled(disabled); this.lookupReference('userAttributesButton').setDisabled(disabled); + this.lookupReference('userDriversButton').setDisabled(disabled); this.lookupReference('userUsersButton').setDisabled(disabled || selected[0].get('userLimit') === 0); this.callParent(arguments); } diff --git a/web/app/view/permissions/DeviceDrivers.js b/web/app/view/permissions/DeviceDrivers.js new file mode 100644 index 00000000..d3aa20b6 --- /dev/null +++ b/web/app/view/permissions/DeviceDrivers.js @@ -0,0 +1,44 @@ +/* + * 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.view.permissions.DeviceDrivers', { + extend: 'Traccar.view.permissions.Base', + xtype: 'deviceDriversView', + + requires: [ + 'Ext.grid.filters.Filters' + ], + + plugins: 'gridfilters', + + columns: { + items: [{ + text: Strings.sharedName, + dataIndex: 'name', + flex: 1, + minWidth: Traccar.Style.columnWidthNormal, + filter: 'string' + }, { + text: Strings.deviceIdentifier, + dataIndex: 'uniqueId', + flex: 1, + minWidth: Traccar.Style.columnWidthNormal, + filter: 'string' + }] + } +}); diff --git a/web/app/view/permissions/GroupDrivers.js b/web/app/view/permissions/GroupDrivers.js new file mode 100644 index 00000000..61aa10ad --- /dev/null +++ b/web/app/view/permissions/GroupDrivers.js @@ -0,0 +1,44 @@ +/* + * 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.view.permissions.GroupDrivers', { + extend: 'Traccar.view.permissions.Base', + xtype: 'groupDriversView', + + requires: [ + 'Ext.grid.filters.Filters' + ], + + plugins: 'gridfilters', + + columns: { + items: [{ + text: Strings.sharedName, + dataIndex: 'name', + flex: 1, + minWidth: Traccar.Style.columnWidthNormal, + filter: 'string' + }, { + text: Strings.deviceIdentifier, + dataIndex: 'uniqueId', + flex: 1, + minWidth: Traccar.Style.columnWidthNormal, + filter: 'string' + }] + } +}); diff --git a/web/app/view/permissions/UserDrivers.js b/web/app/view/permissions/UserDrivers.js new file mode 100644 index 00000000..8f88ddd8 --- /dev/null +++ b/web/app/view/permissions/UserDrivers.js @@ -0,0 +1,44 @@ +/* + * 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.view.permissions.UserDrivers', { + extend: 'Traccar.view.permissions.Base', + xtype: 'userDriversView', + + requires: [ + 'Ext.grid.filters.Filters' + ], + + plugins: 'gridfilters', + + columns: { + items: [{ + text: Strings.sharedName, + dataIndex: 'name', + flex: 1, + minWidth: Traccar.Style.columnWidthNormal, + filter: 'string' + }, { + text: Strings.deviceIdentifier, + dataIndex: 'uniqueId', + flex: 1, + minWidth: Traccar.Style.columnWidthNormal, + filter: 'string' + }] + } +}); -- 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') 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') { diff --git a/web/app/model/Event.js b/web/app/model/Event.js index 70fab178..da866b4c 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 d243a8ae..107008eb 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 0a6572dd..44bfa92f 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 e048c063..b478ae98 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 e9ac17fa..823066d6 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 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') 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 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') diff --git a/web/app/model/Event.js b/web/app/model/Event.js index da866b4c..9455b0dd 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 44bfa92f..c3d6d180 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 404b26f7..ba34d066 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