feat: dashboard
This commit is contained in:
parent
5e0e02cc6e
commit
ec8a0db1be
36
src/main/java/fr/la_banquise/backend/rest/Endpoints.java
Normal file
36
src/main/java/fr/la_banquise/backend/rest/Endpoints.java
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
package fr.la_banquise.backend.rest;
|
||||||
|
|
||||||
|
import fr.la_banquise.backend.rest.response.DashboardResponse;
|
||||||
|
import fr.la_banquise.backend.services.InstanceService;
|
||||||
|
import fr.la_banquise.backend.services.TpService;
|
||||||
|
import io.quarkus.security.identity.SecurityIdentity;
|
||||||
|
import jakarta.inject.Inject;
|
||||||
|
import jakarta.ws.rs.GET;
|
||||||
|
import jakarta.ws.rs.Path;
|
||||||
|
import jakarta.ws.rs.core.Response;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Endpoints
|
||||||
|
*/
|
||||||
|
@Path("api")
|
||||||
|
public class Endpoints {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
SecurityIdentity identity;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
InstanceService instanceService;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
TpService tpService;
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("dashboard")
|
||||||
|
public Response getDashboard() {
|
||||||
|
String username = identity.getPrincipal().getName();
|
||||||
|
DashboardResponse dashboard = new DashboardResponse();
|
||||||
|
dashboard.tps = tpService.getAllTps();
|
||||||
|
dashboard.instances = instanceService.getAllInstances(username);
|
||||||
|
return Response.ok(dashboard).build();
|
||||||
|
}
|
||||||
|
}
|
@ -11,5 +11,5 @@ public class InstanceRequest {
|
|||||||
public String pwd;
|
public String pwd;
|
||||||
public String username;
|
public String username;
|
||||||
@Nullable
|
@Nullable
|
||||||
public int tpId;
|
public Long tpId;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
package fr.la_banquise.backend.rest.response;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import fr.la_banquise.backend.data.model.Instance;
|
||||||
|
import fr.la_banquise.backend.data.model.Tp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DashboardResponse
|
||||||
|
*/
|
||||||
|
public class DashboardResponse {
|
||||||
|
public List<Tp> tps;
|
||||||
|
public List<Instance> instances;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user