aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/org/traccar/web/WebServer.java33
-rw-r--r--web/app/controller/Root.js4
-rw-r--r--web/app/model/Server.js2
-rw-r--r--web/app/model/User.js2
-rw-r--r--web/app/store/AllDevices.js2
-rw-r--r--web/app/store/Devices.js2
-rw-r--r--web/app/store/Positions.js2
-rw-r--r--web/app/store/Users.js2
-rw-r--r--web/app/view/CommandDialogController.js2
-rw-r--r--web/app/view/LoginController.js4
-rw-r--r--web/app/view/RegisterController.js2
-rw-r--r--web/app/view/UserDevicesController.js4
12 files changed, 34 insertions, 27 deletions
diff --git a/src/org/traccar/web/WebServer.java b/src/org/traccar/web/WebServer.java
index cd01d04b4..ebcdc7137 100644
--- a/src/org/traccar/web/WebServer.java
+++ b/src/org/traccar/web/WebServer.java
@@ -71,14 +71,14 @@ public class WebServer {
initServer();
switch (config.getString("web.type", "new")) {
case "api":
- initOldApi(false);
+ initApi();
break;
case "old":
- initOldApi(false);
+ initOldApi();
initOldWebApp();
break;
default:
- initOldApi(true);
+ initApi();
if (config.getBoolean("web.console")) {
initConsole();
}
@@ -122,19 +122,26 @@ public class WebServer {
handlers.addHandler(app);
}
- private void initOldApi(boolean initRest) {
+ private void initApi() {
ServletContextHandler servletHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
servletHandler.setContextPath("/api");
- if (initRest) {
- ResourceConfig resourceConfig = new ResourceConfig();
- resourceConfig.register(ResourceErrorHandler.class);
- resourceConfig.register(SecurityRequestFilter.class);
- resourceConfig.register(CorsResponseFilter.class);
- resourceConfig.registerClasses(ServerResource.class, SessionResource.class, CommandResource.class,
- PermissionResource.class, DeviceResource.class, UserResource.class, PositionResource.class);
- servletHandler.addServlet(new ServletHolder(new ServletContainer(resourceConfig)), "/rest/*");
- }
+
servletHandler.addServlet(new ServletHolder(new AsyncSocketServlet()), "/socket");
+
+ ResourceConfig resourceConfig = new ResourceConfig();
+ resourceConfig.register(ResourceErrorHandler.class);
+ resourceConfig.register(SecurityRequestFilter.class);
+ resourceConfig.register(CorsResponseFilter.class);
+ resourceConfig.registerClasses(ServerResource.class, SessionResource.class, CommandResource.class,
+ PermissionResource.class, DeviceResource.class, UserResource.class, PositionResource.class);
+ servletHandler.addServlet(new ServletHolder(new ServletContainer(resourceConfig)), "/*");
+
+ handlers.addHandler(servletHandler);
+ }
+
+ private void initOldApi() {
+ ServletContextHandler servletHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
+ servletHandler.setContextPath("/api");
servletHandler.addServlet(new ServletHolder(new AsyncServlet()), "/async/*");
servletHandler.addServlet(new ServletHolder(new ServerServlet()), "/server/*");
servletHandler.addServlet(new ServletHolder(new UserServlet()), "/user/*");
diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js
index 36781a2e2..fd76ab159 100644
--- a/web/app/controller/Root.js
+++ b/web/app/controller/Root.js
@@ -33,7 +33,7 @@ Ext.define('Traccar.controller.Root', {
onLaunch: function () {
Ext.Ajax.request({
scope: this,
- url: '/api/rest/server',
+ url: '/api/server',
callback: this.onServerReturn
});
},
@@ -44,7 +44,7 @@ Ext.define('Traccar.controller.Root', {
Traccar.app.setServer(Ext.decode(response.responseText));
Ext.Ajax.request({
scope: this,
- url: '/api/rest/session',
+ url: '/api/session',
callback: this.onSessionReturn
});
} else {
diff --git a/web/app/model/Server.js b/web/app/model/Server.js
index 202c856c9..b200a2d23 100644
--- a/web/app/model/Server.js
+++ b/web/app/model/Server.js
@@ -55,7 +55,7 @@ Ext.define('Traccar.model.Server', {
proxy: {
type: 'ajax',
- url: '/api/rest/server',
+ url: '/api/server',
actionMethods: {
update: 'PUT'
},
diff --git a/web/app/model/User.js b/web/app/model/User.js
index d4c67f8f1..b00918bc8 100644
--- a/web/app/model/User.js
+++ b/web/app/model/User.js
@@ -58,7 +58,7 @@ Ext.define('Traccar.model.User', {
proxy: {
type: 'rest',
- url: '/api/rest/users',
+ url: '/api/users',
writer: {
type: 'json',
writeAllFields: true
diff --git a/web/app/store/AllDevices.js b/web/app/store/AllDevices.js
index 7e268f747..8a6f7d5ef 100644
--- a/web/app/store/AllDevices.js
+++ b/web/app/store/AllDevices.js
@@ -20,7 +20,7 @@ Ext.define('Traccar.store.AllDevices', {
proxy: {
type: 'rest',
- url: '/api/rest/devices',
+ url: '/api/devices',
extraParams: {
all: true
}
diff --git a/web/app/store/Devices.js b/web/app/store/Devices.js
index c8c95bda0..8ba513792 100644
--- a/web/app/store/Devices.js
+++ b/web/app/store/Devices.js
@@ -20,7 +20,7 @@ Ext.define('Traccar.store.Devices', {
proxy: {
type: 'rest',
- url: '/api/rest/devices',
+ url: '/api/devices',
writer: {
writeAllFields: true
}
diff --git a/web/app/store/Positions.js b/web/app/store/Positions.js
index cfccd4f94..b201c219c 100644
--- a/web/app/store/Positions.js
+++ b/web/app/store/Positions.js
@@ -20,6 +20,6 @@ Ext.define('Traccar.store.Positions', {
proxy: {
type: 'rest',
- url: '/api/rest/positions'
+ url: '/api/positions'
}
});
diff --git a/web/app/store/Users.js b/web/app/store/Users.js
index 5427c2d70..16901008d 100644
--- a/web/app/store/Users.js
+++ b/web/app/store/Users.js
@@ -20,7 +20,7 @@ Ext.define('Traccar.store.Users', {
proxy: {
type: 'rest',
- url: '/api/rest/users',
+ url: '/api/users',
writer: {
writeAllFields: true
}
diff --git a/web/app/view/CommandDialogController.js b/web/app/view/CommandDialogController.js
index bf2fe4fde..93109a2d6 100644
--- a/web/app/view/CommandDialogController.js
+++ b/web/app/view/CommandDialogController.js
@@ -42,7 +42,7 @@ Ext.define('Traccar.view.CommandDialogController', {
Ext.Ajax.request({
scope: this,
- url: '/api/rest/commands',
+ url: '/api/commands',
jsonData: record.getData(),
callback: this.onSendResult
});
diff --git a/web/app/view/LoginController.js b/web/app/view/LoginController.js
index 0ac8408fa..3dd8af082 100644
--- a/web/app/view/LoginController.js
+++ b/web/app/view/LoginController.js
@@ -35,7 +35,7 @@ Ext.define('Traccar.view.LoginController', {
Ext.Ajax.request({
scope: this,
method: 'POST',
- url: '/api/rest/session',
+ url: '/api/session',
params: form.getValues(),
callback: function (options, success, response) {
Ext.getBody().unmask();
@@ -54,7 +54,7 @@ Ext.define('Traccar.view.LoginController', {
Ext.Ajax.request({
scope: this,
method: 'DELETE',
- url: '/api/rest/session',
+ url: '/api/session',
callback: function () {
window.location.reload();
}
diff --git a/web/app/view/RegisterController.js b/web/app/view/RegisterController.js
index 9dcfe2107..dfc4a1735 100644
--- a/web/app/view/RegisterController.js
+++ b/web/app/view/RegisterController.js
@@ -24,7 +24,7 @@ Ext.define('Traccar.view.RegisterController', {
Ext.Ajax.request({
scope: this,
method: 'POST',
- url: '/api/rest/users',
+ url: '/api/users',
jsonData: form.getValues(),
callback: this.onCreateReturn
});
diff --git a/web/app/view/UserDevicesController.js b/web/app/view/UserDevicesController.js
index 5232d82ce..4f013fd64 100644
--- a/web/app/view/UserDevicesController.js
+++ b/web/app/view/UserDevicesController.js
@@ -47,7 +47,7 @@ Ext.define('Traccar.view.UserDevicesController', {
onBeforeSelect: function (object, record, index) {
Ext.Ajax.request({
scope: this,
- url: '/api/rest/permissions',
+ url: '/api/permissions',
jsonData: {
userId: this.userId,
deviceId: record.getData().id
@@ -64,7 +64,7 @@ Ext.define('Traccar.view.UserDevicesController', {
Ext.Ajax.request({
scope: this,
method: 'DELETE',
- url: '/api/rest/permissions',
+ url: '/api/permissions',
jsonData: {
userId: this.userId,
deviceId: record.getData().id