fix: deleted few things solid base
This commit is contained in:
parent
9928140682
commit
10fcbbb36b
11
pom.xml
11
pom.xml
@ -15,6 +15,7 @@
|
||||
<quarkus.platform.version>3.10.1</quarkus.platform.version>
|
||||
<skipITs>true</skipITs>
|
||||
<surefire-plugin.version>3.2.5</surefire-plugin.version>
|
||||
<lombok.version>1.8.34</lombok.version>
|
||||
</properties>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
@ -69,11 +70,21 @@
|
||||
<artifactId>quarkus-quinoa</artifactId>
|
||||
<version>2.3.10</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-hibernate-orm</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-junit5</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.22</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
|
@ -1,20 +0,0 @@
|
||||
package fr.la_banquise.backend;
|
||||
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import io.quarkus.security.Authenticated;
|
||||
|
||||
@Path("/api/admin")
|
||||
@Authenticated
|
||||
public class AdminResource {
|
||||
|
||||
@GET
|
||||
@RolesAllowed("admin")
|
||||
@Produces(MediaType.TEXT_PLAIN)
|
||||
public String admin() {
|
||||
return "granted";
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
package fr.la_banquise.backend;
|
||||
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
/**
|
||||
* Auth
|
||||
*/
|
||||
@Path("/user")
|
||||
public class Auth {
|
||||
|
||||
@GET
|
||||
@RolesAllowed("user")
|
||||
public Response hello() {
|
||||
return Response.ok("Hello from Quarkus!").build();
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
package fr.la_banquise.backend;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
|
||||
import io.quarkus.qute.TemplateInstance;
|
||||
import io.quarkus.qute.Template;
|
||||
|
||||
@Path("hello")
|
||||
public class HelloResource {
|
||||
|
||||
@Inject
|
||||
Template hello;
|
||||
|
||||
@GET
|
||||
@Produces(MediaType.TEXT_PLAIN)
|
||||
public TemplateInstance get(@QueryParam("name") String name) {
|
||||
return hello.data("name", "malo");
|
||||
}
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
package fr.la_banquise.backend;
|
||||
|
||||
import io.quarkus.security.Authenticated;
|
||||
import io.quarkus.security.identity.SecurityIdentity;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
/**
|
||||
* Login
|
||||
*/
|
||||
@Authenticated
|
||||
@Path("/logged")
|
||||
public class Login {
|
||||
@Inject
|
||||
SecurityIdentity identity;
|
||||
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Response login() {
|
||||
System.out.println(identity.getPrincipal());
|
||||
return Response.ok(identity.getPrincipal()).build();
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package fr.la_banquise.backend;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import jakarta.ws.rs.FormParam;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
|
||||
import org.jboss.resteasy.annotations.providers.multipart.PartType;
|
||||
|
||||
/**
|
||||
* MultipartBody
|
||||
*/
|
||||
public class MultipartBody {
|
||||
|
||||
@FormParam("file")
|
||||
@PartType(MediaType.APPLICATION_OCTET_STREAM)
|
||||
public InputStream file;
|
||||
|
||||
@FormParam("fileName")
|
||||
@PartType(MediaType.TEXT_PLAIN)
|
||||
public String fileName;
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package fr.la_banquise.backend;
|
||||
|
||||
import io.quarkus.security.Authenticated;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
|
||||
@Path("/mabite")
|
||||
@Authenticated
|
||||
public class SecureResource {
|
||||
|
||||
@GET
|
||||
@Produces(MediaType.TEXT_PLAIN)
|
||||
@RolesAllowed("admin")
|
||||
public String secure() {
|
||||
return "This is a secured resource";
|
||||
}
|
||||
}
|
||||
|
@ -1,21 +0,0 @@
|
||||
package fr.la_banquise.backend;
|
||||
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
|
||||
/**
|
||||
* Test
|
||||
*/
|
||||
@Path("/admin")
|
||||
public class Test {
|
||||
|
||||
@GET
|
||||
@RolesAllowed("user")
|
||||
@Produces(MediaType.TEXT_PLAIN)
|
||||
public String test() {
|
||||
return "Access for subject " + " is granted";
|
||||
}
|
||||
}
|
@ -1,82 +0,0 @@
|
||||
package fr.la_banquise.backend;
|
||||
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import jakarta.ws.rs.core.SecurityContext;
|
||||
|
||||
import io.quarkus.security.Authenticated;
|
||||
|
||||
@Path("/api/user")
|
||||
@Authenticated
|
||||
public class UsersResource {
|
||||
|
||||
@GET
|
||||
@Path("/me")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@RolesAllowed("user")
|
||||
// public Response<Map<String, Object>> me(@Context SecurityContext
|
||||
// securityContext) {
|
||||
public Response me() {
|
||||
// OidcJwtCallerPrincipal principal = (OidcJwtCallerPrincipal)
|
||||
// securityContext.getUserPrincipal();
|
||||
// Map<String, Object> claims = principal.getClaims().getClaimsMap();
|
||||
// System.out.println(claims);
|
||||
|
||||
// Map<String, Object> userInfo = new HashMap<>();
|
||||
// userInfo.put("username", claims.get("name"));
|
||||
// userInfo.put("username", "malo");
|
||||
// userInfo.put("email", token.getEmail());
|
||||
// userInfo.put("firstName", token.getGivenName());
|
||||
// userInfo.put("lastName", token.getFamilyName());
|
||||
|
||||
String test = "yess";
|
||||
return Response.ok(test).build();
|
||||
}
|
||||
// @Inject
|
||||
// SecurityIdentity identity;
|
||||
//
|
||||
// @GET
|
||||
// @Path("/me")
|
||||
// public User me() {
|
||||
// return new User(identity);
|
||||
// }
|
||||
//
|
||||
// public static class User {
|
||||
// private final String userName;
|
||||
// private final Set<String> roles;
|
||||
// private final String sshKey;
|
||||
//
|
||||
// User(SecurityIdentity identity) {
|
||||
// this.userName = identity.getPrincipal().getName();
|
||||
// this.roles = identity.getRoles();
|
||||
//
|
||||
// if (identity.getPrincipal() instanceof OidcJwtCallerPrincipal) {
|
||||
// OidcJwtCallerPrincipal oidcJwtCallerPrincipal = (OidcJwtCallerPrincipal)
|
||||
// identity.getPrincipal();
|
||||
// // Map<String, Object> claims =
|
||||
// oidcJwtCallerPrincipal.getClaims().getClaimsMap();
|
||||
// // System.out.println(claims.get("ssh-key"));
|
||||
// this.sshKey = (String) oidcJwtCallerPrincipal.getClaim("ssh-key");
|
||||
// } else {
|
||||
// this.sshKey = null;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public String getUserName() {
|
||||
// return userName;
|
||||
// }
|
||||
//
|
||||
// public Set<String> getRoles() {
|
||||
// return roles;
|
||||
// }
|
||||
//
|
||||
// public String getSshKey() {
|
||||
// return sshKey;
|
||||
// }
|
||||
// }
|
||||
}
|
@ -1,94 +0,0 @@
|
||||
package fr.la_banquise.backend.api;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.Authenticator;
|
||||
import java.net.PasswordAuthentication;
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import fr.la_banquise.backend.api.response.LdapUserParser;
|
||||
import fr.la_banquise.backend.api.response.UserLdap;
|
||||
import fr.la_banquise.backend.api.response.UserLdapResponse;
|
||||
import fr.la_banquise.backend.api.response.LdapUserParser.User;
|
||||
import fr.la_banquise.backend.data.model.UserModel;
|
||||
import fr.la_banquise.backend.domain.service.UserService;
|
||||
import fr.la_banquise.backend.utils.RequestsHttp;
|
||||
import io.vertx.core.json.JsonArray;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
|
||||
/**
|
||||
* ApiUsers
|
||||
*/
|
||||
@Path("/api/users")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public class ApiUsers {
|
||||
|
||||
@Inject
|
||||
UserService userService;
|
||||
|
||||
@GET
|
||||
@Path("/")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Response getUsers() {
|
||||
return Response.ok(userService.getUsers()).build();
|
||||
}
|
||||
|
||||
@POST
|
||||
@RolesAllowed("admin")
|
||||
@Path("sync")
|
||||
public Response syncUsers() {
|
||||
String jsonBody = "{\"variables\":{\"filters\":null},\"query\":\"query ListUsersQuery($filters: RequestFilter) { users(filters: $filters) { id email displayName firstName lastName creationDate }}query ListUserNames($filters: RequestFilter) { users(filters: $filters) { id displayName }}\",\"operationName\":\"ListUsersQuery\"}";
|
||||
HttpResponse<String> response = RequestsHttp.callLdap("http://localhost:17170/api/graphql", jsonBody);
|
||||
if (response == null) {
|
||||
return Response.status(500).build();
|
||||
}
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
LdapUserParser users;
|
||||
try {
|
||||
users = mapper.readValue(response.body(),
|
||||
LdapUserParser.class);
|
||||
|
||||
for (User user : users.getData().getUsers()) {
|
||||
UserModel existingUser = userService.getUserIdByName(user.getId());
|
||||
if (existingUser != null) {
|
||||
existingUser.userId = user.getId();
|
||||
existingUser.email = user.getEmail();
|
||||
existingUser.displayName = user.getDisplayName();
|
||||
existingUser.firstName = user.getFirstName();
|
||||
existingUser.lastName = user.getLastName();
|
||||
existingUser.creationDate = user.getCreationDate();
|
||||
existingUser.avatar = user.getAvatar();
|
||||
existingUser.sshKeys = user.getSshKeys();
|
||||
userService.updateUser(existingUser);
|
||||
} else {
|
||||
userService.addUser(new UserModel(user.getId(), user.getEmail(), user.getDisplayName(),
|
||||
user.getFirstName(),
|
||||
user.getLastName(), user.getCreationDate(), user.getAvatar(), user.getSshKeys()));
|
||||
}
|
||||
}
|
||||
if (response.statusCode() != 200) {
|
||||
return Response.status(response.statusCode()).build();
|
||||
}
|
||||
return Response.ok(users).build();
|
||||
} catch (JsonProcessingException e) {
|
||||
e.printStackTrace();
|
||||
return Response.status(500).build();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package fr.la_banquise.backend.api;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
/**
|
||||
* Dashboard
|
||||
*/
|
||||
@Path("/api")
|
||||
public class Dashboard {
|
||||
|
||||
@GET
|
||||
@RolesAllowed("user")
|
||||
@Path("/dashboard")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Response getDashboard() {
|
||||
List<String> tp = new ArrayList<>();
|
||||
tp.add("Bot Discord");
|
||||
tp.add("Websocket Chat");
|
||||
return Response.ok(tp).build();
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
package fr.la_banquise.backend.api.response;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* DataLdap
|
||||
*/
|
||||
public class DataLdap {
|
||||
private List<UserLdap> users;
|
||||
}
|
@ -1,102 +0,0 @@
|
||||
package fr.la_banquise.backend.api.response;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* LdapUserParser
|
||||
*/
|
||||
public class LdapUserParser {
|
||||
|
||||
public static class User {
|
||||
private String id;
|
||||
private String email;
|
||||
private String displayName;
|
||||
private String firstName;
|
||||
private String lastName;
|
||||
private String creationDate;
|
||||
private String avatar;
|
||||
private List<String> sshKeys;
|
||||
|
||||
// Getters and Setters
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public void setDisplayName(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
public String getCreationDate() {
|
||||
return creationDate;
|
||||
}
|
||||
|
||||
public void setCreationDate(String creationDate) {
|
||||
this.creationDate = creationDate;
|
||||
}
|
||||
|
||||
public String getAvatar() {
|
||||
return avatar;
|
||||
}
|
||||
|
||||
public List<String> getSshKeys() {
|
||||
return sshKeys;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Data {
|
||||
private List<User> users;
|
||||
|
||||
// Getter and Setter
|
||||
public List<User> getUsers() {
|
||||
return users;
|
||||
}
|
||||
|
||||
public void setUsers(List<User> users) {
|
||||
this.users = users;
|
||||
}
|
||||
}
|
||||
|
||||
private Data data;
|
||||
|
||||
// Getter and Setter
|
||||
public Data getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Data data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
package fr.la_banquise.backend.api.response;
|
||||
|
||||
/**
|
||||
* UserLdap
|
||||
*/
|
||||
public class UserLdap {
|
||||
private String id;
|
||||
private String email;
|
||||
private String displayName;
|
||||
private String firstName;
|
||||
private String lastName;
|
||||
private String creationDate;
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
package fr.la_banquise.backend.api.response;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* UserLdapResponse
|
||||
*/
|
||||
public class UserLdapResponse {
|
||||
private DataLdap data;
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
package fr.la_banquise.backend.converter;
|
||||
|
||||
import fr.la_banquise.backend.data.model.TpModel;
|
||||
import fr.la_banquise.backend.domain.entity.TpItemEntity;
|
||||
|
||||
/**
|
||||
* Mapper
|
||||
*/
|
||||
public class Mapper {
|
||||
public static TpItemEntity toTpEntity(TpModel tp) {
|
||||
return new TpItemEntity(tp.id, tp.name, tp.description, tp.pdfLink, tp.givenLink, tp.respo, tp.endDate);
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package fr.la_banquise.backend.data.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
||||
|
||||
import io.quarkus.hibernate.orm.panache.PanacheEntity;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* Instances
|
||||
*/
|
||||
@Entity
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Table(name = "instance")
|
||||
public class Instance extends PanacheEntity {
|
||||
public String name;
|
||||
public String ssh;
|
||||
public String pwd;
|
||||
|
||||
@JsonBackReference
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "user_id", nullable = false)
|
||||
public User user;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "practical_id")
|
||||
public Tp tp;
|
||||
}
|
22
src/main/java/fr/la_banquise/backend/data/model/Tp.java
Normal file
22
src/main/java/fr/la_banquise/backend/data/model/Tp.java
Normal file
@ -0,0 +1,22 @@
|
||||
package fr.la_banquise.backend.data.model;
|
||||
|
||||
import io.quarkus.hibernate.orm.panache.PanacheEntity;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* Tp
|
||||
*/
|
||||
@Entity
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table(name = "tp")
|
||||
public class Tp extends PanacheEntity {
|
||||
public String name;
|
||||
public String description;
|
||||
public String pdfLink;
|
||||
public String respo;
|
||||
public String date;
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
package fr.la_banquise.backend.data.model;
|
||||
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
/**
|
||||
* TpModel
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "tps")
|
||||
public class TpModel {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
public Long id;
|
||||
public String name;
|
||||
public String description;
|
||||
|
||||
public String pdfLink;
|
||||
public String givenLink;
|
||||
public String respo;
|
||||
public String endDate;
|
||||
|
||||
public TpModel(String name, String description, String pdfLink, String givenLink, String respo, String endDate) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.pdfLink = pdfLink;
|
||||
this.givenLink = givenLink;
|
||||
this.respo = respo;
|
||||
this.endDate = endDate;
|
||||
}
|
||||
|
||||
public TpModel() {
|
||||
}
|
||||
}
|
32
src/main/java/fr/la_banquise/backend/data/model/User.java
Normal file
32
src/main/java/fr/la_banquise/backend/data/model/User.java
Normal file
@ -0,0 +1,32 @@
|
||||
package fr.la_banquise.backend.data.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
||||
|
||||
import io.quarkus.hibernate.orm.panache.PanacheEntity;
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* User
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "penguin")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class User extends PanacheEntity {
|
||||
public String name;
|
||||
|
||||
@JsonManagedReference
|
||||
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL)
|
||||
public List<Instance> instances;
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
package fr.la_banquise.backend.data.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
/**
|
||||
* UserModel
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "users")
|
||||
public class UserModel {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
public Long id;
|
||||
public String userId;
|
||||
public String email;
|
||||
public String displayName;
|
||||
public String firstName;
|
||||
public String lastName;
|
||||
public String creationDate;
|
||||
public String avatar;
|
||||
public List<String> sshKeys;
|
||||
|
||||
public UserModel(String userId, String email, String displayName, String firstName, String lastName,
|
||||
String creationDate, String avatar,
|
||||
List<String> sshKeys) {
|
||||
this.userId = userId;
|
||||
this.email = email;
|
||||
this.displayName = displayName;
|
||||
this.firstName = firstName;
|
||||
this.lastName = lastName;
|
||||
this.creationDate = creationDate;
|
||||
this.avatar = avatar;
|
||||
this.sshKeys = sshKeys;
|
||||
}
|
||||
|
||||
public UserModel() {
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package fr.la_banquise.backend.data.repository;
|
||||
|
||||
import fr.la_banquise.backend.data.model.Instance;
|
||||
import io.quarkus.hibernate.orm.panache.PanacheRepository;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
|
||||
/**
|
||||
* InstanceRepository
|
||||
*/
|
||||
@ApplicationScoped
|
||||
public class InstanceRepository implements PanacheRepository<Instance> {
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package fr.la_banquise.backend.data.repository;
|
||||
|
||||
import fr.la_banquise.backend.data.model.TpModel;
|
||||
import fr.la_banquise.backend.data.model.Tp;
|
||||
import io.quarkus.hibernate.orm.panache.PanacheRepository;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
|
||||
@ -8,5 +8,6 @@ import jakarta.enterprise.context.ApplicationScoped;
|
||||
* TpRepository
|
||||
*/
|
||||
@ApplicationScoped
|
||||
public class TpRepository implements PanacheRepository<TpModel> {
|
||||
public class TpRepository implements PanacheRepository<Tp> {
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package fr.la_banquise.backend.data.repository;
|
||||
|
||||
import fr.la_banquise.backend.data.model.UserModel;
|
||||
import fr.la_banquise.backend.data.model.User;
|
||||
import io.quarkus.hibernate.orm.panache.PanacheRepository;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
|
||||
@ -8,5 +8,5 @@ import jakarta.enterprise.context.ApplicationScoped;
|
||||
* UserRepository
|
||||
*/
|
||||
@ApplicationScoped
|
||||
public class UserRepository implements PanacheRepository<UserModel> {
|
||||
public class UserRepository implements PanacheRepository<User> {
|
||||
}
|
||||
|
@ -1,13 +0,0 @@
|
||||
package fr.la_banquise.backend.domain.entity;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* DashboardEntity
|
||||
*/
|
||||
public class DashboardEntity {
|
||||
public Set<TpItemEntity> tps;
|
||||
public Set<DashboardItem> instances;
|
||||
public Set<DashboardItem> messages;
|
||||
public String userName;
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
package fr.la_banquise.backend.domain.entity;
|
||||
|
||||
/**
|
||||
* DashboardItem
|
||||
*/
|
||||
public class DashboardItem {
|
||||
public Long id;
|
||||
public String name;
|
||||
public String description;
|
||||
public String link;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
package fr.la_banquise.backend.domain.entity;
|
||||
|
||||
/**
|
||||
* TpItemEntity
|
||||
*/
|
||||
public class TpItemEntity {
|
||||
public Long id;
|
||||
public String name;
|
||||
public String description;
|
||||
public String pdfLink;
|
||||
public String givenLink;
|
||||
public String respo;
|
||||
public String endDate;
|
||||
|
||||
public TpItemEntity(Long id, String name, String description,String pdfLink, String givenLink, String respo, String endDate) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.pdfLink = pdfLink;
|
||||
this.givenLink = givenLink;
|
||||
this.respo = respo;
|
||||
this.endDate = endDate;
|
||||
}
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
package fr.la_banquise.backend.domain.entity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* UserEntity
|
||||
*/
|
||||
public class UserEntity {
|
||||
public Long id;
|
||||
public String userId;
|
||||
public String displayName;
|
||||
public String firstName;
|
||||
public String lastName;
|
||||
public String avatar;
|
||||
public List<String> sshKeys;
|
||||
|
||||
public UserEntity(String userId, String displayName, String firstName, String lastName, String avatar,
|
||||
List<String> sshKeys) {
|
||||
this.userId = userId;
|
||||
this.displayName = displayName;
|
||||
this.firstName = firstName;
|
||||
this.lastName = lastName;
|
||||
this.avatar = avatar;
|
||||
this.sshKeys = sshKeys;
|
||||
}
|
||||
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
package fr.la_banquise.backend.domain.service;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import fr.la_banquise.backend.converter.Mapper;
|
||||
import fr.la_banquise.backend.data.model.TpModel;
|
||||
import fr.la_banquise.backend.data.repository.TpRepository;
|
||||
import fr.la_banquise.backend.domain.entity.TpItemEntity;
|
||||
import fr.la_banquise.backend.presentation.rest.request.TpForm;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.transaction.Transactional;
|
||||
|
||||
/**
|
||||
* DashboardItemService
|
||||
*/
|
||||
@ApplicationScoped
|
||||
public class DashboardItemService {
|
||||
@Inject
|
||||
EntityManager em;
|
||||
|
||||
@Inject
|
||||
TpRepository tpRepository;
|
||||
|
||||
public Set<TpItemEntity> getTps(){
|
||||
Set<TpModel> tpModels = tpRepository.findAll().stream().collect(Collectors.toSet());
|
||||
Set<TpItemEntity> res = new HashSet<>();
|
||||
tpModels.forEach(tp -> {
|
||||
res.add(Mapper.toTpEntity(tp));
|
||||
});
|
||||
return res;
|
||||
}
|
||||
|
||||
public TpItemEntity getTp(long id){
|
||||
TpModel tp = tpRepository.findById(id);
|
||||
return Mapper.toTpEntity(tp);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public TpItemEntity newTp(TpForm tp){
|
||||
TpModel newTp = new TpModel(tp.title, tp.description, tp.pdflink, tp.givenlink, tp.respo, tp.date);
|
||||
em.persist(newTp);
|
||||
return Mapper.toTpEntity(newTp);
|
||||
}
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
package fr.la_banquise.backend.domain.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import fr.la_banquise.backend.data.model.UserModel;
|
||||
import fr.la_banquise.backend.data.repository.UserRepository;
|
||||
import fr.la_banquise.backend.domain.entity.UserEntity;
|
||||
import io.quarkus.hibernate.orm.panache.PanacheEntity;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.transaction.Transactional;
|
||||
|
||||
/**
|
||||
* UserService
|
||||
*/
|
||||
@ApplicationScoped
|
||||
public class UserService {
|
||||
@Inject
|
||||
EntityManager em;
|
||||
|
||||
@Inject
|
||||
UserRepository userRepository;
|
||||
|
||||
public List<UserModel> getUsers() {
|
||||
return userRepository.listAll();
|
||||
}
|
||||
|
||||
public UserModel getUserIdByName(String userId) {
|
||||
return userRepository.find("userId", userId.toString()).firstResult();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void addUser(UserModel user) {
|
||||
userRepository.persist(user);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void updateUser(UserModel user) {
|
||||
userRepository.getEntityManager().merge(user);
|
||||
}
|
||||
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
package fr.la_banquise.backend.presentation.resources;
|
||||
|
||||
import io.quarkus.qute.Template;
|
||||
import io.quarkus.qute.TemplateInstance;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
|
||||
/**
|
||||
* AdminResource
|
||||
*/
|
||||
@Path("admin")
|
||||
public class AdminResource {
|
||||
@Inject
|
||||
Template admin;
|
||||
|
||||
@GET
|
||||
@Produces(MediaType.TEXT_HTML)
|
||||
@RolesAllowed("admin")
|
||||
public TemplateInstance admin(){
|
||||
return admin.data("", "");
|
||||
}
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
package fr.la_banquise.backend.presentation.resources;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import fr.la_banquise.backend.domain.entity.DashboardEntity;
|
||||
import fr.la_banquise.backend.domain.entity.TpItemEntity;
|
||||
import fr.la_banquise.backend.domain.service.DashboardItemService;
|
||||
import io.quarkus.qute.Template;
|
||||
import io.quarkus.qute.TemplateInstance;
|
||||
import io.quarkus.security.Authenticated;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.SecurityContext;
|
||||
|
||||
/**
|
||||
* DashboardResource
|
||||
*/
|
||||
@Path("dashboard")
|
||||
@Authenticated
|
||||
public class DashboardResource {
|
||||
|
||||
@Inject
|
||||
Template dashboard;
|
||||
|
||||
@Inject
|
||||
DashboardItemService dashboardItemService;
|
||||
|
||||
@GET
|
||||
@Produces(MediaType.TEXT_HTML)
|
||||
public TemplateInstance dashboard(@Context SecurityContext securityContext){
|
||||
Set<TpItemEntity> tps = dashboardItemService.getTps();
|
||||
var dash = new DashboardEntity();
|
||||
dash.tps = tps;
|
||||
var user = securityContext.getUserPrincipal();
|
||||
dash.userName = user.getName();
|
||||
return dashboard.data(dash);
|
||||
}
|
||||
}
|
||||
|
@ -1,36 +0,0 @@
|
||||
package fr.la_banquise.backend.presentation.resources;
|
||||
|
||||
import fr.la_banquise.backend.domain.entity.TpItemEntity;
|
||||
import fr.la_banquise.backend.domain.service.DashboardItemService;
|
||||
import io.quarkus.qute.Template;
|
||||
import io.quarkus.qute.TemplateInstance;
|
||||
import io.quarkus.security.Authenticated;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
|
||||
/**
|
||||
* TpResource
|
||||
*/
|
||||
@Path("/tps")
|
||||
public class TpResource {
|
||||
@Inject
|
||||
Template tp;
|
||||
|
||||
@Inject
|
||||
DashboardItemService dashboardItemService;
|
||||
|
||||
@Path("/{id}")
|
||||
@GET
|
||||
@Authenticated
|
||||
@Produces(MediaType.TEXT_HTML)
|
||||
public TemplateInstance tp(@PathParam("id") long id){
|
||||
// if not available 404
|
||||
// load it from db
|
||||
TpItemEntity tpItem = dashboardItemService.getTp(id);
|
||||
return tp.data(tpItem);
|
||||
}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
package fr.la_banquise.backend.presentation.rest;
|
||||
|
||||
import fr.la_banquise.backend.domain.service.DashboardItemService;
|
||||
import fr.la_banquise.backend.presentation.rest.request.TpForm;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
/**
|
||||
* ApiEndpoints
|
||||
*/
|
||||
@Path("/api")
|
||||
public class ApiEndpoints {
|
||||
|
||||
@Inject
|
||||
DashboardItemService dashboardItemService;
|
||||
|
||||
@POST
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Path("/tp")
|
||||
public Response newTp(TpForm tp){
|
||||
var newTp = dashboardItemService.newTp(tp);
|
||||
return Response.ok(newTp).build();
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package fr.la_banquise.backend.rest;
|
||||
|
||||
import fr.la_banquise.backend.services.InstanceService;
|
||||
import io.quarkus.security.identity.SecurityIdentity;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
/**
|
||||
* InstanceEndpoints
|
||||
*/
|
||||
@Path("/api/instances")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public class InstanceEndpoints {
|
||||
|
||||
@Inject
|
||||
SecurityIdentity identity;
|
||||
|
||||
@Inject
|
||||
InstanceService instanceService;
|
||||
|
||||
@GET
|
||||
public Response getAllInstances() {
|
||||
System.out.println(identity.getPrincipal());
|
||||
String username = identity.getPrincipal().getName();
|
||||
return Response.ok(instanceService.getAllInstances(username)).build();
|
||||
}
|
||||
}
|
47
src/main/java/fr/la_banquise/backend/rest/TpEndpoints.java
Normal file
47
src/main/java/fr/la_banquise/backend/rest/TpEndpoints.java
Normal file
@ -0,0 +1,47 @@
|
||||
package fr.la_banquise.backend.rest;
|
||||
|
||||
import fr.la_banquise.backend.services.TpService;
|
||||
import fr.la_banquise.backend.rest.request.TpForm;
|
||||
import fr.la_banquise.backend.rest.request.TpRequest;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
/**
|
||||
* TpEndpoints
|
||||
*/
|
||||
@Path("/api/tps")
|
||||
public class TpEndpoints {
|
||||
|
||||
@Inject
|
||||
TpService tpService;
|
||||
|
||||
@GET
|
||||
@RolesAllowed("pingouin")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Response getAllTps() {
|
||||
return Response.ok(tpService.getAllTps()).build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("{id}")
|
||||
public Response getTp(@PathParam("id") Long id) {
|
||||
return Response.ok(tpService.getTp(id)).build();
|
||||
}
|
||||
|
||||
@POST
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Response createTp(TpRequest tp) {
|
||||
System.out.println(tp.date);
|
||||
return Response.ok(tpService.createTp(tp)).build();
|
||||
}
|
||||
}
|
43
src/main/java/fr/la_banquise/backend/rest/UserEndpoints.java
Normal file
43
src/main/java/fr/la_banquise/backend/rest/UserEndpoints.java
Normal file
@ -0,0 +1,43 @@
|
||||
package fr.la_banquise.backend.rest;
|
||||
|
||||
import fr.la_banquise.backend.rest.request.UserRequest;
|
||||
import fr.la_banquise.backend.services.UserService;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
/**
|
||||
* UserEndpoints
|
||||
*/
|
||||
@Path("/api/users")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public class UserEndpoints {
|
||||
|
||||
@Inject
|
||||
UserService userService;
|
||||
|
||||
@GET
|
||||
@RolesAllowed("pingouin")
|
||||
public Response getAllUsers() {
|
||||
return Response.ok(userService.getAllUsers()).build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@RolesAllowed("pingouin")
|
||||
@Path("{id}")
|
||||
public Response getUser(@PathParam("id") Long id) {
|
||||
return Response.ok(userService.getUser(id)).build();
|
||||
}
|
||||
|
||||
@POST
|
||||
@RolesAllowed("admin")
|
||||
public Response createUser(UserRequest user) {
|
||||
return Response.ok(userService.crateUser(user.firstName, user.lastName)).build();
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package fr.la_banquise.backend.presentation.rest.request;
|
||||
package fr.la_banquise.backend.rest.request;
|
||||
|
||||
import jakarta.ws.rs.FormParam;
|
||||
|
||||
@ -10,12 +10,12 @@ public class TpForm {
|
||||
public String title;
|
||||
@FormParam(value = "description")
|
||||
public String description;
|
||||
@FormParam(value = "pdflink")
|
||||
@FormParam(value = "pdf")
|
||||
public String pdflink;
|
||||
@FormParam(value = "givenlink")
|
||||
public String givenlink;
|
||||
@FormParam(value = "respo")
|
||||
public String respo;
|
||||
@FormParam(value = "date")
|
||||
public String date;
|
||||
@FormParam(value = "difficulty")
|
||||
public String difficulty;
|
||||
@FormParam(value = "duration")
|
||||
public String duration;
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package fr.la_banquise.backend.rest.request;
|
||||
|
||||
/**
|
||||
* TpRequest
|
||||
*/
|
||||
public class TpRequest {
|
||||
public String title;
|
||||
public String description;
|
||||
public String pdf;
|
||||
public Long duration;
|
||||
public String tools;
|
||||
public String difficulty;
|
||||
public String date;
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package fr.la_banquise.backend.rest.request;
|
||||
|
||||
/**
|
||||
* UserRequest
|
||||
*/
|
||||
public class UserRequest {
|
||||
public String firstName;
|
||||
public String lastName;
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package fr.la_banquise.backend.rest.response;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
/**
|
||||
* PracticalResponse
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
public class PracticalResponse {
|
||||
public String name;
|
||||
public String description;
|
||||
public String pdfLink;
|
||||
public String respo;
|
||||
public String endDate;
|
||||
|
||||
public String instanceName;
|
||||
public String pwd;
|
||||
public String ssh;
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package fr.la_banquise.backend.services;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import fr.la_banquise.backend.data.model.Instance;
|
||||
import fr.la_banquise.backend.data.model.User;
|
||||
import fr.la_banquise.backend.data.repository.InstanceRepository;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.transaction.Transactional;
|
||||
|
||||
/**
|
||||
* InstanceService
|
||||
*/
|
||||
@ApplicationScoped
|
||||
public class InstanceService {
|
||||
|
||||
@Inject
|
||||
InstanceRepository instanceRepository;
|
||||
|
||||
public List<Instance> getAllInstances() {
|
||||
return instanceRepository.findAll().list();
|
||||
}
|
||||
|
||||
public List<Instance> getAllInstances(String username) {
|
||||
User user = User.find("name", username).firstResult();
|
||||
System.out.println(username);
|
||||
return instanceRepository.find("user", user).list();
|
||||
}
|
||||
|
||||
public Instance getInstance(Long id) {
|
||||
return instanceRepository.findById(id);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Instance createInstance(String name, String ssh, String pwd) {
|
||||
User admin = User.find("name", "admin").firstResult();
|
||||
Instance instance = new Instance(name, ssh, pwd, admin, null);
|
||||
instanceRepository.persist(instance);
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public boolean deleteInstance(Long id) {
|
||||
return instanceRepository.deleteById(id);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Instance updateInstance(Long id) {
|
||||
Instance instance = instanceRepository.findById(id);
|
||||
return instance;
|
||||
}
|
||||
}
|
57
src/main/java/fr/la_banquise/backend/services/TpService.java
Normal file
57
src/main/java/fr/la_banquise/backend/services/TpService.java
Normal file
@ -0,0 +1,57 @@
|
||||
package fr.la_banquise.backend.services;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import fr.la_banquise.backend.data.model.Instance;
|
||||
import fr.la_banquise.backend.data.model.Tp;
|
||||
import fr.la_banquise.backend.data.model.User;
|
||||
import fr.la_banquise.backend.data.repository.TpRepository;
|
||||
import fr.la_banquise.backend.rest.request.TpRequest;
|
||||
import fr.la_banquise.backend.rest.response.PracticalResponse;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.transaction.Transactional;
|
||||
|
||||
/**
|
||||
* TpService
|
||||
*/
|
||||
@ApplicationScoped
|
||||
public class TpService {
|
||||
|
||||
@Inject
|
||||
TpRepository tpRepository;
|
||||
|
||||
public List<Tp> getAllTps() {
|
||||
return tpRepository.listAll();
|
||||
}
|
||||
|
||||
public PracticalResponse getTp(Long id) {
|
||||
User user = User.find("name", "malopieds").firstResult();
|
||||
Tp tp = tpRepository.findById(id);
|
||||
Instance instance = Instance.find("user", user).firstResult();
|
||||
PracticalResponse res = new PracticalResponse(tp.name, tp.description, tp.pdfLink, tp.respo, tp.date,
|
||||
instance.name,
|
||||
instance.pwd, instance.ssh);
|
||||
return res;
|
||||
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Tp createTp(TpRequest requestTp) {
|
||||
User user = User.find("name", "admin").firstResult();
|
||||
Tp tp = new Tp(requestTp.title, requestTp.description, requestTp.pdf, "", requestTp.date);
|
||||
tpRepository.persist(tp);
|
||||
return tp;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void deleteTp(Long id) {
|
||||
tpRepository.deleteById(id);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Tp updateTp(Long id) {
|
||||
Tp tp = tpRepository.findById(id);
|
||||
return tp;
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package fr.la_banquise.backend.services;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import fr.la_banquise.backend.data.model.User;
|
||||
import fr.la_banquise.backend.data.repository.UserRepository;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.transaction.Transactional;
|
||||
|
||||
/**
|
||||
* UserService
|
||||
*/
|
||||
@ApplicationScoped
|
||||
public class UserService {
|
||||
|
||||
@Inject
|
||||
UserRepository userRepository;
|
||||
|
||||
public List<User> getAllUsers() {
|
||||
return userRepository.listAll();
|
||||
}
|
||||
|
||||
public User getUser(Long id) {
|
||||
return userRepository.findById(id);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public User crateUser(String firstName, String lastName) {
|
||||
User user = new User(firstName, lastName);
|
||||
userRepository.persist(user);
|
||||
return user;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void deleteUser(Long id) {
|
||||
userRepository.deleteById(id);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public User updateUser(Long id) {
|
||||
User user = userRepository.findById(id);
|
||||
return user;
|
||||
}
|
||||
|
||||
}
|
@ -18,8 +18,8 @@ quarkus.security.ldap.dir-context.principal=uid=admin,ou=people,dc=example,dc=co
|
||||
quarkus.security.ldap.dir-context.url=ldap://localhost:3890
|
||||
quarkus.security.ldap.dir-context.password=password
|
||||
|
||||
quarkus.http.auth.form.login-page=/login
|
||||
quarkus.http.auth.form.landing-page=hello
|
||||
quarkus.http.auth.form.login-page=
|
||||
quarkus.http.auth.form.landing-page=
|
||||
|
||||
quarkus.security.ldap.identity-mapping.rdn-identifier=uid
|
||||
quarkus.security.ldap.identity-mapping.search-base-dn=ou=people,dc=example,dc=com
|
||||
@ -29,7 +29,6 @@ quarkus.security.ldap.identity-mapping.attribute-mappings."0".filter=(member=uid
|
||||
quarkus.security.ldap.identity-mapping.attribute-mappings."0".filter-base-dn=ou=groups,dc=example,dc=com
|
||||
|
||||
%test.quarkus.security.ldap.dir-context.url=ldap://127.0.0.1:10389
|
||||
quarkus.quinoa.dev-server.port=5173
|
||||
|
||||
# database
|
||||
quarkus.datasource.db-kind = postgresql
|
||||
@ -39,3 +38,7 @@ quarkus.datasource.jdbc.url = jdbc:postgresql://localhost:5432/quarkus
|
||||
|
||||
# drop and create the database at startup (use `update` to only update the schema)drop-and-create
|
||||
quarkus.hibernate-orm.database.generation=update
|
||||
# quarkus.hibernate-orm.database.generation=drop-and-create
|
||||
|
||||
quarkus.quinoa.dev-server.port=5173
|
||||
quarkus.quinoa.enable-spa-routing=true
|
||||
|
@ -1,112 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Admin Dashboard</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
|
||||
</head>
|
||||
<body class="bg-gray-100">
|
||||
<div class="container mx-auto p-6">
|
||||
<h1 class="text-4xl font-bold text-center text-gray-800 mb-8">Admin Dashboard</h1>
|
||||
<div class="flex mb-4">
|
||||
<button onclick="openTab('practicalTab')" class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-l">New Practical</button>
|
||||
<button onclick="openTab('instanceTab')" class="bg-green-500 hover:bg-green-700 text-white font-bold py-2 px-4">New Instance</button>
|
||||
<button onclick="openTab('messageTab')" class="bg-red-500 hover:bg-red-700 text-white font-bold py-2 px-4 rounded-r">New Message</button>
|
||||
</div>
|
||||
<div id="practicalTab" class="tab-content bg-white shadow-lg rounded-lg p-6 hidden">
|
||||
<h2 class="text-2xl font-bold text-gray-700 mb-4">Create New Practical</h2>
|
||||
<form id="practicalForm">
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label for="practicalTitle" class="block text-gray-700 mb-2">Title</label>
|
||||
<input type="text" id="practicalTitle" name="title" class="w-full p-2 border border-gray-300 rounded mb-4" placeholder="Enter title">
|
||||
</div>
|
||||
<div>
|
||||
<label for="practicalDescription" class="block text-gray-700 mb-2">Description</label>
|
||||
<input id="practicalDescription" name="description" class="w-full p-2 border border-gray-300 rounded mb-4" rows="4" placeholder="Enter description">
|
||||
</div>
|
||||
<div>
|
||||
<label for="instancePdfLink" class="block text-gray-700 mb-2">Pdf Link</label>
|
||||
<input type="text" id="instancePdfLink" name="pdflink" class="w-full p-2 border border-gray-300 rounded mb-4" placeholder="Enter pdf link">
|
||||
</div>
|
||||
<div>
|
||||
<label for="instanceGivenLink" class="block text-gray-700 mb-2">Given Files Link</label>
|
||||
<input type="text" id="instanceGivenLink" name="givenlink" class="w-full p-2 border border-gray-300 rounded mb-4" placeholder="Enter the given files link">
|
||||
</div>
|
||||
<div>
|
||||
<label for="instanceRespo" class="block text-gray-700 mb-2">Respo</label>
|
||||
<input type="text" id="instanceRespo" name="respo" class="w-full p-2 border border-gray-300 rounded mb-4" placeholder="Enter Respo">
|
||||
</div>
|
||||
<div>
|
||||
<label for="instanceEndDate" class="block text-gray-700 mb-2">Date</label>
|
||||
<input type="text" id="instanceEndDate" name="date" class="w-full p-2 border border-gray-300 rounded mb-4" placeholder="Enter Date">
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" onclick="submitForm()" class="w-full px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-700">Create</button>
|
||||
</form>
|
||||
</div>
|
||||
<div id="instanceTab" class="tab-content bg-white shadow-lg rounded-lg p-6 hidden">
|
||||
<h2 class="text-2xl font-bold text-gray-700 mb-4">Create New Instance</h2>
|
||||
<form action="http://localhost:8080/api/tp" method="POST">
|
||||
<label for="instanceTitle" class="block text-gray-700 mb-2">Title</label>
|
||||
<input type="text" id="instanceTitle" name="title" class="w-full p-2 border border-gray-300 rounded mb-4" placeholder="Enter title">
|
||||
<label for="instanceDescription" class="block text-gray-700 mb-2">Description</label>
|
||||
<textarea id="instanceDescription" name="description" class="w-full p-2 border border-gray-300 rounded mb-4" rows="4" placeholder="Enter description"></textarea>
|
||||
<button type="submit" class="w-full px-4 py-2 bg-green-500 text-white rounded hover:bg-green-700">Create</button>
|
||||
</form>
|
||||
</div>
|
||||
<div id="messageTab" class="tab-content bg-white shadow-lg rounded-lg p-6 hidden">
|
||||
<h2 class="text-2xl font-bold text-gray-700 mb-4">Create New Message</h2>
|
||||
<form action="http://localhost:8080/api/tp" method="POST">
|
||||
<label for="messageTitle" class="block text-gray-700 mb-2">Title</label>
|
||||
<input type="text" id="messageTitle" name="title" class="w-full p-2 border border-gray-300 rounded mb-4" placeholder="Enter title">
|
||||
<label for="messageContent" class="block text-gray-700 mb-2">Content</label>
|
||||
<textarea id="messageContent" name="content" class="w-full p-2 border border-gray-300 rounded mb-4" rows="4" placeholder="Enter content"></textarea>
|
||||
<button type="submit" class="w-full px-4 py-2 bg-red-500 text-white rounded hover:bg-red-700">Create</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="bg-white shadow-lg rounded-lg p-6 mt-6">
|
||||
<h2 class="text-2xl font-bold text-gray-700 mb-4">Other Functionalities</h2>
|
||||
<p class="text-gray-600">You can add more admin functionalities here.</p>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
function submitForm() {
|
||||
var formData = {
|
||||
title: document.getElementById("practicalTitle").value,
|
||||
description: document.getElementById("practicalDescription").value,
|
||||
pdflink: document.getElementById("instancePdfLink").value,
|
||||
givenlink: document.getElementById("instanceGivenLink").value,
|
||||
respo: document.getElementById("instanceRespo").value,
|
||||
date: document.getElementById("instanceEndDate").value
|
||||
};
|
||||
|
||||
fetch('http://localhost:8080/api/tp', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(formData)
|
||||
})
|
||||
.then(response => {
|
||||
console.log('Form submitted successfully');
|
||||
document.getElementById("practicalForm").reset();
|
||||
})
|
||||
.catch(error => {
|
||||
alert(error)
|
||||
console.error('Error occurred while submitting form:', error);
|
||||
});
|
||||
}
|
||||
|
||||
function openTab(tabName) {
|
||||
var i, tabContent;
|
||||
tabContent = document.getElementsByClassName("tab-content");
|
||||
for (i = 0; i < tabContent.length; i++) {
|
||||
tabContent[i].classList.add("hidden");
|
||||
}
|
||||
document.getElementById(tabName).classList.remove("hidden");
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,65 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Dashboard</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
|
||||
</head>
|
||||
<body class="min-h-screen bg-gray-100">
|
||||
<header class="w-full text-center pt-20">
|
||||
<h2 class="text-4xl font-bold text-center text-blue-500 mb-8">WELCOME {userName}!</h2>
|
||||
</header>
|
||||
|
||||
<main class="w-full flex-grow grid grid-cols-1 lg:grid-cols-3 gap-6 p-8">
|
||||
<section class="bg-white p-6 rounded-lg shadow-lg h-full">
|
||||
<h2 class="text-2xl font-bold mb-4">Practicals</h2>
|
||||
<div class="space-y-6">
|
||||
{#if tps.orEmpty.size == 0}
|
||||
<div class="h-full">
|
||||
<p class="text-gray-700">You have no practicals</p>
|
||||
</div>
|
||||
{/if}
|
||||
{#for tp in tps}
|
||||
<a href="/tps/{tp.id}" class="block p-6 bg-gray-200 rounded-lg shadow-md hover:bg-gray-300">
|
||||
<h3 class="text-xl font-semibold">{tp.name}</h3>
|
||||
<p class="text-gray-700">{tp.description}</p>
|
||||
</a>
|
||||
{/for}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="bg-white p-6 rounded-lg shadow-lg h-full">
|
||||
<h2 class="text-2xl font-bold mb-4">Instances</h2>
|
||||
<div class="space-y-6">
|
||||
{#if instances == null }
|
||||
<div class="h-full">
|
||||
<p class="text-gray-700">You have no instances</p>
|
||||
</div>
|
||||
{/if}
|
||||
{#for instance in instances}
|
||||
<a href={instance.link} class="block p-6 bg-gray-200 rounded-lg shadow-md hover:bg-gray-300">
|
||||
<h3 class="text-xl font-semibold">{instance.name}</h3>
|
||||
<p class="text-gray-700">{instance.description}</p>
|
||||
</a>
|
||||
{/for}
|
||||
</section>
|
||||
|
||||
<section class="bg-white p-6 rounded-lg shadow-lg h-full">
|
||||
<h2 class="text-2xl font-bold mb-4">Messages</h2>
|
||||
<div class="space-y-6">
|
||||
{#if messages == null }
|
||||
<div class="h-full">
|
||||
<p class="text-gray-700">You have no messages</p>
|
||||
</div>
|
||||
{/if}
|
||||
{#for message in messages}
|
||||
<a href={message.link} class="block p-6 bg-gray-200 rounded-lg shadow-md hover:bg-gray-300">
|
||||
<h3 class="text-xl font-semibold">{message.name}</h3>
|
||||
<p class="text-gray-700">{message.description}</p>
|
||||
</a>
|
||||
{/for}
|
||||
</section>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
@ -1 +0,0 @@
|
||||
Hello {name}!
|
@ -1 +0,0 @@
|
||||
<h1>hello</h1>
|
@ -1 +0,0 @@
|
||||
<h1>Hello {http:param('name', 'Quarkus')}!</h1>
|
@ -1 +0,0 @@
|
||||
<h1>Hello</h1>
|
@ -1,91 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Login Form</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
|
||||
</head>
|
||||
|
||||
<body class="bg-gray-100 h-screen flex flex-col justify-center items-center">
|
||||
<img src="logo.png" width="200" height="100" alt="Example Image">
|
||||
<h2 class="text-3xl mb-4">Login</h2>
|
||||
<form id="loginForm" class="bg-white shadow-md rounded px-8 pt-6 pb-8 mb-4 w-80">
|
||||
<div class="mb-4">
|
||||
<label for="username" class="block text-gray-700 text-sm font-bold mb-2">Username:</label>
|
||||
<input type="text" id="username" name="username"
|
||||
class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline">
|
||||
</div>
|
||||
<div class="mb-6">
|
||||
<label for="password" class="block text-gray-700 text-sm font-bold mb-2">Password:</label>
|
||||
<input type="password" id="password" name="password"
|
||||
class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline">
|
||||
</div>
|
||||
<div id="errorMessage" class="text-red-500 mx-auto my-4 hidden text-center">Invalid credentials</div>
|
||||
|
||||
<div class="flex flex-col justify-center items-center">
|
||||
<input type="submit" value="Login"
|
||||
class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline">
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
<!--<button id="logoutButton" class="bg-red-500 hover:bg-red-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline">Logout</button>-->
|
||||
|
||||
|
||||
<script>
|
||||
const login = () => {
|
||||
const formData = new URLSearchParams();
|
||||
const username = document.getElementById('username').value;
|
||||
const password = document.getElementById('password').value;
|
||||
|
||||
formData.append("j_username", username);
|
||||
formData.append("j_password", password);
|
||||
|
||||
const errorMessage = document.getElementById('errorMessage');
|
||||
|
||||
fetch("j_security_check", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
},
|
||||
})
|
||||
.then((response) => {
|
||||
if (response.status === 200) {
|
||||
console.log(response);
|
||||
if (response.redirected) {
|
||||
window.location.href = response.url;
|
||||
console.log("oui");
|
||||
}
|
||||
else {
|
||||
window.location.href = "/user";
|
||||
}
|
||||
} else {
|
||||
errorMessage.classList.remove('hidden');
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
};
|
||||
|
||||
const logout = () => {
|
||||
document.cookie = `quarkus-credential=; Max-Age=0;path=/`;
|
||||
window.location.href = "login";
|
||||
// Perform post-logout actions here, such as redirecting back to your login page
|
||||
};
|
||||
|
||||
document.getElementById("loginForm").addEventListener("submit", function (event) {
|
||||
event.preventDefault(); // Prevent the default form submission
|
||||
login(); // Call the login function
|
||||
});
|
||||
|
||||
document.getElementById("logoutButton").addEventListener("click", function () {
|
||||
logout(); // Call the logout function when the logout button is clicked
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
@ -1,56 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Login</title>
|
||||
</head>
|
||||
<body>
|
||||
<form id="loginForm">
|
||||
<label for="username">Username:</label>
|
||||
<input type="text" id="username" name="username" required><br><br>
|
||||
<label for="password">Password:</label>
|
||||
<input type="password" id="password" name="password" required><br><br>
|
||||
<button type="submit">Login</button>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
document.getElementById('loginForm').addEventListener('submit', async (event) => {
|
||||
event.preventDefault();
|
||||
const username = document.getElementById('username').value;
|
||||
const password = document.getElementById('password').value;
|
||||
|
||||
const formData = new URLSearchParams();
|
||||
formData.append('client_id', 'myclient');
|
||||
formData.append('grant_type', 'password');
|
||||
formData.append('username', username);
|
||||
formData.append('password', password);
|
||||
formData.append('client_secret', 'H5BS5BsEmrVZEYlUUHHz04nJrgKhkhxk');
|
||||
|
||||
const response = await fetch('https://localhost:8543/realms/myrealm/protocol/openid-connect/token', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
body: formData
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
const token = data.access_token;
|
||||
|
||||
console.log(token)
|
||||
document.cookie = "jwt=" + token + "; HttpOnly; Secure; Path=/";
|
||||
|
||||
const aaaa = await fetch('/api/admin', {
|
||||
method: 'GET',
|
||||
});
|
||||
|
||||
// window.location.href = '/home';
|
||||
} else {
|
||||
alert('Login failed');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,111 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Practical Details</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<div class="h-screen">
|
||||
<div class="p-8">
|
||||
<div class="flex flex-1 items-stretch justify-between px-4">
|
||||
<h1 class="text-4xl font-bold text-center text-blue-500 mb-4">{name}</h1>
|
||||
<div class="relative ml-3 mb-4">
|
||||
<button id="profile-dropdown-button-breadcrumb" type="button" class="relative flex rounded-full bg-gray-800 text-sm focus:outline-none focus:ring-2 focus:ring-white focus:ring-offset-2 focus:ring-offset-gray-800" aria-expanded="false">
|
||||
<span class="absolute -inset-1.5"></span>
|
||||
<span class="sr-only">Open user menu</span>
|
||||
<img class="h-10 w-10 rounded-full" src="https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80" alt="">
|
||||
</button>
|
||||
<div id="profile-dropdown-breadcrumb" class="dropdown-enter hidden absolute right-0 z-10 mt-2 w-48 origin-top-right rounded-md bg-white py-1 shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none">
|
||||
<a href="#" class="block px-4 py-2 text-sm text-gray-700" role="menuitem">Profile</a>
|
||||
<a href="#" id="logout-button" class="block px-4 py-2 text-sm text-gray-700" role="menuitem">Sign out</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<nav class="bg-gray-100 p-3 rounded-md w-full flex justify-between items-center">
|
||||
<ol class="list-reset flex">
|
||||
<li><a href="#" class="text-blue-600 hover:text-blue-700">Home</a></li>
|
||||
<li><span class="mx-2 text-gray-500">/</span></li>
|
||||
<li><a href="#" class="text-blue-600 hover:text-blue-700">Library</a></li>
|
||||
<li><span class="mx-2 text-gray-500">/</span></li>
|
||||
<li><a href="#" class="text-blue-600 hover:text-blue-700">Data</a></li>
|
||||
<li><span class="mx-2 text-gray-500">/</span></li>
|
||||
<li class="text-gray-500">{id}</li>
|
||||
</ol>
|
||||
</nav>
|
||||
</div>
|
||||
<div class="lg:grid lg:grid-cols-2 w-full h-4/5 p-8 lg:gap-20">
|
||||
<div class=" flex items-center justify-center lg:h-full h-4/6">
|
||||
<iframe src="{pdfLink}" class="ps-8 w-full h-full aspect-video"></iframe>
|
||||
</div>
|
||||
|
||||
<div class="lg:p-12 p-6 lg:mt-0 mt-4">
|
||||
<div>
|
||||
<h1 class="text-4xl font-bold mb-6">Informations</h1>
|
||||
<p class="ml-4 text-xl text-gray-700">Responsable: {respo}</p>
|
||||
<p class="ml-4 text-xl text-gray-700">Date de fin: {endDate}</p>
|
||||
</div>
|
||||
<div class="mt-4">
|
||||
<h1 class="text-4xl font-bold mb-6">Resources</h1>
|
||||
<p class="ml-4 text-xl text-gray-700">acces SSH: ssh todo</p>
|
||||
<p class="ml-4 text-xl text-gray-700">mot de passe: pwd todo</p>
|
||||
</div>
|
||||
<a href="{pdfLink}" target="_blank" class="mt-8 bg-gray-100 rounded-lg shadow-md p-6 flex items-center justify-between">
|
||||
<div>
|
||||
<div class="text-xl text-gray-900">Subject</div>
|
||||
<p class="text-gray-900">Download</p>
|
||||
</div>
|
||||
|
||||
<svg class="h-6 w-6 flex-shrink-0 text-gray-900" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" />
|
||||
<polyline points="7 10 12 15 17 10" />
|
||||
<line x1="12" y1="15" x2="12" y2="3" />
|
||||
</svg>
|
||||
</a>
|
||||
{#if givenLink != ''}
|
||||
<a href="{givenLink}" class="mt-4 bg-gray-100 rounded-lg shadow-md p-6 flex items-center justify-between">
|
||||
<div>
|
||||
<div class="text-xl text-gray-900">Given files</div>
|
||||
<p class="text-gray-900">Download</p>
|
||||
</div>
|
||||
|
||||
<svg class="h-6 w-6 flex-shrink-0 text-gray-900" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" />
|
||||
<polyline points="7 10 12 15 17 10" />
|
||||
<line x1="12" y1="15" x2="12" y2="3" />
|
||||
</svg>
|
||||
</a>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
<script defer>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const profileButton = document.getElementById('profile-dropdown-button-breadcrumb');
|
||||
const dropdownMenu = document.getElementById('profile-dropdown-breadcrumb');
|
||||
const logoutButton = document.getElementById('logout-button');
|
||||
|
||||
profileButton.addEventListener('click', function(event) {
|
||||
dropdownMenu.classList.toggle('hidden');
|
||||
dropdownMenu.classList.toggle('transition', 'ease-out', 'duration-100', 'transform', 'opacity-0', 'scale-95');
|
||||
dropdownMenu.classList.toggle('transition', 'ease-in', 'duration-75', 'transform', 'opacity-100', 'scale-100');
|
||||
event.stopPropagation();
|
||||
});
|
||||
|
||||
logoutButton.addEventListener('click', function(event) {
|
||||
window.location.replace("https://localhost:8543/realms/myrealm/protocol/openid-connect/logout");
|
||||
});
|
||||
|
||||
document.addEventListener('click', function() {
|
||||
if (!dropdownMenu.classList.contains('hidden')) {
|
||||
dropdownMenu.classList.add('hidden');
|
||||
}
|
||||
});
|
||||
|
||||
dropdownMenu.addEventListener('click', function(event) {
|
||||
event.stopPropagation();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
1
src/main/webui
Submodule
1
src/main/webui
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit de26f9f69dcce2b0b082f87d1954276de67da483
|
Loading…
x
Reference in New Issue
Block a user