aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2017-09-19 09:36:16 +0500
committerAbyss777 <abyss@fox5.ru>2017-09-19 16:38:28 +0500
commit3a5e334b50bf35d11743d937c9fae2fb8c7829ec (patch)
treef66c5d8ddcbe861b045e20d0390e8987ac329d7b
parentd078ef703795ed9c1fb0b6111ee7d12e09143f82 (diff)
downloadetbsa-traccar-web-3a5e334b50bf35d11743d937c9fae2fb8c7829ec.tar.gz
etbsa-traccar-web-3a5e334b50bf35d11743d937c9fae2fb8c7829ec.tar.bz2
etbsa-traccar-web-3a5e334b50bf35d11743d937c9fae2fb8c7829ec.zip
Implement Notifications per device
-rw-r--r--web/app/Application.js6
-rw-r--r--web/app/controller/Root.js37
-rw-r--r--web/app/model/KnownNotification.js32
-rw-r--r--web/app/model/Notification.js6
-rw-r--r--web/app/store/AllNotificationTypes.js32
-rw-r--r--web/app/store/AllNotifications.js7
-rw-r--r--web/app/store/Notifications.js10
-rw-r--r--web/app/view/DeviceMenu.js61
-rw-r--r--web/app/view/DeviceMenuController.js104
-rw-r--r--web/app/view/NotificationsController.js43
-rw-r--r--web/app/view/SettingsMenuController.js6
-rw-r--r--web/app/view/dialog/Notification.js66
-rw-r--r--web/app/view/dialog/SendCommand.js6
-rw-r--r--web/app/view/dialog/SendCommandController.js17
-rw-r--r--web/app/view/edit/Devices.js23
-rw-r--r--web/app/view/edit/DevicesController.js59
-rw-r--r--web/app/view/edit/Groups.js8
-rw-r--r--web/app/view/edit/GroupsController.js17
-rw-r--r--web/app/view/edit/Notifications.js (renamed from web/app/view/Notifications.js)50
-rw-r--r--web/app/view/edit/NotificationsController.js32
-rw-r--r--web/app/view/edit/SavedCommands.js1
-rw-r--r--web/app/view/edit/Users.js4
-rw-r--r--web/app/view/edit/UsersController.js10
-rw-r--r--web/app/view/permissions/Notifications.js73
-rw-r--r--web/l10n/en.json1
25 files changed, 508 insertions, 203 deletions
diff --git a/web/app/Application.js b/web/app/Application.js
index d2ce3c8..ed9a4b6 100644
--- a/web/app/Application.js
+++ b/web/app/Application.js
@@ -41,7 +41,8 @@ Ext.define('Traccar.Application', {
'Calendar',
'KnownAttribute',
'Driver',
- 'KnownCommand'
+ 'KnownCommand',
+ 'KnownNotification'
],
stores: [
@@ -100,7 +101,8 @@ Ext.define('Traccar.Application', {
'AllCommandTypes',
'Commands',
'AllCommands',
- 'DeviceCommands'
+ 'DeviceCommands',
+ 'AllNotificationTypes'
],
controllers: [
diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js
index 64227aa..75c4531 100644
--- a/web/app/controller/Root.js
+++ b/web/app/controller/Root.js
@@ -113,7 +113,19 @@ Ext.define('Traccar.controller.Root', {
Ext.getStore('ComputedAttributes').load();
Ext.getStore('AllCommandTypes').load();
Ext.getStore('Commands').load();
- this.initReportEventTypesStore();
+ Ext.getStore('AllNotificationTypes').load({
+ callback: function (records, operation, success) {
+ var store = Ext.getStore('ReportEventTypes');
+ if (success) {
+ store.add({
+ type: Traccar.store.ReportEventTypes.allEvents,
+ name: Strings.eventAll
+ });
+ store.loadData(records, true);
+ }
+ }
+ });
+ Ext.getStore('Notifications').load();
Ext.getStore('ServerAttributes').loadData(Ext.getStore('CommonDeviceAttributes').getData().items, true);
Ext.getStore('ServerAttributes').loadData(Ext.getStore('CommonUserAttributes').getData().items, true);
@@ -285,28 +297,5 @@ Ext.define('Traccar.controller.Root', {
if (lat === 0 && lon === 0 && zoom === 0) {
this.fireEvent('zoomtoalldevices');
}
- },
-
- initReportEventTypesStore: function () {
- var store = Ext.getStore('ReportEventTypes');
- store.add({
- type: Traccar.store.ReportEventTypes.allEvents,
- name: Strings.eventAll
- });
- Ext.create('Traccar.store.AllNotifications').load({
- scope: this,
- callback: function (records, operation, success) {
- var i, value;
- if (success) {
- for (i = 0; i < records.length; i++) {
- value = records[i].get('type');
- store.add({
- type: value,
- name: Traccar.app.getEventString(value)
- });
- }
- }
- }
- });
}
});
diff --git a/web/app/model/KnownNotification.js b/web/app/model/KnownNotification.js
new file mode 100644
index 0000000..f42ef97
--- /dev/null
+++ b/web/app/model/KnownNotification.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.model.KnownNotification', {
+ extend: 'Ext.data.Model',
+ idProperty: 'type',
+
+ fields: [{
+ name: 'type',
+ type: 'string'
+ }, {
+ name: 'name',
+ convert: function (v, rec) {
+ return Traccar.app.getEventString(rec.get('type'));
+ },
+ depends: ['type']
+ }]
+});
diff --git a/web/app/model/Notification.js b/web/app/model/Notification.js
index 3ae13c0..0d479f4 100644
--- a/web/app/model/Notification.js
+++ b/web/app/model/Notification.js
@@ -17,7 +17,7 @@
Ext.define('Traccar.model.Notification', {
extend: 'Ext.data.Model',
- idProperty: 'type',
+ identifier: 'negative',
fields: [{
name: 'id',
@@ -26,8 +26,8 @@ Ext.define('Traccar.model.Notification', {
name: 'type',
type: 'string'
}, {
- name: 'userId',
- type: 'int'
+ name: 'always',
+ type: 'bool'
}, {
name: 'attributes'
}, {
diff --git a/web/app/store/AllNotificationTypes.js b/web/app/store/AllNotificationTypes.js
new file mode 100644
index 0000000..ded5ef9
--- /dev/null
+++ b/web/app/store/AllNotificationTypes.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.store.AllNotificationTypes', {
+ extend: 'Ext.data.Store',
+ model: 'Traccar.model.KnownNotification',
+
+ proxy: {
+ type: 'rest',
+ url: 'api/notifications/types',
+ listeners: {
+ 'exception': function (proxy, response) {
+ Traccar.app.showError(response);
+ }
+ }
+ }
+});
diff --git a/web/app/store/AllNotifications.js b/web/app/store/AllNotifications.js
index 61aa75a..a3e59e1 100644
--- a/web/app/store/AllNotifications.js
+++ b/web/app/store/AllNotifications.js
@@ -21,14 +21,9 @@ Ext.define('Traccar.store.AllNotifications', {
proxy: {
type: 'rest',
- url: 'api/users/notifications',
+ url: 'api/notifications',
extraParams: {
all: true
}
- },
- sortOnLoad: true,
- sorters: {
- property: 'type',
- direction: 'ASC'
}
});
diff --git a/web/app/store/Notifications.js b/web/app/store/Notifications.js
index a672fd4..b30505f 100644
--- a/web/app/store/Notifications.js
+++ b/web/app/store/Notifications.js
@@ -21,11 +21,9 @@ Ext.define('Traccar.store.Notifications', {
proxy: {
type: 'rest',
- url: 'api/users/notifications'
- },
- sortOnLoad: true,
- sorters: {
- property: 'type',
- direction: 'ASC'
+ url: 'api/notifications',
+ writer: {
+ writeAllFields: true
+ }
}
});
diff --git a/web/app/view/DeviceMenu.js b/web/app/view/DeviceMenu.js
new file mode 100644
index 0000000..236d5f4
--- /dev/null
+++ b/web/app/view/DeviceMenu.js
@@ -0,0 +1,61 @@
+/*
+ * 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.DeviceMenu', {
+ extend: 'Ext.button.Button',
+ xtype: 'deviceMenu',
+
+ requires: [
+ 'Traccar.view.DeviceMenuController'
+ ],
+
+ glyph: 'xf013@FontAwesome',
+ tooltip: Strings.settingsTitle,
+ tooltipType: 'title',
+
+ menu: {
+ controller: 'deviceMenu',
+
+ items: [{
+ text: Strings.sharedDrivers,
+ glyph: 'xf2c2@FontAwesome',
+ handler: 'onDriversClick',
+ reference: 'menuDriversButton'
+ }, {
+ text: Strings.sharedGeofences,
+ glyph: 'xf21d@FontAwesome',
+ handler: 'onGeofencesClick',
+ reference: 'menuGeofencesButton'
+ }, {
+ text: Strings.sharedNotifications,
+ glyph: 'xf003@FontAwesome',
+ handler: 'onNotificationsClick',
+ reference: 'menuNotificationsButton'
+ }, {
+ text: Strings.sharedComputedAttributes,
+ glyph: 'xf0ae@FontAwesome',
+ handler: 'onComputedAttributesClick',
+ reference: 'menuComputedAttributesButton'
+ }, {
+ text: Strings.sharedSavedCommands,
+ glyph: 'xf093@FontAwesome',
+ handler: 'onCommandsClick',
+ reference: 'menuCommandsButton'
+ }]
+ }
+});
diff --git a/web/app/view/DeviceMenuController.js b/web/app/view/DeviceMenuController.js
new file mode 100644
index 0000000..58749a5
--- /dev/null
+++ b/web/app/view/DeviceMenuController.js
@@ -0,0 +1,104 @@
+/*
+ * 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.DeviceMenuController', {
+ extend: 'Ext.app.ViewController',
+ alias: 'controller.deviceMenu',
+
+ requires: [
+ 'Traccar.view.permissions.Geofences',
+ 'Traccar.view.permissions.Drivers',
+ 'Traccar.view.permissions.Notifications',
+ 'Traccar.view.edit.ComputedAttributes',
+ 'Traccar.view.permissions.SavedCommands',
+ 'Traccar.view.BaseWindow'
+ ],
+
+ init: function () {
+ this.lookupReference('menuDriversButton').setHidden(
+ Traccar.app.getVehicleFeaturesDisabled() || Traccar.app.getBooleanAttributePreference('ui.disableDrivers'));
+ this.lookupReference('menuComputedAttributesButton').setHidden(
+ Traccar.app.getBooleanAttributePreference('ui.disableComputedAttributes'));
+ this.lookupReference('menuCommandsButton').setHidden(Traccar.app.getPreference('limitCommands', false));
+ },
+
+ onGeofencesClick: function () {
+ Ext.create('Traccar.view.BaseWindow', {
+ title: Strings.sharedGeofences,
+ items: {
+ xtype: 'linkGeofencesView',
+ baseObjectName: 'deviceId',
+ linkObjectName: 'geofenceId',
+ storeName: 'Geofences',
+ baseObject: this.getView().ownerCmp.device.getId()
+ }
+ }).show();
+ },
+
+ onNotificationsClick: function () {
+ Ext.create('Traccar.view.BaseWindow', {
+ title: Strings.sharedNotifications,
+ items: {
+ xtype: 'linkNotificationsView',
+ baseObjectName: 'deviceId',
+ linkObjectName: 'notificationId',
+ storeName: 'Notifications',
+ baseObject: this.getView().ownerCmp.device.getId()
+ }
+ }).show();
+ },
+
+ onComputedAttributesClick: function () {
+ Ext.create('Traccar.view.BaseWindow', {
+ title: Strings.sharedComputedAttributes,
+ items: {
+ xtype: 'linkComputedAttributesView',
+ baseObjectName: 'deviceId',
+ linkObjectName: 'attributeId',
+ storeName: 'ComputedAttributes',
+ baseObject: this.getView().ownerCmp.device.getId()
+ }
+ }).show();
+ },
+
+ onDriversClick: function () {
+ Ext.create('Traccar.view.BaseWindow', {
+ title: Strings.sharedDrivers,
+ items: {
+ xtype: 'linkDriversView',
+ baseObjectName: 'deviceId',
+ linkObjectName: 'driverId',
+ storeName: 'Drivers',
+ baseObject: this.getView().ownerCmp.device.getId()
+ }
+ }).show();
+ },
+
+ onCommandsClick: function () {
+ Ext.create('Traccar.view.BaseWindow', {
+ title: Strings.sharedSavedCommands,
+ items: {
+ xtype: 'linkSavedCommandsView',
+ baseObjectName: 'deviceId',
+ linkObjectName: 'commandId',
+ storeName: 'Commands',
+ baseObject: this.getView().ownerCmp.device.getId()
+ }
+ }).show();
+ }
+});
diff --git a/web/app/view/NotificationsController.js b/web/app/view/NotificationsController.js
deleted file mode 100644
index 651f57f..0000000
--- a/web/app/view/NotificationsController.js
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright 2016 Anton Tananaev (anton@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.NotificationsController', {
- extend: 'Ext.app.ViewController',
- alias: 'controller.notificationsController',
-
- init: function () {
- this.getView().getStore().load({
- params: {
- userId: this.getView().user.getId()
- }
- });
- },
-
- onCheckChange: function (column, rowIndex) {
- var record = this.getView().getStore().getAt(rowIndex);
- Ext.Ajax.request({
- scope: this,
- url: 'api/users/notifications',
- jsonData: record.data,
- callback: function (options, success, response) {
- if (!success) {
- Traccar.app.showError(response);
- }
- }
- });
- }
-});
diff --git a/web/app/view/SettingsMenuController.js b/web/app/view/SettingsMenuController.js
index caa57a6..2ebb858 100644
--- a/web/app/view/SettingsMenuController.js
+++ b/web/app/view/SettingsMenuController.js
@@ -27,7 +27,7 @@ Ext.define('Traccar.view.SettingsMenuController', {
'Traccar.view.edit.Groups',
'Traccar.view.edit.Geofences',
'Traccar.view.edit.Drivers',
- 'Traccar.view.Notifications',
+ 'Traccar.view.edit.Notifications',
'Traccar.view.edit.ComputedAttributes',
'Traccar.view.Statistics',
'Traccar.view.dialog.DeviceDistance',
@@ -110,12 +110,10 @@ Ext.define('Traccar.view.SettingsMenuController', {
},
onNotificationsClick: function () {
- var user = Traccar.app.getUser();
Ext.create('Traccar.view.BaseWindow', {
title: Strings.sharedNotifications,
items: {
- xtype: 'notificationsView',
- user: user
+ xtype: 'notificationsView'
}
}).show();
},
diff --git a/web/app/view/dialog/Notification.js b/web/app/view/dialog/Notification.js
new file mode 100644
index 0000000..7e7fe45
--- /dev/null
+++ b/web/app/view/dialog/Notification.js
@@ -0,0 +1,66 @@
+/*
+ * 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.Notification', {
+ extend: 'Traccar.view.dialog.BaseEdit',
+
+ title: Strings.sharedNotification,
+
+ items: {
+ xtype: 'form',
+ items: [{
+ xtype: 'fieldset',
+ title: Strings.sharedRequired,
+ items: [{
+ xtype: 'combobox',
+ name: 'type',
+ fieldLabel: Strings.sharedType,
+ store: 'AllNotificationTypes',
+ queryMode: 'local',
+ displayField: 'name',
+ valueField: 'type',
+ editable: false,
+ allowBlank: false
+ }, {
+ xtype: 'checkboxfield',
+ inputValue: true,
+ uncheckedValue: false,
+ name: 'always',
+ fieldLabel: Strings.notificationAlways
+ }, {
+ xtype: 'checkboxfield',
+ inputValue: true,
+ uncheckedValue: false,
+ name: 'web',
+ fieldLabel: Strings.notificationWeb
+ }, {
+ xtype: 'checkboxfield',
+ inputValue: true,
+ uncheckedValue: false,
+ name: 'mail',
+ fieldLabel: Strings.notificationMail
+ }, {
+ xtype: 'checkboxfield',
+ inputValue: true,
+ uncheckedValue: false,
+ name: 'sms',
+ fieldLabel: Strings.notificationSms
+ }]
+ }]
+ }
+});
diff --git a/web/app/view/dialog/SendCommand.js b/web/app/view/dialog/SendCommand.js
index f4224be..9e07cbf 100644
--- a/web/app/view/dialog/SendCommand.js
+++ b/web/app/view/dialog/SendCommand.js
@@ -79,12 +79,6 @@ Ext.define('Traccar.view.dialog.SendCommand', {
}],
buttons: [{
- glyph: 'xf093@FontAwesome',
- text: Strings.sharedSavedCommands,
- reference: 'linkButton',
- handler: 'onLinkCommands',
- hidden: true
- }, {
xtype: 'tbfill'
}, {
glyph: 'xf093@FontAwesome',
diff --git a/web/app/view/dialog/SendCommandController.js b/web/app/view/dialog/SendCommandController.js
index 0e9442a..567be94 100644
--- a/web/app/view/dialog/SendCommandController.js
+++ b/web/app/view/dialog/SendCommandController.js
@@ -24,10 +24,6 @@ Ext.define('Traccar.view.dialog.SendCommandController', {
'Traccar.view.permissions.SavedCommands'
],
- init: function () {
- this.lookupReference('linkButton').setHidden(Traccar.app.getPreference('limitCommands', false));
- },
-
onSendClick: function (button) {
var record;
this.fillAttributes(button);
@@ -67,19 +63,6 @@ Ext.define('Traccar.view.dialog.SendCommandController', {
this.lookupReference('sendButton').setDisabled(command.getId() === 0);
},
- onLinkCommands: function () {
- Ext.create('Traccar.view.BaseWindow', {
- title: Strings.sharedSavedCommands,
- items: {
- xtype: 'linkSavedCommandsView',
- baseObjectName: 'deviceId',
- linkObjectName: 'commandId',
- storeName: 'Commands',
- baseObject: this.getView().deviceId
- }
- }).show();
- },
-
onSendResult: function (options, success, response) {
if (success) {
this.closeView();
diff --git a/web/app/view/edit/Devices.js b/web/app/view/edit/Devices.js
index 5ec452b..d2ba0f3 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 915f724..40202e7 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];
+ this.lookupReference('toolbarDeviceMenu').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/Groups.js b/web/app/view/edit/Groups.js
index 05c5723..691df8a 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 872fea4..a4ced61 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/Notifications.js b/web/app/view/edit/Notifications.js
index 8e02204..8bbdb71 100644
--- a/web/app/view/Notifications.js
+++ b/web/app/view/edit/Notifications.js
@@ -1,5 +1,6 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * 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
@@ -15,23 +16,27 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-Ext.define('Traccar.view.Notifications', {
+Ext.define('Traccar.view.edit.Notifications', {
extend: 'Ext.grid.Panel',
xtype: 'notificationsView',
requires: [
- 'Traccar.view.NotificationsController'
+ 'Ext.grid.filters.Filters',
+ 'Traccar.view.edit.NotificationsController',
+ 'Traccar.view.edit.Toolbar'
],
- controller: 'notificationsController',
+ plugins: 'gridfilters',
+
+ controller: 'notifications',
store: 'Notifications',
- selModel: {
- selType: 'cellmodel'
+ tbar: {
+ xtype: 'editToolbar'
},
- viewConfig: {
- markDirty: false
+ listeners: {
+ selectionchange: 'onSelectionChange'
},
columns: {
@@ -45,28 +50,33 @@ Ext.define('Traccar.view.Notifications', {
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',
- xtype: 'checkcolumn',
- listeners: {
- checkChange: 'onCheckChange'
- }
+ renderer: Traccar.AttributeFormatter.getFormatter('web'),
+ filter: 'boolean'
}, {
text: Strings.notificationMail,
dataIndex: 'mail',
- xtype: 'checkcolumn',
- listeners: {
- checkChange: 'onCheckChange'
- }
+ renderer: Traccar.AttributeFormatter.getFormatter('mail'),
+ filter: 'boolean'
}, {
text: Strings.notificationSms,
dataIndex: 'sms',
- xtype: 'checkcolumn',
- listeners: {
- checkChange: 'onCheckChange'
- }
+ 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 0000000..bf6a666
--- /dev/null
+++ b/web/app/view/edit/NotificationsController.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.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 869fbf9..b0cf89d 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/Users.js b/web/app/view/edit/Users.js
index c77ba49..d98d49c 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 f710ed2..db82b4f 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();
},
diff --git a/web/app/view/permissions/Notifications.js b/web/app/view/permissions/Notifications.js
new file mode 100644
index 0000000..6538e67
--- /dev/null
+++ b/web/app/view/permissions/Notifications.js
@@ -0,0 +1,73 @@
+/*
+ * 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.permissions.Notifications', {
+ extend: 'Traccar.view.permissions.Base',
+ xtype: 'linkNotificationsView',
+
+ requires: [
+ 'Ext.grid.filters.Filters'
+ ],
+
+ plugins: 'gridfilters',
+
+ columns: {
+ 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',
+ flex: 1,
+ minWidth: Traccar.Style.columnWidthNormal,
+ renderer: Traccar.AttributeFormatter.getFormatter('always'),
+ filter: 'boolean'
+ }, {
+ text: Strings.notificationWeb,
+ dataIndex: 'web',
+ flex: 1,
+ minWidth: Traccar.Style.columnWidthNormal,
+ renderer: Traccar.AttributeFormatter.getFormatter('web'),
+ filter: 'boolean'
+ }, {
+ text: Strings.notificationMail,
+ dataIndex: 'mail',
+ flex: 1,
+ minWidth: Traccar.Style.columnWidthNormal,
+ renderer: Traccar.AttributeFormatter.getFormatter('mail'),
+ filter: 'boolean'
+ }, {
+ text: Strings.notificationSms,
+ dataIndex: 'sms',
+ flex: 1,
+ minWidth: Traccar.Style.columnWidthNormal,
+ renderer: Traccar.AttributeFormatter.getFormatter('sms'),
+ filter: 'boolean'
+ }]
+ }
+});
diff --git a/web/l10n/en.json b/web/l10n/en.json
index aeb20dd..156f3ec 100644
--- a/web/l10n/en.json
+++ b/web/l10n/en.json
@@ -340,6 +340,7 @@
"alarmTampering": "Tampering Alarm",
"alarmRemoving": "Removing Alarm",
"notificationType": "Type of Notification",
+ "notificationAlways": "Send Always",
"notificationWeb": "Send via Web",
"notificationMail": "Send via Mail",
"notificationSms": "Send via SMS",