diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-12-02 11:07:11 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-12-02 11:07:11 +1300 |
commit | 831a7b81004c0456c317ef4c521cbebd4cbf5fc2 (patch) | |
tree | 28c4d7a4ccb95f7b5fb9d947505b6ed717505583 /web/app/controller | |
parent | eadf492fe75fcfb0da617c9bc66bddd03139c96e (diff) | |
download | traccar-server-831a7b81004c0456c317ef4c521cbebd4cbf5fc2.tar.gz traccar-server-831a7b81004c0456c317ef4c521cbebd4cbf5fc2.tar.bz2 traccar-server-831a7b81004c0456c317ef4c521cbebd4cbf5fc2.zip |
Start web app migration to REST API
Diffstat (limited to 'web/app/controller')
-rw-r--r-- | web/app/controller/Root.js | 48 |
1 files changed, 21 insertions, 27 deletions
diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js index 733055cdf..de20a8f2b 100644 --- a/web/app/controller/Root.js +++ b/web/app/controller/Root.js @@ -33,43 +33,37 @@ Ext.define('Traccar.controller.Root', { onLaunch: function () { Ext.Ajax.request({ scope: this, - url: '/api/server/get', + url: '/rest/server', callback: this.onServerReturn }); }, onServerReturn: function (options, success, response) { - var result; Ext.get('spinner').remove(); - if (Traccar.ErrorManager.check(success, response)) { - result = Ext.decode(response.responseText); - if (result.success) { - Traccar.app.setServer(result.data); - Ext.Ajax.request({ - scope: this, - url: '/api/session', - callback: this.onSessionReturn - }); - } + if (success) { + Traccar.app.setServer(Ext.decode(response.responseText)); + Ext.Ajax.request({ + scope: this, + url: '/rest/session', + callback: this.onSessionReturn + }); + } else { + Traccar.app.showError(response); } }, onSessionReturn: function (options, success, response) { - var result; - if (Traccar.ErrorManager.check(success, response)) { - result = Ext.decode(response.responseText); - if (result.success) { - Traccar.app.setUser(result.data); - this.loadApp(); - } else { - this.login = Ext.create('widget.login', { - listeners: { - scope: this, - login: this.onLogin - } - }); - this.login.show(); - } + if (success) { + Traccar.app.setUser(Ext.decode(response.responseText)); + this.loadApp(); + } else { + this.login = Ext.create('widget.login', { + listeners: { + scope: this, + login: this.onLogin + } + }); + this.login.show(); } }, |