aboutsummaryrefslogtreecommitdiff
path: root/web/app/controller
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2016-06-02 12:45:22 +0500
committerAbyss777 <abyss@fox5.ru>2016-06-02 12:45:22 +0500
commitd9e57775e5bb10e722d0043186308df05eea3296 (patch)
tree599b6836f717aec30859ee281a5dd57d06667490 /web/app/controller
parentbf296b4af4714a3fe62cd6f9fcff8ac29fcd0178 (diff)
downloadtraccar-server-d9e57775e5bb10e722d0043186308df05eea3296.tar.gz
traccar-server-d9e57775e5bb10e722d0043186308df05eea3296.tar.bz2
traccar-server-d9e57775e5bb10e722d0043186308df05eea3296.zip
Show events in toast
Diffstat (limited to 'web/app/controller')
-rw-r--r--web/app/controller/Root.js31
1 files changed, 30 insertions, 1 deletions
diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js
index bb65e0048..3e2358c8d 100644
--- a/web/app/controller/Root.js
+++ b/web/app/controller/Root.js
@@ -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,35 @@ 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]);
+ var text;
+ if (array[i].type === 'commandResult' && data.positions) {
+ var j;
+ 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 {
+ var typeKey = 'event' + array[i].type.charAt(0).toUpperCase() + array[i].type.slice(1);
+ var text = Strings[typeKey];
+ if (typeof text == "undefined") {
+ text = typeKey;
+ }
+ }
+ var device = Ext.getStore('Devices').getById(array[i].deviceId);
+ if (typeof device != "undefined") {
+ Ext.toast(text, device.getData().name);
+ }
+ }
+ }
};
}
});