aboutsummaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
Diffstat (limited to 'web')
-rw-r--r--web/app/Application.js8
-rw-r--r--web/app/controller/Root.js48
2 files changed, 29 insertions, 27 deletions
diff --git a/web/app/Application.js b/web/app/Application.js
index ebf685dbc..34d65d13a 100644
--- a/web/app/Application.js
+++ b/web/app/Application.js
@@ -78,6 +78,14 @@ Ext.define('Traccar.Application', {
return this.getUser().get(key) || this.getServer().get(key) || defaultValue;
},
+ showError: function (response) {
+ if (response.statusText) {
+ Ext.Msg.alert(Strings.errorTitle, response.statusText);
+ } else {
+ Ext.Msg.alert(Strings.errorTitle, Strings.errorConnection);
+ }
+ },
+
getErrorHandler: function (scope, handler) {
return function (options, success, response) {
var result;
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();
}
},