diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2017-09-20 19:37:14 +1200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-20 19:37:14 +1200 |
commit | adf79e9bc86bc485ea3fa02c4d25b11d8fffee1f (patch) | |
tree | 5879cb06e5b81dcc7570f35754ef443005200cb7 /web/app/view/edit | |
parent | d078ef703795ed9c1fb0b6111ee7d12e09143f82 (diff) | |
parent | cf1c138bca946cd354e97cea0c841af1ad0f3e4e (diff) | |
download | trackermap-web-adf79e9bc86bc485ea3fa02c4d25b11d8fffee1f.tar.gz trackermap-web-adf79e9bc86bc485ea3fa02c4d25b11d8fffee1f.tar.bz2 trackermap-web-adf79e9bc86bc485ea3fa02c4d25b11d8fffee1f.zip |
Merge pull request #588 from Abyss777/extended_notifications2
Implement Notifications per device
Diffstat (limited to 'web/app/view/edit')
-rw-r--r-- | web/app/view/edit/CalendarsController.js | 1 | ||||
-rw-r--r-- | web/app/view/edit/Devices.js | 23 | ||||
-rw-r--r-- | web/app/view/edit/DevicesController.js | 59 | ||||
-rw-r--r-- | web/app/view/edit/DriversController.js | 1 | ||||
-rw-r--r-- | web/app/view/edit/Groups.js | 8 | ||||
-rw-r--r-- | web/app/view/edit/GroupsController.js | 17 | ||||
-rw-r--r-- | web/app/view/edit/Notifications.js | 82 | ||||
-rw-r--r-- | web/app/view/edit/NotificationsController.js | 31 | ||||
-rw-r--r-- | web/app/view/edit/SavedCommands.js | 1 | ||||
-rw-r--r-- | web/app/view/edit/SavedCommandsController.js | 1 | ||||
-rw-r--r-- | web/app/view/edit/Users.js | 4 | ||||
-rw-r--r-- | web/app/view/edit/UsersController.js | 10 |
12 files changed, 163 insertions, 75 deletions
diff --git a/web/app/view/edit/CalendarsController.js b/web/app/view/edit/CalendarsController.js index f5822279..d11ec379 100644 --- a/web/app/view/edit/CalendarsController.js +++ b/web/app/view/edit/CalendarsController.js @@ -28,5 +28,4 @@ Ext.define('Traccar.view.edit.CalendarsController', { objectModel: 'Traccar.model.Calendar', objectDialog: 'Traccar.view.dialog.Calendar', removeTitle: Strings.sharedCalendar - }); diff --git a/web/app/view/edit/Devices.js b/web/app/view/edit/Devices.js index 5ec452b8..d2ba0f3d 100644 --- a/web/app/view/edit/Devices.js +++ b/web/app/view/edit/Devices.js @@ -23,7 +23,8 @@ Ext.define('Traccar.view.edit.Devices', { 'Ext.grid.filters.Filters', 'Traccar.AttributeFormatter', 'Traccar.view.edit.DevicesController', - 'Traccar.view.ArrayListFilter' + 'Traccar.view.ArrayListFilter', + 'Traccar.view.DeviceMenu' ], controller: 'devices', @@ -65,26 +66,14 @@ Ext.define('Traccar.view.edit.Devices', { glyph: 'xf00d@FontAwesome', tooltip: Strings.sharedRemove }, { - handler: 'onGeofencesClick', - reference: 'toolbarGeofencesButton', - glyph: 'xf21d@FontAwesome', - tooltip: Strings.sharedGeofences - }, { - handler: 'onAttributesClick', - reference: 'toolbarAttributesButton', - glyph: 'xf0ae@FontAwesome', - tooltip: Strings.sharedComputedAttributes - }, { - xtype: 'button', - handler: 'onDriversClick', - reference: 'toolbarDriversButton', - glyph: 'xf2c2@FontAwesome', - tooltip: Strings.sharedDrivers - }, { handler: 'onCommandClick', reference: 'deviceCommandButton', glyph: 'xf093@FontAwesome', tooltip: Strings.deviceCommand + }, { + xtype: 'deviceMenu', + reference: 'toolbarDeviceMenu', + enableToggle: false }] }, diff --git a/web/app/view/edit/DevicesController.js b/web/app/view/edit/DevicesController.js index 915f724a..a4bbd4ba 100644 --- a/web/app/view/edit/DevicesController.js +++ b/web/app/view/edit/DevicesController.js @@ -62,58 +62,13 @@ Ext.define('Traccar.view.edit.DevicesController', { deviceReadonly = Traccar.app.getPreference('deviceReadonly', false) && !Traccar.app.getUser().get('admin'); readonly = Traccar.app.getPreference('readonly', false) && !Traccar.app.getUser().get('admin'); this.lookupReference('toolbarAddButton').setDisabled(readonly || deviceReadonly); - this.lookupReference('toolbarDriversButton').setHidden( - Traccar.app.getVehicleFeaturesDisabled() || Traccar.app.getBooleanAttributePreference('ui.disableDrivers')); - this.lookupReference('toolbarAttributesButton').setHidden( - Traccar.app.getBooleanAttributePreference('ui.disableComputedAttributes')); + this.lookupReference('toolbarDeviceMenu').setHidden(readonly || deviceReadonly); setInterval(function () { self.getView().getView().refresh(); }, Traccar.Style.refreshPeriod); }, - onGeofencesClick: function () { - var device = this.getView().getSelectionModel().getSelection()[0]; - Ext.create('Traccar.view.BaseWindow', { - title: Strings.sharedGeofences, - items: { - xtype: 'linkGeofencesView', - baseObjectName: 'deviceId', - linkObjectName: 'geofenceId', - storeName: 'Geofences', - baseObject: device.getId() - } - }).show(); - }, - - onAttributesClick: function () { - var device = this.getView().getSelectionModel().getSelection()[0]; - Ext.create('Traccar.view.BaseWindow', { - title: Strings.sharedComputedAttributes, - items: { - xtype: 'linkComputedAttributesView', - baseObjectName: 'deviceId', - linkObjectName: 'attributeId', - storeName: 'ComputedAttributes', - baseObject: device.getId() - } - }).show(); - }, - - onDriversClick: function () { - var device = this.getView().getSelectionModel().getSelection()[0]; - Ext.create('Traccar.view.BaseWindow', { - title: Strings.sharedDrivers, - items: { - xtype: 'linkDriversView', - baseObjectName: 'deviceId', - linkObjectName: 'driverId', - storeName: 'Drivers', - baseObject: device.getId() - } - }).show(); - }, - onCommandClick: function () { var device, deviceId, dialog, typesStore, online, commandsStore; device = this.getView().getSelectionModel().getSelection()[0]; @@ -143,15 +98,15 @@ Ext.define('Traccar.view.edit.DevicesController', { }, updateButtons: function (selected) { - var readonly, deviceReadonly, empty; + var readonly, deviceReadonly, empty, deviceMenu; deviceReadonly = Traccar.app.getPreference('deviceReadonly', false) && !Traccar.app.getUser().get('admin'); readonly = Traccar.app.getPreference('readonly', false) && !Traccar.app.getUser().get('admin'); empty = selected.length === 0; this.lookupReference('toolbarEditButton').setDisabled(empty || readonly || deviceReadonly); 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); + deviceMenu = this.lookupReference('toolbarDeviceMenu'); + deviceMenu.device = empty ? null : selected[0]; + deviceMenu.setDisabled(empty); this.lookupReference('deviceCommandButton').setDisabled(empty || readonly); }, @@ -166,7 +121,7 @@ Ext.define('Traccar.view.edit.DevicesController', { selectDevice: function (device) { this.getView().getSelectionModel().select([device], false, true); - this.updateButtons(this.getView().getSelectionModel()); + this.updateButtons(this.getView().getSelectionModel().getSelected().items); this.getView().getView().focusRow(device); }, @@ -177,7 +132,7 @@ Ext.define('Traccar.view.edit.DevicesController', { }, onUpdateDevice: function () { - this.updateButtons(this.getView().getSelectionModel()); + this.updateButtons(this.getView().getSelectionModel().getSelected().items); }, deselectFeature: function () { diff --git a/web/app/view/edit/DriversController.js b/web/app/view/edit/DriversController.js index 2840c2a7..6c8a63cc 100644 --- a/web/app/view/edit/DriversController.js +++ b/web/app/view/edit/DriversController.js @@ -28,5 +28,4 @@ Ext.define('Traccar.view.edit.DriversController', { 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 05c5723d..691df8ae 100644 --- a/web/app/view/edit/Groups.js +++ b/web/app/view/edit/Groups.js @@ -65,6 +65,14 @@ Ext.define('Traccar.view.edit.Groups', { glyph: 'xf093@FontAwesome', tooltip: Strings.sharedSavedCommands, tooltipType: 'title' + }, { + xtype: 'button', + disabled: true, + handler: 'onNotificationsClick', + reference: 'toolbarNotificationsButton', + glyph: 'xf003@FontAwesome', + tooltip: Strings.sharedNotifications, + tooltipType: 'title' }] }, diff --git a/web/app/view/edit/GroupsController.js b/web/app/view/edit/GroupsController.js index 872fea4a..a4ced617 100644 --- a/web/app/view/edit/GroupsController.js +++ b/web/app/view/edit/GroupsController.js @@ -105,12 +105,29 @@ Ext.define('Traccar.view.edit.GroupsController', { }).show(); }, + onNotificationsClick: function () { + var admin, group; + admin = Traccar.app.getUser().get('admin'); + group = this.getView().getSelectionModel().getSelection()[0]; + Ext.create('Traccar.view.BaseWindow', { + title: Strings.sharedSavedCommands, + items: { + xtype: 'linkNotificationsView', + baseObjectName: 'groupId', + linkObjectName: 'notificationId', + storeName: admin ? 'AllNotifications' : 'Notifications', + baseObject: group.getId() + } + }).show(); + }, + onSelectionChange: function (selection, selected) { var disabled = selected.length === 0; this.lookupReference('toolbarGeofencesButton').setDisabled(disabled); this.lookupReference('toolbarAttributesButton').setDisabled(disabled); this.lookupReference('toolbarDriversButton').setDisabled(disabled); this.lookupReference('toolbarCommandsButton').setDisabled(disabled); + this.lookupReference('toolbarNotificationsButton').setDisabled(disabled); this.callParent(arguments); } }); diff --git a/web/app/view/edit/Notifications.js b/web/app/view/edit/Notifications.js new file mode 100644 index 00000000..8bbdb711 --- /dev/null +++ b/web/app/view/edit/Notifications.js @@ -0,0 +1,82 @@ +/* + * 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.edit.Notifications', { + extend: 'Ext.grid.Panel', + xtype: 'notificationsView', + + requires: [ + 'Ext.grid.filters.Filters', + 'Traccar.view.edit.NotificationsController', + 'Traccar.view.edit.Toolbar' + ], + + plugins: 'gridfilters', + + controller: 'notifications', + store: 'Notifications', + + tbar: { + xtype: 'editToolbar' + }, + + listeners: { + selectionchange: 'onSelectionChange' + }, + + columns: { + defaults: { + flex: 1, + minWidth: Traccar.Style.columnWidthNormal + }, + items: [{ + text: Strings.notificationType, + dataIndex: 'type', + flex: 2, + renderer: function (value) { + return Traccar.app.getEventString(value); + }, + filter: { + type: 'list', + idField: 'type', + labelField: 'name', + store: 'AllNotificationTypes' + } + }, { + text: Strings.notificationAlways, + dataIndex: 'always', + renderer: Traccar.AttributeFormatter.getFormatter('always'), + filter: 'boolean' + }, { + text: Strings.notificationWeb, + dataIndex: 'web', + renderer: Traccar.AttributeFormatter.getFormatter('web'), + filter: 'boolean' + }, { + text: Strings.notificationMail, + dataIndex: 'mail', + renderer: Traccar.AttributeFormatter.getFormatter('mail'), + filter: 'boolean' + }, { + text: Strings.notificationSms, + dataIndex: 'sms', + renderer: Traccar.AttributeFormatter.getFormatter('sms'), + filter: 'boolean' + }] + } +}); diff --git a/web/app/view/edit/NotificationsController.js b/web/app/view/edit/NotificationsController.js new file mode 100644 index 00000000..ad22a686 --- /dev/null +++ b/web/app/view/edit/NotificationsController.js @@ -0,0 +1,31 @@ +/* + * 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.edit.NotificationsController', { + extend: 'Traccar.view.edit.ToolbarController', + alias: 'controller.notifications', + + requires: [ + 'Traccar.view.dialog.Notification', + 'Traccar.model.Notification' + ], + + objectModel: 'Traccar.model.Notification', + objectDialog: 'Traccar.view.dialog.Notification', + removeTitle: Strings.sharedNotification +}); diff --git a/web/app/view/edit/SavedCommands.js b/web/app/view/edit/SavedCommands.js index 869fbf9a..b0cf89d0 100644 --- a/web/app/view/edit/SavedCommands.js +++ b/web/app/view/edit/SavedCommands.js @@ -61,6 +61,7 @@ Ext.define('Traccar.view.edit.SavedCommands', { }, { text: Strings.notificationSms, dataIndex: 'textChannel', + renderer: Traccar.AttributeFormatter.getFormatter('textChannel'), filter: 'boolean' }] } diff --git a/web/app/view/edit/SavedCommandsController.js b/web/app/view/edit/SavedCommandsController.js index 989aeabf..1511661e 100644 --- a/web/app/view/edit/SavedCommandsController.js +++ b/web/app/view/edit/SavedCommandsController.js @@ -28,5 +28,4 @@ Ext.define('Traccar.view.edit.SavedCommandsController', { objectModel: 'Traccar.model.Command', objectDialog: 'Traccar.view.dialog.SavedCommand', removeTitle: Strings.sharedSavedCommand - }); diff --git a/web/app/view/edit/Users.js b/web/app/view/edit/Users.js index c77ba49b..d98d49ce 100644 --- a/web/app/view/edit/Users.js +++ b/web/app/view/edit/Users.js @@ -121,20 +121,24 @@ Ext.define('Traccar.view.edit.Users', { }, { text: Strings.userAdmin, dataIndex: 'admin', + renderer: Traccar.AttributeFormatter.getFormatter('admin'), filter: 'boolean' }, { text: Strings.serverReadonly, dataIndex: 'readonly', hidden: true, + renderer: Traccar.AttributeFormatter.getFormatter('readonly'), filter: 'boolean' }, { text: Strings.userDeviceReadonly, dataIndex: 'deviceReadonly', + renderer: Traccar.AttributeFormatter.getFormatter('deviceReadonly'), hidden: true, filter: 'boolean' }, { text: Strings.userDisabled, dataIndex: 'disabled', + renderer: Traccar.AttributeFormatter.getFormatter('disabled'), filter: 'boolean' }, { text: Strings.userExpirationTime, diff --git a/web/app/view/edit/UsersController.js b/web/app/view/edit/UsersController.js index f710ed24..db82b4f4 100644 --- a/web/app/view/edit/UsersController.js +++ b/web/app/view/edit/UsersController.js @@ -30,7 +30,7 @@ Ext.define('Traccar.view.edit.UsersController', { 'Traccar.view.permissions.ComputedAttributes', 'Traccar.view.permissions.Drivers', 'Traccar.view.permissions.SavedCommands', - 'Traccar.view.Notifications', + 'Traccar.view.permissions.Notifications', 'Traccar.view.BaseWindow', 'Traccar.model.User' ], @@ -125,8 +125,12 @@ Ext.define('Traccar.view.edit.UsersController', { Ext.create('Traccar.view.BaseWindow', { title: Strings.sharedNotifications, items: { - xtype: 'notificationsView', - user: user + xtype: 'linkNotificationsView', + baseObjectName: 'userId', + linkObjectName: 'notificationId', + storeName: 'AllNotifications', + linkStoreName: 'Notifications', + baseObject: user.getId() } }).show(); }, |