aboutsummaryrefslogtreecommitdiff
path: root/web/app/controller
diff options
context:
space:
mode:
Diffstat (limited to 'web/app/controller')
-rw-r--r--web/app/controller/Root.js51
1 files changed, 32 insertions, 19 deletions
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();
+ }
}
},