aboutsummaryrefslogtreecommitdiff
path: root/web
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
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')
-rw-r--r--web/app/Application.js7
-rw-r--r--web/app/controller/Root.js2
-rw-r--r--web/app/model/Notification.js33
-rw-r--r--web/app/model/User.js2
-rw-r--r--web/app/store/AllNotifications.js30
-rw-r--r--web/app/store/Notifications.js25
-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
-rw-r--r--web/l10n/en.json8
13 files changed, 278 insertions, 5 deletions
diff --git a/web/app/Application.js b/web/app/Application.js
index dbbc7a594..5911579b8 100644
--- a/web/app/Application.js
+++ b/web/app/Application.js
@@ -32,7 +32,8 @@ Ext.define('Traccar.Application', {
'Attribute',
'Command',
'Event',
- 'Geofence'
+ 'Geofence',
+ 'Notification'
],
stores: [
@@ -52,7 +53,9 @@ Ext.define('Traccar.Application', {
'Languages',
'Events',
'Geofences',
- 'AllGeofences'
+ 'AllGeofences',
+ 'Notifications',
+ 'AllNotifications'
],
controllers: [
diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js
index da3e3a2a9..ba23b90bf 100644
--- a/web/app/controller/Root.js
+++ b/web/app/controller/Root.js
@@ -144,7 +144,7 @@ Ext.define('Traccar.controller.Root', {
break;
}
}
- text = Strings.eventCommandResult + text;
+ text = Strings.eventCommandResult + ": " + text;
} else {
typeKey = 'event' + array[i].type.charAt(0).toUpperCase() + array[i].type.slice(1);
text = Strings[typeKey];
diff --git a/web/app/model/Notification.js b/web/app/model/Notification.js
new file mode 100644
index 000000000..9b4d61eb4
--- /dev/null
+++ b/web/app/model/Notification.js
@@ -0,0 +1,33 @@
+/*
+ * 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.model.Notification', {
+ extend: 'Ext.data.Model',
+ identifier: 'negative',
+
+ fields: [{
+ name: 'id',
+ type: 'int'
+ }, {
+ name: 'type',
+ type: 'string'
+ }, {
+ name: 'userId',
+ type: 'int'
+ }, {
+ name: 'attributes'
+ }]
+});
diff --git a/web/app/model/User.js b/web/app/model/User.js
index 35b849187..352acc651 100644
--- a/web/app/model/User.js
+++ b/web/app/model/User.js
@@ -54,6 +54,8 @@ Ext.define('Traccar.model.User', {
}, {
name: 'twelveHourFormat',
type: 'boolean'
+ }, {
+ name: 'attributes'
}],
proxy: {
diff --git a/web/app/store/AllNotifications.js b/web/app/store/AllNotifications.js
new file mode 100644
index 000000000..fed02b260
--- /dev/null
+++ b/web/app/store/AllNotifications.js
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2015 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.store.AllNotifications', {
+ extend: 'Ext.data.Store',
+ model: 'Traccar.model.Notification',
+
+ proxy: {
+ type: 'rest',
+ url: '/api/users/notifications',
+ extraParams: {
+ all: true
+ }
+ },
+ sortOnLoad: true,
+ sorters: { property: 'type', direction : 'ASC' }
+});
diff --git a/web/app/store/Notifications.js b/web/app/store/Notifications.js
new file mode 100644
index 000000000..5dc8cb614
--- /dev/null
+++ b/web/app/store/Notifications.js
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2015 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.store.Notifications', {
+ extend: 'Ext.data.Store',
+ model: 'Traccar.model.Notification',
+
+ proxy: {
+ type: 'rest',
+ url: '/api/users/notifications'
+ }
+});
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);
}
});
diff --git a/web/l10n/en.json b/web/l10n/en.json
index 8ac09caf2..351ad462d 100644
--- a/web/l10n/en.json
+++ b/web/l10n/en.json
@@ -19,6 +19,7 @@
"sharedSearch": "Search",
"sharedGeofence": "Geofence",
"sharedGeofences": "Geofences",
+ "sharedNotifications": "Notifications",
"errorTitle": "Error",
"errorUnknown": "Unknown error",
"errorConnection": "Connection error",
@@ -106,7 +107,10 @@
"eventDeviceMoving": "Device is moving",
"eventDeviceStopped": "Device is stopped",
"eventDeviceOverspeed": "Device exceeds the speed",
- "eventCommandResult": "Command result: ",
+ "eventCommandResult": "Command result",
"eventGeofenceEnter": "Device has entered geofence",
- "eventGeofenceExit": "Device has exited geofence"
+ "eventGeofenceExit": "Device has exited geofence",
+ "notificationType": "Type of Notification",
+ "notificationWeb": "Send via Web",
+ "notificationMail": "Send via Mail"
} \ No newline at end of file