From dcfe1d48998c3fb3baa704fafed43d996f329a07 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 4 Oct 2015 17:13:52 +1300 Subject: Get rid of login manager class --- web/app/controller/Root.js | 51 +++++++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 19 deletions(-) (limited to 'web/app/controller/Root.js') diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js index 3d2a82d48..bb67d4e86 100644 --- a/web/app/controller/Root.js +++ b/web/app/controller/Root.js @@ -20,7 +20,6 @@ extend: 'Ext.app.Controller', requires: [ - 'Traccar.LoginManager', 'Traccar.view.Login', 'Traccar.view.Main', 'Traccar.view.MainMobile' @@ -34,30 +33,44 @@ }, onLaunch: function () { - Traccar.LoginManager.server({ + Ext.Ajax.request({ scope: this, - callback: 'onServer' + url: '/api/server/get', + callback: this.onServerReturn }); }, - onServer: function () { - Traccar.LoginManager.session({ - scope: this, - callback: 'onSession' - }); + onServerReturn: function (options, success, response) { + var result; + 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 + }); + } + } }, - onSession: function (success) { - if (success) { - this.loadApp(); - } else { - this.login = Ext.create('widget.login', { - listeners: { - scope: this, - login: 'onLogin' - } - }); - this.login.show(); + 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(); + } } }, -- cgit v1.2.3