aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-12-02 13:35:15 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-12-02 13:35:15 +1300
commitdc99e22966e542e6399df429c1e7611bc9c3bd52 (patch)
tree419630187f555348f1e469014d36c9e1e6ff5590
parent2d934d61544b1fbe3e8ec733988f90a358809956 (diff)
downloadtraccar-server-dc99e22966e542e6399df429c1e7611bc9c3bd52.tar.gz
traccar-server-dc99e22966e542e6399df429c1e7611bc9c3bd52.tar.bz2
traccar-server-dc99e22966e542e6399df429c1e7611bc9c3bd52.zip
Implement server config update API
-rw-r--r--src/org/traccar/api/resource/ServerResource.java12
-rw-r--r--src/org/traccar/api/resource/UserResource.java2
-rw-r--r--src/org/traccar/database/PermissionsManager.java1
-rw-r--r--web/app/model/Server.js5
-rw-r--r--web/app/view/RegisterController.js7
5 files changed, 24 insertions, 3 deletions
diff --git a/src/org/traccar/api/resource/ServerResource.java b/src/org/traccar/api/resource/ServerResource.java
index 2c0373c62..36f7f14c3 100644
--- a/src/org/traccar/api/resource/ServerResource.java
+++ b/src/org/traccar/api/resource/ServerResource.java
@@ -22,10 +22,12 @@ import org.traccar.model.Server;
import javax.annotation.security.PermitAll;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
+import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
import java.sql.SQLException;
@Path("server")
@@ -43,4 +45,14 @@ public class ServerResource extends BaseResource {
}
}
+ @PUT
+ public Response update(Server entity) {
+ try {
+ Context.getDataManager().updateServer(entity);
+ return Response.ok(entity).build();
+ } catch (SQLException e) {
+ throw new WebApplicationException(e);
+ }
+ }
+
}
diff --git a/src/org/traccar/api/resource/UserResource.java b/src/org/traccar/api/resource/UserResource.java
index 43bef891f..ac81ba865 100644
--- a/src/org/traccar/api/resource/UserResource.java
+++ b/src/org/traccar/api/resource/UserResource.java
@@ -17,6 +17,7 @@ package org.traccar.api.resource;
import java.sql.SQLException;
import java.util.Collection;
+import javax.annotation.security.PermitAll;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
@@ -47,6 +48,7 @@ public class UserResource extends BaseResource {
}
}
+ @PermitAll
@POST
public Response add(User entity) {
try {
diff --git a/src/org/traccar/database/PermissionsManager.java b/src/org/traccar/database/PermissionsManager.java
index 0a43f4ff4..4f3acf00c 100644
--- a/src/org/traccar/database/PermissionsManager.java
+++ b/src/org/traccar/database/PermissionsManager.java
@@ -90,4 +90,5 @@ public class PermissionsManager {
checkDevice(userId, entityId);
}
}
+
}
diff --git a/web/app/model/Server.js b/web/app/model/Server.js
index 2ed2c456f..202c856c9 100644
--- a/web/app/model/Server.js
+++ b/web/app/model/Server.js
@@ -55,7 +55,10 @@ Ext.define('Traccar.model.Server', {
proxy: {
type: 'ajax',
- url: '/api/server/update',
+ url: '/api/rest/server',
+ actionMethods: {
+ update: 'PUT'
+ },
writer: {
type: 'json',
writeAllFields: true
diff --git a/web/app/view/RegisterController.js b/web/app/view/RegisterController.js
index 5cf41fc65..9dcfe2107 100644
--- a/web/app/view/RegisterController.js
+++ b/web/app/view/RegisterController.js
@@ -23,7 +23,8 @@ Ext.define('Traccar.view.RegisterController', {
if (form.isValid()) {
Ext.Ajax.request({
scope: this,
- url: '/api/register',
+ method: 'POST',
+ url: '/api/rest/users',
jsonData: form.getValues(),
callback: this.onCreateReturn
});
@@ -31,9 +32,11 @@ Ext.define('Traccar.view.RegisterController', {
},
onCreateReturn: function (options, success, response) {
- if (Traccar.ErrorManager.check(success, response)) {
+ if (success) {
this.closeView();
Ext.toast(Strings.loginCreated);
+ } else {
+ Traccar.app.showError(response);
}
}