['dateOfBirth' non obligatoire] + [popup forgotten password]

This commit is contained in:
MiharyR 2021-12-03 17:34:02 +01:00
parent a70574a8e2
commit 7a0d1136a9
30 changed files with 262 additions and 454 deletions

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">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Date de naissance </th>
<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>
</ng-container>
@ -125,7 +126,8 @@
<ng-container matColumnDef="age">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Âge </th>
<td mat-cell *matCellDef="let user">
{{user.age}}
<span *ngIf="(user.age < 0) ; else elseAge"></span>
<ng-template #elseAge> {{user.age}} </ng-template>
</td>
</ng-container>
@ -133,8 +135,8 @@
<ng-container matColumnDef="sexe">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Sexe </th>
<td mat-cell *matCellDef="let user">
<span *ngIf="user.gender === 'man'">H</span>
<span *ngIf="user.gender === 'woman'">F</span>
<span *ngIf="(user.gender === 'man') ; else elseSexe"> H </span>
<ng-template #elseSexe> F </ng-template>
</td>
</ng-container>
@ -143,8 +145,8 @@
<th mat-header-cell *matHeaderCellDef> Centres d'intérêt </th>
<td mat-cell *matCellDef="let user">
<span *ngFor="let interest of user.interests; let isLast = last;">
<span *ngIf="!isLast"> {{interest}}, </span>
<span *ngIf="isLast"> {{interest}} </span>
<span *ngIf="!isLast ; else elseInterests"> {{interest}}, </span>
<ng-template #elseInterests> {{interest}} </ng-template>
</span>
</td>
</ng-container>
@ -173,19 +175,6 @@
</td>
</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 -->
<tr mat-header-row *matHeaderRowDef="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 {MatTableDataSource} from "@angular/material/table";
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 {PopupCreateUserComponent} from "../popup-create-user/popup-create-user.component";
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
{
const config = {
@ -139,9 +125,12 @@ export class PageUserListComponent implements AfterViewInit
getAge(date: Date): number
{
const diff = Date.now() - date.getTime();
const age = new Date(diff);
return Math.abs(age.getUTCFullYear() - 1970);
if((date === null) || (date === undefined)) return -1;
else {
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.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)) {
this.errorMessage = "Veuillez remplir le champ 'entreprise'.";
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;
}
}