Skip to content

Commit bb6dd00

Browse files
committed
Tiny changes: changed name of folder demande, and fixed bug creation of formation with no image with just a single line (!=null), and cascade remove demandes when i delete formation, thank you for visiting!
1 parent bcf64c9 commit bb6dd00

15 files changed

+30
-41
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { NgModule } from '@angular/core';
2+
import { RouterModule, Routes } from '@angular/router';
3+
4+
5+
const routes: Routes = [
6+
7+
];
8+
9+
@NgModule({
10+
imports: [RouterModule.forChild(routes)],
11+
exports: [RouterModule],
12+
})
13+
export class DemandeRoutingModule {}

angular-frontend/src/app/Admin/formation copy/demande.module.ts angular-frontend/src/app/Admin/demande/demande.module.ts

-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ import { DemandeComponent } from './list-demandes/list-demandes.component';
88
@NgModule({
99
declarations: [
1010

11-
// DashboardComponent,
1211
DemandeComponent,
13-
// OneDemandeComponent,
1412
],
1513
imports: [
1614
CommonModule,

angular-frontend/src/app/Admin/formation copy/demande.service.ts angular-frontend/src/app/Admin/demande/demande.service.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class DemandeService {
2626
}
2727

2828

29-
// POST ADD GETS CALLED IN HOME
29+
// ADD DEMANDE, first we add formateur to his DB then we take him and add it to demande db
3030
async addDemande(request: any): Promise<any> {
3131
console.log("addDemande service " + request);
3232

@@ -36,11 +36,9 @@ export class DemandeService {
3636
// Perform the formateur/add request
3737
const response = await axios.post(`/formateur/add`, request.formateur, { headers });
3838

39-
// Handle the response
40-
this.formatorData = response.data;
39+
this.formatorData = response.data;
4140
console.log("/formateur/add RESPONSE " + this.formatorData.name);
4241

43-
// Build the request data for /demande/add
4442
const reqData = {
4543
id: Math.random(),
4644
formateur: this.formatorData,
@@ -55,7 +53,7 @@ export class DemandeService {
5553
return demandeResponse;
5654
} catch (error) {
5755
console.error(error);
58-
throw error; // Rethrow the error to be caught by the calling function/component
56+
throw error;
5957
}
6058
}
6159

angular-frontend/src/app/Admin/formation copy/list-demandes/list-demandes.component.ts angular-frontend/src/app/Admin/demande/list-demandes/list-demandes.component.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class DemandeComponent implements OnInit {
1919
) {}
2020

2121
ngOnInit() {
22-
this.getAllDemandes(); // on loand we call the function below
22+
this.getAllDemandes(); // on load we call the function below
2323
this.permission = this.userAuthsService.isAdmin();
2424
}
2525

@@ -42,7 +42,6 @@ export class DemandeComponent implements OnInit {
4242
}
4343
fetchImageForDemande(Demande: any): void {
4444
this.DemandeService.getDemandeById(Demande.id).then((response) => {
45-
// Assuming the image data is in response.data.image_data
4645
Demande.image_data = response.data.image_data;
4746
});
4847
}

angular-frontend/src/app/Admin/formation copy/demande-routing.module.ts

-23
This file was deleted.

angular-frontend/src/app/components/sidebar/sidebar.component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Component, OnInit } from '@angular/core';
2-
import { DemandeService } from 'app/Admin/formation copy/demande.service';
2+
import { DemandeService } from 'app/Admin/demande/demande.service';
33
import { UserAuthsService } from 'app/services/user-auths.service';
44

55
declare const $: any;
@@ -9,7 +9,7 @@ interface RouteInfo {
99
title: string;
1010
icon: string;
1111
class: string;
12-
role: boolean;
12+
role: boolean;
1313
}
1414

1515
export let ROUTES: RouteInfo[] = [];

angular-frontend/src/app/home/inscrire-formateur/inscrire-formateur.component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Component, OnInit } from '@angular/core';
22
import { FormControl, FormGroup, Validators } from '@angular/forms';
33
import { ActivatedRoute, Router } from '@angular/router';
4-
import { Demande } from 'app/Admin/formation copy/demande';
5-
import { DemandeService } from 'app/Admin/formation copy/demande.service';
4+
import { Demande } from 'app/Admin/demande/demande';
5+
import { DemandeService } from 'app/Admin/demande/demande.service';
66
import { Formation } from 'app/Admin/formation/formation';
77
import { FormationService } from 'app/Admin/formation/formation.service';
88
import { Formator } from 'app/model/formator.model';

angular-frontend/src/app/layouts/admin-layout/admin-layout.component.html

+1
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@
1919
</div>
2020
</div>
2121
</div>
22+

angular-frontend/src/app/layouts/admin-layout/admin-layout.routing.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { CalendarComponent } from 'app/Admin/calendar/calendar.component';
1616
import { Logout } from '../../Admin/logout/logout.component';
1717
import { AdminLayoutComponent } from './admin-layout.component';
1818
import { NomFormationComponent } from 'app/Admin/formation/nom-formation/nom-formation.component';
19-
import { DemandeComponent } from 'app/Admin/formation copy/list-demandes/list-demandes.component';
19+
import { DemandeComponent } from 'app/Admin/demande/list-demandes/list-demandes.component';
2020
// import { OneDemandeComponent } from 'app/Admin/formation copy/one-demande/one-demande.component';
2121

2222
export const AdminLayoutRoutes: Routes = [

springboot-backend/src/main/java/univ/iwa/model/Formation.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55

66
import com.fasterxml.jackson.annotation.JsonIgnore;
77

8+
import jakarta.persistence.CascadeType;
89
import jakarta.persistence.Column;
910
import jakarta.persistence.Entity;
11+
import jakarta.persistence.FetchType;
1012
import jakarta.persistence.GeneratedValue;
1113
import jakarta.persistence.GenerationType;
1214
import jakarta.persistence.Id;
@@ -49,10 +51,10 @@ public class Formation {
4951
private String imageName;
5052

5153
// Formation accepts one and only one formateur, formateur can be in many formation, has a list of formations he is affected to
52-
@ManyToOne()
54+
@ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH})
5355
private UserInfo formateur;
5456

55-
@ManyToOne()
57+
@ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH})
5658
private Entreprise entreprise;
5759

5860
@ManyToMany
@@ -63,7 +65,7 @@ public class Formation {
6365
)
6466
private List<Individu> individus;
6567

66-
@OneToMany(mappedBy = "formation")
68+
@OneToMany(mappedBy = "formation", cascade = CascadeType.REMOVE)
6769
@JsonIgnore
6870
List<Demande> demandes;
6971
}

springboot-backend/src/main/java/univ/iwa/service/FormationService.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,11 @@ public List<Individu> findIndividusByFormationId( Long id) {
5050

5151
public Formation addFormation(Formation formation, MultipartFile imageFile) throws java.io.IOException {
5252
try {
53+
if(imageFile!=null) {
5354
formation.setImageName(imageFile.getOriginalFilename());
5455

5556
byte[] imageData = imageFile.getBytes();
56-
formation.setImageData(imageData);
57+
formation.setImageData(imageData);}
5758

5859
return formationRepository.save(formation);
5960
} catch (IOException e) {

0 commit comments

Comments
 (0)