aboutsummaryrefslogtreecommitdiff
path: root/web/app/controller/Root.js
diff options
context:
space:
mode:
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);
+ }
+ }
+ }
};
}
});