Compare commits

...

21 Commits

Author SHA1 Message Date
eaf7ad0a45
Merge branch 'master' into tonitch/front/serviceInscription
All checks were successful
Build and test backend / Build-backend (pull_request) Successful in 1m57s
Build and test backend / Test-backend (pull_request) Successful in 1m55s
Build and test FrontEnd / Build-frontend (pull_request) Successful in 20s
2024-03-06 23:11:55 +01:00
0e7c18e088 Base for rest api utilisation (#53)
All checks were successful
Build and test backend / Build-backend (push) Successful in 2m11s
Build and test backend / Test-backend (push) Successful in 1m23s
deploy to production / deploy-frontend (push) Successful in 23s
deploy to production / deploy-backend (push) Successful in 2m18s
Build and test FrontEnd / Build-frontend (push) Successful in 21s
The restConsumer will be the base, then I will create a js file per
"object" (for instance there will be users.js with all endpoints for
users using the restConsumer.js)

Reviewed-on: #53
Reviewed-by: Wal <karpinskiwal@gmail.com>
Reviewed-by: Maxime <231026@umons.ac.be>
Co-authored-by: Anthony Debucquoy <debucquoy.anthony@gmail.com>
Co-committed-by: Anthony Debucquoy <debucquoy.anthony@gmail.com>
2024-03-06 21:38:09 +01:00
6df81a66f2
Fixing i18n path
All checks were successful
Build and test backend / Build-backend (pull_request) Successful in 1m58s
Build and test backend / Test-backend (pull_request) Successful in 1m56s
Build and test FrontEnd / Build-frontend (pull_request) Successful in 19s
Build and test backend / Build-backend (push) Successful in 2m5s
Build and test backend / Test-backend (push) Successful in 1m17s
deploy to production / deploy-frontend (push) Successful in 21s
deploy to production / deploy-backend (push) Successful in 2m17s
Build and test FrontEnd / Build-frontend (push) Successful in 20s
2024-03-06 14:41:03 +01:00
a253a5152d
My life is a potato
All checks were successful
Build and test backend / Build-backend (push) Successful in 2m9s
Build and test backend / Test-backend (push) Successful in 1m20s
deploy to production / deploy-frontend (push) Successful in 22s
deploy to production / deploy-backend (push) Successful in 2m17s
Build and test FrontEnd / Build-frontend (push) Successful in 20s
2024-03-06 11:20:29 +01:00
38ed249150
using unix socket
All checks were successful
Build and test backend / Build-backend (push) Successful in 2m9s
Build and test backend / Test-backend (push) Successful in 1m18s
Build and test FrontEnd / Build-frontend (push) Successful in 21s
deploy to production / deploy-frontend (push) Successful in 20s
deploy to production / deploy-backend (push) Successful in 1m33s
2024-03-06 10:52:11 +01:00
212ab638a2
allow unix socket connection for database in prod
All checks were successful
Build and test backend / Build-backend (push) Successful in 2m3s
Build and test backend / Test-backend (push) Successful in 1m16s
deploy to production / deploy-frontend (push) Successful in 22s
deploy to production / deploy-backend (push) Successful in 2m17s
Build and test FrontEnd / Build-frontend (push) Successful in 21s
2024-03-06 10:01:55 +01:00
b72c0a8e17 Merge pull request 'LeoMoulin/Backend/Leo' (#55) from LeoMoulin/Backend/Leo into master
All checks were successful
Build and test backend / Build-backend (push) Successful in 2m2s
Build and test backend / Test-backend (push) Successful in 1m19s
deploy to production / deploy-frontend (push) Successful in 21s
deploy to production / deploy-backend (push) Successful in 2m13s
Build and test FrontEnd / Build-frontend (push) Successful in 19s
Reviewed-on: #55
2024-03-05 23:41:59 +01:00
bb0e6783ec correction commit
All checks were successful
Build and test backend / Build-backend (pull_request) Successful in 2m3s
Build and test backend / Test-backend (pull_request) Successful in 1m53s
Build and test FrontEnd / Build-frontend (pull_request) Successful in 19s
2024-03-05 23:34:49 +01:00
57de070eb1
Merge branch 'master' into LeoMoulin/Backend/Leo
All checks were successful
Build and test backend / Build-backend (pull_request) Successful in 1m55s
Build and test backend / Test-backend (pull_request) Successful in 1m52s
Build and test FrontEnd / Build-frontend (pull_request) Successful in 24s
2024-03-05 20:30:00 +01:00
24a54bdee4 removing useless function & calling reloadLang properly (#52)
All checks were successful
Build and test backend / Build-backend (push) Successful in 2m8s
Build and test backend / Test-backend (push) Successful in 1m25s
deploy to production / deploy-frontend (push) Successful in 32s
deploy to production / deploy-backend (push) Successful in 2m17s
Build and test FrontEnd / Build-frontend (push) Successful in 25s
Reviewed-on: #52
Reviewed-by: Maxime <231026@umons.ac.be>
Reviewed-by: Wal <karpinskiwal@gmail.com>
Co-authored-by: Anthony Debucquoy <debucquoy.anthony@gmail.com>
Co-committed-by: Anthony Debucquoy <debucquoy.anthony@gmail.com>
2024-03-05 20:28:23 +01:00
c27c3ac9fb - Ajout des champs password et salt dans user
All checks were successful
Build and test backend / Build-backend (pull_request) Successful in 2m25s
Build and test backend / Test-backend (pull_request) Successful in 2m1s
Build and test FrontEnd / Build-frontend (pull_request) Successful in 25s
Build and test FrontEnd / Test-frontend (pull_request) Successful in 23s
- Ajout de la table token
- Ajout des foreign keys
2024-03-05 14:14:56 +01:00
dcd1fad6ac
solve access to /login
All checks were successful
Build and test backend / Build-backend (pull_request) Successful in 1m55s
Build and test backend / Test-backend (pull_request) Successful in 1m49s
Build and test FrontEnd / Build-frontend (pull_request) Successful in 20s
Build and test backend / Build-backend (push) Successful in 2m6s
Build and test backend / Test-backend (push) Successful in 1m23s
deploy to production / deploy-frontend (push) Successful in 22s
deploy to production / deploy-backend (push) Successful in 2m16s
Build and test FrontEnd / Build-frontend (push) Successful in 20s
Vite won't export not specified page, so I specified it in the config.
2024-03-05 10:57:48 +01:00
cc89d7f5b7 added ResponseEntity and TODOs 2024-03-04 23:35:15 +01:00
36f1ab3203 added .idea/ to .gitignore
All checks were successful
Build and test backend / Build-backend (push) Successful in 2m8s
Build and test backend / Test-backend (push) Successful in 1m17s
deploy to production / deploy-frontend (push) Successful in 21s
deploy to production / deploy-backend (push) Successful in 2m13s
Build and test FrontEnd / Build-frontend (push) Successful in 21s
2024-03-04 21:30:16 +01:00
45bfe08c9a added .idea/ to .gitignore 2024-03-04 21:27:22 +01:00
6c688dab59 added Admin and Secretary 2024-03-04 21:25:44 +01:00
684c3095eb - Changement des noms de variables
- Ajout des getters/setters appropriés
- Ajout des constructeur nécessaires
2024-03-03 17:42:26 +01:00
bbe1f9767c Merge remote-tracking branch 'origin/LeoMoulin/Backend/Leo' into LeoMoulin/Backend/Leo 2024-03-03 17:05:09 +01:00
3956037ab5 example backend api with user table 2024-03-02 23:33:48 +01:00
25019d8b91 Suppression de TeacherOwnerCourse.java et ajout d'un booléen Owned dans TeacherGivenCourse.java 2024-03-01 01:47:11 +01:00
69c3a3b965 Implémentation des différentes classes représentants les tables 2024-02-29 20:08:12 +01:00
19 changed files with 507 additions and 14 deletions

View File

@ -53,5 +53,5 @@ jobs:
scp -o "StrictHostKeyChecking=no" -o "LogLevel=ERROR" -i key -r * ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:api/
- name: restarting the backend
run: |
ssh -o "StrictHostKeyChecking=no" -o "LogLevel=ERROR" -i key ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "cd api/backend && docker build -t clyde/backend . && docker rm clyde_backend_prod -f || true && docker run --rm -d --name clyde_backend_prod -p 4000:8080 clyde/backend && docker image prune -f"
ssh -o "StrictHostKeyChecking=no" -o "LogLevel=ERROR" -i key ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} 'cd api/backend && docker build -t clyde/backend . && docker rm clyde_backend_prod -f || true && docker run --rm -d -u $(id -u clyde):$(id -g clyde) -v /var/run/postgresql:/var/run/postgresql --name clyde_backend_prod -p 4000:8080 clyde/backend && docker image prune -f'
- run: echo "The backend has been deployed. running at https://clyde.herisson.ovh/api"

1
.gitignore vendored
View File

@ -6,3 +6,4 @@ build
.project
.settings
.idea/

View File

@ -20,6 +20,8 @@ dependencies {
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-mail")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("com.kohlschutter.junixsocket:junixsocket-core:2.9.0")
// implementation("org.springframework.session:spring-session-jdbc")
developmentOnly("org.springframework.boot:spring-boot-devtools")
developmentOnly("org.springframework.boot:spring-boot-docker-compose")

View File

@ -0,0 +1,44 @@
package ovh.herisson.Clyde.EndPoints;
import org.springframework.http.HttpStatus;
import org.springframework.http.HttpStatusCode;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import ovh.herisson.Clyde.Repositories.UserRepository;
import ovh.herisson.Clyde.Tables.User;
@RestController
@CrossOrigin(origins = "http://localhost:5173")
public class UserController {
private final UserRepository userRepo;
public UserController(UserRepository userRepo){
this.userRepo = userRepo;
}
@GetMapping("/user")
public ResponseEntity<User> getUsers(@RequestHeader("Authorization") String token){
//TODO
// Get the token thru the data base
// tokenRepo.findToken(token) => User userFromToken
// si role != secretary => return error : ResponseEntity<User>(null, HttpStatus.UNAUTHORIZED)
return new ResponseEntity<User>(/**userRepo.findById(userFromToken.id),**/ HttpStatus.OK);
}
@PostMapping("/user")
public ResponseEntity<String> postUser(@RequestBody User user){
userRepo.save(user);
return new ResponseEntity<String>(String.format("Account created with ID:%s",user.getRegNo()),HttpStatus.CREATED);
}
@GetMapping("/users")
public Iterable<User> getAllUsers(){//TODO ne l'accepter que si c'est le secrétariat
return userRepo.findAll();
}
}

View File

@ -29,7 +29,7 @@ public class JdbcConfig {
public DataSource psqlSourceProd(){
DriverManagerDataSource source = new DriverManagerDataSource();
source.setDriverClassName("org.postgresql.Driver");
source.setUrl("jdbc:postgresql://localhost:5432/clyde");
source.setUrl("jdbc:postgresql:clyde?socketFactory=org.newsclub.net.unix.AFUNIXSocketFactory$FactoryArg&socketFactoryArg=/var/run/postgresql/.s.PGSQL.5432");
source.setUsername("clyde");
return source;

View File

@ -0,0 +1,16 @@
package ovh.herisson.Clyde.Repositories;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import ovh.herisson.Clyde.Tables.User;
import java.util.List;
public interface UserRepository extends CrudRepository<User, Long> {
User findById(long id);
/**
@Query(value = "select a.* from Users a ",nativeQuery = true)
Iterable<User> findAllUsers();**/
}

View File

@ -0,0 +1,52 @@
package ovh.herisson.Clyde.Tables;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
@Entity
public class Course {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int courseID;
private int credits;
private String title;
private String faculty;
public Course(int credits, String title, String faculty){
this.credits = credits;
this.title = title;
this.faculty = faculty;
}
public Course() {}
public int getCourseID() {
return courseID;
}
public int getCredits() {
return credits;
}
public void setCredits(int credits){
this.credits = credits;
}
public String getFaculty() {
return faculty;
}
public void setFaculty(String faculty){
this.faculty = faculty;
}
public String getTitle() {
return title;
}
public void setTitle(String title){
this.title = title;
}
}

View File

@ -0,0 +1,43 @@
package ovh.herisson.Clyde.Tables;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
@Entity
public class Cursus {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int cursusId;
private int year;
private String option;
public Cursus(int year, String option){
this.year = year;
this.option = option;
}
public Cursus() {}
public int getCursusId(){
return this.cursusId;
}
public int getYear(){
return this.year;
}
public void setYear(int year){
this.year = year;
}
public String getOption(){
return this.option;
}
public void setOption(String option){
this.option = option;
}
}

View File

@ -0,0 +1,43 @@
package ovh.herisson.Clyde.Tables;
import jakarta.persistence.*;
@Entity
public class CursusCourse {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
@JoinColumn(name = "Cursus")
private int cursusId;
@JoinColumn(name = "Course")
private int courseId;
public CursusCourse(int cursusId, int courseId){
this.cursusId = cursusId;
this.courseId = courseId;
}
public CursusCourse() {}
public int getId() {
return id;
}
public int getCourseId() {
return courseId;
}
public void setCourseId(int courseId){
this.courseId = courseId;
}
public int getCursusId() {
return cursusId;
}
public void setCursusId(int cursusId) {
this.cursusId = cursusId;
}
}

View File

@ -0,0 +1,8 @@
package ovh.herisson.Clyde.Tables;
public enum Role {
Teacher,
Student,
Admin,
Secretary;
}

View File

@ -0,0 +1,41 @@
package ovh.herisson.Clyde.Tables;
import jakarta.persistence.*;
@Entity
public class Secretary {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
@JoinColumn(name = "Users")
private int regNo;
private String faculty;
public Secretary(int regNo, String faculty){
this.regNo = regNo;
this.faculty = faculty;
}
public Secretary() {}
public int getId() {
return id;
}
public int getRegNo() {
return regNo;
}
public void setRegNo(int regNo) {
this.regNo = regNo;
}
public String getFaculty() {
return faculty;
}
public void setFaculty(String faculty) {
this.faculty = faculty;
}
}

View File

@ -0,0 +1,55 @@
package ovh.herisson.Clyde.Tables;
import jakarta.persistence.*;
@Entity
public class TeacherGivenCourse {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
@JoinColumn(name = "Users")
private int regNo;
@JoinColumn(name = "Course")
private int courseId;
//This flag helps make the difference between an assistant or a Teacher (who owns the course)
private boolean owned;
public TeacherGivenCourse(int regNo, int courseId, boolean owned){
this.regNo = regNo;
this.courseId = courseId;
this.owned = owned;
}
public TeacherGivenCourse() {}
public int getId() {
return id;
}
public int getRegNo() {
return regNo;
}
public void setRegNo(int regNo) {
this.regNo = regNo;
}
public int getCourseId() {
return courseId;
}
public void setCourseId(int courseId) {
this.courseId = courseId;
}
public boolean isOwned() {
return owned;
}
public void setOwned(boolean owned) {
this.owned = owned;
}
}

View File

@ -0,0 +1,40 @@
package ovh.herisson.Clyde.Tables;
import jakarta.persistence.*;
@Entity
public class Token {
@GeneratedValue(strategy = GenerationType.AUTO)
@Id
private int id;
@JoinColumn(name ="Users")
private int regNo;
private String token;
public Token(int regNo, String token){
this.regNo = regNo;
this.token = token;
}
public Token(){}
public int getId() {
return id;
}
public int getRegNo() {
return regNo;
}
public void setRegNo(int regNo) {
this.regNo = regNo;
}
public String getToken(){
return token;
}
public void setToken(String data) {
this.token = data;
}
}

View File

@ -0,0 +1,103 @@
package ovh.herisson.Clyde.Tables;
import jakarta.persistence.*;
import java.util.Date;
//Classe représentant un utilisateur l'attribut password demande surement un peu de rafinement niveau sécurité
//et l'attribut tokenApi doit encore être ajouté vu qu'il faut en discuter
@Entity
//Je rajoute un s au nom de la table pour éviter les conflits avec les mots réservés
@Table(name = "Users")
public class User {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int regNo;
private String lastName;
private String firstName;
private String email;
private String address;
private String country;
private Date birthDate;
private ovh.herisson.Clyde.Tables.Role role;
private String password;
public User(String lastName, String firstName, String email, String address, String country, Date birthDate, Role role, String password){
this.lastName = lastName;
this.firstName = firstName;
this.email = email;
this.address = address;
this.country = country;
this.birthDate = birthDate;
this.role = role;
this.password = password;
}
public User() {}
public int getRegNo(){
return this.regNo;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getAddress() {
return address;
}
public void setAddress(String adress) {
this.address = adress;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public Date getBirthDate() {
return birthDate;
}
public void setBirthDate(Date birthDate) {
this.birthDate = birthDate;
}
public ovh.herisson.Clyde.Tables.Role getRole() {
return role;
}
public void setRole(ovh.herisson.Clyde.Tables.Role role) {
this.role = role;
}
public String getPassword(){
return password;
}
public void setPassword(String password) {
this.password = password;
}
}

View File

@ -0,0 +1,42 @@
package ovh.herisson.Clyde.Tables;
import jakarta.persistence.*;
@Entity
public class UserCursus {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
@JoinColumn(name = "Users")
private int regNo;
@JoinColumn(name = "Cursus")
private int cursusId;
public UserCursus(int regNo, int cursusId){
this.regNo = regNo;
this.cursusId = cursusId;
}
public UserCursus() {}
public int getId() {
return id;
}
public int getRegNo() {
return regNo;
}
public void setRegNo(int regNo) {
this.regNo = regNo;
}
public int getCursusId() {
return cursusId;
}
public void setCursusId(int cursusId) {
this.cursusId = cursusId;
}
}

View File

@ -1 +1,2 @@
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect

View File

@ -24,7 +24,7 @@ let langs;
*
* @return :string The translated text
*/
function i18n(key, options) {
export default function i18n(key, options) {
let ret = langs[key];
if(options != null){
for (let key in options) {
@ -34,14 +34,6 @@ function i18n(key, options) {
return ret;
}
async function reloadLang(){
langs = await loadLangs();
}
reloadLang();
export default i18n;
//
// Those functions are utility functions use by previous exported functions.
//
@ -51,11 +43,11 @@ export default i18n;
* @param select the language to load. could be null to fetch the cookies for an answer
* if nothing is found. default to EN.txt
*/
async function loadLangs(lang){
export async function loadLangs(lang){
lang = lang != null ? lang : getCookie("lang");
lang = lang != "" ? lang : default_lang;
const filename = "./i18n/" + lang.toUpperCase() + ".txt";
const filename = "/i18n/" + lang.toUpperCase() + ".txt";
const content = await (await fetch(filename)).text();
const lines = content.split("\n");
@ -66,5 +58,6 @@ async function loadLangs(lang){
filteredLines[line.substr(0, split)] = line.substr(split+1, line.length);
};
}
return filteredLines;
langs = filteredLines;
}
await loadLangs();

View File

@ -8,6 +8,15 @@ export default defineConfig({
plugins: [
vue(),
],
build: {
rollupOptions:{
input:{
main: './index.html',
login: './login/index.html'
}
}
},
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))