aboutsummaryrefslogtreecommitdiff
path: root/web/app/controller/Root.js
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-10-04 17:13:52 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-10-04 17:13:52 +1300
commitdcfe1d48998c3fb3baa704fafed43d996f329a07 (patch)
tree3dc5410942d7a8dc474074405e74ee479fde7e23 /web/app/controller/Root.js
parentc64a77edfdcd6ed4e7cb61bef5e3f2762a607da7 (diff)
downloadtraccar-server-dcfe1d48998c3fb3baa704fafed43d996f329a07.tar.gz
traccar-server-dcfe1d48998c3fb3baa704fafed43d996f329a07.tar.bz2
traccar-server-dcfe1d48998c3fb3baa704fafed43d996f329a07.zip
Get rid of login manager class
Diffstat (limited to 'web/app/controller/Root.js')
-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();
+ }
}
},