diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2018-11-04 14:38:49 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2018-11-04 14:38:49 +1300 |
commit | c3f8353377eedecab9f3b973645e613c9ff2c80a (patch) | |
tree | f76a0c6f45457e4b3e14f150d3d51e61e8d599e9 /web/app | |
parent | 46e9aa513032822ccfa6989d33c837dccc0f5299 (diff) | |
download | etbsa-traccar-web-c3f8353377eedecab9f3b973645e613c9ff2c80a.tar.gz etbsa-traccar-web-c3f8353377eedecab9f3b973645e613c9ff2c80a.tar.bz2 etbsa-traccar-web-c3f8353377eedecab9f3b973645e613c9ff2c80a.zip |
Alarm types filtering option
Diffstat (limited to 'web/app')
-rw-r--r-- | web/app/Application.js | 1 | ||||
-rw-r--r-- | web/app/store/AlarmTypes.js | 34 | ||||
-rw-r--r-- | web/app/view/dialog/Notification.js | 21 | ||||
-rw-r--r-- | web/app/view/dialog/NotificationController.js | 26 | ||||
-rw-r--r-- | web/app/view/edit/Notifications.js | 17 |
5 files changed, 97 insertions, 2 deletions
diff --git a/web/app/Application.js b/web/app/Application.js index 9b71880..91bdc58 100644 --- a/web/app/Application.js +++ b/web/app/Application.js @@ -52,6 +52,7 @@ Ext.define('Traccar.Application', { 'Devices', 'AllGroups', 'AllDevices', + 'AlarmTypes', 'Positions', 'LatestPositions', 'EventPositions', diff --git a/web/app/store/AlarmTypes.js b/web/app/store/AlarmTypes.js new file mode 100644 index 0000000..9520359 --- /dev/null +++ b/web/app/store/AlarmTypes.js @@ -0,0 +1,34 @@ +/* + * 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.AlarmTypes', { + extend: 'Ext.data.Store', + fields: ['key', 'name'], + + data: function () { + var items = []; + for (key in Strings) { + if (Strings.hasOwnProperty(key) && key.lastIndexOf('alarm', 0) === 0) { + items.push({ + key: key.charAt(5).toLowerCase() + key.slice(6), + name: Strings[key] + }); + } + } + return items; + }() +}); diff --git a/web/app/view/dialog/Notification.js b/web/app/view/dialog/Notification.js index dc4362d..51af5b8 100644 --- a/web/app/view/dialog/Notification.js +++ b/web/app/view/dialog/Notification.js @@ -41,7 +41,10 @@ Ext.define('Traccar.view.dialog.Notification', { displayField: 'name', valueField: 'type', editable: false, - allowBlank: false + allowBlank: false, + listeners: { + change: 'onTypeChange' + } }, { xtype: 'checkboxfield', inputValue: true, @@ -49,8 +52,22 @@ Ext.define('Traccar.view.dialog.Notification', { name: 'always', fieldLabel: Strings.notificationAlways }, { - fieldLabel: Strings.notificationNotificators, xtype: 'tagfield', + reference: 'alarmsField', + fieldLabel: Strings.sharedAlarms, + maxWidth: Traccar.Style.formFieldWidth, + store: 'AlarmTypes', + valueField: 'key', + displayField: 'name', + queryMode: 'local', + hidden: true, + listeners: { + beforerender: 'onAlarmsLoad', + change: 'onAlarmsChange' + } + }, { + xtype: 'tagfield', + fieldLabel: Strings.notificationNotificators, name: 'notificators', maxWidth: Traccar.Style.formFieldWidth, store: 'AllNotificators', diff --git a/web/app/view/dialog/NotificationController.js b/web/app/view/dialog/NotificationController.js index ad65c33..5da669a 100644 --- a/web/app/view/dialog/NotificationController.js +++ b/web/app/view/dialog/NotificationController.js @@ -23,5 +23,31 @@ Ext.define('Traccar.view.dialog.NotificationController', { init: function () { this.lookupReference('calendarCombo').setHidden( Traccar.app.getBooleanAttributePreference('ui.disableCalendars')); + }, + + onTypeChange: function (view, value) { + this.lookupReference('alarmsField').setHidden(value !== 'alarm'); + }, + + onAlarmsLoad: function (view) { + var attributes, record = view.up('form').getRecord(); + attributes = record.get('attributes') || {}; + if (attributes['alarms']) { + view.suspendEvents(false); + view.setValue(attributes['alarms'].split(',')); + view.resumeEvents(); + } + }, + + onAlarmsChange: function (view, value) { + var attributes, record = view.up('window').down('form').getRecord(); + attributes = record.get('attributes') || {}; + + value = value.join(); + if (attributes['alarms'] !== value) { + attributes['alarms'] = value; + record.set('attributes', attributes); + record.dirty = true; + } } }); diff --git a/web/app/view/edit/Notifications.js b/web/app/view/edit/Notifications.js index 9e24d3d..7983c4d 100644 --- a/web/app/view/edit/Notifications.js +++ b/web/app/view/edit/Notifications.js @@ -60,6 +60,23 @@ Ext.define('Traccar.view.edit.Notifications', { renderer: Traccar.AttributeFormatter.getFormatter('always'), filter: 'boolean' }, { + text: Strings.sharedAlarms, + dataIndex: 'attributes', + renderer: function (value) { + var i, key, result = '', alarms = value && value['alarms']; + if (alarms) { + alarms = alarms.split(','); + for (i = 0; i < alarms.length; i++) { + var key = 'alarm' + alarms[i].charAt(0).toUpperCase() + alarms[i].slice(1); + if (result) { + result += ', '; + } + result += Strings[key] || key; + } + } + return result; + } + }, { text: Strings.notificationNotificators, dataIndex: 'notificators', flex: 2, |