aboutsummaryrefslogtreecommitdiff
path: root/web/app/controller/Root.js
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-06-03 10:57:09 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2016-06-03 10:57:09 +1200
commit9ecabbef669cbd1a91490f4872d4c220b54e37a4 (patch)
tree7d2afe2b865dc5f9f10faa5ce7d213a219afa82a /web/app/controller/Root.js
parent06a746b44dae69b0c84a5302f92a1bcbe2dc827f (diff)
parent0271fa29703f24df24756c117209b9b04e127fc3 (diff)
downloadtrackermap-server-9ecabbef669cbd1a91490f4872d4c220b54e37a4.tar.gz
trackermap-server-9ecabbef669cbd1a91490f4872d4c220b54e37a4.tar.bz2
trackermap-server-9ecabbef669cbd1a91490f4872d4c220b54e37a4.zip
Merge pull request #1992 from Abyss777/master
Show events in web interface with toasts
Diffstat (limited to 'web/app/controller/Root.js')
-rw-r--r--web/app/controller/Root.js31
1 files changed, 29 insertions, 2 deletions
diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js
index bb65e0048..991a2572c 100644
--- a/web/app/controller/Root.js
+++ b/web/app/controller/Root.js
@@ -94,7 +94,7 @@ Ext.define('Traccar.controller.Root', {
};
socket.onmessage = function (event) {
- var i, store, data, array, entity;
+ var i, j, store, data, array, entity, device, typeKey, text;
data = Ext.decode(event.data);
@@ -114,7 +114,7 @@ Ext.define('Traccar.controller.Root', {
}
}
- if (data.positions) {
+ if (data.positions && !data.events) {
array = data.positions;
store = Ext.getStore('LatestPositions');
for (i = 0; i < array.length; i++) {
@@ -126,6 +126,33 @@ Ext.define('Traccar.controller.Root', {
}
}
}
+
+ if (data.events) {
+ array = data.events;
+ store = Ext.getStore('Events');
+ for (i = 0; i < array.length; i++) {
+ store.add(array[i]);
+ if (array[i].type === 'commandResult' && data.positions) {
+ for (j = 0; j < data.positions.length; j++) {
+ if (data.positions[j].id == array[i].positionId) {
+ text = data.positions[j].attributes.result;
+ break;
+ }
+ }
+ text = Strings.eventCommandResult + text;
+ } else {
+ typeKey = 'event' + array[i].type.charAt(0).toUpperCase() + array[i].type.slice(1);
+ text = Strings[typeKey];
+ if (typeof text == "undefined") {
+ text = typeKey;
+ }
+ }
+ device = Ext.getStore('Devices').getById(array[i].deviceId);
+ if (typeof device != "undefined") {
+ Ext.toast(text, device.getData().name);
+ }
+ }
+ }
};
}
});