aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/org/traccar/http/WebServer.java2
-rw-r--r--web/app/LoginManager.js24
-rw-r--r--web/app/controller/Root.js7
-rw-r--r--web/app/view/login/Login.js3
-rw-r--r--web/app/view/login/LoginController.js6
5 files changed, 40 insertions, 2 deletions
diff --git a/src/org/traccar/http/WebServer.java b/src/org/traccar/http/WebServer.java
index c6dd6e04d..477e54c3c 100644
--- a/src/org/traccar/http/WebServer.java
+++ b/src/org/traccar/http/WebServer.java
@@ -52,7 +52,7 @@ public class WebServer {
ServletContextHandler servletHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
servletHandler.setContextPath("/api");
servletHandler.addServlet(new ServletHolder(new AsyncServlet()), "/async/*");
- servletHandler.addServlet(new ServletHolder(new DeviceServlet()), "/server/*");
+ servletHandler.addServlet(new ServletHolder(new ServerServlet()), "/server/*");
servletHandler.addServlet(new ServletHolder(new DeviceServlet()), "/device/*");
servletHandler.addServlet(new ServletHolder(new PositionServlet()), "/position/*");
servletHandler.addServlet(new ServletHolder(new MainServlet()), "/*");
diff --git a/web/app/LoginManager.js b/web/app/LoginManager.js
index 914b7d6a9..93b3e913c 100644
--- a/web/app/LoginManager.js
+++ b/web/app/LoginManager.js
@@ -25,6 +25,30 @@ Ext.define('Traccar.LoginManager', {
reader.readRecords(data).getRecords()[0]);
},
+ server: function(options) {
+ Ext.Ajax.request({
+ scope: this,
+ url: '/api/server/get',
+ callback: this.onServerReturn,
+ original: options
+ });
+ },
+
+ onServerReturn: function(options, success, response) {
+ options = options.original;
+ if (Traccar.ErrorManager.check(success, response)) {
+ var result = Ext.decode(response.responseText);
+ if (result.success) {
+ var reader = Ext.create('Ext.data.reader.Json', {
+ model: 'Traccar.model.Server'
+ });
+ Traccar.getApplication().setServer(
+ reader.readRecords(result.data).getRecords()[0]);
+ }
+ Ext.callback(options.callback, options.scope, [result.success]);
+ }
+ },
+
session: function(options) {
Ext.Ajax.request({
scope: this,
diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js
index f999cf462..10deb69c8 100644
--- a/web/app/controller/Root.js
+++ b/web/app/controller/Root.js
@@ -24,6 +24,13 @@ Ext.define('Traccar.controller.Root', {
],
onLaunch: function () {
+ Traccar.LoginManager.server({
+ scope: this,
+ callback: 'onServer'
+ });
+ },
+
+ onServer: function() {
Traccar.LoginManager.session({
scope: this,
callback: 'onSession'
diff --git a/web/app/view/login/Login.js b/web/app/view/login/Login.js
index c56557186..6cfaa4645 100644
--- a/web/app/view/login/Login.js
+++ b/web/app/view/login/Login.js
@@ -58,7 +58,8 @@ Ext.define('Traccar.view.login.Login', {
buttons: [{
text: strings.login_register,
- handler: 'onRegisterClick'
+ handler: 'onRegisterClick',
+ reference: 'registerButton'
}, {
text: strings.login_login,
handler: 'onLoginClick'
diff --git a/web/app/view/login/LoginController.js b/web/app/view/login/LoginController.js
index c22b0e09a..e94d0de9d 100644
--- a/web/app/view/login/LoginController.js
+++ b/web/app/view/login/LoginController.js
@@ -22,6 +22,12 @@ Ext.define('Traccar.view.login.LoginController', {
'Traccar.view.login.Register'
],
+ init: function() {
+ this.lookupReference('registerButton').setDisabled(
+ !Traccar.getApplication().getServer().get('registration')
+ );
+ },
+
onAfterRender: function(field) {
field.focus();
},