Merge remote-tracking branch 'origin/main' into main
This commit is contained in:
commit
2b02e13321
23 changed files with 457 additions and 223 deletions
|
|
@ -97,9 +97,9 @@
|
||||||
<ng-container matColumnDef="interests">
|
<ng-container matColumnDef="interests">
|
||||||
<th mat-header-cell *matHeaderCellDef> Sujets </th>
|
<th mat-header-cell *matHeaderCellDef> Sujets </th>
|
||||||
<td mat-cell *matCellDef="let advert">
|
<td mat-cell *matCellDef="let advert">
|
||||||
<span *ngFor="let interest of advert.interests; let isLast = last;">
|
<span *ngFor="let objectInterest of advert.interests; let isLast = last;">
|
||||||
<span *ngIf="!isLast"> {{interest}}, </span>
|
<span *ngIf="!isLast"> {{objectInterest.interest}}, </span>
|
||||||
<span *ngIf="isLast"> {{interest}} </span>
|
<span *ngIf="isLast"> {{objectInterest.interest}} </span>
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
|
||||||
|
|
@ -8,16 +8,14 @@ import {MatTableDataSource} from "@angular/material/table";
|
||||||
import {Advert} from "../../../utils/interfaces/advert";
|
import {Advert} from "../../../utils/interfaces/advert";
|
||||||
import {PopupDeleteAdAdminComponent} from "../popup-delete-ad-admin/popup-delete-ad-admin.component";
|
import {PopupDeleteAdAdminComponent} from "../popup-delete-ad-admin/popup-delete-ad-admin.component";
|
||||||
import {PopupVisualizeImagesAdminComponent} from "../popup-visualize-images-admin/popup-visualize-images-admin.component";
|
import {PopupVisualizeImagesAdminComponent} from "../popup-visualize-images-admin/popup-visualize-images-admin.component";
|
||||||
import {FictitiousAdvertsService} from "../../../utils/services/fictitiousDatas/fictitiousAdverts/fictitious-adverts.service";
|
|
||||||
import {FormControl} from "@angular/forms";
|
import {FormControl} from "@angular/forms";
|
||||||
import {FictitiousUtilsService} from "../../../utils/services/fictitiousDatas/fictitiousUtils/fictitious-utils.service";
|
import {MessageService} from "../../../utils/services/message/message.service";
|
||||||
import {User} from "../../../utils/interfaces/user";
|
import {HttpParams} from "@angular/common/http";
|
||||||
import {FictitiousUsersService} from "../../../utils/services/fictitiousDatas/fictitiousUsers/fictitious-users.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 +44,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;
|
||||||
|
|
@ -61,24 +59,65 @@ export class PageAdListAdminComponent implements AfterViewInit
|
||||||
|
|
||||||
|
|
||||||
constructor( public themeService: ThemeService,
|
constructor( public themeService: ThemeService,
|
||||||
private fictitiousAdvertsService: FictitiousAdvertsService,
|
|
||||||
private fictitiousUtilsService: FictitiousUtilsService,
|
|
||||||
private fictitiousUsersService: FictitiousUsersService,
|
|
||||||
public dialog: MatDialog,
|
public dialog: MatDialog,
|
||||||
private snackBar: MatSnackBar ) { }
|
private snackBar: MatSnackBar,
|
||||||
|
private messageService: MessageService) { }
|
||||||
|
|
||||||
|
|
||||||
ngAfterViewInit(): void
|
ngAfterViewInit(): void
|
||||||
{
|
{
|
||||||
// --- FAUX CODE ---
|
// Ask for ads and then for advertiser
|
||||||
const tabAdvert = this.fictitiousAdvertsService.getTabAdvert(8);
|
let params = new HttpParams();
|
||||||
this.allInterests = this.fictitiousUtilsService.getTags();
|
params = params.append("isActive", true);
|
||||||
this.tabAdvertiser = this.fictitiousUsersService.getTabAdvertiser(3);
|
this.messageService
|
||||||
|
.get("ad/findAll", params)
|
||||||
|
.subscribe(ret => this.afterReceivingAds(ret), err => this.afterReceivingAds(err) );
|
||||||
|
|
||||||
|
// Ask for interest
|
||||||
|
this.messageService
|
||||||
|
.get("misc/getInterests")
|
||||||
|
.subscribe(ret => this.afterReceivingInterests(ret), err => this.afterReceivingInterests(err) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
afterReceivingAds(retour: any): void
|
||||||
|
{
|
||||||
|
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
|
||||||
|
{
|
||||||
|
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));
|
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();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
afterReceivingInterests(retour: any): void
|
||||||
|
{
|
||||||
|
if(retour.status !== "success") {
|
||||||
|
console.log(retour);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.allInterests = retour.data.map(x => x.interest);
|
||||||
|
this.allInterests.sort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
applyFilter(event: Event): void
|
applyFilter(event: Event): void
|
||||||
|
|
@ -89,6 +128,8 @@ export class PageAdListAdminComponent implements AfterViewInit
|
||||||
|
|
||||||
|
|
||||||
onVisualizeImages(advert: AdvertWithCountViewsAndCompany)
|
onVisualizeImages(advert: AdvertWithCountViewsAndCompany)
|
||||||
|
{
|
||||||
|
if(advert.images.length !== 0)
|
||||||
{
|
{
|
||||||
const config = {
|
const config = {
|
||||||
width: '30%',
|
width: '30%',
|
||||||
|
|
@ -104,6 +145,12 @@ export class PageAdListAdminComponent implements AfterViewInit
|
||||||
.afterClosed()
|
.afterClosed()
|
||||||
.subscribe(retour => {});
|
.subscribe(retour => {});
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
const config = { duration: 2000, panelClass: "custom-class" };
|
||||||
|
const message = "Cette annonce ne contient aucune image" ;
|
||||||
|
this.snackBar.open( message, "", config);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
onDelete(advert: AdvertWithCountViewsAndCompany): void
|
onDelete(advert: AdvertWithCountViewsAndCompany): void
|
||||||
|
|
@ -122,7 +169,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 +234,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,23 @@ 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 {
|
||||||
|
console.log("suppr");
|
||||||
|
console.log(retour);
|
||||||
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
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,8 @@
|
||||||
<mat-icon>power_settings_new</mat-icon>
|
<mat-icon>power_settings_new</mat-icon>
|
||||||
</th>
|
</th>
|
||||||
<td mat-cell *matCellDef="let user">
|
<td mat-cell *matCellDef="let user">
|
||||||
<mat-slide-toggle [(ngModel)]="user.isActive" (click)="onSliderIsActive(user)"></mat-slide-toggle>
|
<mat-slide-toggle *ngIf="user.role.name !== 'superAdmin'" [(ngModel)]="user.isActive" (click)="onSliderIsActive(user)"></mat-slide-toggle>
|
||||||
|
<mat-slide-toggle *ngIf="user.role.name === 'superAdmin'" [(ngModel)]="user.isActive" disabled></mat-slide-toggle>
|
||||||
</td>
|
</td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
|
|
@ -107,7 +108,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 +172,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>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,9 @@ import {ThemeService} from "../../../utils/services/theme/theme.service";
|
||||||
import {MatDialog} from "@angular/material/dialog";
|
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 {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 {MessageService} from "../../../utils/services/message/message.service";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -25,8 +24,8 @@ export class PageUserListComponent implements AfterViewInit
|
||||||
displayedColumnsAdmin: string[] = [ 'isActive', 'login', 'email', 'createdAt', 'lastConnexion' ];
|
displayedColumnsAdmin: string[] = [ 'isActive', 'login', 'email', 'createdAt', 'lastConnexion' ];
|
||||||
|
|
||||||
tabUser: any[] = [];
|
tabUser: any[] = [];
|
||||||
tabAdvertiser: User[] = [];
|
tabAdvertiser: any[] = [];
|
||||||
tabAdmin: User[] = [];
|
tabAdmin: any[] = [];
|
||||||
|
|
||||||
roleName: string = "user" ;
|
roleName: string = "user" ;
|
||||||
dataSource ;
|
dataSource ;
|
||||||
|
|
@ -40,22 +39,37 @@ export class PageUserListComponent implements AfterViewInit
|
||||||
|
|
||||||
|
|
||||||
constructor( public themeService: ThemeService,
|
constructor( public themeService: ThemeService,
|
||||||
private fictitiousUsersService: FictitiousUsersService,
|
|
||||||
public dialog: MatDialog,
|
public dialog: MatDialog,
|
||||||
private snackBar: MatSnackBar ) { }
|
private snackBar: MatSnackBar,
|
||||||
|
private messageService: MessageService ) { }
|
||||||
|
|
||||||
|
|
||||||
ngAfterViewInit(): void
|
ngAfterViewInit(): void
|
||||||
{
|
{
|
||||||
// --- FAUX CODE ---
|
this.messageService
|
||||||
this.tabUser = this.fictitiousUsersService.getTabUser(32);
|
.get("user/findAll")
|
||||||
this.tabAdvertiser = this.fictitiousUsersService.getTabAdvertiser(8);
|
.subscribe(ret => this.ngAfterViewInitCallback(ret), err => this.ngAfterViewInitCallback(err));
|
||||||
this.tabAdmin = this.fictitiousUsersService.getTabAdmin(4);
|
}
|
||||||
|
|
||||||
for(const user of this.tabUser) user.age = this.getAge(user.dateOfBirth);
|
|
||||||
|
|
||||||
|
ngAfterViewInitCallback(retour: any): void
|
||||||
|
{
|
||||||
|
if(retour.status !== "success") {
|
||||||
|
console.log(retour);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for(let person of retour.data)
|
||||||
|
{
|
||||||
|
if(person.role.name === "user") {
|
||||||
|
person["age"] = this.getAge(person.dateOfBirth);
|
||||||
|
this.tabUser.push(person);
|
||||||
|
}
|
||||||
|
else if(person.role.name === "advertiser") this.tabAdvertiser.push(person);
|
||||||
|
else this.tabAdmin.push(person);
|
||||||
|
}
|
||||||
this.onFilter();
|
this.onFilter();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
applyFilter(event: Event): void
|
applyFilter(event: Event): void
|
||||||
|
|
@ -65,7 +79,7 @@ export class PageUserListComponent implements AfterViewInit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
onDelete(user: User): void
|
onDelete(user: any): void
|
||||||
{
|
{
|
||||||
const config = {
|
const config = {
|
||||||
data: { user: user }
|
data: { user: user }
|
||||||
|
|
@ -81,13 +95,13 @@ export class PageUserListComponent implements AfterViewInit
|
||||||
message = "Opération annulée" ;
|
message = "Opération annulée" ;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const index = this.dataSource.data.findIndex( elt => (elt._id === user._id));
|
const index = this.dataSource.data.findIndex( elt => (elt.id === user.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;
|
||||||
message = user.login + " a bien été supprimée ✔" ;
|
message = user.login + " a bien été supprimée ✔" ;
|
||||||
}
|
}
|
||||||
this.snackBar.open( message, "", config);
|
this.snackBar.open(message, "", config);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -106,20 +120,47 @@ export class PageUserListComponent implements AfterViewInit
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.snackBar.open( "L'utilisateur a bien été créé", "", config);
|
this.snackBar.open( "L'utilisateur a bien été créé", "", config);
|
||||||
|
if(retour.role.name === "user") this.tabUser.push(retour);
|
||||||
|
else if(retour.role.name === "advertiser") this.tabAdvertiser.push(retour);
|
||||||
|
else if(retour.role.name === "admin") this.tabAdmin.push(retour);
|
||||||
|
this.onFilter();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
onSliderIsActive(user: User): void
|
onSliderIsActive(user: any): void
|
||||||
{
|
{
|
||||||
// il faut envoyer la négation de user.isActive
|
// il faut envoyer la négation de user.isActive
|
||||||
|
this.messageService
|
||||||
|
.put("user/update/"+user.id, { isActive: !user.isActive })
|
||||||
|
.subscribe(
|
||||||
|
ret => {},
|
||||||
|
err => {
|
||||||
|
console.log("onSliderIsActive");
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
onSlideIsAccepted(user: User): void
|
onSlideIsAccepted(user: any): void
|
||||||
{
|
{
|
||||||
// il faut envoyer la négation de user.isActive
|
// il faut envoyer la négation de user.role.isAccepted
|
||||||
|
const role0 = {
|
||||||
|
name: user.role.name,
|
||||||
|
permission: user.role.permission,
|
||||||
|
isAccepted: !user.role.isAccepted,
|
||||||
|
};
|
||||||
|
this.messageService
|
||||||
|
.put("user/update/"+user.id, {role: role0})
|
||||||
|
.subscribe(
|
||||||
|
ret => {},
|
||||||
|
err => {
|
||||||
|
console.log("onSlideIsAccepted");
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -127,7 +168,7 @@ export class PageUserListComponent implements AfterViewInit
|
||||||
{
|
{
|
||||||
if((date === null) || (date === undefined)) return -1;
|
if((date === null) || (date === undefined)) return -1;
|
||||||
else {
|
else {
|
||||||
const diff = Date.now() - date.getTime();
|
const diff = Date.now() - (new Date(date)).getTime();
|
||||||
const age = new Date(diff);
|
const age = new Date(diff);
|
||||||
return Math.abs(age.getUTCFullYear() - 1970);
|
return Math.abs(age.getUTCFullYear() - 1970);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import {Component, Inject, OnInit} from '@angular/core';
|
import {Component, Inject, OnInit} from '@angular/core';
|
||||||
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
|
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
|
||||||
import {User} from "../../../utils/interfaces/user";
|
import {MessageService} from "../../../utils/services/message/message.service";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -11,7 +11,7 @@ import {User} from "../../../utils/interfaces/user";
|
||||||
})
|
})
|
||||||
export class PopupCreateUserComponent implements OnInit
|
export class PopupCreateUserComponent implements OnInit
|
||||||
{
|
{
|
||||||
user: User;
|
user: any;
|
||||||
hasError: boolean = false;
|
hasError: boolean = false;
|
||||||
errorMessage: string = "";
|
errorMessage: string = "";
|
||||||
password: string = "";
|
password: string = "";
|
||||||
|
|
@ -19,7 +19,8 @@ export class PopupCreateUserComponent implements OnInit
|
||||||
|
|
||||||
|
|
||||||
constructor( public dialogRef: MatDialogRef<PopupCreateUserComponent>,
|
constructor( public dialogRef: MatDialogRef<PopupCreateUserComponent>,
|
||||||
@Inject(MAT_DIALOG_DATA) public data ) { }
|
@Inject(MAT_DIALOG_DATA) public data,
|
||||||
|
private messageService: MessageService ) { }
|
||||||
|
|
||||||
|
|
||||||
// Initialise l'utilisateur qui va être créé
|
// Initialise l'utilisateur qui va être créé
|
||||||
|
|
@ -33,6 +34,7 @@ export class PopupCreateUserComponent implements OnInit
|
||||||
role: {
|
role: {
|
||||||
name: "",
|
name: "",
|
||||||
permission: 0,
|
permission: 0,
|
||||||
|
isAccepted: false,
|
||||||
},
|
},
|
||||||
profileImageUrl: "",
|
profileImageUrl: "",
|
||||||
dateOfBirth: null,
|
dateOfBirth: null,
|
||||||
|
|
@ -40,7 +42,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()
|
||||||
|
|
@ -52,12 +53,25 @@ export class PopupCreateUserComponent implements OnInit
|
||||||
onEnregistrer(): void
|
onEnregistrer(): void
|
||||||
{
|
{
|
||||||
this.checkField();
|
this.checkField();
|
||||||
|
|
||||||
if(!this.hasError)
|
if(!this.hasError)
|
||||||
{
|
{
|
||||||
this.user.hashPass = this.hashage(this.password);
|
this.user.hashPass = this.password;
|
||||||
this.dialogRef.close(this.user);
|
this.user.role = this.user.role.name;
|
||||||
// VRAI CODE ...
|
this.messageService
|
||||||
|
.post("user/create", this.user)
|
||||||
|
.subscribe(ret => this.onEnregistrerCallback(ret), err => this.onEnregistrerCallback(err));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Callback de 'onEnregistrer'
|
||||||
|
onEnregistrerCallback(retour: any): void
|
||||||
|
{
|
||||||
|
if(retour.status !== "success") {
|
||||||
|
console.log(retour);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.dialogRef.close(retour.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -110,17 +124,4 @@ export class PopupCreateUserComponent implements OnInit
|
||||||
this.user.interests = myInterets;
|
this.user.interests = myInterets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Fonction de hashage (faible)
|
|
||||||
hashage(input: string): string
|
|
||||||
{
|
|
||||||
let hash = 0;
|
|
||||||
for (let i = 0; i < input.length; i++) {
|
|
||||||
let ch = input.charCodeAt(i);
|
|
||||||
hash = ((hash << 5) - hash) + ch;
|
|
||||||
hash = hash & hash;
|
|
||||||
}
|
|
||||||
return hash.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,10 +38,19 @@ export class InputInterestsAdComponent implements OnInit
|
||||||
startWith(null),
|
startWith(null),
|
||||||
map((fruit: string | null) => fruit ? this._filter(fruit) : this.allTags.slice()));
|
map((fruit: string | null) => fruit ? this._filter(fruit) : this.allTags.slice()));
|
||||||
|
|
||||||
// --- FAUX CODE ---
|
this.messageService
|
||||||
this.allTags = this.fictitiousUtilsService.getTags();
|
.get("misc/getInterests")
|
||||||
|
.subscribe( retour => {
|
||||||
|
|
||||||
|
if(retour.status !== "success") {
|
||||||
|
console.log(retour);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.allTags = retour.data.map(x => x.interest)
|
||||||
this.allTags.sort();
|
this.allTags.sort();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
add(event: MatChipInputEvent): void
|
add(event: MatChipInputEvent): void
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,8 @@ import {PopupVisualizeImagesAdvertiserComponent} from "../popup-visualize-images
|
||||||
import {FictitiousAdvertsService} from "../../../utils/services/fictitiousDatas/fictitiousAdverts/fictitious-adverts.service";
|
import {FictitiousAdvertsService} from "../../../utils/services/fictitiousDatas/fictitiousAdverts/fictitious-adverts.service";
|
||||||
import {FormControl} from "@angular/forms";
|
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 {MessageService} from "../../../utils/services/message/message.service";
|
||||||
|
import {HttpParams} from "@angular/common/http";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -24,7 +26,7 @@ export class PageAdListAdvertiserComponent implements AfterViewInit
|
||||||
{
|
{
|
||||||
displayedColumns: string[] = [ 'isVisible', 'title', 'interests', 'createdAt', 'updatedAt', 'countViews', 'actions' ];
|
displayedColumns: string[] = [ 'isVisible', 'title', 'interests', 'createdAt', 'updatedAt', 'countViews', 'actions' ];
|
||||||
tabAdvertWithCountViews: AdvertWithCountViews[] = [];
|
tabAdvertWithCountViews: AdvertWithCountViews[] = [];
|
||||||
dataSource ;
|
dataSource;
|
||||||
@ViewChild(MatSort) sort: MatSort;
|
@ViewChild(MatSort) sort: MatSort;
|
||||||
@ViewChild(MatPaginator) paginator: MatPaginator;
|
@ViewChild(MatPaginator) paginator: MatPaginator;
|
||||||
|
|
||||||
|
|
@ -33,6 +35,8 @@ export class PageAdListAdvertiserComponent implements AfterViewInit
|
||||||
startDate: Date = null;
|
startDate: Date = null;
|
||||||
endDate: Date = null;
|
endDate: Date = null;
|
||||||
formControlInterests = new FormControl();
|
formControlInterests = new FormControl();
|
||||||
|
|
||||||
|
allVideoCategorie = [];
|
||||||
allInterests: string[] = [];
|
allInterests: string[] = [];
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -40,19 +44,51 @@ export class PageAdListAdvertiserComponent implements AfterViewInit
|
||||||
private fictitiousAdvertsService: FictitiousAdvertsService,
|
private fictitiousAdvertsService: FictitiousAdvertsService,
|
||||||
private fictitiousUtilsService: FictitiousUtilsService,
|
private fictitiousUtilsService: FictitiousUtilsService,
|
||||||
public dialog: MatDialog,
|
public dialog: MatDialog,
|
||||||
private snackBar: MatSnackBar ) { }
|
private snackBar: MatSnackBar,
|
||||||
|
private messageService: MessageService ) { }
|
||||||
|
|
||||||
|
|
||||||
ngAfterViewInit(): void
|
ngAfterViewInit(): void
|
||||||
{
|
{
|
||||||
// --- FAUX CODE ---
|
// Ask interests
|
||||||
const tabAdvert = this.fictitiousAdvertsService.getTabAdvert(8);
|
this.messageService
|
||||||
this.allInterests = this.fictitiousUtilsService.getTags();
|
.get("misc/getInterests")
|
||||||
|
.subscribe(ret => this.afterReceivingInterests(ret), err => this.afterReceivingInterests(err) );
|
||||||
|
|
||||||
for(let advert of tabAdvert) this.tabAdvertWithCountViews.push(this.advertToAdvertWithCountViews(advert));
|
// Ask ads
|
||||||
this.dataSource = new MatTableDataSource<Advert>();
|
let params = new HttpParams();
|
||||||
|
params = params.append("isActive", true);
|
||||||
|
this.messageService
|
||||||
|
.get("ad/findAll", params)
|
||||||
|
.subscribe(ret => this.afterReceivingAds(ret), err => this.afterReceivingAds(err));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
afterReceivingInterests(retour: any): void
|
||||||
|
{
|
||||||
|
if(retour.status !== "success") {
|
||||||
|
console.log("afterReceivingInterests");
|
||||||
|
console.log(retour);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.allVideoCategorie = retour.data;
|
||||||
|
this.allInterests = retour.data.map(x => x.interest);
|
||||||
|
this.allInterests.sort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
afterReceivingAds(retour: any): void
|
||||||
|
{
|
||||||
|
if(retour.status !== "success") {
|
||||||
|
console.log(retour);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for(let advert of retour.data) this.tabAdvertWithCountViews.push(this.advertToAdvertWithCountViews(advert));
|
||||||
|
this.dataSource = new MatTableDataSource<AdvertWithCountViews>();
|
||||||
this.onFilter();
|
this.onFilter();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
applyFilter(event: Event): void
|
applyFilter(event: Event): void
|
||||||
|
|
@ -86,7 +122,7 @@ export class PageAdListAdvertiserComponent implements AfterViewInit
|
||||||
width: '75%',
|
width: '75%',
|
||||||
height: '80%',
|
height: '80%',
|
||||||
panelClass: 'custom-dialog-container',
|
panelClass: 'custom-dialog-container',
|
||||||
data: { action: "add", advert: null }
|
data: { action: "add", advert: null, allVideoCategorie: this.allVideoCategorie }
|
||||||
};
|
};
|
||||||
this.dialog
|
this.dialog
|
||||||
.open(PopupAddOrUpdateAdComponent, config)
|
.open(PopupAddOrUpdateAdComponent, config)
|
||||||
|
|
@ -99,10 +135,9 @@ export class PageAdListAdvertiserComponent implements AfterViewInit
|
||||||
message = "Opération annulée" ;
|
message = "Opération annulée" ;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.dataSource.data.push(advertAdded);
|
this.tabAdvertWithCountViews.push(this.advertToAdvertWithCountViews(advertAdded));
|
||||||
this.dataSource.data = this.dataSource.data;
|
this.onFilter();
|
||||||
this.dataSource = this.dataSource;
|
message = "L'annoonce a bien été ajoutée ✔" ;
|
||||||
message = "L'annoonce a bien été ajoutée ✔"
|
|
||||||
}
|
}
|
||||||
this.snackBar.open( message, "", config);
|
this.snackBar.open( message, "", config);
|
||||||
});
|
});
|
||||||
|
|
@ -115,7 +150,7 @@ export class PageAdListAdvertiserComponent implements AfterViewInit
|
||||||
width: '75%',
|
width: '75%',
|
||||||
height: '80%',
|
height: '80%',
|
||||||
panelClass: 'custom-dialog-container',
|
panelClass: 'custom-dialog-container',
|
||||||
data: { action: "update", advert: advertToUpdate }
|
data: { action: "update", advert: advertToUpdate, allVideoCategorie: this.allVideoCategorie }
|
||||||
};
|
};
|
||||||
this.dialog
|
this.dialog
|
||||||
.open(PopupAddOrUpdateAdComponent, config)
|
.open(PopupAddOrUpdateAdComponent, config)
|
||||||
|
|
@ -128,11 +163,10 @@ export class PageAdListAdvertiserComponent implements AfterViewInit
|
||||||
message = "Opération annulée" ;
|
message = "Opération annulée" ;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const index = this.dataSource.data.findIndex( elt => (elt._id === advertToUpdate._id));
|
const index = this.tabAdvertWithCountViews.findIndex(elt => (elt.id === advertToUpdate.id));
|
||||||
this.dataSource.data.splice(index, 1, advertUpdated);
|
this.tabAdvertWithCountViews.splice(index, 1, this.advertToAdvertWithCountViews(advertUpdated));
|
||||||
this.dataSource.data = this.dataSource.data;
|
this.onFilter();
|
||||||
this.dataSource = this.dataSource;
|
message = "L'annonce a bien été modifiée ✔" ;
|
||||||
message = "L'annonce a bien été modifiée ✔"
|
|
||||||
}
|
}
|
||||||
this.snackBar.open( message, "", config);
|
this.snackBar.open( message, "", config);
|
||||||
});
|
});
|
||||||
|
|
@ -155,7 +189,7 @@ export class PageAdListAdvertiserComponent 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;
|
||||||
|
|
@ -168,6 +202,7 @@ export class PageAdListAdvertiserComponent implements AfterViewInit
|
||||||
|
|
||||||
onFilter(): void
|
onFilter(): void
|
||||||
{
|
{
|
||||||
|
if(this.dataSource === null || this.dataSource === undefined) this.dataSource = new MatTableDataSource();
|
||||||
this.dataSource.data = [];
|
this.dataSource.data = [];
|
||||||
for(let advert of this.tabAdvertWithCountViews)
|
for(let advert of this.tabAdvertWithCountViews)
|
||||||
{
|
{
|
||||||
|
|
@ -220,21 +255,30 @@ export class PageAdListAdvertiserComponent implements AfterViewInit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
onSliderIsVisible(advert: Advert): void
|
onSliderIsVisible(advert: any): void
|
||||||
{
|
{
|
||||||
// il faut envoyer la négation de user.isActive
|
// il faut envoyer la négation de user.isActive
|
||||||
|
this.messageService
|
||||||
|
.put("ad/update/"+advert.id, { isVisible: !advert.isVisible })
|
||||||
|
.subscribe(
|
||||||
|
ret => {},
|
||||||
|
err => {
|
||||||
|
console.log("onSliderIsVisible");
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
advertToAdvertWithCountViews(advert: Advert): AdvertWithCountViews
|
advertToAdvertWithCountViews(advert): AdvertWithCountViews
|
||||||
{
|
{
|
||||||
return {
|
return {
|
||||||
_id: advert._id,
|
id: advert.id,
|
||||||
userId: advert.userId,
|
userId: advert.userId,
|
||||||
title: advert.title,
|
title: advert.title,
|
||||||
url: advert.url,
|
url: advert.url,
|
||||||
images: advert.images,
|
images: advert.images,
|
||||||
interests: advert.interests,
|
interests: advert.interests.map(x => x.interest),
|
||||||
comment: advert.comment,
|
comment: advert.comment,
|
||||||
views: advert.views,
|
views: advert.views,
|
||||||
countViews: advert.views.length,
|
countViews: advert.views.length,
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,9 @@ const ADVERT_VIDE: Advert = {
|
||||||
})
|
})
|
||||||
export class PopupAddOrUpdateAdComponent implements OnInit
|
export class PopupAddOrUpdateAdComponent implements OnInit
|
||||||
{
|
{
|
||||||
advert: Advert;
|
advert: any;
|
||||||
urlBackend: string = "" ;
|
|
||||||
title: string = "" ;
|
title: string = "" ;
|
||||||
|
allVideoCategorie = [];
|
||||||
tabWaitingFile: File[] = []; // fichiers selectionnés mais pas encore "validés"
|
tabWaitingFile: File[] = []; // fichiers selectionnés mais pas encore "validés"
|
||||||
tabSelectedFile: File[] = []; // fichier "validés"
|
tabSelectedFile: File[] = []; // fichier "validés"
|
||||||
_event;
|
_event;
|
||||||
|
|
@ -44,18 +44,17 @@ export class PopupAddOrUpdateAdComponent implements OnInit
|
||||||
|
|
||||||
ngOnInit(): void
|
ngOnInit(): void
|
||||||
{
|
{
|
||||||
|
this.allVideoCategorie = this.data.allVideoCategorie
|
||||||
if(this.data.action === "add")
|
if(this.data.action === "add")
|
||||||
{
|
{
|
||||||
this.advert = Object.assign({}, ADVERT_VIDE);
|
this.advert = Object.assign({}, ADVERT_VIDE);
|
||||||
this.advert.interests = [];
|
this.advert.interests = [];
|
||||||
this.urlBackend = "url/add/ad" ;
|
|
||||||
this.title = "Ajouter annonce" ;
|
this.title = "Ajouter annonce" ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.advert = Object.assign({}, this.data.advert);
|
this.advert = Object.assign({}, this.data.advert);
|
||||||
this.advert.interests = this.data.advert.interests.slice();
|
this.advert.interests = this.data.advert.interests.slice();
|
||||||
this.urlBackend = "url/update/ad" ;
|
|
||||||
this.title = "Modifier annonce" ;
|
this.title = "Modifier annonce" ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -63,24 +62,59 @@ export class PopupAddOrUpdateAdComponent implements OnInit
|
||||||
|
|
||||||
onValidate(): void
|
onValidate(): void
|
||||||
{
|
{
|
||||||
// --- FAUX CODE ---
|
// On transforme 'this.user.interests' en tableau de 'videoCategorie'
|
||||||
this.dialogRef.close(this.advert);
|
let interests = []; // tableau de videoCategorie
|
||||||
|
for(let interest of this.advert.interests)
|
||||||
|
{
|
||||||
|
for(let videoCategorie of this.allVideoCategorie)
|
||||||
|
{
|
||||||
|
if(videoCategorie.interest === interest) {
|
||||||
|
interests.push(videoCategorie);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.advert.interests = interests;
|
||||||
|
|
||||||
// --- VRAI CODE ---
|
if(this.data.action === "add")
|
||||||
/*
|
{
|
||||||
this.messageService
|
this.messageService
|
||||||
.sendMessage(this.urlBackend, this.advert)
|
.post("ad/create", this.advert)
|
||||||
.subscribe( retour => {
|
.subscribe(ret => this.onCreateCallback(ret), err => this.onCreateCallback(err));
|
||||||
|
|
||||||
if(retour.status === "error") {
|
|
||||||
console.log(retour);
|
|
||||||
this.dialogRef.close(this.advert);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.dialogRef.close(retour.data.advert);
|
const id = this.advert.id;
|
||||||
|
Reflect.deleteProperty(this.advert, "id");
|
||||||
|
Reflect.deleteProperty(this.advert, "_id");
|
||||||
|
this.messageService
|
||||||
|
.put("ad/update/"+id, this.advert)
|
||||||
|
.subscribe(ret => this.onUpdateCallback(ret,id), err => this.onUpdateCallback(err,id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
onCreateCallback(retour: any): void
|
||||||
|
{
|
||||||
|
if(retour.status !== "success") {
|
||||||
|
console.log(retour);
|
||||||
|
this.dialogRef.close();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.dialogRef.close(retour.data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
onUpdateCallback(retour: any, id: string): void
|
||||||
|
{
|
||||||
|
if(retour.status !== "success") {
|
||||||
|
console.log(retour);
|
||||||
|
this.dialogRef.close();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.advert.id = id;
|
||||||
|
this.dialogRef.close(this.advert);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import {Component, Inject, OnInit} from '@angular/core';
|
import {Component, Inject, OnInit} from '@angular/core';
|
||||||
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";
|
||||||
import {Advert} from "../../../utils/interfaces/advert";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -12,7 +11,7 @@ import {Advert} from "../../../utils/interfaces/advert";
|
||||||
})
|
})
|
||||||
export class PopupDeleteAdAdvertiserComponent implements OnInit
|
export class PopupDeleteAdAdvertiserComponent implements OnInit
|
||||||
{
|
{
|
||||||
advert: Advert;
|
advert: any;
|
||||||
|
|
||||||
|
|
||||||
constructor( public dialogRef: MatDialogRef<PopupDeleteAdAdvertiserComponent>,
|
constructor( public dialogRef: MatDialogRef<PopupDeleteAdAdvertiserComponent>,
|
||||||
|
|
@ -28,24 +27,21 @@ export class PopupDeleteAdAdvertiserComponent 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 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()
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@ import { Router} from "@angular/router";
|
||||||
import {FictitiousAdvertsService} from "../../utils/services/fictitiousDatas/fictitiousAdverts/fictitious-adverts.service";
|
import {FictitiousAdvertsService} from "../../utils/services/fictitiousDatas/fictitiousAdverts/fictitious-adverts.service";
|
||||||
import {FictitiousVideosService} from "../../utils/services/fictitiousDatas/fictitiousVideos/fictitious-videos.service";
|
import {FictitiousVideosService} from "../../utils/services/fictitiousDatas/fictitiousVideos/fictitious-videos.service";
|
||||||
import {ThemeService} from "../../utils/services/theme/theme.service";
|
import {ThemeService} from "../../utils/services/theme/theme.service";
|
||||||
|
import {MessageService} from "../../utils/services/message/message.service";
|
||||||
|
import {HttpParams} from "@angular/common/http";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -26,6 +28,8 @@ export class PagesPopularityComponent implements OnInit
|
||||||
formControl: FormControl;
|
formControl: FormControl;
|
||||||
allCoupleNameViews: CoupleNameViews[] = [];
|
allCoupleNameViews: CoupleNameViews[] = [];
|
||||||
|
|
||||||
|
allInterests: string[] = [];
|
||||||
|
|
||||||
startDate: Date = null;
|
startDate: Date = null;
|
||||||
endDate: Date = null;
|
endDate: Date = null;
|
||||||
step: number = 1;
|
step: number = 1;
|
||||||
|
|
@ -48,38 +52,80 @@ export class PagesPopularityComponent implements OnInit
|
||||||
constructor( private router: Router,
|
constructor( private router: Router,
|
||||||
public themeService: ThemeService,
|
public themeService: ThemeService,
|
||||||
private fictitiousAdvertsService: FictitiousAdvertsService,
|
private fictitiousAdvertsService: FictitiousAdvertsService,
|
||||||
private fictitiousVideosService: FictitiousVideosService ) {}
|
private fictitiousVideosService: FictitiousVideosService,
|
||||||
|
private messageService: MessageService ) {}
|
||||||
|
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
ngOnInit(): void
|
ngOnInit(): void
|
||||||
{
|
{
|
||||||
if(this.router.url.includes("ads")) this.ngOnInitAds();
|
// Sera excuté si on est sur la page 'adsPopularity'
|
||||||
else if(this.router.url.includes("subjects")) this.ngOnInitSubjects();
|
// Remplie l'attribut 'allCoupleNameViews'
|
||||||
this.formControl = new FormControl(this.allCoupleNameViews);
|
if(this.router.url.includes("ads"))
|
||||||
this.onApplyFilter();
|
{
|
||||||
|
let params = new HttpParams();
|
||||||
|
params = params.append("isActive", true);
|
||||||
|
this.messageService
|
||||||
|
.get("ad/findAll", params )
|
||||||
|
.subscribe(ret => this.afterReceivingAds(ret), err => this.afterReceivingAds(err));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sera excuté si on est sur la page 'subjectsPopularity'
|
||||||
|
// Remplie l'attribut 'allCoupleNameViews'
|
||||||
|
else if(this.router.url.includes("subjects"))
|
||||||
|
{
|
||||||
|
this.messageService
|
||||||
|
.get("misc/getInterests")
|
||||||
|
.subscribe( retour => {
|
||||||
|
|
||||||
|
if(retour.status !== "success") {
|
||||||
|
console.log(retour);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.allInterests = retour.data.map(x => x.interest);
|
||||||
|
this.allInterests.sort();
|
||||||
|
this.messageService
|
||||||
|
.get("video/findAll")
|
||||||
|
.subscribe(ret => this.afterReceivingVideos(ret), err => this.afterReceivingVideos(err));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Sera excuté si on est sur la page 'adsPopularity'
|
// Callback: Sera excuté si on est sur la page 'adsPopularity'
|
||||||
// Remplie l'attribut 'allCoupleNameViews'
|
afterReceivingAds(retour: any): void
|
||||||
ngOnInitAds(): void
|
|
||||||
{
|
{
|
||||||
const allAdverts = this.fictitiousAdvertsService.get_TAB_ADVERT();
|
if(retour.status !== "success") {
|
||||||
|
console.log(retour);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const allAdverts = retour.data;
|
||||||
for(let advert of allAdverts)
|
for(let advert of allAdverts)
|
||||||
{
|
{
|
||||||
let couple = {name: advert.title, views: advert.views }
|
let couple = {name: advert.title, views: advert.views }
|
||||||
this.allCoupleNameViews.push(couple);
|
this.allCoupleNameViews.push(couple);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.formControl = new FormControl(this.allCoupleNameViews);
|
||||||
|
this.onApplyFilter();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Sera excuté si on est sur la page 'subjectsPopularity'
|
// Callback: Sera excuté si on est sur la page 'subjectsPopularity'
|
||||||
// Remplie l'attribut 'allCoupleNameViews'
|
afterReceivingVideos(retour: any): void
|
||||||
ngOnInitSubjects(): void
|
|
||||||
{
|
{
|
||||||
const allVideos = this.fictitiousVideosService.get_TAB_VIDEO();
|
if(retour.status !== "success") {
|
||||||
|
console.log(retour);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const allVideos = retour.data;
|
||||||
let myMap: Map<string,Date[]> = new Map();
|
let myMap: Map<string,Date[]> = new Map();
|
||||||
|
|
||||||
|
// parcours des interest de chaque video
|
||||||
for(let video of allVideos)
|
for(let video of allVideos)
|
||||||
{
|
{
|
||||||
const key = video.interest;
|
const key = video.interest;
|
||||||
|
|
@ -91,12 +137,26 @@ export class PagesPopularityComponent implements OnInit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// parcours les interest qui n'ont pas p été vu dans les videos
|
||||||
|
for(let interest of this.allInterests)
|
||||||
|
{
|
||||||
|
if(!myMap.has(interest)) myMap.set(interest, []);
|
||||||
|
}
|
||||||
|
|
||||||
|
// parcours de la map pour remplir 'allCoupleNameViews'
|
||||||
for(const [key, value] of myMap.entries())
|
for(const [key, value] of myMap.entries())
|
||||||
{
|
{
|
||||||
let couple = {name: key, views: value }
|
let couple = {name: key, views: value }
|
||||||
this.allCoupleNameViews.push(couple);
|
this.allCoupleNameViews.push(couple);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.formControl = new FormControl(this.allCoupleNameViews);
|
||||||
|
this.onApplyFilter();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
// Applique le filtre
|
// Applique le filtre
|
||||||
|
|
@ -137,7 +197,7 @@ export class PagesPopularityComponent implements OnInit
|
||||||
|
|
||||||
for(let date0 of coupleNameViews.views)
|
for(let date0 of coupleNameViews.views)
|
||||||
{
|
{
|
||||||
const time0 = date0.getTime();
|
const time0 = (new Date(date0)).getTime();
|
||||||
|
|
||||||
if(time0 > endTime) break;
|
if(time0 > endTime) break;
|
||||||
|
|
||||||
|
|
@ -172,7 +232,7 @@ export class PagesPopularityComponent implements OnInit
|
||||||
return date0.toLocaleDateString();
|
return date0.toLocaleDateString();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const time2 = this.addStep(date0.getTime()) - this.oneDay;
|
const time2 = this.addStep((new Date(date0)).getTime()) - this.oneDay;
|
||||||
let date2 = new Date(time2);
|
let date2 = new Date(time2);
|
||||||
return date0.toLocaleDateString() + " à " + date2.toLocaleDateString();
|
return date0.toLocaleDateString() + " à " + date2.toLocaleDateString();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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()
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ export interface Advert
|
||||||
|
|
||||||
|
|
||||||
export interface AdvertWithCountViews {
|
export interface AdvertWithCountViews {
|
||||||
_id: string,
|
id: string,
|
||||||
userId: string,
|
userId: string,
|
||||||
title: string,
|
title: string,
|
||||||
url: string,
|
url: string,
|
||||||
|
|
|
||||||
|
|
@ -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