mirror of
https://github.com/traccar/traccar.git
synced 2026-02-05 05:03:44 -05:00
Implement server config update API
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -90,4 +90,5 @@ public class PermissionsManager {
|
||||
checkDevice(userId, entityId);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user