aboutsummaryrefslogtreecommitdiff
path: root/web/app/controller/Root.js
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-07-25 16:20:15 +1200
committerGitHub <noreply@github.com>2016-07-25 16:20:15 +1200
commit4a31e34ca62d4b1941d3bc329afc127ef7263f34 (patch)
tree09b9ad0420a4819a350bcdcffeeee2342c5d2483 /web/app/controller/Root.js
parent866c3073ef48a24d86834a391a4d3d91209a6eed (diff)
parentb4841fa0a6293c0b895cf6bb65c6c2d871c78397 (diff)
downloadtrackermap-server-4a31e34ca62d4b1941d3bc329afc127ef7263f34.tar.gz
trackermap-server-4a31e34ca62d4b1941d3bc329afc127ef7263f34.tar.bz2
trackermap-server-4a31e34ca62d4b1941d3bc329afc127ef7263f34.zip
Merge pull request #2104 from ninioe/master
Added support for Alarm notifications & positions history cleaner & show alarms in report & Mute button & unlock UI files (for windows)
Diffstat (limited to 'web/app/controller/Root.js')
-rw-r--r--web/app/controller/Root.js44
1 files changed, 40 insertions, 4 deletions
diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js
index 98ded9c47..7070c48b0 100644
--- a/web/app/controller/Root.js
+++ b/web/app/controller/Root.js
@@ -81,7 +81,10 @@ Ext.define('Traccar.controller.Root', {
this.asyncUpdate(true);
}
});
- Ext.get('attribution').remove();
+ var attribution = Ext.get('attribution');
+ if (attribution) {
+ attribution.remove();
+ }
if (this.isPhone) {
Ext.create('widget.mainMobile');
} else {
@@ -89,6 +92,18 @@ Ext.define('Traccar.controller.Root', {
}
},
+ beep: function () {
+ if (!this.beepSound) {
+ this.beepSound = new Audio('beep.wav');
+ }
+ this.beepSound.play();
+ },
+
+ mutePressed: function () {
+ var muteButton = Ext.getCmp('nuteButton');
+ return muteButton && !muteButton.pressed;
+ },
+
asyncUpdate: function (first) {
var protocol, socket, self = this;
protocol = location.protocol === 'https:' ? 'wss:' : 'ws:';
@@ -99,7 +114,7 @@ Ext.define('Traccar.controller.Root', {
};
socket.onmessage = function (event) {
- var i, j, store, data, array, entity, device, typeKey, text, geofence;
+ var i, j, store, data, array, entity, device, typeKey, alarmKey, text, geofence;
data = Ext.decode(event.data);
@@ -145,10 +160,28 @@ Ext.define('Traccar.controller.Root', {
}
}
text = Strings.eventCommandResult + ': ' + text;
+ } else if (array[i].type === 'alarm' && data.positions) {
+ alarmKey = 'alarm';
+ text = Strings[alarmKey];
+ if (!text) {
+ text = alarmKey;
+ }
+ for (j = 0; j < data.positions.length; j++) {
+ if (data.positions[j].id === array[i].positionId && data.positions[j].attributes.alarm !== null) {
+ if (typeof data.positions[j].attributes.alarm === 'string' && data.positions[j].attributes.alarm.length >= 2) {
+ alarmKey = 'alarm' + data.positions[j].attributes.alarm.charAt(0).toUpperCase() + data.positions[j].attributes.alarm.slice(1);
+ text = Strings[alarmKey];
+ if (!text) {
+ text = alarmKey;
+ }
+ }
+ break;
+ }
+ }
} else {
typeKey = 'event' + array[i].type.charAt(0).toUpperCase() + array[i].type.slice(1);
text = Strings[typeKey];
- if (typeof text === 'undefined') {
+ if (!text) {
text = typeKey;
}
}
@@ -160,7 +193,10 @@ Ext.define('Traccar.controller.Root', {
}
device = Ext.getStore('Devices').getById(array[i].deviceId);
if (typeof device !== 'undefined') {
- Ext.toast(text, device.getData().name);
+ if (self.mutePressed()) {
+ self.beep();
+ }
+ Ext.toast(text, device.get('name'));
}
}
}