Merge remote-tracking branch 'origin/main' into main

This commit is contained in:
Yûki VACHOT 2021-12-04 10:14:15 +01:00
commit e6e3b6b15d
30 changed files with 262 additions and 454 deletions

View file

@ -144,11 +144,6 @@
<button mat-icon-button (click)="onVisualizeImages(advert)"> <button mat-icon-button (click)="onVisualizeImages(advert)">
<mat-icon> insert_photo</mat-icon> <mat-icon> insert_photo</mat-icon>
</button> </button>
<!--
<button mat-icon-button (click)="onVisualizeInfo(advert)">
<mat-icon>aspect_ratio</mat-icon>
</button>
-->
<button mat-icon-button (click)="onDelete(advert)"> <button mat-icon-button (click)="onDelete(advert)">
<mat-icon>delete</mat-icon> <mat-icon>delete</mat-icon>
</button> </button>

View file

@ -1,77 +0,0 @@
<div [class]="themeService.getClassTheme()">
<h1 mat-dialog-title>{{advert.title}}</h1>
<!-- ----------------------------------------------------------------------------------------------------------------- -->
<mat-divider></mat-divider>
<mat-dialog-content>
<!-- URL -->
<div class="row myRow">
<div class="col-6 myLabel"> Annonceur: </div>
<div class="col-6 myValue"> {{advert.url}} </div>
</div>
<!-- Images -->
<div class="row myRow">
<div class="col-6 myLabel"> Images: </div>
<div class="col-6 myValue" style="border-left: solid 1px #e6e6e6">
<div *ngFor="let image of advert.images"> {{image.url}} </div>
</div>
</div>
<!-- Tags -->
<div class="row myRow">
<div class="col-6 myLabel"> Tags: </div>
<div class="col-6 myValue" style="border-left: solid 1px #e6e6e6">
<div *ngFor="let interest of advert.interests"> {{interest}} </div>
</div>
</div>
<!-- Comment -->
<div class="row myRow">
<div class="col-6 myLabel"> Commentaire: </div>
<div class="col-6 myValue"> {{advert.comment}} </div>
</div>
<!-- Views -->
<div class="row myRow">
<label class="col-6 myLabel"> Vues: </label>
<div class="col-6 myValue"> {{advert.views}} </div>
</div>
<!-- Created at -->
<div class="row myRow">
<label class="col-6 myLabel"> Date de création: </label>
<div class="col-6 myValue">
{{ advert.createdAt | date:'dd/LL/YYYY à HH:mm:ss' }}
</div>
</div>
<!-- Last updtade -->
<div class="row myRow">
<label class="col-6 myLabel"> Date de dernière modification: </label>
<div class="col-6 myValue">
{{ advert.updatedAt | date:'dd/LL/YYYY à HH:mm:ss' }}
</div>
</div>
<!-- IsVisible -->
<div class="row myRow">
<label class="col-6 myLabel"> Visibilité: </label>
<div class="col-6 myValue">
<mat-icon *ngIf="advert.isVisible">checked</mat-icon>
<mat-icon *ngIf="!advert.isVisible">close</mat-icon>
</div>
</div>
</mat-dialog-content>
<!-- ----------------------------------------------------------------------------------------------------------------- -->
<mat-dialog-actions align="end">
<button mat-button (click)="dialogRef.close()">Fermer</button>
</mat-dialog-actions>
</div>

View file

@ -1,28 +0,0 @@
.lightTheme, .darkTheme {
background-image: none;
}
h1 {
text-align: center;
font-size: xx-large;
}
.myRow {
margin: 15px 0px 15px 0px;
}
.myLabel {
text-align: right;
padding: 0px 5px 0px 0px;
margin: 0px;
font-weight: bold;
}
.myValue {
text-align: left;
padding: 0px 0px 0px 5px;
margin: 0px;
}

View file

