aboutsummaryrefslogtreecommitdiff
path: root/web/app/controller/Root.js
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-12-18 11:27:28 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2016-12-18 11:27:28 +1300
commit545705b01818d4239710633ef9b1dacfafc61b44 (patch)
treec80abdddbc67b034dc7de81869f470aca7b8d4eb /web/app/controller/Root.js
parentdee1624d4730f2a7c91f940371798956377ff6f2 (diff)
downloadtrackermap-web-545705b01818d4239710633ef9b1dacfafc61b44.tar.gz
trackermap-web-545705b01818d4239710633ef9b1dacfafc61b44.tar.bz2
trackermap-web-545705b01818d4239710633ef9b1dacfafc61b44.zip
Fallback to REST if WebSocket not available
Diffstat (limited to 'web/app/controller/Root.js')
-rw-r--r--web/app/controller/Root.js23
1 files changed, 22 insertions, 1 deletions
diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js
index 2a20dbe3..0cc2a148 100644
--- a/web/app/controller/Root.js
+++ b/web/app/controller/Root.js
@@ -130,7 +130,28 @@ Ext.define('Traccar.controller.Root', {
socket = new WebSocket(protocol + '//' + window.location.host + pathname + 'api/socket');
socket.onclose = function (event) {
- self.asyncUpdate(false);
+ Ext.toast(Strings.errorSocket, Strings.errorTitle, 'br');
+
+ Ext.Ajax.request({
+ url: 'api/devices',
+ success: function(response) {
+ self.updateDevices(Ext.decode(response.responseText));
+ }
+ });
+
+ Ext.Ajax.request({
+ url: 'api/positions',
+ headers: {
+ Accept: 'application/json'
+ },
+ success: function(response) {
+ self.updatePositions(Ext.decode(response.responseText));
+ }
+ });
+
+ setTimeout(function() {
+ self.asyncUpdate(false);
+ }, Traccar.Style.reconnectTimeout);
};
socket.onmessage = function (event) {