aboutsummaryrefslogtreecommitdiff
path: root/web/app/view
diff options
context:
space:
mode:
Diffstat (limited to 'web/app/view')
-rw-r--r--web/app/view/dialog/Notification.js21
-rw-r--r--web/app/view/dialog/NotificationController.js26
-rw-r--r--web/app/view/edit/Notifications.js17
3 files changed, 62 insertions, 2 deletions
diff --git a/web/app/view/dialog/Notification.js b/web/app/view/dialog/Notification.js
index dc4362d9..51af5b8e 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 ad65c333..5da669a4 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 9e24d3d0..7983c4db 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,