@ -1,25 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { PopupVisualizeAdAdminComponent } from './popup-visualize-ad-admin.component';
describe('PopupVisualizeAdAdminComponent', () => {
let component: PopupVisualizeAdAdminComponent;
let fixture: ComponentFixture<PopupVisualizeAdAdminComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ PopupVisualizeAdAdminComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(PopupVisualizeAdAdminComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View file

@ -1,26 +0,0 @@
import {Component, Inject, OnInit} from '@angular/core';
import {Advert} from "../../../utils/interfaces/advert";
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
import {ThemeService} from "../../../utils/services/theme/theme.service";
@Component({
selector: 'app-popup-visualize-ad-admin',
templateUrl: './popup-visualize-ad-admin.component.html',
styleUrls: ['./popup-visualize-ad-admin.component.scss']
})
export class PopupVisualizeAdAdminComponent implements OnInit
{
advert: Advert;
constructor( public dialogRef: MatDialogRef<PopupVisualizeAdAdminComponent>,
@Inject(MAT_DIALOG_DATA) public data,
public themeService: ThemeService ) { }
ngOnInit(): void
{
this.advert = this.data.advert;
}
}

View file

@ -30,7 +30,7 @@ export class PopupUpdateAdminComponent implements OnInit
_id: admin0._id, _id: admin0._id,
login: admin0.login, login: admin0.login,
hashPass: admin0.hashPass, hashPass: admin0.hashPass,
email: admin0.mail, email: admin0.email,
role: { role: {
name: admin0.role.name, name: admin0.role.name,
permission: admin0.role.permission, permission: admin0.role.permission,
@ -79,14 +79,13 @@ export class PopupUpdateAdminComponent implements OnInit
this.errorMessage = "Email invalide" ; this.errorMessage = "Email invalide" ;
this.hasError = true; this.hasError = true;
} }
else if(this.changePassword) { else if((this.changePassword) && (this.newPassword.length === 0)) {
if (this.newPassword.length === 0) { this.errorMessage = "Veuillez remplir le champ 'mot de passe'" ;
this.errorMessage = "Veuillez remplir le champ 'mot de passe'" ; this.hasError = true;
this.hasError = true; }
} else if (this.newPassword !== this.confirmNewPassword) { else if((this.changePassword) && (this.newPassword !== this.confirmNewPassword)) {
this.errorMessage = "Le mot de passe est différent de sa confirmation" ; this.errorMessage = "Le mot de passe est différent de sa confirmation" ;
this.hasError = true; this.hasError = true;
}
} }
else { else {
this.errorMessage = "" ; this.errorMessage = "" ;

View file

@ -2,7 +2,7 @@
<!-- ------------------------------------------------------------------------------------ --> <!-- ------------------------------------------------------------------------------------ -->
<mat-label>Tags</mat-label> <mat-label>Centres d'intérêt</mat-label>
<!-- ------------------------------------------------------------------------------------ --> <!-- ------------------------------------------------------------------------------------ -->

View file

@ -117,7 +117,8 @@
<ng-container matColumnDef="dateOfBirth"> <ng-container matColumnDef="dateOfBirth">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Date de naissance </th> <th mat-header-cell *matHeaderCellDef mat-sort-header> Date de naissance </th>
<td mat-cell *matCellDef="let user"> <td mat-cell *matCellDef="let user">
{{ user.dateOfBirth | date:'dd/LL/YYYY' }} <span *ngIf="((user.dateOfBirth === null) || (user.dateOfBirth === undefined)); else elseDateOfBirth"></span>
<ng-template #elseDateOfBirth> {{ user.dateOfBirth | date:'dd/LL/YYYY' }} </ng-template>
</td> </td>
</ng-container> </ng-container>
@ -125,7 +126,8 @@
<ng-container matColumnDef="age"> <ng-container matColumnDef="age">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Âge </th> <th mat-header-cell *matHeaderCellDef mat-sort-header> Âge </th>
<td mat-cell *matCellDef="let user"> <td mat-cell *matCellDef="let user">
{{user.age}} <span *ngIf="(user.age < 0) ; else elseAge"></span>
<ng-template #elseAge> {{user.age}} </ng-template>
</td> </td>
</ng-container> </ng-container>
@ -133,8 +135,8 @@
<ng-container matColumnDef="sexe"> <ng-container matColumnDef="sexe">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Sexe </th> <th mat-header-cell *matHeaderCellDef mat-sort-header> Sexe </th>
<td mat-cell *matCellDef="let user"> <td mat-cell *matCellDef="let user">
<span *ngIf="user.gender === 'man'">H</span> <span *ngIf="(user.gender === 'man') ; else elseSexe"> H </span>
<span *ngIf="user.gender === 'woman'">F</span> <ng-template #elseSexe> F </ng-template>
</td> </td>
</ng-container> </ng-container>
@ -143,8 +145,8 @@
<th mat-header-cell *matHeaderCellDef> Centres d'intérêt </th> <th mat-header-cell *matHeaderCellDef> Centres d'intérêt </th>
<td mat-cell *matCellDef="let user"> <td mat-cell *matCellDef="let user">
<span *ngFor="let interest of user.interests; let isLast = last;"> <span *ngFor="let interest of user.interests; let isLast = last;">
<span *ngIf="!isLast"> {{interest}}, </span> <span *ngIf="!isLast ; else elseInterests"> {{interest}}, </span>
<span *ngIf="isLast"> {{interest}} </span> <ng-template #elseInterests> {{interest}} </ng-template>
</span> </span>
</td> </td>
</ng-container> </ng-container>
@ -173,19 +175,6 @@
</td> </td>
</ng-container> </ng-container>
<!-- Delete Column -->
<ng-container matColumnDef="actions">
<th mat-header-cell *matHeaderCellDef> Actions </th>
<td mat-cell *matCellDef="let user">
<button mat-icon-button (click)="onVisualize(user)">
<mat-icon>aspect_ratio</mat-icon>
</button>
<button mat-icon-button (click)="onDelete(user)">
<mat-icon>delete</mat-icon>
</button>
</td>
</ng-container>
<!-- Directives --> <!-- Directives -->
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>

View file

@ -6,7 +6,6 @@ import {MatDialog} from "@angular/material/dialog";
import {MatSnackBar} from "@angular/material/snack-bar"; import {MatSnackBar} from "@angular/material/snack-bar";
import {MatTableDataSource} from "@angular/material/table"; import {MatTableDataSource} from "@angular/material/table";
import {User} from "../../../utils/interfaces/user"; import {User} from "../../../utils/interfaces/user";
import {PopupVisualizeUserComponent} from "../popup-visualize-user/popup-visualize-user.component";
import {PopupDeleteUserComponent} from "../popup-delete-user/popup-delete-user.component"; import {PopupDeleteUserComponent} from "../popup-delete-user/popup-delete-user.component";
import {PopupCreateUserComponent} from "../popup-create-user/popup-create-user.component"; import {PopupCreateUserComponent} from "../popup-create-user/popup-create-user.component";
import {FictitiousUsersService} from "../../../utils/services/fictitiousDatas/fictitiousUsers/fictitious-users.service"; import {FictitiousUsersService} from "../../../utils/services/fictitiousDatas/fictitiousUsers/fictitious-users.service";
@ -66,19 +65,6 @@ export class PageUserListComponent implements AfterViewInit
} }
onVisualize(user: User): void
{
const config = {
width: '50%',
data: { user: user }
};
this.dialog
.open(PopupVisualizeUserComponent, config)
.afterClosed()
.subscribe(retour => {});
}
onDelete(user: User): void onDelete(user: User): void
{ {
const config = { const config = {
@ -139,9 +125,12 @@ export class PageUserListComponent implements AfterViewInit
getAge(date: Date): number getAge(date: Date): number
{ {
const diff = Date.now() - date.getTime(); if((date === null) || (date === undefined)) return -1;
const age = new Date(diff); else {
return Math.abs(age.getUTCFullYear() - 1970); const diff = Date.now() - date.getTime();
const age = new Date(diff);
return Math.abs(age.getUTCFullYear() - 1970);
}
} }

View file

@ -85,10 +85,6 @@ export class PopupCreateUserComponent implements OnInit
this.errorMessage = "Le mot de passe est différent de sa confirmation."; this.errorMessage = "Le mot de passe est différent de sa confirmation.";
this.hasError = true; this.hasError = true;
} }
else if((this.user.role.name === 'user') && ((this.user.dateOfBirth === undefined) || (this.user.dateOfBirth === null))) {
this.errorMessage = "Veuillez remplir le champ 'date de naissance'.";
this.hasError = true;
}
else if((this.user.role.name === 'advertiser') && (this.user.company.length === 0)) { else if((this.user.role.name === 'advertiser') && (this.user.company.length === 0)) {
this.errorMessage = "Veuillez remplir le champ 'entreprise'."; this.errorMessage = "Veuillez remplir le champ 'entreprise'.";
this.hasError = true; this.hasError = true;

View file

@ -1,76 +0,0 @@
<div class="myContainer">
<!-- Photo de profil -->
<div style="text-align: center">
<img [src]="user.profilePictureUrl"
onerror="this.onerror=null; this.src='assets/profil.png'">
</div>
<!-- login -->
<div class="row myRow">
<div class="col-6 myLabel">Login:</div>
<div class="col-6 myValue"> {{user.login}} </div>
</div>
<!-- email -->
<div class="row myRow">
<div class="col-6 myLabel">Mail:</div>
<div class="col-6 myValue"> {{user.email}} </div>
</div>
<div *ngIf="user.role.name === 'user'">
<!-- dateOfBirth -->
<div class="row myRow">
<div class="col-6 myLabel">Date de naissance:</div>
<div class="col-6 myValue">{{ user.dateOfBirth | date:'dd/LL/YYYY' }}</div>
</div>
<!-- age -->
<div class="row myRow">
<div class="col-6 myLabel">Âge:</div>
<div class="col-6 myValue">{{user.age}}</div>
</div>
<!-- gender -->
<div class="row myRow">
<div class="col-6 myLabel">Sexe:</div>
<div class="col-6 myValue">
<span *ngIf="user.gender==='man'"> Homme </span>
<span *ngIf="user.gender==='woman'"> Femme </span>
</div>
</div>
<!-- interets -->
<div class="row myRow">
<div class="col-6 myLabel">Centres d'intérêt:</div>
<div class="col-6 myValue" style="border-left: solid 1px #e6e6e6">
<div *ngFor="let interest of user.interests">• {{interest}}</div>
</div>
</div>
<!-- createdAt -->
<div class="row myRow">
<div class="col-6 myLabel">Date de création:</div>
<div class="col-6 myValue">{{ user.createdAt | date:'dd/LL/YYYY' }}</div>
</div>
</div>
<!-- Role -->
<div class="row myRow">
<div class="col-6 myLabel">Rôle:</div>
<div class="col-6 myValue">
<span *ngIf="user.role.name === 'user'">Utilisateur</span>
<span *ngIf="user.role.name === 'url'">Annonceur</span>
<span *ngIf="user.role.name === 'admin'">Admin</span>
</div>
</div>
<br>
<!-- boutons -->
<div style="text-align: center">
<button mat-button (click)="this.dialogRef.close(null)"> Fermer </button>
</div>
</div>

View file

@ -1,29 +0,0 @@
.myContainer {
font-size: small;
}
img {
margin: 0px 0px 10px 0px;
width: 5vw;
height: 5vw;
border: solid 2px black;
border-radius: 50%;
font-size: xxx-large;
}
.myRow {
margin: 15px 0px 15px 0px;
}
.myLabel {
text-align: right;
padding: 0px 5px 0px 0px;
margin: 0px;
font-weight: bold;
}
.myValue {
text-align: left;
padding: 0px 0px 0px 5px;
margin: 0px;
}

View file

@ -1,25 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { PopupVisualizeUserComponent } from './popup-visualize-user.component';
describe('PopupVisualizeUserComponent', () => {
let component: PopupVisualizeUserComponent;
let fixture: ComponentFixture<PopupVisualizeUserComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ PopupVisualizeUserComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(PopupVisualizeUserComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View file

@ -1,23 +0,0 @@
import {Component, Inject, OnInit} from '@angular/core';
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
@Component({
selector: 'app-popup-visualize-user',
templateUrl: './popup-visualize-user.component.html',
styleUrls: ['./popup-visualize-user.component.scss']
})
export class PopupVisualizeUserComponent implements OnInit
{
user;
constructor( public dialogRef: MatDialogRef<PopupVisualizeUserComponent>,
@Inject(MAT_DIALOG_DATA) public data ) { }
ngOnInit(): void
{
this.user = this.data.user;
}
}

View file

@ -84,6 +84,8 @@ export class PageAdListAdvertiserComponent implements AfterViewInit
{ {
const config = { const config = {
width: '75%', width: '75%',
height: '80%',
panelClass: 'custom-dialog-container',
data: { action: "add", advert: null } data: { action: "add", advert: null }
}; };
this.dialog this.dialog
@ -111,6 +113,8 @@ export class PageAdListAdvertiserComponent implements AfterViewInit
{ {
const config = { const config = {
width: '75%', width: '75%',
height: '80%',
panelClass: 'custom-dialog-container',
data: { action: "update", advert: advertToUpdate } data: { action: "update", advert: advertToUpdate }
}; };
this.dialog this.dialog

View file

@ -1,76 +1,79 @@
<div [class]="themeService.getClassTheme()"> <div class="myContainer1">
<div class="myContainer2">
<!-- titre popup --> <!-- titre popup -->
<h1 mat-dialog-title>{{title}}</h1> <h1 mat-dialog-title>{{title}}</h1>
<mat-divider></mat-divider><br> <mat-divider></mat-divider><br>
<!-- tous les champs --> <!-- tous les champs -->
<div class="row"> <div class="row">
<!-- title + interests + comments + isVisible --> <!-- title + interests + comments + isVisible -->
<div class="col-6"> <div class="col-6">
<!-- Title --> <!-- Title -->
<mat-form-field appearance="fill"> <mat-form-field appearance="fill">
<mat-label> Titre annonce </mat-label> <mat-label> Titre annonce </mat-label>
<input matInput type="text" [(ngModel)]="advert.title"> <input matInput type="text" [(ngModel)]="advert.title">
</mat-form-field> </mat-form-field>
<!-- Interests --> <!-- Interests -->
<app-input-interests-ad [myTags]="advert.interests" (eventEmitter)="onEventInputTags($event)"></app-input-interests-ad> <app-input-interests-ad [myTags]="advert.interests" (eventEmitter)="onEventInputTags($event)"></app-input-interests-ad>
<!-- Comments --> <!-- Comments -->
<mat-form-field class="commentContainer" appearance="fill"> <mat-form-field class="commentContainer" appearance="fill">
<mat-label> Commentaire </mat-label> <mat-label> Commentaire </mat-label>
<textarea matInput [(ngModel)]="advert.comment"></textarea> <textarea matInput [(ngModel)]="advert.comment"></textarea>
</mat-form-field><br> </mat-form-field><br>
<!-- url --> <!-- url -->
<mat-form-field class="commentContainer" appearance="fill"> <mat-form-field class="commentContainer" appearance="fill">
<mat-label> URL </mat-label> <mat-label> URL </mat-label>
<textarea matInput [(ngModel)]="advert.url"></textarea> <textarea matInput [(ngModel)]="advert.url"></textarea>
</mat-form-field><br> </mat-form-field><br>
<!-- IsVisible --> <!-- IsVisible -->
<mat-checkbox [(ngModel)]="advert.isVisible"> Visible </mat-checkbox><br><br> <mat-checkbox [(ngModel)]="advert.isVisible"> Visible </mat-checkbox><br><br>
<!-- Images déjà présentes --> <!-- Images déjà présentes -->
<div *ngIf="advert.images.length !== 0"> <div *ngIf="advert.images.length !== 0">
<div style="font-weight: bold; margin-bottom: 5px;"> <div style="font-weight: bold; margin-bottom: 5px;">
Images déjà associées: Images déjà associées:
</div> </div>
<div style="margin-left: 20px; padding-left: 2px; border-left: solid 1px #a4a4a4"> <div style="margin-left: 20px; padding-left: 2px; border-left: solid 1px #a4a4a4">
<div *ngFor="let image of advert.images" style="padding: 2px 0px 2px 0px;"> <div *ngFor="let image of advert.images" style="padding: 2px 0px 2px 0px;">
<mat-chip [selectable]="true" [removable]="true" style="font-size: small;"> <mat-chip [selectable]="true" [removable]="true" style="font-size: small;">
{{image.description}} {{image.description}}
<button matChipRemove (click)="onRemoveImgAlreadyPresent(image)"> <button matChipRemove (click)="onRemoveImgAlreadyPresent(image)">
<mat-icon>cancel</mat-icon> <mat-icon>cancel</mat-icon>
</button> </button>
</mat-chip> </mat-chip>
</div>
</div> </div>
</div> </div>
</div>
<!-- nouvelles images -->
<div class="col-6" style="overflow-x: hidden; overflow-y: scroll; max-height: 70vh;">
<app-drag-and-drop></app-drag-and-drop>
</div> </div>
</div> </div>
<!-- nouvelles images -->
<div class="col-6" style="overflow-x: hidden; overflow-y: scroll; max-height: 70vh;"> <br><mat-divider></mat-divider>
<app-drag-and-drop></app-drag-and-drop>
</div>
<!-- Actions -->
<mat-dialog-actions align="end">
<button mat-button (click)="dialogRef.close()">Annuler</button>
<button mat-button (click)="onValidate()">Valider</button>
</mat-dialog-actions>
</div> </div>
<br><mat-divider></mat-divider>
<!-- Actions -->
<mat-dialog-actions align="end">
<button mat-button (click)="dialogRef.close()">Annuler</button>
<button mat-button (click)="onValidate()" cdkFocusInitial>Valider</button>
</mat-dialog-actions>
</div> </div>

View file

@ -1,10 +1,24 @@
.lightTheme, .darkTheme { .myContainer1 {
background-image: none; padding: 10px 10px 0px 25px;
overflow-y: hidden; margin: 0px 0px 0px 0px;
overflow-x: hidden;
font-size: small; font-size: small;
} }
.myContainer2 {
padding: 0px 0px 0px 0px;
margin: 0px 0px 0px 0px;
overflow-y: hidden;
overflow-x: hidden;
-ms-overflow-style: none;
scrollbar-width: none;
}
.myContainer2::-webkit-scrollbar {
display: none;
}
h1 { h1 {
text-align: center; text-align: center;
font-size: large; font-size: large;
@ -26,6 +40,10 @@ h1 {
border: solid 1px grey; border: solid 1px grey;
} }
mat-dialog-actions {
margin-bottom: 0px;
}
button { button {
font-size: small; font-size: small;
} }

View file

@ -30,7 +30,7 @@ export class PopupUpdateAdvertiserComponent implements OnInit
_id: advertiser0._id, _id: advertiser0._id,
login: advertiser0.login, login: advertiser0.login,
hashPass: advertiser0.hashPass, hashPass: advertiser0.hashPass,
email: advertiser0.mail, email: advertiser0.email,
role: { role: {
name: advertiser0.role.name, name: advertiser0.role.name,
permission: advertiser0.role.permission, permission: advertiser0.role.permission,
@ -79,14 +79,13 @@ export class PopupUpdateAdvertiserComponent implements OnInit
this.errorMessage = "Email invalide" ; this.errorMessage = "Email invalide" ;
this.hasError = true; this.hasError = true;
} }
else if(this.changePassword) { else if((this.changePassword) && (this.newPassword.length === 0)) {
if (this.newPassword.length === 0) { this.errorMessage = "Veuillez remplir le champ 'mot de passe'" ;
this.errorMessage = "Veuillez remplir le champ 'mot de passe'" ; this.hasError = true;
this.hasError = true; }
} else if (this.newPassword !== this.confirmNewPassword) { else if((this.changePassword) && (this.newPassword !== this.confirmNewPassword)) {
this.errorMessage = "Le mot de passe est différent de sa confirmation" ; this.errorMessage = "Le mot de passe est différent de sa confirmation" ;
this.hasError = true; this.hasError = true;
}
} }
else { else {
this.errorMessage = "" ; this.errorMessage = "" ;

View file

@ -60,10 +60,8 @@ import { InputInterestsRegisterComponent } from './beforeConnexion/register/inpu
import {MatPaginatorModule} from "@angular/material/paginator"; import {MatPaginatorModule} from "@angular/material/paginator";
import { PageAdListAdminComponent } from './admin/adList/page-ad-list-admin/page-ad-list-admin.component'; import { PageAdListAdminComponent } from './admin/adList/page-ad-list-admin/page-ad-list-admin.component';
import { PopupDeleteAdAdminComponent } from './admin/adList/popup-delete-ad-admin/popup-delete-ad-admin.component'; import { PopupDeleteAdAdminComponent } from './admin/adList/popup-delete-ad-admin/popup-delete-ad-admin.component';
import { PopupVisualizeAdAdminComponent } from './admin/adList/popup-visualize-ad-admin/popup-visualize-ad-admin.component';
import { PopupVisualizeImagesAdminComponent } from './admin/adList/popup-visualize-images-admin/popup-visualize-images-admin.component'; import { PopupVisualizeImagesAdminComponent } from './admin/adList/popup-visualize-images-admin/popup-visualize-images-admin.component';
import { PageUserListComponent } from './admin/userList/page-user-list/page-user-list.component'; import { PageUserListComponent } from './admin/userList/page-user-list/page-user-list.component';
import { PopupVisualizeUserComponent } from './admin/userList/popup-visualize-user/popup-visualize-user.component';
import { PopupDeleteUserComponent } from './admin/userList/popup-delete-user/popup-delete-user.component'; import { PopupDeleteUserComponent } from './admin/userList/popup-delete-user/popup-delete-user.component';
import { PopupCreateUserComponent } from './admin/userList/popup-create-user/popup-create-user.component'; import { PopupCreateUserComponent } from './admin/userList/popup-create-user/popup-create-user.component';
import { InputInterestsAdminComponent } from './admin/userList/input-interests-admin/input-interests-admin.component'; import { InputInterestsAdminComponent } from './admin/userList/input-interests-admin/input-interests-admin.component';
@ -72,6 +70,7 @@ import {MatDatepickerModule} from "@angular/material/datepicker";
import { PagesPopularityComponent } from './advertiser/pages-popularity/pages-popularity.component'; import { PagesPopularityComponent } from './advertiser/pages-popularity/pages-popularity.component';
import { ChartsModule } from 'ng2-charts'; import { ChartsModule } from 'ng2-charts';
import { PopupDeletePlaylistComponent } from './user/myPlaylists/popup-delete-playlist/popup-delete-playlist.component'; import { PopupDeletePlaylistComponent } from './user/myPlaylists/popup-delete-playlist/popup-delete-playlist.component';
import { PopupForgottenPasswordComponent } from './beforeConnexion/login/popup-forgotten-password/popup-forgotten-password.component';
@NgModule({ @NgModule({
@ -112,16 +111,15 @@ import { PopupDeletePlaylistComponent } from './user/myPlaylists/popup-delete-pl
InputInterestsRegisterComponent, InputInterestsRegisterComponent,
PageAdListAdminComponent, PageAdListAdminComponent,
PopupDeleteAdAdminComponent, PopupDeleteAdAdminComponent,
PopupVisualizeAdAdminComponent,
PopupVisualizeImagesAdminComponent, PopupVisualizeImagesAdminComponent,
PageUserListComponent, PageUserListComponent,
PopupVisualizeUserComponent,
PopupDeleteUserComponent, PopupDeleteUserComponent,
PopupCreateUserComponent, PopupCreateUserComponent,
InputInterestsAdminComponent, InputInterestsAdminComponent,
PageWatchingVideoComponent, PageWatchingVideoComponent,
PagesPopularityComponent, PagesPopularityComponent,
PopupDeletePlaylistComponent, PopupDeletePlaylistComponent,
PopupForgottenPasswordComponent,
], ],
imports: [ imports: [
BrowserModule, BrowserModule,

View file

@ -25,7 +25,7 @@
<!-- Oubli mot de passe --> <!-- Oubli mot de passe -->
<div id="formFooter"> <div id="formFooter">
<a class="underlineHover" href="https://disney.fandom.com/fr/wiki/Tristesse">J'ai oublié mon mot de passe</a> <a class="underlineHover" (click)="onForgottenPassword()">J'ai oublié mon mot de passe</a>
</div> </div>
</div> </div>

View file

@ -2,6 +2,9 @@ import {Component, OnInit} from '@angular/core';
import {MessageService} from "../../../utils/services/message/message.service"; import {MessageService} from "../../../utils/services/message/message.service";
import {Router} from "@angular/router"; import {Router} from "@angular/router";
import {ThemeService} from "../../../utils/services/theme/theme.service"; import {ThemeService} from "../../../utils/services/theme/theme.service";
import {MatDialog} from "@angular/material/dialog";
import {PopupForgottenPasswordComponent} from "../popup-forgotten-password/popup-forgotten-password.component";
import {MatSnackBar} from "@angular/material/snack-bar";
@ -20,7 +23,9 @@ export class PageLoginComponent implements OnInit
constructor( private messageService: MessageService, constructor( private messageService: MessageService,
private router: Router, private router: Router,
public themeService: ThemeService ) { } public themeService: ThemeService,
public dialog: MatDialog,
private snackBar: MatSnackBar ) { }
ngOnInit(): void {} ngOnInit(): void {}
@ -43,6 +48,21 @@ export class PageLoginComponent implements OnInit
} }
onForgottenPassword(): void
{
this.dialog
.open(PopupForgottenPasswordComponent, {width: '30%'})
.afterClosed()
.subscribe(result => {
if((result !== null) && (result !== undefined))
{
const config = { duration: 5000, panelClass: "custom-class" };
this.snackBar.open( "Un mail de réinitialisation de mot de passe vous a été envoyé.", "", config);
}
});
}
maCallback(retour): void maCallback(retour): void
{ {
console.log(retour.data) console.log(retour.data)
@ -72,6 +92,7 @@ export class PageLoginComponent implements OnInit
} }
} }
// Fonction de hashage (faible) // Fonction de hashage (faible)
hashage(input: string): string hashage(input: string): string
{ {

View file

@ -0,0 +1,24 @@
<h4>Oubli mot de passe</h4>
<mat-divider></mat-divider><br>
<!-- email -->
<div class="myDiv">
<mat-form-field appearance="fill">
<mat-label>Email</mat-label>
<input matInput type="email" [(ngModel)]="email" required>
</mat-form-field>
</div>
<!-- message d'erreur -->
<div class="myError" *ngIf="hasError">
<span class="mat-error">{{errorMessage}}</span>
</div>
<mat-divider></mat-divider>
<!-- boutons -->
<mat-dialog-actions align="end">
<button mat-button (click)="dialogRef.close()">Annuler</button>
<button mat-button (click)="onValidate()" cdkFocusInitial>Valider</button>
</mat-dialog-actions>

View file

@ -0,0 +1,12 @@
h4 {
text-align: center;
}
.myDiv {
text-align: center;
font-size: small;
}
.myError {
text-align: center;
}

View file

@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { PopupForgottenPasswordComponent } from './popup-forgotten-password.component';
describe('PopupForgottenPasswordComponent', () => {
let component: PopupForgottenPasswordComponent;
let fixture: ComponentFixture<PopupForgottenPasswordComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ PopupForgottenPasswordComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(PopupForgottenPasswordComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View file

@ -0,0 +1,47 @@
import { Component } from '@angular/core';
import {MatDialogRef} from "@angular/material/dialog";
@Component({
selector: 'app-popup-forgotten-password',
templateUrl: './popup-forgotten-password.component.html',
styleUrls: ['./popup-forgotten-password.component.scss']
})
export class PopupForgottenPasswordComponent
{
email: string;
hasError: boolean = false;
errorMessage: string = "";
constructor(public dialogRef: MatDialogRef<PopupForgottenPasswordComponent>) {}
// Click sur valider
onValidate()
{
if(this.email.length === 0) {
this.errorMessage = "Veuillez remplir le champ 'email'." ;
this.hasError = true;
}
else if(!this.isValidEmail(this.email)) {
this.errorMessage = "Email invalide." ;
this.hasError = true;
}
else {
this.errorMessage = "" ;
this.hasError = false;
this.dialogRef.close(true);
}
}
// Indique si email a bien le format d'un email
isValidEmail(email): boolean
{
let re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(email);
}
}

View file

@ -105,7 +105,7 @@
<mat-label>Date de naissance</mat-label> <mat-label>Date de naissance</mat-label>
<input matInput type="date" <input matInput type="date"
[ngModel] ="user.dateOfBirth | date:'yyyy-MM-dd'" [ngModel] ="user.dateOfBirth | date:'yyyy-MM-dd'"
(ngModelChange)="user.dateOfBirth = $event" required> (ngModelChange)="user.dateOfBirth = $event">
</mat-form-field> </mat-form-field>
<!-- interests --> <!-- interests -->

View file

@ -119,10 +119,6 @@ export class PageRegisterComponent
this.errorMessage = "Le mot de passe est différent de sa confirmation."; this.errorMessage = "Le mot de passe est différent de sa confirmation.";
this.hasError = true; this.hasError = true;
} }
else if((this.user.role.name === 'user') && ((this.user.dateOfBirth === undefined) || (this.user.dateOfBirth === null))) {
this.errorMessage = "Veuillez remplir le champ 'date de naissance'.";
this.hasError = true;
}
else { else {
this.errorMessage = "" ; this.errorMessage = "" ;
this.hasError = false; this.hasError = false;

View file

@ -12,6 +12,7 @@ import {Router} from "@angular/router";
interface VideoHistory { interface VideoHistory {
videoId: string,
imageUrl: string, imageUrl: string,
title: string, title: string,
date: Date, date: Date,
@ -115,6 +116,7 @@ export class PageHistoryUserComponent implements AfterViewInit
videoAllToVideoHistory(videoAll: VideoAll): VideoHistory videoAllToVideoHistory(videoAll: VideoAll): VideoHistory
{ {
return { return {
videoId: videoAll.videoId,
imageUrl: videoAll.imageUrl, imageUrl: videoAll.imageUrl,
title: videoAll.title, title: videoAll.title,
date: videoAll.watchedDates[videoAll.watchedDates.length-1], date: videoAll.watchedDates[videoAll.watchedDates.length-1],

View file

@ -30,7 +30,7 @@ export class PopupUpdateUserComponent implements OnInit
_id: user0._id, _id: user0._id,
login: user0.login, login: user0.login,
hashPass: user0.hashPass, hashPass: user0.hashPass,
email: user0.mail, email: user0.email,
role: { role: {
name: user0.role.name, name: user0.role.name,
permission: user0.role.permission, permission: user0.role.permission,
@ -79,18 +79,13 @@ export class PopupUpdateUserComponent implements OnInit
this.errorMessage = "Email invalide." ; this.errorMessage = "Email invalide." ;
this.hasError = true; this.hasError = true;
} }
else if((this.userCopy.dateOfBirth === undefined) || (this.userCopy.dateOfBirth === null)) { else if((this.changePassword) && (this.newPassword.length === 0)) {
this.errorMessage = "Veuillez remplir le champ 'date de naissance'."; this.errorMessage = "Veuillez remplir le champ 'mot de passe'" ;
this.hasError = true; this.hasError = true;
} }
else if(this.changePassword) { else if((this.changePassword) && (this.newPassword !== this.confirmNewPassword)) {
if (this.newPassword.length === 0) { this.errorMessage = "Le mot de passe est différent de sa confirmation" ;
this.errorMessage = "Veuillez remplir le champ 'mot de passe'." ; this.hasError = true;
this.hasError = true;
} else if (this.newPassword !== this.confirmNewPassword) {
this.errorMessage = "Le mot de passe est différent de sa confirmation." ;
this.hasError = true;
}
} }
else { else {
this.errorMessage = "" ; this.errorMessage = "" ;

View file

@ -31,6 +31,11 @@ body { margin: 0; }
} }
.custom-dialog-container .mat-dialog-container {
margin: 0px 0px 0px 0px;
padding: 0px 0px 0px 0px;
}
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------