connexion avec back de 'admin/adList'
This commit is contained in:
parent
b617af0051
commit
fd722f613d
15 changed files with 112 additions and 50 deletions
|
|
@ -13,11 +13,12 @@ import {FormControl} from "@angular/forms";
|
||||||
import {FictitiousUtilsService} from "../../../utils/services/fictitiousDatas/fictitiousUtils/fictitious-utils.service";
|
import {FictitiousUtilsService} from "../../../utils/services/fictitiousDatas/fictitiousUtils/fictitious-utils.service";
|
||||||
import {User} from "../../../utils/interfaces/user";
|
import {User} from "../../../utils/interfaces/user";
|
||||||
import {FictitiousUsersService} from "../../../utils/services/fictitiousDatas/fictitiousUsers/fictitious-users.service";
|
import {FictitiousUsersService} from "../../../utils/services/fictitiousDatas/fictitiousUsers/fictitious-users.service";
|
||||||
|
import {MessageService} from "../../../utils/services/message/message.service";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export interface AdvertWithCountViewsAndCompany {
|
export interface AdvertWithCountViewsAndCompany {
|
||||||
_id: string,
|
id: string,
|
||||||
userId: string,
|
userId: string,
|
||||||
company: string,
|
company: string,
|
||||||
title: string,
|
title: string,
|
||||||
|
|
@ -46,7 +47,7 @@ export interface AdvertWithCountViewsAndCompany {
|
||||||
export class PageAdListAdminComponent implements AfterViewInit
|
export class PageAdListAdminComponent implements AfterViewInit
|
||||||
{
|
{
|
||||||
tabAdvertWithCountViews: AdvertWithCountViewsAndCompany[] = [];
|
tabAdvertWithCountViews: AdvertWithCountViewsAndCompany[] = [];
|
||||||
tabAdvertiser: User[];
|
tabAdvertiser: any[];
|
||||||
displayedColumns: string[] = [ 'title', 'company', 'interests', 'createdAt', 'updatedAt', 'countViews', 'isVisible', 'actions' ];
|
displayedColumns: string[] = [ 'title', 'company', 'interests', 'createdAt', 'updatedAt', 'countViews', 'isVisible', 'actions' ];
|
||||||
dataSource ;
|
dataSource ;
|
||||||
@ViewChild(MatSort) sort: MatSort;
|
@ViewChild(MatSort) sort: MatSort;
|
||||||
|
|
@ -65,19 +66,81 @@ export class PageAdListAdminComponent implements AfterViewInit
|
||||||
private fictitiousUtilsService: FictitiousUtilsService,
|
private fictitiousUtilsService: FictitiousUtilsService,
|
||||||
private fictitiousUsersService: FictitiousUsersService,
|
private fictitiousUsersService: FictitiousUsersService,
|
||||||
public dialog: MatDialog,
|
public dialog: MatDialog,
|
||||||
private snackBar: MatSnackBar ) { }
|
private snackBar: MatSnackBar,
|
||||||
|
private messageService: MessageService) { }
|
||||||
|
|
||||||
|
|
||||||
ngAfterViewInit(): void
|
ngAfterViewInit(): void
|
||||||
{
|
{
|
||||||
// --- FAUX CODE ---
|
// --- FAUX CODE ---
|
||||||
|
/*
|
||||||
const tabAdvert = this.fictitiousAdvertsService.getTabAdvert(8);
|
const tabAdvert = this.fictitiousAdvertsService.getTabAdvert(8);
|
||||||
this.allInterests = this.fictitiousUtilsService.getTags();
|
this.allInterests = this.fictitiousUtilsService.getTags();
|
||||||
this.tabAdvertiser = this.fictitiousUsersService.getTabAdvertiser(3);
|
this.tabAdvertiser = this.fictitiousUsersService.getTabAdvertiser(3);
|
||||||
|
|
||||||
for(let advert of tabAdvert) this.tabAdvertWithCountViews.push(this.advertToAdvertWithCountViewsAndCompany(advert));
|
for(let advert of tabAdvert) this.tabAdvertWithCountViews.push(this.advertToAdvertWithCountViewsAndCompany(advert));
|
||||||
this.dataSource = new MatTableDataSource<Advert>();
|
this.dataSource = new MatTableDataSource<Advert>();
|
||||||
this.onFilter();
|
this.onFilter();
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Ask for interest
|
||||||
|
this.messageService
|
||||||
|
.get("misc/getInterests")
|
||||||
|
.subscribe(ret => this.afterReceivingInterests(ret), err => this.afterReceivingInterests(err) );
|
||||||
|
|
||||||
|
// Ask for ads
|
||||||
|
this.messageService
|
||||||
|
.get("ad/findAll")
|
||||||
|
.subscribe(ret => this.afterReceivingAds(ret), err => this.afterReceivingAds(err) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
afterReceivingAds(retour: any): void
|
||||||
|
{
|
||||||
|
console.log("afterReceivingAds");
|
||||||
|
console.log(retour);
|
||||||
|
|
||||||
|
if(retour.status !== "success") {
|
||||||
|
//console.log(retour);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const tabAdvert = retour.data;
|
||||||
|
this.messageService
|
||||||
|
.get("user/findAll")
|
||||||
|
.subscribe(ret => this.afterReceivingAdvertiser(ret, tabAdvert), err => this.afterReceivingAdvertiser(err, tabAdvert) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
afterReceivingAdvertiser(retour: any, tabAdvert): void
|
||||||
|
{
|
||||||
|
console.log("afterReceivingAdvertiser");
|
||||||
|
console.log(retour);
|
||||||
|
|
||||||
|
if(retour.status !== "success") {
|
||||||
|
//console.log(retour);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.tabAdvertiser = retour.data.filter(x => x.role.name === "advertiser");
|
||||||
|
for(let advert of tabAdvert) this.tabAdvertWithCountViews.push(this.advertToAdvertWithCountViewsAndCompany(advert));
|
||||||
|
this.dataSource = new MatTableDataSource<Advert>();
|
||||||
|
this.onFilter();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
afterReceivingInterests(retour: any): void
|
||||||
|
{
|
||||||
|
console.log("afterReceivingInterests");
|
||||||
|
console.log(retour);
|
||||||
|
|
||||||
|
if(retour.status !== "success") {
|
||||||
|
console.log(retour);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.allInterests = [];
|
||||||
|
this.allInterests = retour.data.map(x => x.interest);
|
||||||
|
this.allInterests.sort();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -122,7 +185,7 @@ export class PageAdListAdminComponent implements AfterViewInit
|
||||||
message = "Opération annulée" ;
|
message = "Opération annulée" ;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const index = this.dataSource.data.findIndex( elt => (elt._id === advert._id));
|
const index = this.dataSource.data.findIndex( elt => (elt.id === advert.id));
|
||||||
this.dataSource.data.splice(index, 1);
|
this.dataSource.data.splice(index, 1);
|
||||||
this.dataSource.data = this.dataSource.data;
|
this.dataSource.data = this.dataSource.data;
|
||||||
this.dataSource = this.dataSource;
|
this.dataSource = this.dataSource;
|
||||||
|
|
@ -187,19 +250,19 @@ export class PageAdListAdminComponent implements AfterViewInit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
advertToAdvertWithCountViewsAndCompany(advert: Advert): AdvertWithCountViewsAndCompany
|
advertToAdvertWithCountViewsAndCompany(advert): AdvertWithCountViewsAndCompany
|
||||||
{
|
{
|
||||||
let company0 = "company" ;
|
let company0 = "company" ;
|
||||||
for(let advertiser of this.tabAdvertiser)
|
for(let advertiser of this.tabAdvertiser)
|
||||||
{
|
{
|
||||||
if(advert.userId === advertiser._id) {
|
if(advert.userId === advertiser.id) {
|
||||||
company0 = advertiser.company;
|
company0 = advertiser.company;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
_id: advert._id,
|
id: advert.id,
|
||||||
userId: advert.userId,
|
userId: advert.userId,
|
||||||
title: advert.title,
|
title: advert.title,
|
||||||
company: company0,
|
company: company0,
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import {Component, Inject, OnInit} from '@angular/core';
|
import {Component, Inject, OnInit} from '@angular/core';
|
||||||
import {Advert} from "../../../utils/interfaces/advert";
|
|
||||||
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
|
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
|
||||||
import {MessageService} from "../../../utils/services/message/message.service";
|
import {MessageService} from "../../../utils/services/message/message.service";
|
||||||
|
|
||||||
|
|
@ -12,7 +11,7 @@ import {MessageService} from "../../../utils/services/message/message.service";
|
||||||
})
|
})
|
||||||
export class PopupDeleteAdAdminComponent implements OnInit
|
export class PopupDeleteAdAdminComponent implements OnInit
|
||||||
{
|
{
|
||||||
advert: Advert;
|
advert: any;
|
||||||
|
|
||||||
|
|
||||||
constructor( public dialogRef: MatDialogRef<PopupDeleteAdAdminComponent>,
|
constructor( public dialogRef: MatDialogRef<PopupDeleteAdAdminComponent>,
|
||||||
|
|
@ -28,24 +27,21 @@ export class PopupDeleteAdAdminComponent implements OnInit
|
||||||
|
|
||||||
onValidate(): void
|
onValidate(): void
|
||||||
{
|
{
|
||||||
// --- FAUX CODE ---
|
|
||||||
this.dialogRef.close(true);
|
|
||||||
|
|
||||||
// --- VRAI CODE ---
|
|
||||||
/*
|
|
||||||
this.messageService
|
this.messageService
|
||||||
.sendMessage("url/delete/ad", {"advert": this.advert})
|
.delete("ad/delete/"+this.advert.id)
|
||||||
.subscribe( retour => {
|
.subscribe(ret => this.onValidateCallback(ret), err => this.onValidateCallback(err) );
|
||||||
|
}
|
||||||
|
|
||||||
if(retour.status === "error") {
|
|
||||||
|
onValidateCallback(retour: any): void
|
||||||
|
{
|
||||||
|
if(retour.status !== "success") {
|
||||||
console.log(retour);
|
console.log(retour);
|
||||||
this.dialogRef.close();
|
this.dialogRef.close();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.dialogRef.close(true);
|
this.dialogRef.close(true);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,14 +24,14 @@ export class PageProfilAdminComponent implements OnInit
|
||||||
role: {
|
role: {
|
||||||
name: "admin",
|
name: "admin",
|
||||||
permission: 10,
|
permission: 10,
|
||||||
|
isAccepted: true,
|
||||||
},
|
},
|
||||||
profileImageUrl: "",
|
profileImageUrl: "",
|
||||||
dateOfBirth: null,
|
dateOfBirth: null,
|
||||||
gender: "man",
|
gender: "man",
|
||||||
interests: [],
|
interests: [],
|
||||||
company: "",
|
company: "",
|
||||||
isActive: false,
|
isActive: true,
|
||||||
isAccepted: false,
|
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
updatedAt: new Date(),
|
updatedAt: new Date(),
|
||||||
lastConnexion: null
|
lastConnexion: null
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ export class PopupUpdateAdminComponent implements OnInit
|
||||||
role: {
|
role: {
|
||||||
name: admin0.role.name,
|
name: admin0.role.name,
|
||||||
permission: admin0.role.permission,
|
permission: admin0.role.permission,
|
||||||
|
isAccepted: admin0.role.isAccepted,
|
||||||
},
|
},
|
||||||
profileImageUrl: admin0.profileImageUrl,
|
profileImageUrl: admin0.profileImageUrl,
|
||||||
dateOfBirth: admin0.dateOfBirth,
|
dateOfBirth: admin0.dateOfBirth,
|
||||||
|
|
@ -45,7 +46,6 @@ export class PopupUpdateAdminComponent implements OnInit
|
||||||
interests: [],
|
interests: [],
|
||||||
company: "",
|
company: "",
|
||||||
isActive: admin0.isActive,
|
isActive: admin0.isActive,
|
||||||
isAccepted: admin0.isisAccepted,
|
|
||||||
createdAt: admin0.createdAt,
|
createdAt: admin0.createdAt,
|
||||||
updatedAt: admin0.updatedAt,
|
updatedAt: admin0.updatedAt,
|
||||||
lastConnexion: admin0.lastConnexion
|
lastConnexion: admin0.lastConnexion
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,7 @@
|
||||||
|
|
||||||
<!-- Mail Column -->
|
<!-- Mail Column -->
|
||||||
<ng-container matColumnDef="email">
|
<ng-container matColumnDef="email">
|
||||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Mail </th>
|
<th mat-header-cell *matHeaderCellDef mat-sort-header> Email </th>
|
||||||
<td mat-cell *matCellDef="let user">
|
<td mat-cell *matCellDef="let user">
|
||||||
{{user.email}}
|
{{user.email}}
|
||||||
</td>
|
</td>
|
||||||
|
|
@ -171,7 +171,7 @@
|
||||||
<ng-container matColumnDef="isAccepted">
|
<ng-container matColumnDef="isAccepted">
|
||||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Accepté </th>
|
<th mat-header-cell *matHeaderCellDef mat-sort-header> Accepté </th>
|
||||||
<td mat-cell *matCellDef="let user">
|
<td mat-cell *matCellDef="let user">
|
||||||
<mat-slide-toggle [(ngModel)]="user.isAccepted" (click)="onSlideIsAccepted(user)"></mat-slide-toggle>
|
<mat-slide-toggle [(ngModel)]="user.role.isAccepted" (click)="onSlideIsAccepted(user)"></mat-slide-toggle>
|
||||||
</td>
|
</td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -126,12 +126,12 @@
|
||||||
<!-- email -->
|
<!-- email -->
|
||||||
<mat-form-field appearance="fill">
|
<mat-form-field appearance="fill">
|
||||||
<mat-label>Email</mat-label>
|
<mat-label>Email</mat-label>
|
||||||
<input matInput type="text" [(ngModel)]="user.email">
|
<input matInput type="text" [(ngModel)]="user.email" required>
|
||||||
</mat-form-field><br>
|
</mat-form-field><br>
|
||||||
<!-- login -->
|
<!-- login -->
|
||||||
<mat-form-field appearance="fill">
|
<mat-form-field appearance="fill">
|
||||||
<mat-label>Pseudo</mat-label>
|
<mat-label>Pseudo</mat-label>
|
||||||
<input matInput type="text" [(ngModel)]="user.login">
|
<input matInput type="text" [(ngModel)]="user.login" required>
|
||||||
</mat-form-field><br>
|
</mat-form-field><br>
|
||||||
<!-- company -->
|
<!-- company -->
|
||||||
<mat-form-field appearance="fill" *ngIf="user.role.name === 'advertiser'">
|
<mat-form-field appearance="fill" *ngIf="user.role.name === 'advertiser'">
|
||||||
|
|
@ -145,12 +145,12 @@
|
||||||
<!-- mot de passe -->
|
<!-- mot de passe -->
|
||||||
<mat-form-field appearance="fill">
|
<mat-form-field appearance="fill">
|
||||||
<mat-label>Mot de passe</mat-label>
|
<mat-label>Mot de passe</mat-label>
|
||||||
<input matInput type="password" [(ngModel)]="password">
|
<input matInput type="password" [(ngModel)]="password" required>
|
||||||
</mat-form-field><br>
|
</mat-form-field><br>
|
||||||
<!-- confirmation mot de passe -->
|
<!-- confirmation mot de passe -->
|
||||||
<mat-form-field appearance="fill">
|
<mat-form-field appearance="fill">
|
||||||
<mat-label>Confirmation nouveau mot de passe</mat-label>
|
<mat-label>Confirmation nouveau mot de passe</mat-label>
|
||||||
<input matInput type="password" [(ngModel)]="confirmPassword">
|
<input matInput type="password" [(ngModel)]="confirmPassword" required>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ export class PopupCreateUserComponent implements OnInit
|
||||||
role: {
|
role: {
|
||||||
name: "",
|
name: "",
|
||||||
permission: 0,
|
permission: 0,
|
||||||
|
isAccepted: false,
|
||||||
},
|
},
|
||||||
profileImageUrl: "",
|
profileImageUrl: "",
|
||||||
dateOfBirth: null,
|
dateOfBirth: null,
|
||||||
|
|
@ -40,7 +41,6 @@ export class PopupCreateUserComponent implements OnInit
|
||||||
interests: [],
|
interests: [],
|
||||||
company: "",
|
company: "",
|
||||||
isActive: false,
|
isActive: false,
|
||||||
isAccepted: false,
|
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
updatedAt: new Date(),
|
updatedAt: new Date(),
|
||||||
lastConnexion: new Date()
|
lastConnexion: new Date()
|
||||||
|
|
|
||||||
|
|
@ -24,14 +24,14 @@ export class PageProfilAdvertiserComponent implements OnInit
|
||||||
role: {
|
role: {
|
||||||
name: "advertiser",
|
name: "advertiser",
|
||||||
permission: 5,
|
permission: 5,
|
||||||
|
isAccepted: true,
|
||||||
},
|
},
|
||||||
profileImageUrl: "",
|
profileImageUrl: "",
|
||||||
dateOfBirth: null,
|
dateOfBirth: null,
|
||||||
gender: "man",
|
gender: "man",
|
||||||
interests: [],
|
interests: [],
|
||||||
company: "",
|
company: "",
|
||||||
isActive: false,
|
isActive: true,
|
||||||
isAccepted: false,
|
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
updatedAt: new Date(),
|
updatedAt: new Date(),
|
||||||
lastConnexion: null
|
lastConnexion: null
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ export class PopupUpdateAdvertiserComponent implements OnInit
|
||||||
role: {
|
role: {
|
||||||
name: advertiser0.role.name,
|
name: advertiser0.role.name,
|
||||||
permission: advertiser0.role.permission,
|
permission: advertiser0.role.permission,
|
||||||
|
isAccepted: advertiser0.role.isAccepted,
|
||||||
},
|
},
|
||||||
profileImageUrl: advertiser0.profileImageUrl,
|
profileImageUrl: advertiser0.profileImageUrl,
|
||||||
dateOfBirth: advertiser0.dateOfBirth,
|
dateOfBirth: advertiser0.dateOfBirth,
|
||||||
|
|
@ -45,7 +46,6 @@ export class PopupUpdateAdvertiserComponent implements OnInit
|
||||||
interests: [],
|
interests: [],
|
||||||
company: advertiser0.company,
|
company: advertiser0.company,
|
||||||
isActive: advertiser0.isActive,
|
isActive: advertiser0.isActive,
|
||||||
isAccepted: advertiser0.isAccepted,
|
|
||||||
createdAt: advertiser0.createdAt,
|
createdAt: advertiser0.createdAt,
|
||||||
updatedAt: advertiser0.updatedAt,
|
updatedAt: advertiser0.updatedAt,
|
||||||
lastConnexion: new Date()
|
lastConnexion: new Date()
|
||||||
|
|
|
||||||
|
|
@ -27,14 +27,14 @@ export class PageRegisterComponent
|
||||||
role: {
|
role: {
|
||||||
name: "user",
|
name: "user",
|
||||||
permission: 0,
|
permission: 0,
|
||||||
|
isAccepted: false,
|
||||||
},
|
},
|
||||||
profileImageUrl: "",
|
profileImageUrl: "",
|
||||||
dateOfBirth: null,
|
dateOfBirth: null,
|
||||||
gender: "man",
|
gender: "man",
|
||||||
interests: [],
|
interests: [],
|
||||||
company: "",
|
company: "",
|
||||||
isActive: false,
|
isActive: true,
|
||||||
isAccepted: false,
|
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
updatedAt: new Date(),
|
updatedAt: new Date(),
|
||||||
lastConnexion: null
|
lastConnexion: null
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
</mat-chip>
|
</mat-chip>
|
||||||
|
|
||||||
<input
|
<input
|
||||||
placeholder="Tapez un centre d'intérêt"
|
placeholder="Tapez centres d'intérêt"
|
||||||
#tagInput
|
#tagInput
|
||||||
[formControl]="formControl"
|
[formControl]="formControl"
|
||||||
[matAutocomplete]="auto"
|
[matAutocomplete]="auto"
|
||||||
|
|
|
||||||
|
|
@ -24,14 +24,14 @@ export class PageProfilUserComponent implements OnInit
|
||||||
role: {
|
role: {
|
||||||
name: "user",
|
name: "user",
|
||||||
permission: 0,
|
permission: 0,
|
||||||
|
isAccepted: false,
|
||||||
},
|
},
|
||||||
profileImageUrl: "",
|
profileImageUrl: "",
|
||||||
dateOfBirth: null,
|
dateOfBirth: null,
|
||||||
gender: "man",
|
gender: "man",
|
||||||
interests: [],
|
interests: [],
|
||||||
company: "",
|
company: "",
|
||||||
isActive: false,
|
isActive: true,
|
||||||
isAccepted: false,
|
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
updatedAt: new Date(),
|
updatedAt: new Date(),
|
||||||
lastConnexion: null
|
lastConnexion: null
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ export class PopupUpdateUserComponent implements OnInit
|
||||||
role: {
|
role: {
|
||||||
name: user0.role.name,
|
name: user0.role.name,
|
||||||
permission: user0.role.permission,
|
permission: user0.role.permission,
|
||||||
|
isAccepted: user0.role.isAccepted,
|
||||||
},
|
},
|
||||||
profileImageUrl: user0.profileImageUrl,
|
profileImageUrl: user0.profileImageUrl,
|
||||||
dateOfBirth: user0.dateOfBirth,
|
dateOfBirth: user0.dateOfBirth,
|
||||||
|
|
@ -45,7 +46,6 @@ export class PopupUpdateUserComponent implements OnInit
|
||||||
interests: [],
|
interests: [],
|
||||||
company: "",
|
company: "",
|
||||||
isActive: user0.isActive,
|
isActive: user0.isActive,
|
||||||
isAccepted: user0.isAccepted,
|
|
||||||
createdAt: user0.createdAt,
|
createdAt: user0.createdAt,
|
||||||
updatedAt: user0.updatedAt,
|
updatedAt: user0.updatedAt,
|
||||||
lastConnexion: new Date()
|
lastConnexion: new Date()
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ export interface User
|
||||||
role: {
|
role: {
|
||||||
name: string,
|
name: string,
|
||||||
permission: number,
|
permission: number,
|
||||||
|
isAccepted: boolean,
|
||||||
},
|
},
|
||||||
profileImageUrl: string,
|
profileImageUrl: string,
|
||||||
dateOfBirth: Date,
|
dateOfBirth: Date,
|
||||||
|
|
@ -14,7 +15,6 @@ export interface User
|
||||||
interests: any[],
|
interests: any[],
|
||||||
company: string,
|
company: string,
|
||||||
isActive: boolean,
|
isActive: boolean,
|
||||||
isAccepted: boolean,
|
|
||||||
lastConnexion: Date,
|
lastConnexion: Date,
|
||||||
createdAt: Date,
|
createdAt: Date,
|
||||||
updatedAt: Date
|
updatedAt: Date
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,8 @@ const USER: User = {
|
||||||
role: {
|
role: {
|
||||||
name: "user",
|
name: "user",
|
||||||
permission: 0,
|
permission: 0,
|
||||||
|
isAccepted: true,
|
||||||
|
|
||||||
},
|
},
|
||||||
profileImageUrl: "https://www.figurines-goodies.com/1185-thickbox_default/huey-duck-tales-disney-funko-pop.jpg",
|
profileImageUrl: "https://www.figurines-goodies.com/1185-thickbox_default/huey-duck-tales-disney-funko-pop.jpg",
|
||||||
dateOfBirth: new Date(),
|
dateOfBirth: new Date(),
|
||||||
|
|
@ -19,7 +21,6 @@ const USER: User = {
|
||||||
interests: ["foot", "jeux-vidéo"],
|
interests: ["foot", "jeux-vidéo"],
|
||||||
company: "",
|
company: "",
|
||||||
isActive: true,
|
isActive: true,
|
||||||
isAccepted: true,
|
|
||||||
lastConnexion: new Date(),
|
lastConnexion: new Date(),
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
updatedAt: new Date()
|
updatedAt: new Date()
|
||||||
|
|
@ -33,6 +34,8 @@ const ADVERTISER: User = {
|
||||||
role: {
|
role: {
|
||||||
name: "advertiser",
|
name: "advertiser",
|
||||||
permission: 5,
|
permission: 5,
|
||||||
|
isAccepted: true,
|
||||||
|
|
||||||
},
|
},
|
||||||
profileImageUrl: "https://www.figurines-goodies.com/1188-large_default/dewey-duck-tales-disney-funko-pop.jpg",
|
profileImageUrl: "https://www.figurines-goodies.com/1188-large_default/dewey-duck-tales-disney-funko-pop.jpg",
|
||||||
dateOfBirth: null,
|
dateOfBirth: null,
|
||||||
|
|
@ -40,7 +43,6 @@ const ADVERTISER: User = {
|
||||||
interests: [],
|
interests: [],
|
||||||
company: "My company",
|
company: "My company",
|
||||||
isActive: true,
|
isActive: true,
|
||||||
isAccepted: true,
|
|
||||||
lastConnexion: new Date(),
|
lastConnexion: new Date(),
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
updatedAt: new Date(),
|
updatedAt: new Date(),
|
||||||
|
|
@ -54,6 +56,7 @@ const ADMIN: User = {
|
||||||
role: {
|
role: {
|
||||||
name: "admin",
|
name: "admin",
|
||||||
permission: 5,
|
permission: 5,
|
||||||
|
isAccepted: true,
|
||||||
},
|
},
|
||||||
profileImageUrl: "https://www.reference-gaming.com/assets/media/product/41195/figurine-pop-duck-tales-n-309-loulou.jpg?format=product-cover-large&k=1519639530",
|
profileImageUrl: "https://www.reference-gaming.com/assets/media/product/41195/figurine-pop-duck-tales-n-309-loulou.jpg?format=product-cover-large&k=1519639530",
|
||||||
dateOfBirth: null,
|
dateOfBirth: null,
|
||||||
|
|
@ -61,7 +64,6 @@ const ADMIN: User = {
|
||||||
interests: [],
|
interests: [],
|
||||||
company: "",
|
company: "",
|
||||||
isActive: true,
|
isActive: true,
|
||||||
isAccepted: true,
|
|
||||||
lastConnexion: new Date(),
|
lastConnexion: new Date(),
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
updatedAt: new Date(),
|
updatedAt: new Date(),
|
||||||
|
|
@ -83,7 +85,7 @@ export class FictitiousUsersService
|
||||||
res._id += this.fictitiousUtilsService.makeid(5);
|
res._id += this.fictitiousUtilsService.makeid(5);
|
||||||
res.login += (Math.floor(Math.random() * 1000)).toString();
|
res.login += (Math.floor(Math.random() * 1000)).toString();
|
||||||
res.email = res.login + "@gmail.com" ;
|
res.email = res.login + "@gmail.com" ;
|
||||||
res.isAccepted = (Math.random() < 0.5);
|
res.role.isAccepted = (Math.random() < 0.5);
|
||||||
res.isActive = (Math.random() < 0.5);
|
res.isActive = (Math.random() < 0.5);
|
||||||
res.dateOfBirth = this.fictitiousUtilsService.randomDate(new Date(1900, 0, 1), new Date());
|
res.dateOfBirth = this.fictitiousUtilsService.randomDate(new Date(1900, 0, 1), new Date());
|
||||||
res.lastConnexion = this.fictitiousUtilsService.randomDate(new Date(2000, 0, 1), new Date());
|
res.lastConnexion = this.fictitiousUtilsService.randomDate(new Date(2000, 0, 1), new Date());
|
||||||
|
|
@ -122,4 +124,5 @@ export class FictitiousUsersService
|
||||||
for(let i=0 ; i<n ; i++) res.push(this.getAdmin());
|
for(let i=0 ; i<n ; i++) res.push(this.getAdmin());
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Reference in a new issue