aboutsummaryrefslogtreecommitdiff
path: root/web/app/view
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2016-06-26 00:51:33 +0500
committerAbyss777 <abyss@fox5.ru>2016-06-26 00:51:33 +0500
commita25e7bd56c128fb2a1c673abf735b3e64706f9a8 (patch)
treea99d2cde526f97082d7bc95531772b6835064fcd /web/app/view
parent67f46c80d3b5e34440a2644f52b81dddfbaba5fa (diff)
downloadtrackermap-server-a25e7bd56c128fb2a1c673abf735b3e64706f9a8.tar.gz
trackermap-server-a25e7bd56c128fb2a1c673abf735b3e64706f9a8.tar.bz2
trackermap-server-a25e7bd56c128fb2a1c673abf735b3e64706f9a8.zip
Added notifications via email
Added notifications settings
Diffstat (limited to 'web/app/view')
-rw-r--r--web/app/view/Notifications.js58
-rw-r--r--web/app/view/NotificationsController.js83
-rw-r--r--web/app/view/SettingsMenu.js3
-rw-r--r--web/app/view/SettingsMenuController.js13
-rw-r--r--web/app/view/Users.js5
-rw-r--r--web/app/view/UsersController.js14
6 files changed, 176 insertions, 0 deletions
diff --git a/web/app/view/Notifications.js b/web/app/view/Notifications.js
new file mode 100644
index 000000000..8efebd038
--- /dev/null
+++ b/web/app/view/Notifications.js
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2016 Anton Tananaev (anton.tananaev@gmail.com)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+Ext.define('Traccar.view.Notifications', {
+ extend: 'Ext.grid.Panel',
+ xtype: 'notificationsView',
+
+ requires: [
+ 'Traccar.view.NotificationsController'
+ ],
+
+ controller: 'notificationsController',
+ store: 'AllNotifications',
+
+ selModel: {
+ selType: 'cellmodel',
+ },
+
+ columns: [{
+ text: Strings.notificationType,
+ dataIndex: 'type',
+ flex: 1,
+ renderer: function (value) {
+ var typeKey = 'event' + value.charAt(0).toUpperCase() + value.slice(1);
+ return Strings[typeKey];
+ }
+ }, {
+ text: Strings.notificationWeb,
+ dataIndex: 'web',
+ xtype: 'checkcolumn',
+ flex: 1,
+ listeners: {
+ checkChange: 'onCheckChange'
+ }
+ }, {
+ text: Strings.notificationMail,
+ dataIndex: 'mail',
+ xtype: 'checkcolumn',
+ flex: 1,
+ listeners: {
+ checkChange: 'onCheckChange'
+ }
+ }],
+
+});
diff --git a/web/app/view/NotificationsController.js b/web/app/view/NotificationsController.js
new file mode 100644
index 000000000..7a609ef19
--- /dev/null
+++ b/web/app/view/NotificationsController.js
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2016 Anton Tananaev (anton.tananaev@gmail.com)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+Ext.define('Traccar.view.NotificationsController', {
+ extend: 'Ext.app.ViewController',
+ alias: 'controller.notificationsController',
+
+ init: function () {
+ this.userId = this.getView().user.getData().id;
+ this.getView().getStore().load({
+ scope: this,
+ callback: function (records, operation, success) {
+ var notificationsStore = Ext.create('Traccar.store.Notifications');
+ notificationsStore.load({
+ params: {
+ userId: this.userId
+ },
+ scope: this,
+ callback: function (records, operation, success) {
+ var i, index, attributes, storeRecord;
+ if (success) {
+ for (i = 0; i < records.length; i++) {
+ index = this.getView().getStore().find('type', records[i].getData().type);
+ attributes = records[i].getData().attributes;
+ storeRecord = this.getView().getStore().getAt(index);
+ if (typeof attributes.web != 'undefined') {
+ storeRecord.set('web', attributes.web);
+ }
+ if (typeof attributes.mail != 'undefined') {
+ storeRecord.set('mail', attributes.mail);
+ }
+
+ storeRecord.commit();
+ }
+ }
+ }
+ });
+ }
+ });
+ },
+
+ onCheckChange: function (column, rowIndex, checked, eOpts) {
+ var record = this.getView().getStore().getAt(rowIndex);
+ var web, mail;
+ var data = {
+ userId: this.userId,
+ type: record.getData().type,
+ attributes: {}
+ };
+ web = record.getData().web;
+ if (typeof web != 'undefined' && web) {
+ data.attributes.web = "true";
+ }
+ mail = record.getData().mail;
+ if (typeof mail != 'undefined' && mail) {
+ data.attributes.mail = "true";
+ }
+ Ext.Ajax.request({
+ scope: this,
+ url: '/api/users/notifications',
+ jsonData: data,
+ callback: function (options, success, response) {
+ if (!success) {
+ Traccar.app.showError(response);
+ }
+ }
+ });
+
+ }
+});
diff --git a/web/app/view/SettingsMenu.js b/web/app/view/SettingsMenu.js
index 704884928..70041bd63 100644
--- a/web/app/view/SettingsMenu.js
+++ b/web/app/view/SettingsMenu.js
@@ -48,6 +48,9 @@ Ext.define('Traccar.view.SettingsMenu', {
handler: 'onUsersClick',
reference: 'settingsUsersButton'
}, {
+ text: Strings.sharedNotifications,
+ handler: 'onNotificationsClick',
+ }, {
text: Strings.loginLogout,
handler: 'onLogoutClick'
}]
diff --git a/web/app/view/SettingsMenuController.js b/web/app/view/SettingsMenuController.js
index 48ae60aa5..45b159ccb 100644
--- a/web/app/view/SettingsMenuController.js
+++ b/web/app/view/SettingsMenuController.js
@@ -25,6 +25,7 @@ Ext.define('Traccar.view.SettingsMenuController', {
'Traccar.view.Users',
'Traccar.view.Groups',
'Traccar.view.Geofences',
+ 'Traccar.view.Notifications',
'Traccar.view.BaseWindow'
],
@@ -77,6 +78,18 @@ Ext.define('Traccar.view.SettingsMenuController', {
}).show();
},
+ onNotificationsClick: function () {
+ var user = Traccar.app.getUser();
+ Ext.create('Traccar.view.BaseWindow', {
+ title: Strings.sharedNotifications,
+ modal: false,
+ items: {
+ xtype: 'notificationsView',
+ user: user
+ }
+ }).show();
+ },
+
onLogoutClick: function () {
Ext.create('Traccar.view.LoginController').logout();
}
diff --git a/web/app/view/Users.js b/web/app/view/Users.js
index b6301b38b..4abfff1ef 100644
--- a/web/app/view/Users.js
+++ b/web/app/view/Users.js
@@ -45,6 +45,11 @@ Ext.define('Traccar.view.Users', {
disabled: true,
handler: 'onGeofencesClick',
reference: 'userGeofencesButton'
+ }, {
+ text: Strings.sharedNotifications,
+ disabled: true,
+ handler: 'onNotificationsClick',
+ reference: 'userNotificationsButton'
}]
},
diff --git a/web/app/view/UsersController.js b/web/app/view/UsersController.js
index acba66b4d..e745ee04c 100644
--- a/web/app/view/UsersController.js
+++ b/web/app/view/UsersController.js
@@ -23,6 +23,7 @@ Ext.define('Traccar.view.UsersController', {
'Traccar.view.UserDevices',
'Traccar.view.UserGroups',
'Traccar.view.UserGeofences',
+ 'Traccar.view.Notifications',
'Traccar.view.BaseWindow'
],
@@ -114,6 +115,18 @@ Ext.define('Traccar.view.UsersController', {
}).show();
},
+ onNotificationsClick: function () {
+ var user = this.getView().getSelectionModel().getSelection()[0];
+ Ext.create('Traccar.view.BaseWindow', {
+ title: Strings.sharedNotifications,
+ modal: false,
+ items: {
+ xtype: 'notificationsView',
+ user: user
+ }
+ }).show();
+ },
+
onSelectionChange: function (selected) {
var disabled = selected.length > 0;
this.lookupReference('toolbarEditButton').setDisabled(disabled);
@@ -121,5 +134,6 @@ Ext.define('Traccar.view.UsersController', {
this.lookupReference('userDevicesButton').setDisabled(disabled);
this.lookupReference('userGroupsButton').setDisabled(disabled);
this.lookupReference('userGeofencesButton').setDisabled(disabled);
+ this.lookupReference('userNotificationsButton').setDisabled(disabled);
}
});