diff options
Diffstat (limited to 'web')
-rw-r--r-- | web/app/Application.js | 8 | ||||
-rw-r--r-- | web/app/AttributeFormatter.js | 11 | ||||
-rw-r--r-- | web/app/controller/Root.js | 3 | ||||
-rw-r--r-- | web/app/model/KnownNotificator.js | 32 | ||||
-rw-r--r-- | web/app/model/Notification.js | 10 | ||||
-rw-r--r-- | web/app/store/AllNotificators.js | 32 | ||||
-rw-r--r-- | web/app/view/ArrayListFilter.js | 9 | ||||
-rw-r--r-- | web/app/view/dialog/Notification.js | 25 | ||||
-rw-r--r-- | web/app/view/edit/Notifications.js | 33 | ||||
-rw-r--r-- | web/app/view/permissions/Notifications.js | 39 | ||||
-rw-r--r-- | web/l10n/en.json | 1 |
11 files changed, 141 insertions, 62 deletions
diff --git a/web/app/Application.js b/web/app/Application.js index cef03d51..fe920395 100644 --- a/web/app/Application.js +++ b/web/app/Application.js @@ -108,7 +108,8 @@ Ext.define('Traccar.Application', { 'Maintenances', 'AllMaintenances', 'MaintenanceTypes', - 'HoursUnits' + 'HoursUnits', + 'AllNotificators' ], controllers: [ @@ -128,6 +129,11 @@ Ext.define('Traccar.Application', { return Strings[key] || key; }, + getNotificatorString: function (eventType) { + var key = 'notification' + eventType.charAt(0).toUpperCase() + eventType.slice(1); + return Strings[key] || key; + }, + showReports: function (show) { var rootPanel = Ext.getCmp('rootPanel'); if (rootPanel) { diff --git a/web/app/AttributeFormatter.js b/web/app/AttributeFormatter.js index b2286249..c2793827 100644 --- a/web/app/AttributeFormatter.js +++ b/web/app/AttributeFormatter.js @@ -73,7 +73,16 @@ Ext.define('Traccar.AttributeFormatter', { }, deviceIdFormatter: function (value) { - return Ext.getStore('Devices').getById(value).get('name'); + var device, store; + if (value !== 0) { + store = Ext.getStore('AllDevices'); + if (store.getTotalCount() === 0) { + store = Ext.getStore('Devices'); + } + device = store.getById(value); + return device ? device.get('name') : ''; + } + return null; }, groupIdFormatter: function (value) { diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js index 312fc157..0edc049a 100644 --- a/web/app/controller/Root.js +++ b/web/app/controller/Root.js @@ -129,6 +129,7 @@ Ext.define('Traccar.controller.Root', { } } }); + Ext.getStore('AllNotificators').load(); Ext.getStore('Notifications').load(); Ext.getStore('ServerAttributes').loadData(Ext.getStore('CommonDeviceAttributes').getData().items, true); @@ -289,6 +290,8 @@ Ext.define('Traccar.controller.Root', { this.beep(); } Traccar.app.showToast(array[i].text, device.get('name')); + } else { + Traccar.app.showToast(array[i].text); } } }, diff --git a/web/app/model/KnownNotificator.js b/web/app/model/KnownNotificator.js new file mode 100644 index 00000000..7855a12b --- /dev/null +++ b/web/app/model/KnownNotificator.js @@ -0,0 +1,32 @@ +/* + * Copyright 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2018 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.KnownNotificator', { + extend: 'Ext.data.Model', + idProperty: 'type', + + fields: [{ + name: 'type', + type: 'string' + }, { + name: 'name', + convert: function (v, rec) { + return Traccar.app.getNotificatorString(rec.get('type')); + }, + depends: ['type'] + }] +}); diff --git a/web/app/model/Notification.js b/web/app/model/Notification.js index 6ccaecaf..fc9d84d7 100644 --- a/web/app/model/Notification.js +++ b/web/app/model/Notification.js @@ -31,14 +31,8 @@ Ext.define('Traccar.model.Notification', { }, { name: 'attributes' }, { - name: 'web', - type: 'bool' - }, { - name: 'mail', - type: 'bool' - }, { - name: 'sms', - type: 'bool' + name: 'notificators', + type: 'string' }, { name: 'calendarId', type: 'int' diff --git a/web/app/store/AllNotificators.js b/web/app/store/AllNotificators.js new file mode 100644 index 00000000..96aeaedc --- /dev/null +++ b/web/app/store/AllNotificators.js @@ -0,0 +1,32 @@ +/* + * Copyright 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2018 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.AllNotificators', { + extend: 'Ext.data.Store', + model: 'Traccar.model.KnownNotificator', + + proxy: { + type: 'rest', + url: 'api/notifications/notificators', + listeners: { + 'exception': function (proxy, response) { + Traccar.app.showError(response); + } + } + } +}); diff --git a/web/app/view/ArrayListFilter.js b/web/app/view/ArrayListFilter.js index b6c1512f..e8d1c130 100644 --- a/web/app/view/ArrayListFilter.js +++ b/web/app/view/ArrayListFilter.js @@ -25,7 +25,7 @@ Ext.define('Traccar.view.ArrayListFilter', { constructor: function (config) { this.callParent([config]); this.filter.setFilterFn(function (item) { - var i, property, value; + var i, property, value, splits; property = item.get(this.getProperty()); value = this.getValue(); if (Ext.isArray(property)) { @@ -34,6 +34,13 @@ Ext.define('Traccar.view.ArrayListFilter', { return true; } } + } else if (property.indexOf(',') !== -1) { + splits = property.split(/[ ,]+/).filter(Boolean); + for (i = 0; i < splits.length; i++) { + if (value.indexOf(splits[i]) !== -1) { + return true; + } + } } else if (value.indexOf(property) !== -1) { return true; } diff --git a/web/app/view/dialog/Notification.js b/web/app/view/dialog/Notification.js index 4cba519c..dc4362d9 100644 --- a/web/app/view/dialog/Notification.js +++ b/web/app/view/dialog/Notification.js @@ -49,23 +49,14 @@ Ext.define('Traccar.view.dialog.Notification', { 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 + fieldLabel: Strings.notificationNotificators, + xtype: 'tagfield', + name: 'notificators', + maxWidth: Traccar.Style.formFieldWidth, + store: 'AllNotificators', + valueField: 'type', + displayField: 'name', + queryMode: 'local' }] }, { xtype: 'fieldset', diff --git a/web/app/view/edit/Notifications.js b/web/app/view/edit/Notifications.js index 36206825..9e24d3d0 100644 --- a/web/app/view/edit/Notifications.js +++ b/web/app/view/edit/Notifications.js @@ -60,20 +60,25 @@ Ext.define('Traccar.view.edit.Notifications', { 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' + text: Strings.notificationNotificators, + dataIndex: 'notificators', + flex: 2, + filter: { + type: 'arraylist', + idField: 'type', + labelField: 'name', + store: 'AllNotificators' + }, + renderer: function (value) { + var result = '', i, notificators; + if (value) { + notificators = value.split(/[ ,]+/).filter(Boolean); + for (i = 0; i < notificators.length; i++) { + result += Traccar.app.getNotificatorString(notificators[i]) + (i < notificators.length - 1 ? ', ' : ''); + } + } + return result; + } }, { text: Strings.sharedCalendar, dataIndex: 'calendarId', diff --git a/web/app/view/permissions/Notifications.js b/web/app/view/permissions/Notifications.js index e21d277f..a8570fea 100644 --- a/web/app/view/permissions/Notifications.js +++ b/web/app/view/permissions/Notifications.js @@ -42,26 +42,25 @@ Ext.define('Traccar.view.permissions.Notifications', { 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' + text: Strings.notificationNotificators, + dataIndex: 'notificators', + flex: 2, + filter: { + type: 'arraylist', + idField: 'type', + labelField: 'name', + store: 'AllNotificators' + }, + renderer: function (value) { + var result = '', i, notificators; + if (value) { + notificators = value.split(/[ ,]+/).filter(Boolean); + for (i = 0; i < notificators.length; i++) { + result += Traccar.app.getNotificatorString(notificators[i]) + (i < notificators.length - 1 ? ', ' : ''); + } + } + return result; + } }, { text: Strings.sharedCalendar, dataIndex: 'calendarId', diff --git a/web/l10n/en.json b/web/l10n/en.json index 65ee9e4f..fbb7f019 100644 --- a/web/l10n/en.json +++ b/web/l10n/en.json @@ -359,6 +359,7 @@ "notificationWeb": "Send via Web", "notificationMail": "Send via Mail", "notificationSms": "Send via SMS", + "notificationNotificators": "Way of Notification", "reportRoute": "Route", "reportEvents": "Events", "reportTrips": "Trips", |