From cc505ca3accf9c2a1bcb5b837237ee4e72a05691 Mon Sep 17 00:00:00 2001 From: wilfriedvallee Date: Mon, 13 Dec 2021 10:48:31 +0100 Subject: [PATCH 1/8] =?UTF-8?q?register=20:=20correction=20mot=20"centre?= =?UTF-8?q?=20d'int=C3=A9r=C3=AAt"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../input-interests-admin/input-interests-admin.component.html | 2 +- .../popup-visualize-ad-advertiser.component.html | 2 +- .../input-interests-register.component.html | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/admin/userList/input-interests-admin/input-interests-admin.component.html b/src/app/admin/userList/input-interests-admin/input-interests-admin.component.html index b70c15f..2a7c484 100644 --- a/src/app/admin/userList/input-interests-admin/input-interests-admin.component.html +++ b/src/app/admin/userList/input-interests-admin/input-interests-admin.component.html @@ -20,7 +20,7 @@
-
Tags:
+
Centre d'intérêt :
• {{tag}}
diff --git a/src/app/beforeConnexion/register/input-interests-register/input-interests-register.component.html b/src/app/beforeConnexion/register/input-interests-register/input-interests-register.component.html index 847d672..c53b83d 100644 --- a/src/app/beforeConnexion/register/input-interests-register/input-interests-register.component.html +++ b/src/app/beforeConnexion/register/input-interests-register/input-interests-register.component.html @@ -20,7 +20,7 @@ Date: Mon, 13 Dec 2021 10:49:23 +0100 Subject: [PATCH 2/8] =?UTF-8?q?register=20:=20correction=20mot=20"centre?= =?UTF-8?q?=20d'int=C3=A9r=C3=AAt"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../popup-visualize-ad-advertiser.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/advertiser/adList/popup-visualize-ad-advertiser/popup-visualize-ad-advertiser.component.html b/src/app/advertiser/adList/popup-visualize-ad-advertiser/popup-visualize-ad-advertiser.component.html index cb1a8c7..a768258 100644 --- a/src/app/advertiser/adList/popup-visualize-ad-advertiser/popup-visualize-ad-advertiser.component.html +++ b/src/app/advertiser/adList/popup-visualize-ad-advertiser/popup-visualize-ad-advertiser.component.html @@ -17,7 +17,7 @@
-
Centre d'intérêt :
+
Centre d'intérêt :
• {{tag}}
From a2c9dc2502790926dc08b86eef3499994c4ba728 Mon Sep 17 00:00:00 2001 From: wilfriedvallee Date: Mon, 13 Dec 2021 10:58:46 +0100 Subject: [PATCH 3/8] Update: correction mot "Rechercher..." --- .../user/myPlaylists/playlist-list/playlist-list.component.html | 2 +- .../popup-create-or-update-playlist.component.html | 2 +- src/app/user/search/page-search/page-search.component.html | 2 +- .../page-watching-video/page-watching-video.component.html | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app/user/myPlaylists/playlist-list/playlist-list.component.html b/src/app/user/myPlaylists/playlist-list/playlist-list.component.html index 4ab952a..2185a77 100644 --- a/src/app/user/myPlaylists/playlist-list/playlist-list.component.html +++ b/src/app/user/myPlaylists/playlist-list/playlist-list.component.html @@ -4,7 +4,7 @@
- +
diff --git a/src/app/user/myPlaylists/popup-create-or-update-playlist/popup-create-or-update-playlist.component.html b/src/app/user/myPlaylists/popup-create-or-update-playlist/popup-create-or-update-playlist.component.html index c366837..d88fa34 100644 --- a/src/app/user/myPlaylists/popup-create-or-update-playlist/popup-create-or-update-playlist.component.html +++ b/src/app/user/myPlaylists/popup-create-or-update-playlist/popup-create-or-update-playlist.component.html @@ -11,7 +11,7 @@
diff --git a/src/app/user/search/page-search/page-search.component.html b/src/app/user/search/page-search/page-search.component.html index eb2ad12..3142d35 100644 --- a/src/app/user/search/page-search/page-search.component.html +++ b/src/app/user/search/page-search/page-search.component.html @@ -16,7 +16,7 @@
- + diff --git a/src/app/user/watching/page-watching-video/page-watching-video.component.html b/src/app/user/watching/page-watching-video/page-watching-video.component.html index 631c309..f16432f 100644 --- a/src/app/user/watching/page-watching-video/page-watching-video.component.html +++ b/src/app/user/watching/page-watching-video/page-watching-video.component.html @@ -17,7 +17,7 @@
- + From a72a89eedf58376c522742161b866db887f4c3af Mon Sep 17 00:00:00 2001 From: wilfriedvallee Date: Mon, 13 Dec 2021 11:01:18 +0100 Subject: [PATCH 4/8] Update: correction mot "filtre..." --- .../history/page-history-user/page-history-user.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/user/history/page-history-user/page-history-user.component.html b/src/app/user/history/page-history-user/page-history-user.component.html index d14ad31..97f7344 100644 --- a/src/app/user/history/page-history-user/page-history-user.component.html +++ b/src/app/user/history/page-history-user/page-history-user.component.html @@ -7,7 +7,7 @@
- +

