aboutsummaryrefslogtreecommitdiff
path: root/web/app/view/edit
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 /web/app/view/edit
parentd078ef703795ed9c1fb0b6111ee7d12e09143f82 (diff)
downloadtrackermap-web-3a5e334b50bf35d11743d937c9fae2fb8c7829ec.tar.gz
trackermap-web-3a5e334b50bf35d11743d937c9fae2fb8c7829ec.tar.bz2
trackermap-web-3a5e334b50bf35d11743d937c9fae2fb8c7829ec.zip
Implement Notifications per device
Diffstat (limited to 'web/app/view/edit')
-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.js82
-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
9 files changed, 164 insertions, 72 deletions
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..40202e75 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 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..bf6a6669
--- /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 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/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();
},