aboutsummaryrefslogtreecommitdiff
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
parentc64a77edfdcd6ed4e7cb61bef5e3f2762a607da7 (diff)
downloadtrackermap-server-dcfe1d48998c3fb3baa704fafed43d996f329a07.tar.gz
trackermap-server-dcfe1d48998c3fb3baa704fafed43d996f329a07.tar.bz2
trackermap-server-dcfe1d48998c3fb3baa704fafed43d996f329a07.zip
Get rid of login manager class
-rw-r--r--web/app/LoginManager.js65
-rw-r--r--web/app/controller/Root.js51
-rw-r--r--web/app/view/Login.js1
-rw-r--r--web/app/view/LoginController.js2
4 files changed, 34 insertions, 85 deletions
diff --git a/web/app/LoginManager.js b/web/app/LoginManager.js
deleted file mode 100644
index c18d6cb44..000000000
--- a/web/app/LoginManager.js
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-(function () {
- 'use strict';
-
- Ext.define('Traccar.LoginManager', {
- singleton: true,
-
- server: function (options) {
- Ext.Ajax.request({
- scope: this,
- url: '/api/server/get',
- callback: this.onServerReturn,
- original: options
- });
- },
-
- onServerReturn: function (options, success, response) {
- var result;
- options = options.original;
- if (Traccar.ErrorManager.check(success, response)) {
- result = Ext.decode(response.responseText);
- if (result.success) {
- Traccar.app.setServer(result.data);
- }
- Ext.callback(options.callback, options.scope, [result.success]);
- }
- },
-
- session: function (options) {
- Ext.Ajax.request({
- scope: this,
- url: '/api/session',
- callback: this.onSessionReturn,
- original: options
- });
- },
-
- onSessionReturn: function (options, success, response) {
- var result;
- options = options.original;
- if (Traccar.ErrorManager.check(success, response)) {
- result = Ext.decode(response.responseText);
- if (result.success) {
- Traccar.app.setUser(result.data);
- }
- Ext.callback(options.callback, options.scope, [result.success]);
- }
- }
- });
-
-})();
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();
+ }
}
},
diff --git a/web/app/view/Login.js b/web/app/view/Login.js
index 7f34c51cb..6e10a6824 100644
--- a/web/app/view/Login.js
+++ b/web/app/view/Login.js
@@ -27,6 +27,7 @@
controller: 'login',
closable: false,
+ modal: false,
items: {
xtype: 'form',
diff --git a/web/app/view/LoginController.js b/web/app/view/LoginController.js
index 141905da8..baf27a751 100644
--- a/web/app/view/LoginController.js
+++ b/web/app/view/LoginController.js
@@ -102,7 +102,7 @@
},
onRegisterClick: function () {
- Ext.create('Traccar.view.login.Register').show();
+ Ext.create('Traccar.view.Register').show();
}
});