diff --git a/src/app/admin/adList/page-ad-list-admin/page-ad-list-admin.component.ts b/src/app/admin/adList/page-ad-list-admin/page-ad-list-admin.component.ts index a98964f..acc3632 100644 --- a/src/app/admin/adList/page-ad-list-admin/page-ad-list-admin.component.ts +++ b/src/app/admin/adList/page-ad-list-admin/page-ad-list-admin.component.ts @@ -13,11 +13,12 @@ import {FormControl} from "@angular/forms"; import {FictitiousUtilsService} from "../../../utils/services/fictitiousDatas/fictitiousUtils/fictitious-utils.service"; import {User} from "../../../utils/interfaces/user"; import {FictitiousUsersService} from "../../../utils/services/fictitiousDatas/fictitiousUsers/fictitious-users.service"; +import {MessageService} from "../../../utils/services/message/message.service"; export interface AdvertWithCountViewsAndCompany { - _id: string, + id: string, userId: string, company: string, title: string, @@ -46,7 +47,7 @@ export interface AdvertWithCountViewsAndCompany { export class PageAdListAdminComponent implements AfterViewInit { tabAdvertWithCountViews: AdvertWithCountViewsAndCompany[] = []; - tabAdvertiser: User[]; + tabAdvertiser: any[]; displayedColumns: string[] = [ 'title', 'company', 'interests', 'createdAt', 'updatedAt', 'countViews', 'isVisible', 'actions' ]; dataSource ; @ViewChild(MatSort) sort: MatSort; @@ -65,19 +66,81 @@ export class PageAdListAdminComponent implements AfterViewInit private fictitiousUtilsService: FictitiousUtilsService, private fictitiousUsersService: FictitiousUsersService, public dialog: MatDialog, - private snackBar: MatSnackBar ) { } + private snackBar: MatSnackBar, + private messageService: MessageService) { } ngAfterViewInit(): void { // --- FAUX CODE --- + /* const tabAdvert = this.fictitiousAdvertsService.getTabAdvert(8); this.allInterests = this.fictitiousUtilsService.getTags(); this.tabAdvertiser = this.fictitiousUsersService.getTabAdvertiser(3); - for(let advert of tabAdvert) this.tabAdvertWithCountViews.push(this.advertToAdvertWithCountViewsAndCompany(advert)); this.dataSource = new MatTableDataSource(); 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(); + 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" ; } 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 = this.dataSource.data; this.dataSource = this.dataSource; @@ -187,19 +250,19 @@ export class PageAdListAdminComponent implements AfterViewInit } - advertToAdvertWithCountViewsAndCompany(advert: Advert): AdvertWithCountViewsAndCompany + advertToAdvertWithCountViewsAndCompany(advert): AdvertWithCountViewsAndCompany { let company0 = "company" ; for(let advertiser of this.tabAdvertiser) { - if(advert.userId === advertiser._id) { + if(advert.userId === advertiser.id) { company0 = advertiser.company; break; } } return { - _id: advert._id, + id: advert.id, userId: advert.userId, title: advert.title, company: company0, diff --git a/src/app/admin/adList/popup-delete-ad-admin/popup-delete-ad-admin.component.ts b/src/app/admin/adList/popup-delete-ad-admin/popup-delete-ad-admin.component.ts index 2fae562..02d0630 100644 --- a/src/app/admin/adList/popup-delete-ad-admin/popup-delete-ad-admin.component.ts +++ b/src/app/admin/adList/popup-delete-ad-admin/popup-delete-ad-admin.component.ts @@ -1,5 +1,4 @@ import {Component, Inject, OnInit} from '@angular/core'; -import {Advert} from "../../../utils/interfaces/advert"; import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog"; 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 { - advert: Advert; + advert: any; constructor( public dialogRef: MatDialogRef, @@ -28,24 +27,21 @@ export class PopupDeleteAdAdminComponent implements OnInit onValidate(): void { - // --- FAUX CODE --- - this.dialogRef.close(true); - - // --- VRAI CODE --- - /* this.messageService - .sendMessage("url/delete/ad", {"advert": this.advert}) - .subscribe( retour => { + .delete("ad/delete/"+this.advert.id) + .subscribe(ret => this.onValidateCallback(ret), err => this.onValidateCallback(err) ); + } - if(retour.status === "error") { - console.log(retour); - this.dialogRef.close(); - } - else { - this.dialogRef.close(true); - } - }); - */ + + onValidateCallback(retour: any): void + { + if(retour.status !== "success") { + console.log(retour); + this.dialogRef.close(); + } + else { + this.dialogRef.close(true); + } } } diff --git a/src/app/admin/myProfil/page-profil-admin/page-profil-admin.component.ts b/src/app/admin/myProfil/page-profil-admin/page-profil-admin.component.ts index f6199c9..3aaf319 100644 --- a/src/app/admin/myProfil/page-profil-admin/page-profil-admin.component.ts +++ b/src/app/admin/myProfil/page-profil-admin/page-profil-admin.component.ts @@ -24,14 +24,14 @@ export class PageProfilAdminComponent implements OnInit role: { name: "admin", permission: 10, + isAccepted: true, }, profileImageUrl: "", dateOfBirth: null, gender: "man", interests: [], company: "", - isActive: false, - isAccepted: false, + isActive: true, createdAt: new Date(), updatedAt: new Date(), lastConnexion: null diff --git a/src/app/admin/myProfil/popup-update-admin/popup-update-admin.component.ts b/src/app/admin/myProfil/popup-update-admin/popup-update-admin.component.ts index 8ca8996..e184b1b 100644 --- a/src/app/admin/myProfil/popup-update-admin/popup-update-admin.component.ts +++ b/src/app/admin/myProfil/popup-update-admin/popup-update-admin.component.ts @@ -38,6 +38,7 @@ export class PopupUpdateAdminComponent implements OnInit role: { name: admin0.role.name, permission: admin0.role.permission, + isAccepted: admin0.role.isAccepted, }, profileImageUrl: admin0.profileImageUrl, dateOfBirth: admin0.dateOfBirth, @@ -45,7 +46,6 @@ export class PopupUpdateAdminComponent implements OnInit interests: [], company: "", isActive: admin0.isActive, - isAccepted: admin0.isisAccepted, createdAt: admin0.createdAt, updatedAt: admin0.updatedAt, lastConnexion: admin0.lastConnexion diff --git a/src/app/admin/userList/page-user-list/page-user-list.component.html b/src/app/admin/userList/page-user-list/page-user-list.component.html index ddacff9..40ae292 100644 --- a/src/app/admin/userList/page-user-list/page-user-list.component.html +++ b/src/app/admin/userList/page-user-list/page-user-list.component.html @@ -107,7 +107,7 @@ - Mail + Email {{user.email}} @@ -171,7 +171,7 @@ Accepté - + diff --git a/src/app/admin/userList/popup-create-user/popup-create-user.component.html b/src/app/admin/userList/popup-create-user/popup-create-user.component.html index 2085ccd..dc7ac87 100644 --- a/src/app/admin/userList/popup-create-user/popup-create-user.component.html +++ b/src/app/admin/userList/popup-create-user/popup-create-user.component.html @@ -126,12 +126,12 @@ Email - +
Pseudo - +
@@ -145,12 +145,12 @@ Mot de passe - +
Confirmation nouveau mot de passe - + diff --git a/src/app/admin/userList/popup-create-user/popup-create-user.component.ts b/src/app/admin/userList/popup-create-user/popup-create-user.component.ts index 8fd4c14..09543ea 100644 --- a/src/app/admin/userList/popup-create-user/popup-create-user.component.ts +++ b/src/app/admin/userList/popup-create-user/popup-create-user.component.ts @@ -33,6 +33,7 @@ export class PopupCreateUserComponent implements OnInit role: { name: "", permission: 0, + isAccepted: false, }, profileImageUrl: "", dateOfBirth: null, @@ -40,7 +41,6 @@ export class PopupCreateUserComponent implements OnInit interests: [], company: "", isActive: false, - isAccepted: false, createdAt: new Date(), updatedAt: new Date(), lastConnexion: new Date() diff --git a/src/app/advertiser/myProfil/page-profil-advertiser/page-profil-advertiser.component.ts b/src/app/advertiser/myProfil/page-profil-advertiser/page-profil-advertiser.component.ts index 1213210..ec86cdf 100644 --- a/src/app/advertiser/myProfil/page-profil-advertiser/page-profil-advertiser.component.ts +++ b/src/app/advertiser/myProfil/page-profil-advertiser/page-profil-advertiser.component.ts @@ -24,14 +24,14 @@ export class PageProfilAdvertiserComponent implements OnInit role: { name: "advertiser", permission: 5, + isAccepted: true, }, profileImageUrl: "", dateOfBirth: null, gender: "man", interests: [], company: "", - isActive: false, - isAccepted: false, + isActive: true, createdAt: new Date(), updatedAt: new Date(), lastConnexion: null diff --git a/src/app/advertiser/myProfil/popup-update-advertiser/popup-update-advertiser.component.ts b/src/app/advertiser/myProfil/popup-update-advertiser/popup-update-advertiser.component.ts index e32bbc7..1517582 100644 --- a/src/app/advertiser/myProfil/popup-update-advertiser/popup-update-advertiser.component.ts +++ b/src/app/advertiser/myProfil/popup-update-advertiser/popup-update-advertiser.component.ts @@ -38,6 +38,7 @@ export class PopupUpdateAdvertiserComponent implements OnInit role: { name: advertiser0.role.name, permission: advertiser0.role.permission, + isAccepted: advertiser0.role.isAccepted, }, profileImageUrl: advertiser0.profileImageUrl, dateOfBirth: advertiser0.dateOfBirth, @@ -45,7 +46,6 @@ export class PopupUpdateAdvertiserComponent implements OnInit interests: [], company: advertiser0.company, isActive: advertiser0.isActive, - isAccepted: advertiser0.isAccepted, createdAt: advertiser0.createdAt, updatedAt: advertiser0.updatedAt, lastConnexion: new Date() diff --git a/src/app/beforeConnexion/register/page-register/page-register.component.ts b/src/app/beforeConnexion/register/page-register/page-register.component.ts index 8632fe8..833a656 100644 --- a/src/app/beforeConnexion/register/page-register/page-register.component.ts +++ b/src/app/beforeConnexion/register/page-register/page-register.component.ts @@ -27,14 +27,14 @@ export class PageRegisterComponent role: { name: "user", permission: 0, + isAccepted: false, }, profileImageUrl: "", dateOfBirth: null, gender: "man", interests: [], company: "", - isActive: false, - isAccepted: false, + isActive: true, createdAt: new Date(), updatedAt: new Date(), lastConnexion: null diff --git a/src/app/user/myProfil/input-interests-profil/input-interests-profil.component.html b/src/app/user/myProfil/input-interests-profil/input-interests-profil.component.html index be2bd07..084e9e7 100644 --- a/src/app/user/myProfil/input-interests-profil/input-interests-profil.component.html +++ b/src/app/user/myProfil/input-interests-profil/input-interests-profil.component.html @@ -16,7 +16,7 @@