diff --git a/src/app/members/account/account-routing.module.ts b/src/app/members/account/account-routing.module.ts index 3ef262c0deeee4e5fca87c1cf66a6266c4f9683a..a56759b6926a957bf9001404ed53888267e8f380 100644 --- a/src/app/members/account/account-routing.module.ts +++ b/src/app/members/account/account-routing.module.ts @@ -1,6 +1,7 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; +//Components import { AccountComponent } from './account.component'; import {MyDataComponent} from './my-data/my-data.component' import {EditDataComponent} from './edit-data/edit-data.component' diff --git a/src/app/members/account/account.component.ts b/src/app/members/account/account.component.ts index 2c1e6716a34053b823fee5a3d6953167b5aea29b..033dd584d4026f58c8b83128ef6e9209996fc9fc 100644 --- a/src/app/members/account/account.component.ts +++ b/src/app/members/account/account.component.ts @@ -18,7 +18,7 @@ export class AccountComponent implements OnInit { ]; ngOnInit() { - this.router.navigate(['./membres/compte/donnees']) + this.router.navigate(['./membres/compte/modifier_donnees']) } } diff --git a/src/app/members/account/account.module.ts b/src/app/members/account/account.module.ts index 8b448259b93d0fe74a1c42b47b34e2daeb550c9a..8d19200616ce6f02f7b5efd89ca1c32656396091 100644 --- a/src/app/members/account/account.module.ts +++ b/src/app/members/account/account.module.ts @@ -34,7 +34,9 @@ import {MyDataComponent} from './my-data/my-data.component' import {EditDataComponent} from './edit-data/edit-data.component' import {MyFileComponent} from './my-file/my-file.component' import {UploadComponent} from './upload/upload.component' -import { DialogComponent } from './upload/dialog/dialog.component'; +import { StudentChartDialogComponent } from './upload/dialog/studentChartDialog.component' +import {ImageRightsDialogComponent} from './upload/dialog/imageRightsDialog.component' +import {ParentalAuthDialogComponent} from './upload/dialog/parentalAuthDialog.component' @NgModule({ imports: [ CommonModule, @@ -69,8 +71,10 @@ import { DialogComponent } from './upload/dialog/dialog.component'; EditDataComponent, MyFileComponent, UploadComponent, - DialogComponent + ParentalAuthDialogComponent, + ImageRightsDialogComponent, + StudentChartDialogComponent ], - entryComponents:[DialogComponent] + entryComponents:[ParentalAuthDialogComponent,ImageRightsDialogComponent,StudentChartDialogComponent] }) export class AccountModule { } diff --git a/src/app/members/account/core/personnal-data.model.ts b/src/app/members/account/core/personnal-data.model.ts index 1772e4390b554ea4adbc492a61b87d98ca21a084..b0e09c6ca11f384662abcd433febbdaad63f7d26 100644 --- a/src/app/members/account/core/personnal-data.model.ts +++ b/src/app/members/account/core/personnal-data.model.ts @@ -1,9 +1,5 @@ import { User, UserAdapter, IAdapter } from 'app/core'; - - - - export class PersonnalDataSchema { user : User; firstName:string; @@ -19,7 +15,6 @@ export class PersonnalDataSchema { parentsEmail:string; school:string; grade:string; - section:string; specialTeaching:string; scholarship:string; fatherActivity:string; @@ -57,7 +52,6 @@ export class PersonnalDataAdapter implements IAdapter<PersonnalData> { parentsEmail:data.parentsEmail, school:data.school, grade:data.grade, - section:data.section, specialTeaching:data.specialTeaching, scholarship:data.scholarship, fatherActivity:data.fatherActivity, @@ -80,7 +74,6 @@ export class PersonnalDataAdapter implements IAdapter<PersonnalData> { parentsEmail:obj.parentsEmail, school:obj.school, grade:obj.grade, - section:obj.section, specialTeaching:obj.specialTeaching, scholarship:obj.scholarship, fatherActivity:obj.fatherActivity, diff --git a/src/app/members/account/core/personnal-data.service.ts b/src/app/members/account/core/personnal-data.service.ts index da7817e833287bad83bec532e81900925020494d..a179cee59e0297719c9771f1d216531ce9f9624e 100644 --- a/src/app/members/account/core/personnal-data.service.ts +++ b/src/app/members/account/core/personnal-data.service.ts @@ -12,27 +12,31 @@ import {PersonnalDataAdapter,PersonnalData} from './personnal-data.model' }) export class PersonnalDataService extends ApiService { - private baseUrl = this.apiUrl + 'personnalData/'; + //api url + private baseUrl = this.apiUrl + 'students'; private adapter = new PersonnalDataAdapter(); constructor( private http: HttpClient, - ) { super(); } + ) { super(); console.log(this.baseUrl) } - + //get personnalData by user get(filters: any): Observable<PersonnalData> { const url = this.baseUrl; return this.http.get(url, { params: filters }).pipe( - map((data: any) => data.map(item => this.adapter.adapt(item))), + map((data: any) => { + console.log() + return data.map(item => this.adapter.adapt(item))}), ); } + forUser(userId: number): Observable<PersonnalData> { - return this.get({ user: String(userId) }); + return this.get({ user: String(userId)}); } - + //edit personnalData for a user edit(personnalData: PersonnalData): Observable<any> { const body: any = this.adapter.encode(personnalData); - return this.http.patch(this.baseUrl, body); + return this.http.post(this.baseUrl, body); } } @@ -42,7 +46,7 @@ export class PersonnalDataService extends ApiService { export class PersonnalDataResolver implements Resolve<PersonnalData>{ constructor(private service: PersonnalDataService, private auth: AuthService) { } - + //fetch user resolve() { const user = this.auth.getUserSnapshot(); return this.service.forUser(user.id); diff --git a/src/app/members/account/edit-data/edit-data.component.html b/src/app/members/account/edit-data/edit-data.component.html index c8454422f5772ee3bd79bf9bc64302b48d5194ef..6b335198c64bfcbe7f3f39d8450b9053e063ffb8 100644 --- a/src/app/members/account/edit-data/edit-data.component.html +++ b/src/app/members/account/edit-data/edit-data.component.html @@ -56,7 +56,13 @@ <p class="text-center">Informations scolaires</p> <mat-form-field class="full-width" > - <input matInput type="text" formControlName="school" placeholder="Lycée" required> + <mat-label>Etablissement </mat-label> + <mat-select formControlName="school"> + <mat-option *ngFor="let school of possibleSchools" [value]="school.id">{{ school.name }}</mat-option> + </mat-select> + </mat-form-field> + <mat-form-field class="full-width" > + <input matInput type="text" formControlName="specialTeaching" placeholder="Enseignements de spécialité (entrer 'aucun' si jamais vous n'etes pas concerné)" > </mat-form-field> <div class="form-group"> <mat-form-field class="horizontal-display"> @@ -68,32 +74,17 @@ <mat-option value="terminale">Terminale</mat-option> </mat-select> </mat-form-field> - - <mat-form-field class="horizontal-display"> - <mat-label>Section</mat-label> - <mat-select formControlName="section"> - <mat-option value="none">Aucune</mat-option> - <mat-option value="s">S</mat-option> - <mat-option value="es" >ES</mat-option> - <mat-option value="l">L</mat-option> - <mat-option value="sti2d">STI2D</mat-option> - <mat-option value="sti2a">STI2A</mat-option> - <mat-option value="stmg">STMG</mat-option> + + <mat-form-field> + <mat-label>Boursier </mat-label> + <mat-select formControlName="scholarship"> + <mat-option *ngFor="let scholarship of possibleScholarships" [value]="scholarship.id">{{ scholarship.name }}</mat-option> </mat-select> </mat-form-field> + </div> - - - <mat-form-field class="full-width" > - <input matInput type="text" formControlName="specialTeaching" placeholder="Enseignement de spécialité" required> - </mat-form-field> - <mat-form-field> - <mat-label>Boursier </mat-label> - <mat-select formControlName="scholarship"> - <mat-option *ngFor="let scholarship of possibleScholarships" [value]="scholarship.id">{{ scholarship.name }}</mat-option> - </mat-select> - </mat-form-field> + <p class="text-center">Informations parentales</p> <div class="form-group"> @@ -126,8 +117,8 @@ </div> - <div class="text-center"> - <button mat-raised-button color="primary" [disabled]="!formGroup.valid || loading"> + <div class="text-center"> + <button mat-raised-button color="primary" [disabled]="loading"> Modifier <app-load-spinner *ngIf="loading" [block]="false"></app-load-spinner> </button> diff --git a/src/app/members/account/edit-data/edit-data.component.ts b/src/app/members/account/edit-data/edit-data.component.ts index 208d6f07ffd19b7c14f01d6f8777848c34cf5a55..cf38e97f96d84ac2590ef647e1b2286bda6fc541 100644 --- a/src/app/members/account/edit-data/edit-data.component.ts +++ b/src/app/members/account/edit-data/edit-data.component.ts @@ -39,6 +39,18 @@ export class EditDataComponent implements OnInit { {id:"other",name:"Autre"} ] + public possibleSchools = [ + {id:"Jean Perrin (Longjumeau)", name:"Jean Perrin (Longjumeau)"}, + {id:"Robert Doisneau (Corbeil-Essonnes)",name:"Robert Doisneau (Corbeil-Essonnes)"}, + {id:"Henri Matisse (Montreuil)",name:"Henri Matisse (Montreuil)"}, + {id:"Jean Jaurès (Montreuil)",name:"Jean Jaurès (Montreuil)"}, + {id:"Charles Péguy (Bobigny)",name:"Charles Péguy (Bobigny)"}, + {id:"Jean Jaurès (Chatenay-Malabry)",name:"Jean Jaurès (Chatenay-Malabry)"}, + {id:"Parc des Loges (Evry)",name:"Parc des Loges (Evry)"}, + {id:"Jean-Baptiste Corot (Savigny-sur-Orge)",name:"Jean-Baptiste Corot (Savigny-sur-Orge)"}, + {id:"Gaspard Monge (Savigny-sur-Orge)",name:"Gaspard Monge (Savigny-sur-Orge)"}, + ] + public possibleScholarships = [ {id:"echelon1",name:"Oui, échelon 1"}, {id:"echelon2",name:"Oui, échelon 2"}, @@ -63,7 +75,7 @@ export class EditDataComponent implements OnInit { ngOnInit() { - //this.personnalData = this.route.snapshot.data['personnalData']; + // this.personnalData = this.route.snapshot.data['personnalData']; //On enlevera l'exemple quand on se connectera au back this.personnalData = { user: new User({id:0}), @@ -80,7 +92,6 @@ export class EditDataComponent implements OnInit { parentsEmail:"email@email.com", school:"ecole", grade:"troisieme", - section:"es", specialTeaching:"specialite", scholarship:"echelon2", fatherActivity:"farmer", @@ -108,7 +119,6 @@ export class EditDataComponent implements OnInit { parentsEmail:[this.personnalData.parentsEmail,Validators.email], school:this.personnalData.school, grade:this.personnalData.grade, - section:this.personnalData.section, specialTeaching:this.personnalData.specialTeaching, scholarship:this.personnalData.scholarship, fatherActivity:this.personnalData.fatherActivity, @@ -121,18 +131,18 @@ export class EditDataComponent implements OnInit { submit(){ //this.loading = true; - const {firstName,lastName,gender,nationality,adressNumber,street,zipCode,city,personnalPhone,parentsPhone,parentsEmail,school,grade,section,specialTeaching,scholarship,fatherActivity,motherActivity,parentsStatus,dependantsNumber} = this.formGroup.value; - const personnalData: PersonnalData = {user:this.personnalData.user,firstName,lastName,gender,nationality,adressNumber,street,zipCode,city,personnalPhone,parentsPhone,parentsEmail,school,grade,section,specialTeaching,scholarship,fatherActivity,motherActivity,parentsStatus,dependantsNumber}; + const {firstName,lastName,gender,nationality,adressNumber,street,zipCode,city,personnalPhone,parentsPhone,parentsEmail,school,grade,specialTeaching,scholarship,fatherActivity,motherActivity,parentsStatus,dependantsNumber} = this.formGroup.value; + const personnalData: PersonnalData = {user:this.personnalData.user,firstName,lastName,gender,nationality,adressNumber,street,zipCode,city,personnalPhone,parentsPhone,parentsEmail,school,grade,specialTeaching,scholarship,fatherActivity,motherActivity,parentsStatus,dependantsNumber}; console.log("data",personnalData) //La partie commentée sera à rajouter lors de la connexion au back - // this.personnalDataService.edit(personnalData).pipe( - // tap(() => this.loading = false), - // tap(() => this.router.navigate(['./membres/compte/donnees'])), - // ).subscribe( - // () => {}, - // (error) => this.loading = false, - // ); + this.personnalDataService.edit(personnalData).pipe( + tap(() => this.loading = false), + tap(() => this.router.navigate(['./membres/compte/donnees'])), + ).subscribe( + () => {}, + (error) => this.loading = false, + ); } diff --git a/src/app/members/account/my-data/my-data.component.html b/src/app/members/account/my-data/my-data.component.html index 2472ea48043e23ff72e00010e1e1519b454dbd2d..f78417371382725813b6b25b171c4b30ff1c31b6 100644 --- a/src/app/members/account/my-data/my-data.component.html +++ b/src/app/members/account/my-data/my-data.component.html @@ -11,7 +11,7 @@ <p><span class='label'>Numéro de téléphone des parents : </span>{{personnalData.parentsPhone}}</p> <p><span class='label'>Email des parents : </span>{{personnalData.parentsEmail}}</p> <mat-divider></mat-divider> - <p><span class='label'>Lycée : </span>{{personnalData.school}}</p> + <p><span class='label'>Etablissement : </span>{{personnalData.school}}</p> <p><span class='label'>Classe : </span>{{grade[personnalData.grade]}}</p> <p><span class='label'>Section : </span>{{personnalData.section.toUpperCase()}}</p> <p><span class='label'>Enseignement de spécialité : </span>{{personnalData.specialTeaching}}</p> @@ -21,6 +21,10 @@ <p><span class='label'>Activité de la mère : </span>{{activity[personnalData.motherActivity]}}</p> <p><span class='label'>Statut des parents : </span>{{status[personnalData.parentsStatus]}}</p> <p><span class='label'>Nombre de personnes à charge : </span>{{personnalData.dependantsNumber}}</p> + <div class="text-center"> + <button mat-raised-button color="primary" (click)="editData()" [disabled]="loading"><mat-icon aria-hidden="false" aria-label="Example home icon">edit</mat-icon>Modifier mes données</button> + </div> + </app-form-page> <messages></messages> <router-outlet></router-outlet> diff --git a/src/app/members/account/my-data/my-data.component.ts b/src/app/members/account/my-data/my-data.component.ts index 8caa539957e524559b89c52508a902e565975af6..a2ae81039de8b2ec07fe91a7401d14a1b12ff87d 100644 --- a/src/app/members/account/my-data/my-data.component.ts +++ b/src/app/members/account/my-data/my-data.component.ts @@ -1,15 +1,17 @@ import { Component, OnInit } from '@angular/core'; -import {ActivatedRoute} from '@angular/router' +import {ActivatedRoute,Router} from '@angular/router' import {PersonnalData} from '../core' import {User} from 'app/core' + @Component({ selector: 'app-my-data', templateUrl: './my-data.component.html', styleUrls: ['./my-data.component.scss'] }) export class MyDataComponent implements OnInit { - + personnalData: PersonnalData; + public gender= { "man":"Homme", "woman":"Femme", @@ -51,11 +53,16 @@ export class MyDataComponent implements OnInit { "cohabitation":"En concubinage", "monoparental":"Famille monoparentale" } + + public editData = (e)=> { + this.router.navigate(['./membres/compte/modifier_donnees']) + } - constructor(private route: ActivatedRoute) { } - + constructor(private route: ActivatedRoute, private router:Router) { } + ngOnInit() { - //this.personnalData = this.route.snapshot.data['personnalData']; + + // this.personnalData = this.route.snapshot.data['personnalData']; //On enlevera l'exemple quand on se connectera au back this.personnalData = { user: new User({id:0}), @@ -72,7 +79,6 @@ export class MyDataComponent implements OnInit { parentsEmail:"email@email.com", school:"ecole", grade:"troisieme", - section:"es", specialTeaching:"specialite", scholarship:"echelon2", fatherActivity:"farmer", @@ -80,6 +86,6 @@ export class MyDataComponent implements OnInit { parentsStatus:"divorced", dependantsNumber:3, } - } + } } diff --git a/src/app/members/account/my-file/my-file.component.ts b/src/app/members/account/my-file/my-file.component.ts index aad52249c627fa53b776ebd78378ece794c5f6c5..6aaae008cccd84f64d16643eca41a9dff6b85dcc 100644 --- a/src/app/members/account/my-file/my-file.component.ts +++ b/src/app/members/account/my-file/my-file.component.ts @@ -13,8 +13,5 @@ export class MyFileComponent implements OnInit { constructor(private route: ActivatedRoute) { } - ngOnInit() { - - -} + ngOnInit() {} } diff --git a/src/app/members/account/upload/dialog/imageRightsDialog.component.ts b/src/app/members/account/upload/dialog/imageRightsDialog.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..610713b56495b0853e16ad41bc491fc1396652e3 --- /dev/null +++ b/src/app/members/account/upload/dialog/imageRightsDialog.component.ts @@ -0,0 +1,82 @@ +import { Component, OnInit, ViewChild } from '@angular/core' +import { MatDialogRef } from '@angular/material' +import { UploadService } from '../upload.service' +import { forkJoin } from 'rxjs' + +@Component({ + selector: 'app-dialog', + templateUrl: './dialog.component.html', + styleUrls: ['./dialog.component.scss'], +}) + +export class ImageRightsDialogComponent{ + constructor(public dialogRef : MatDialogRef<ImageRightsDialogComponent>, public uploadService : UploadService) { } + @ViewChild('file') file + public files: Set<File> = new Set() + progress + canBeClosed = true + primaryButtonText = 'Envoyer' + showCancelButton = true + uploading = false + uploadSuccessful = false + + addFiles() { + this.file.nativeElement.click(); + } + + onFilesAdded() { + console.log(this.file.nativeElement.files) + const files: { [key: string]: File } = this.file.nativeElement.files; + for (let key in files) { + if (!isNaN(parseInt(key))) { + this.files.clear() + this.files.add(files[key]); + } + } + } + + + closeDialog() { + // if everything was uploaded already, just close the dialog + if (this.uploadSuccessful) { + return this.dialogRef.close(); + } + + // set the component state to "uploading" + this.uploading = true; + + // start the upload and save the progress map + this.progress = this.uploadService.upload(this.files,"image"); + + // convert the progress map into an array + let allProgressObservables = []; + for (let key in this.progress) { + allProgressObservables.push(this.progress[key].progress); + } + + // Adjust the state variables + + // The OK-button should have the text "Finish" now + this.primaryButtonText = 'Terminer'; + + // The dialog should not be closed while uploading + this.canBeClosed = false; + this.dialogRef.disableClose = true; + + // Hide the cancel-button + this.showCancelButton = false; + + // When all progress-observables are completed... + forkJoin(allProgressObservables).subscribe(end => { + // ... the dialog can be closed again... + this.canBeClosed = true; + this.dialogRef.disableClose = false; + + // ... the upload was successful... + this.uploadSuccessful = true; + + // ... and the component is no longer uploading + this.uploading = false; + }); + } + } \ No newline at end of file diff --git a/src/app/members/account/upload/dialog/parentalAuthDialog.component.ts b/src/app/members/account/upload/dialog/parentalAuthDialog.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..c2a038b9750aa846a270ed5e9c85f62b3fbd0ce3 --- /dev/null +++ b/src/app/members/account/upload/dialog/parentalAuthDialog.component.ts @@ -0,0 +1,84 @@ +import { Component, OnInit, ViewChild } from '@angular/core' +import { MatDialogRef } from '@angular/material' +import { UploadService } from '../upload.service' +import { forkJoin } from 'rxjs' + +@Component({ + selector: 'app-dialog', + templateUrl: './dialog.component.html', + styleUrls: ['./dialog.component.scss'], +}) + +export class ParentalAuthDialogComponent { + constructor(public dialogRef : MatDialogRef<ParentalAuthDialogComponent>, public uploadService : UploadService) { } + @ViewChild('file') file + public files: Set<File> = new Set() + progress + canBeClosed = true + primaryButtonText = 'Envoyer' + showCancelButton = true + uploading = false + uploadSuccessful = false + + addFiles() { + this.file.nativeElement.click(); + } + + onFilesAdded() { + console.log(this.file.nativeElement.files) + const files: { [key: string]: File } = this.file.nativeElement.files; + for (let key in files) { + if (!isNaN(parseInt(key))) { + this.files.clear() + this.files.add(files[key]); + } + } + } + + + closeDialog() { + // if everything was uploaded already, just close the dialog + if (this.uploadSuccessful) { + return this.dialogRef.close(); + } + + // set the component state to "uploading" + this.uploading = true; + + // start the upload and save the progress map + this.progress = this.uploadService.upload(this.files,"parental"); + + // convert the progress map into an array + let allProgressObservables = []; + for (let key in this.progress) { + allProgressObservables.push(this.progress[key].progress); + } + + // Adjust the state variables + + // The OK-button should have the text "Finish" now + this.primaryButtonText = 'Terminer'; + + // The dialog should not be closed while uploading + this.canBeClosed = false; + this.dialogRef.disableClose = true; + + // Hide the cancel-button + this.showCancelButton = false; + + // When all progress-observables are completed... + forkJoin(allProgressObservables).subscribe(end => { + // ... the dialog can be closed again... + this.canBeClosed = true; + this.dialogRef.disableClose = false; + + // ... the upload was successful... + this.uploadSuccessful = true; + + // ... and the component is no longer uploading + this.uploading = false; + }); + } + } + + \ No newline at end of file diff --git a/src/app/members/account/upload/dialog/dialog.component.ts b/src/app/members/account/upload/dialog/studentChartDialog.component.ts similarity index 89% rename from src/app/members/account/upload/dialog/dialog.component.ts rename to src/app/members/account/upload/dialog/studentChartDialog.component.ts index 0815eb8ee2b37f9623583bf614806e4306b9becd..f2b3ff6d83267173205633d086693765f181e8cb 100644 --- a/src/app/members/account/upload/dialog/dialog.component.ts +++ b/src/app/members/account/upload/dialog/studentChartDialog.component.ts @@ -11,7 +11,10 @@ import { forkJoin } from 'rxjs' -export class DialogComponent { + + +export class StudentChartDialogComponent { + constructor(public dialogRef : MatDialogRef<StudentChartDialogComponent>, public uploadService : UploadService) { } @ViewChild('file') file public files: Set<File> = new Set() progress @@ -36,6 +39,7 @@ export class DialogComponent { } } + closeDialog() { // if everything was uploaded already, just close the dialog if (this.uploadSuccessful) { @@ -46,7 +50,7 @@ export class DialogComponent { this.uploading = true; // start the upload and save the progress map - this.progress = this.uploadService.upload(this.files); + this.progress = this.uploadService.upload(this.files,"chart"); // convert the progress map into an array let allProgressObservables = []; @@ -79,6 +83,5 @@ export class DialogComponent { this.uploading = false; }); } +} - constructor(public dialogRef: MatDialogRef<DialogComponent>, public uploadService: UploadService) {} -} \ No newline at end of file diff --git a/src/app/members/account/upload/upload.component.ts b/src/app/members/account/upload/upload.component.ts index 40da1f749c05caf6fc2556b66f4d7d8e5e0b5832..374e0effdd6f75faf9dbc4079cce28587ea2bd92 100644 --- a/src/app/members/account/upload/upload.component.ts +++ b/src/app/members/account/upload/upload.component.ts @@ -1,6 +1,8 @@ import { Component } from '@angular/core' import { MatDialog } from '@angular/material' -import { DialogComponent } from './dialog/dialog.component' +import {StudentChartDialogComponent } from './dialog/studentChartDialog.component' +import {ParentalAuthDialogComponent} from './dialog/parentalAuthDialog.component' +import {ImageRightsDialogComponent} from './dialog/imageRightsDialog.component' import { UploadService } from './upload.service' @Component({ @@ -12,19 +14,19 @@ export class UploadComponent { constructor(public dialog: MatDialog, public uploadService: UploadService) {} public openStudentChartDialog() { - let dialogRef = this.dialog.open(DialogComponent, { + let dialogRef = this.dialog.open(StudentChartDialogComponent, { width: '50%', height: '50%', }) } public openParentalAuthDialog() { - let dialogRef = this.dialog.open(DialogComponent, { + let dialogRef = this.dialog.open(ParentalAuthDialogComponent, { width: '50%', height: '50%', }) } public openImageRightsDialog() { - let dialogRef = this.dialog.open(DialogComponent, { + let dialogRef = this.dialog.open(ImageRightsDialogComponent, { width: '50%', height: '50%', }) diff --git a/src/app/members/account/upload/upload.module.ts b/src/app/members/account/upload/upload.module.ts index 50a8f2f659fba6c0e1c88af7cb58ac3dce5952b0..a40c62aa653ecfb9889ed3a109d5da477c686de5 100644 --- a/src/app/members/account/upload/upload.module.ts +++ b/src/app/members/account/upload/upload.module.ts @@ -1,7 +1,10 @@ import { NgModule } from '@angular/core' import { CommonModule } from '@angular/common' +//Components import { UploadComponent } from './upload.component' -import { DialogComponent } from './dialog/dialog.component' +import {StudentChartDialogComponent} from './dialog/studentChartDialog.component' +import {ImageRightsDialogComponent} from './dialog/imageRightsDialog.component' +import {ParentalAuthDialogComponent} from './dialog/parentalAuthDialog.component' import { MatButtonModule, MatDialogModule, @@ -25,9 +28,9 @@ import { HttpClientModule } from '@angular/common/http' BrowserAnimationsModule, MatProgressBarModule, ], - declarations: [UploadComponent, DialogComponent], + declarations: [UploadComponent, ParentalAuthDialogComponent,ImageRightsDialogComponent,StudentChartDialogComponent], exports: [UploadComponent], providers: [UploadService], - entryComponents : [DialogComponent] + entryComponents : [ParentalAuthDialogComponent,ImageRightsDialogComponent,StudentChartDialogComponent] }) export class UploadModule {} \ No newline at end of file diff --git a/src/app/members/account/upload/upload.service.ts b/src/app/members/account/upload/upload.service.ts index c7687462f94b842cadeb016795ae596344e8c03b..9e5663f395a5cc51c3293c6db9e6bb7688a2a1b4 100644 --- a/src/app/members/account/upload/upload.service.ts +++ b/src/app/members/account/upload/upload.service.ts @@ -6,17 +6,19 @@ import { HttpResponse, } from '@angular/common/http' import { Observable,Subject } from 'rxjs' +import { ApiService } from 'app/core'; -const url = 'http://localhost:8000/upload' //to change + @Injectable({ providedIn: 'root' }) -export class UploadService { - constructor(private http: HttpClient) {} - +export class UploadService extends ApiService { + constructor(private http: HttpClient) {super();} + private url = this.apiUrl + 'upload/' public upload( - files: Set<File> + files: Set<File>, + uploadedFileType : String ): { [key: string]: { progress: Observable<number> } } { // this will be the our resulting map const status: { [key: string]: { progress: Observable<number> } } = {}; @@ -24,11 +26,12 @@ export class UploadService { files.forEach(file => { // create a new multipart-form for every file const formData: FormData = new FormData(); - formData.append('file', file, file.name); + formData.append('fichier', file, file.name); // create a http-post request and pass the form // tell it to report the upload progress - const req = new HttpRequest('POST', url, formData, { + console.log('url',this.url+uploadedFileType) + const req = new HttpRequest('POST', this.url+uploadedFileType, formData, { reportProgress: true });