From 26a1c1b040ea006259cc4d503ac244e2254f3dd8 Mon Sep 17 00:00:00 2001 From: wilfriedvallee Date: Mon, 13 Dec 2021 11:08:17 +0100 Subject: [PATCH 5/8] =?UTF-8?q?Update:=20correction=20mot=20"d=C3=A9connex?= =?UTF-8?q?ion"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/admin/utils/navbar-admin/navbar-admin.component.html | 2 +- .../utils/navbar-advertiser/navbar-advertiser.component.html | 2 +- .../input-interests-profil.component.html | 2 +- .../utils/components/navbar-user/navbar-user.component.html | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app/admin/utils/navbar-admin/navbar-admin.component.html b/src/app/admin/utils/navbar-admin/navbar-admin.component.html index 322bf13..a69004d 100644 --- a/src/app/admin/utils/navbar-admin/navbar-admin.component.html +++ b/src/app/admin/utils/navbar-admin/navbar-admin.component.html @@ -31,7 +31,7 @@ diff --git a/src/app/advertiser/utils/navbar-advertiser/navbar-advertiser.component.html b/src/app/advertiser/utils/navbar-advertiser/navbar-advertiser.component.html index c1a8267..69ae5ad 100644 --- a/src/app/advertiser/utils/navbar-advertiser/navbar-advertiser.component.html +++ b/src/app/advertiser/utils/navbar-advertiser/navbar-advertiser.component.html @@ -35,7 +35,7 @@ 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 084e9e7..be2bd07 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 @@ From 9b1d29649adaa66b70511c258a065f593c2c653c Mon Sep 17 00:00:00 2001 From: wilfriedvallee Date: Mon, 13 Dec 2021 11:15:37 +0100 Subject: [PATCH 6/8] Update: correction mot "filtre..." car oubli --- .../adList/page-ad-list-admin/page-ad-list-admin.component.html | 2 +- .../admin/userList/page-user-list/page-user-list.component.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/admin/adList/page-ad-list-admin/page-ad-list-admin.component.html b/src/app/admin/adList/page-ad-list-admin/page-ad-list-admin.component.html index 459c21e..76bc154 100644 --- a/src/app/admin/adList/page-ad-list-admin/page-ad-list-admin.component.html +++ b/src/app/admin/adList/page-ad-list-admin/page-ad-list-admin.component.html @@ -18,7 +18,7 @@
- +
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 1d815a3..25fe6f5 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 @@ -23,7 +23,7 @@
- +
From 0ea00bf062baa189a06175dc2c4a18bf6db08d18 Mon Sep 17 00:00:00 2001 From: MiharyR Date: Mon, 13 Dec 2021 15:01:35 +0100 Subject: [PATCH 7/8] gestion des images --- .../page-ad-list-admin.component.ts | 6 +- ...opup-visualize-images-admin.component.html | 19 ++- .../popup-visualize-images-admin.component.ts | 23 +-- .../drag-and-drop/drag-and-drop.component.ts | 8 +- .../page-ad-list-advertiser.component.ts | 46 +++--- .../popup-add-or-update-ad.component.html | 6 +- .../popup-add-or-update-ad.component.ts | 133 ++++++++++++++---- ...visualize-images-advertiser.component.html | 19 ++- ...p-visualize-images-advertiser.component.ts | 23 +-- 9 files changed, 201 insertions(+), 82 deletions(-) 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 5eec7ff..3b89012 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 @@ -134,11 +134,7 @@ export class PageAdListAdminComponent implements AfterViewInit const config = { width: '30%', height: '90%', - data: { - images: advert.images, - width: 300, - height: 800, - } + data: { images: advert.images } }; this.dialog .open(PopupVisualizeImagesAdminComponent, config) diff --git a/src/app/admin/adList/popup-visualize-images-admin/popup-visualize-images-admin.component.html b/src/app/admin/adList/popup-visualize-images-admin/popup-visualize-images-admin.component.html index c860766..dfbc2fe 100644 --- a/src/app/admin/adList/popup-visualize-images-admin/popup-visualize-images-admin.component.html +++ b/src/app/admin/adList/popup-visualize-images-admin/popup-visualize-images-admin.component.html @@ -5,9 +5,16 @@
-
- -
+ + + + + + + + + + + + + diff --git a/src/app/admin/adList/popup-visualize-images-admin/popup-visualize-images-admin.component.ts b/src/app/admin/adList/popup-visualize-images-admin/popup-visualize-images-admin.component.ts index 944ecbd..5b98819 100644 --- a/src/app/admin/adList/popup-visualize-images-admin/popup-visualize-images-admin.component.ts +++ b/src/app/admin/adList/popup-visualize-images-admin/popup-visualize-images-admin.component.ts @@ -11,8 +11,8 @@ import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog"; export class PopupVisualizeImagesAdminComponent implements OnInit { tabImages = []; - width: number = 0; - height: number = 0; + index: number = 0; + nbImage: number = 0; constructor( public dialogRef: MatDialogRef, @@ -21,15 +21,18 @@ export class PopupVisualizeImagesAdminComponent implements OnInit ngOnInit(): void { - this.width = this.data.width*0.8; - this.height = this.data.height*0.8; + this.tabImages = this.data.images; + this.nbImage = this.tabImages.length; + } - for(let couple of this.data.images) - { - const elt = { path: "assets/pub/"+couple.url }; - this.tabImages.push(elt); - } - console.log(this.tabImages); + onPrecedent(): void + { + if(this.index !== 0) this.index -= 1; + } + + onSuivant(): void + { + if(this.index !== (this.nbImage-1)) this.index += 1; } } diff --git a/src/app/advertiser/adList/drag-and-drop/drag-and-drop.component.ts b/src/app/advertiser/adList/drag-and-drop/drag-and-drop.component.ts index 40b9626..8c4de43 100644 --- a/src/app/advertiser/adList/drag-and-drop/drag-and-drop.component.ts +++ b/src/app/advertiser/adList/drag-and-drop/drag-and-drop.component.ts @@ -1,4 +1,4 @@ -import {Component, ElementRef, OnInit, ViewChild} from '@angular/core'; +import {Component, ElementRef, EventEmitter, OnInit, Output, ViewChild} from '@angular/core'; @Component({ selector: 'app-drag-and-drop', @@ -8,15 +8,16 @@ import {Component, ElementRef, OnInit, ViewChild} from '@angular/core'; export class DragAndDropComponent { @ViewChild("fileDropRef", { static: false }) fileDropEl: ElementRef; - files: any[] = []; info_image = "Vos annonces seront affichées dans un rectangle de rapport 1/5 avec: \n • 1 la largeur du rectangle \n • 5 la hauteur du rectangle" ; - + files: any[] = []; + @Output() eventEmitter = new EventEmitter(); /** * on file drop handler */ onFileDropped($event) { this.prepareFilesList($event); + this.eventEmitter.emit(this.files); } /** @@ -24,6 +25,7 @@ export class DragAndDropComponent */ fileBrowseHandler(files) { this.prepareFilesList(files); + this.eventEmitter.emit(this.files); } /** diff --git a/src/app/advertiser/adList/page-ad-list-advertiser/page-ad-list-advertiser.component.ts b/src/app/advertiser/adList/page-ad-list-advertiser/page-ad-list-advertiser.component.ts index 79971ec..7810130 100644 --- a/src/app/advertiser/adList/page-ad-list-advertiser/page-ad-list-advertiser.component.ts +++ b/src/app/advertiser/adList/page-ad-list-advertiser/page-ad-list-advertiser.component.ts @@ -2,7 +2,7 @@ import {AfterViewInit, Component, OnInit, ViewChild} from '@angular/core'; import {MatSort} from "@angular/material/sort"; import {ThemeService} from "../../../utils/services/theme/theme.service"; import {MatTableDataSource} from "@angular/material/table"; -import {Advert, AdvertWithCountViews} from "../../../utils/interfaces/advert"; +import {AdvertWithCountViews} from "../../../utils/interfaces/advert"; import {MatDialog} from "@angular/material/dialog"; import {PopupAddOrUpdateAdComponent} from "../popup-add-or-update-ad/popup-add-or-update-ad.component"; import {MatSnackBar} from "@angular/material/snack-bar"; @@ -100,19 +100,23 @@ export class PageAdListAdvertiserComponent implements AfterViewInit onVisualizeImages(advert: AdvertWithCountViews) { - const config = { - width: '30%', - height: '90%', - data: { - images: advert.images, - width: 300, - height: 800, - } - }; - this.dialog - .open(PopupVisualizeImagesAdvertiserComponent, config) - .afterClosed() - .subscribe(retour => {}); + if(advert.images.length !== 0) + { + const config = { + width: '30%', + height: '90%', + data: { images: advert.images } + }; + this.dialog + .open(PopupVisualizeImagesAdvertiserComponent, config) + .afterClosed() + .subscribe(retour => {}); + } + else { + const config = { duration: 2000, panelClass: "custom-class" }; + const message = "Cette annonce ne contient aucune image" ; + this.snackBar.open( message, "", config); + } } @@ -122,7 +126,12 @@ export class PageAdListAdvertiserComponent implements AfterViewInit width: '75%', height: '80%', panelClass: 'custom-dialog-container', - data: { action: "add", advert: null, allVideoCategorie: this.allVideoCategorie } + data: { + action: "add", + advert: null, + allVideoCategorie: this.allVideoCategorie, + allTitle: this.tabAdvertWithCountViews.map(x => x.title) + } }; this.dialog .open(PopupAddOrUpdateAdComponent, config) @@ -150,7 +159,12 @@ export class PageAdListAdvertiserComponent implements AfterViewInit width: '75%', height: '80%', panelClass: 'custom-dialog-container', - data: { action: "update", advert: advertToUpdate, allVideoCategorie: this.allVideoCategorie } + data: { + action: "update", + advert: advertToUpdate, + allVideoCategorie: this.allVideoCategorie, + allTitle: this.tabAdvertWithCountViews.map(x => x.title) + } }; this.dialog .open(PopupAddOrUpdateAdComponent, config) diff --git a/src/app/advertiser/adList/popup-add-or-update-ad/popup-add-or-update-ad.component.html b/src/app/advertiser/adList/popup-add-or-update-ad/popup-add-or-update-ad.component.html index bda058c..f461435 100644 --- a/src/app/advertiser/adList/popup-add-or-update-ad/popup-add-or-update-ad.component.html +++ b/src/app/advertiser/adList/popup-add-or-update-ad/popup-add-or-update-ad.component.html @@ -59,7 +59,7 @@
- +
@@ -67,6 +67,10 @@
+ +
+ {{errorMessage}} +
diff --git a/src/app/advertiser/adList/popup-add-or-update-ad/popup-add-or-update-ad.component.ts b/src/app/advertiser/adList/popup-add-or-update-ad/popup-add-or-update-ad.component.ts index f943a07..8601e49 100644 --- a/src/app/advertiser/adList/popup-add-or-update-ad/popup-add-or-update-ad.component.ts +++ b/src/app/advertiser/adList/popup-add-or-update-ad/popup-add-or-update-ad.component.ts @@ -5,6 +5,8 @@ import {MessageService} from "../../../utils/services/message/message.service"; import {ThemeService} from "../../../utils/services/theme/theme.service"; + + const ADVERT_VIDE: Advert = { _id: "", userId: "", @@ -31,9 +33,14 @@ export class PopupAddOrUpdateAdComponent implements OnInit advert: any; title: string = "" ; allVideoCategorie = []; - tabWaitingFile: File[] = []; // fichiers selectionnés mais pas encore "validés" - tabSelectedFile: File[] = []; // fichier "validés" - _event; + allTitle = []; + + tabOfNewImagesBase64 = []; + tabOfNewImagesName = []; + + hasError: boolean = false; + errorMessage: string = "" ; + constructor( public dialogRef: MatDialogRef, @@ -44,7 +51,8 @@ export class PopupAddOrUpdateAdComponent implements OnInit ngOnInit(): void { - this.allVideoCategorie = this.data.allVideoCategorie + this.allVideoCategorie = this.data.allVideoCategorie; + this.allTitle = this.data.allTitle.slice(); if(this.data.action === "add") { this.advert = Object.assign({}, ADVERT_VIDE); @@ -56,43 +64,61 @@ export class PopupAddOrUpdateAdComponent implements OnInit this.advert = Object.assign({}, this.data.advert); this.advert.interests = this.data.advert.interests.slice(); this.title = "Modifier annonce" ; + const indexOldTitle = this.allTitle.findIndex(title => title == this.advert.title); + this.allTitle.splice(indexOldTitle, 1); } } onValidate(): void { - // On transforme 'this.user.interests' en tableau de 'videoCategorie' - let interests = []; // tableau de videoCategorie - for(let interest of this.advert.interests) + this.checkField(); + if(!this.hasError) { - for(let videoCategorie of this.allVideoCategorie) + // preparation des donnees + this.prepareAdvertInterests(); + this.prepareAdvertImages(); + + // si creation + if (this.data.action === "add") { - if(videoCategorie.interest === interest) { - interests.push(videoCategorie); - break; - } + this.messageService + .post("ad/create", this.advert) + .subscribe(ret => this.onCreateCallback(ret), err => this.onCreateCallback(err)); + } + // si update + else + { + 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)); } } - this.advert.interests = interests; + } - if(this.data.action === "add") + + checkField() + { + if(this.advert.title.length === 0) { + this.errorMessage = "Veuillez remplir le champ 'titre'" ; + this.hasError = true; + } + else if(this.allTitle.includes(this.advert.title)) { - this.messageService - .post("ad/create", this.advert) - .subscribe(ret => this.onCreateCallback(ret), err => this.onCreateCallback(err)); + this.errorMessage = "Ce titre est déjà pris" ; + this.hasError = true; } else { - 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)); + this.errorMessage = ""; + this.hasError = false; } } + onCreateCallback(retour: any): void { if(retour.status !== "success") { @@ -127,8 +153,65 @@ export class PopupAddOrUpdateAdComponent implements OnInit onRemoveImgAlreadyPresent(image) { const index = this.advert.images.indexOf(image); - console.log("idx: " + index); - this.advert.images.slice(index, 1); + this.advert.images.splice(index, 1); + } + + + onReceiveNewImages(files: any): void + { + this.tabOfNewImagesBase64 = []; + this.tabOfNewImagesName = []; + if(files) + { + for(let file of files) + { + if(file) + { + const reader = new FileReader(); + reader.onload = this.handleReaderLoaded.bind(this); + this.tabOfNewImagesName.push(file.name) + reader.readAsBinaryString(file); + } + } + } + } + handleReaderLoaded(e) + { + this.tabOfNewImagesBase64.push('data:image/png;base64,' + btoa(e.target.result)) + } + + + // Met bien en forme les "images" avant d'être envoyer + prepareAdvertImages(): void + { + for(let i=0; i
-
- -
+ + + + + + + + + + + + + diff --git a/src/app/advertiser/adList/popup-visualize-images-advertiser/popup-visualize-images-advertiser.component.ts b/src/app/advertiser/adList/popup-visualize-images-advertiser/popup-visualize-images-advertiser.component.ts index dd99e36..59e7c3d 100644 --- a/src/app/advertiser/adList/popup-visualize-images-advertiser/popup-visualize-images-advertiser.component.ts +++ b/src/app/advertiser/adList/popup-visualize-images-advertiser/popup-visualize-images-advertiser.component.ts @@ -11,8 +11,8 @@ import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog"; export class PopupVisualizeImagesAdvertiserComponent implements OnInit { tabImages = []; - width: number = 0; - height: number = 0; + index: number = 0; + nbImage: number = 0; constructor( public dialogRef: MatDialogRef, @@ -21,15 +21,18 @@ export class PopupVisualizeImagesAdvertiserComponent implements OnInit ngOnInit(): void { - this.width = this.data.width; - this.height = this.data.height; + this.tabImages = this.data.images; + this.nbImage = this.tabImages.length; + } - for(let couple of this.data.images) - { - const elt = { path: "assets/pub/"+couple.url }; - this.tabImages.push(elt); - } - console.log(this.tabImages); + onPrecedent(): void + { + if(this.index !== 0) this.index -= 1; + } + + onSuivant(): void + { + if(this.index !== (this.nbImage-1)) this.index += 1; } } From 326ea73b864eb608caf453c6ec4491ce0a132e96 Mon Sep 17 00:00:00 2001 From: MiharyR Date: Mon, 13 Dec 2021 18:54:45 +0100 Subject: [PATCH 8/8] on ne peut pas ajouter plusieurs fois le memme 'centre d'interet'/'sujet' --- .../input-interests-admin.component.ts | 25 +++++++++++++------ .../input-interests-ad.component.ts | 9 +++---- .../input-interests-register.component.html | 2 +- .../input-interests-register.component.ts | 5 ++-- .../input-interests-profil.component.ts | 5 ++-- 5 files changed, 28 insertions(+), 18 deletions(-) diff --git a/src/app/admin/userList/input-interests-admin/input-interests-admin.component.ts b/src/app/admin/userList/input-interests-admin/input-interests-admin.component.ts index 9ec0c25..d197e33 100644 --- a/src/app/admin/userList/input-interests-admin/input-interests-admin.component.ts +++ b/src/app/admin/userList/input-interests-admin/input-interests-admin.component.ts @@ -6,7 +6,6 @@ import {MessageService} from "../../../utils/services/message/message.service"; import {map, startWith} from "rxjs/operators"; import {MatChipInputEvent} from "@angular/material/chips"; import {MatAutocompleteSelectedEvent} from "@angular/material/autocomplete"; -import {FictitiousUtilsService} from "../../../utils/services/fictitiousDatas/fictitiousUtils/fictitious-utils.service"; @@ -28,8 +27,7 @@ export class InputInterestsAdminComponent implements OnInit @ViewChild('tagInput') tagInput: ElementRef; - constructor( private fictitiousUtilsService: FictitiousUtilsService, - private messageService: MessageService ) {} + constructor( private messageService: MessageService ) {} ngOnInit(): void @@ -38,16 +36,26 @@ export class InputInterestsAdminComponent implements OnInit startWith(null), map((fruit: string | null) => fruit ? this._filter(fruit) : this.allInterests.slice())); - // --- FAUX CODE --- - this.allInterests = this.fictitiousUtilsService.getTags(); - this.allInterests.sort(); + this.messageService + .get("misc/getInterests") + .subscribe( retour => { + + if(retour.status !== "success") { + console.log(retour); + } + else { + this.allInterests = []; + for(let elt of retour.data) this.allInterests.push(elt.interest); + this.allInterests.sort(); + } + }); } add(event: MatChipInputEvent): void { const value = (event.value || '').trim(); - if (value && (this.allInterests.indexOf(value) !== -1)) + if (value && (this.allInterests.indexOf(value) !== -1) && (!this.myInterests.includes(value))) { this.myInterests.push(value); event.chipInput!.clear(); @@ -67,7 +75,8 @@ export class InputInterestsAdminComponent implements OnInit selected(event: MatAutocompleteSelectedEvent): void { - this.myInterests.push(event.option.viewValue); + const value = event.option.viewValue; + if(!this.myInterests.includes(value))this.myInterests.push(value); this.tagInput.nativeElement.value = ''; this.formControl.setValue(null); this.eventEmitter.emit(this.myInterests); diff --git a/src/app/advertiser/adList/input-interests-ad/input-interests-ad.component.ts b/src/app/advertiser/adList/input-interests-ad/input-interests-ad.component.ts index e5a83fe..be873b4 100644 --- a/src/app/advertiser/adList/input-interests-ad/input-interests-ad.component.ts +++ b/src/app/advertiser/adList/input-interests-ad/input-interests-ad.component.ts @@ -6,7 +6,6 @@ import {map, startWith} from "rxjs/operators"; import {MatChipInputEvent} from "@angular/material/chips"; import {MatAutocompleteSelectedEvent} from "@angular/material/autocomplete"; import {MessageService} from "../../../utils/services/message/message.service"; -import {FictitiousUtilsService} from "../../../utils/services/fictitiousDatas/fictitiousUtils/fictitious-utils.service"; @@ -28,8 +27,7 @@ export class InputInterestsAdComponent implements OnInit @ViewChild('tagInput') tagInput: ElementRef; - constructor( private fictitiousUtilsService: FictitiousUtilsService, - private messageService: MessageService ) {} + constructor( private messageService: MessageService ) {} ngOnInit(): void @@ -56,7 +54,7 @@ export class InputInterestsAdComponent implements OnInit add(event: MatChipInputEvent): void { const value = (event.value || '').trim(); - if (value && (this.allTags.indexOf(value) !== -1)) + if (value && (this.allTags.indexOf(value) !== -1) && (!this.myTags.includes(value))) { this.myTags.push(value); event.chipInput!.clear(); @@ -76,7 +74,8 @@ export class InputInterestsAdComponent implements OnInit selected(event: MatAutocompleteSelectedEvent): void { - this.myTags.push(event.option.viewValue); + const value = event.option.viewValue; + if(!this.myTags.includes(value))this.myTags.push(value); this.tagInput.nativeElement.value = ''; this.formControl.setValue(null); this.eventEmitter.emit(this.myTags); diff --git a/src/app/beforeConnexion/register/input-interests-register/input-interests-register.component.html b/src/app/beforeConnexion/register/input-interests-register/input-interests-register.component.html index c53b83d..2a7c484 100644 --- a/src/app/beforeConnexion/register/input-interests-register/input-interests-register.component.html +++ b/src/app/beforeConnexion/register/input-interests-register/input-interests-register.component.html @@ -2,7 +2,7 @@ - Tags + Centres d'intérêt diff --git a/src/app/beforeConnexion/register/input-interests-register/input-interests-register.component.ts b/src/app/beforeConnexion/register/input-interests-register/input-interests-register.component.ts index 6f8301b..1a2395b 100644 --- a/src/app/beforeConnexion/register/input-interests-register/input-interests-register.component.ts +++ b/src/app/beforeConnexion/register/input-interests-register/input-interests-register.component.ts @@ -55,7 +55,7 @@ export class InputInterestsRegisterComponent implements OnInit add(event: MatChipInputEvent): void { const value = (event.value || '').trim(); - if (value && (this.allInterests.indexOf(value) !== -1)) + if (value && (this.allInterests.indexOf(value) !== -1) && (!this.myInterests.includes(value))) { this.myInterests.push(value); event.chipInput!.clear(); @@ -75,7 +75,8 @@ export class InputInterestsRegisterComponent implements OnInit selected(event: MatAutocompleteSelectedEvent): void { - this.myInterests.push(event.option.viewValue); + const value = event.option.viewValue; + if(!this.myInterests.includes(value))this.myInterests.push(value); this.tagInput.nativeElement.value = ''; this.formControl.setValue(null); this.eventEmitter.emit(this.myInterests); diff --git a/src/app/user/myProfil/input-interests-profil/input-interests-profil.component.ts b/src/app/user/myProfil/input-interests-profil/input-interests-profil.component.ts index 70c60da..228b6fc 100644 --- a/src/app/user/myProfil/input-interests-profil/input-interests-profil.component.ts +++ b/src/app/user/myProfil/input-interests-profil/input-interests-profil.component.ts @@ -55,7 +55,7 @@ export class InputInterestsProfilComponent implements OnInit add(event: MatChipInputEvent): void { const value = (event.value || '').trim(); - if (value && (this.allInterests.indexOf(value) !== -1)) + if (value && (this.allInterests.indexOf(value) !== -1) && (!this.myInterests.includes(value))) { this.myInterests.push(value); event.chipInput!.clear(); @@ -75,7 +75,8 @@ export class InputInterestsProfilComponent implements OnInit selected(event: MatAutocompleteSelectedEvent): void { - this.myInterests.push(event.option.viewValue); + const value = event.option.viewValue; + if(!this.myInterests.includes(value))this.myInterests.push(value); this.tagInput.nativeElement.value = ''; this.formControl.setValue(null); this.eventEmitter.emit(this.myInterests);