From 831a7b81004c0456c317ef4c521cbebd4cbf5fc2 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 2 Dec 2015 11:07:11 +1300 Subject: Start web app migration to REST API --- web/app/controller/Root.js | 48 ++++++++++++++++++++-------------------------- 1 file changed, 21 insertions(+), 27 deletions(-) (limited to 'web/app/controller') 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(); } }, -- cgit v1.2.3