remove "ADD" , "EDIT" and "DELETE" device buttons from the user's panel

Sviatoslav2 years ago

Hi, how do I remove "ADD" and "DELETE" device buttons from the user's panel?

Readonly isn't good

How can I remove it ?

Anton Tananaev2 years ago
RastreameMX2 years ago

If you want to disable add or delete, then you should check for permissions of the user account and limit it (Read only maybe).

If you want to dissapear buttons from the web interface, you need to modify a web interface and compile it.

Greets.

Sviatoslav2 years ago

Thank you, Captain Obvious!

RastreameMX2 years ago

Man, nobody here will do your homework for free. If you want to learn how to modify and compile your own build of modern interface like me and many here, then learn.

If you want to know what files can you modify to delete buttons, you could question that, and maybe we could give you a clue.

But we will not give you the code exact for what you want to do.

Greets.

Sviatoslav2 years ago

Is there any guide how to edit and compile? Which files are for edit? I am just started few weeks in Java.

RastreameMX2 years ago

https://www.traccar.org/build-web-app/

You need to learn about react and NodeJS.

I don't know exactly what buttons do you want to delete, but if you want to modify something in the Device popup that appears when you select a device in map, file is StatusCard.js

Greets.

Cristian2 years ago

sviatoslav
Maybe you should share an image marking the buttons you want to remove so you don't have to guess what you really need. And explain why. It doesn't make much sense to me what you are ask

Sviatoslav16 days ago

Delete device only by administrator. File src/main/java/org.traccar/api/BaseObjectResource.java

@Path("{id}")
@DELETE
public Response remove(@PathParam("id") long id) throws Exception {
    // Получаем пользователя по ID
    User user = permissionsService.getUser(getUserId());

    // Проверяем, является ли пользователь администратором
    if (!user.getAdministrator()) {
        return Response.status(Response.Status.FORBIDDEN)
                .entity("Удаление устройства доступно только администраторам").build();
    }

    permissionsService.checkPermission(baseClass, getUserId(), id);
    permissionsService.checkEdit(getUserId(), baseClass, false, false);

    storage.removeObject(baseClass, new Request(new Condition.Equals("id", id)));
    cacheManager.invalidateObject(true, baseClass, id, ObjectOperation.DELETE);

    LogAction.remove(getUserId(), baseClass, id);

    return Response.noContent().build();
}