aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2018-06-26 12:00:15 +0500
committerAbyss777 <abyss@fox5.ru>2018-06-26 13:55:11 +0500
commit17157262fef1c046d116b2270f4e1d335fe9da1b (patch)
tree751583dde65b666e4ab249b26010b7bec6f279b6
parentd67213556dcc87453c0ad5cd6f9e8851c477a2f3 (diff)
downloadetbsa-traccar-web-17157262fef1c046d116b2270f4e1d335fe9da1b.tar.gz
etbsa-traccar-web-17157262fef1c046d116b2270f4e1d335fe9da1b.tar.bz2
etbsa-traccar-web-17157262fef1c046d116b2270f4e1d335fe9da1b.zip
Implement refactored notifications
-rw-r--r--web/app/Application.js8
-rw-r--r--web/app/AttributeFormatter.js11
-rw-r--r--web/app/controller/Root.js3
-rw-r--r--web/app/model/KnownNotificator.js32
-rw-r--r--web/app/model/Notification.js10
-rw-r--r--web/app/store/AllNotificators.js32
-rw-r--r--web/app/view/ArrayListFilter.js9
-rw-r--r--web/app/view/dialog/Notification.js25
-rw-r--r--web/app/view/edit/Notifications.js33
-rw-r--r--web/app/view/permissions/Notifications.js39
-rw-r--r--web/l10n/en.json1
11 files changed, 141 insertions, 62 deletions
diff --git a/web/app/Application.js b/web/app/Application.js
index cef03d5..fe92039 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 b228624..c279382 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 312fc15..0edc049 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 0000000..7855a12
--- /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 6ccaeca..fc9d84d 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 0000000..96aeaed
--- /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 b6c1512..e8d1c13 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 4cba519..dc4362d 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 3620682..9e24d3d 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 e21d277..a8570fe 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 65ee9e4..fbb7f01 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",