From 1643f3f3367d5b69d0adf286432a0d63bdbada2e Mon Sep 17 00:00:00 2001 From: MiharyR Date: Tue, 23 Nov 2021 12:52:22 +0100 Subject: [PATCH 1/5] amelioration de la partie advertiser --- .../page-ad-list-admin.component.html | 26 ++-- .../page-ad-list-admin.component.scss | 2 +- .../page-ad-list-admin.component.ts | 23 ++- .../popup-visualize-ad-admin.component.html | 2 +- .../page-user-list.component.scss | 2 +- .../drag-and-drop.component.html | 4 +- .../drag-and-drop/drag-and-drop.component.ts | 2 +- .../input-interests-ad.component.html} | 4 +- .../input-interests-ad.component.scss} | 0 .../input-interests-ad.component.spec.ts} | 10 +- .../input-interests-ad.component.ts} | 8 +- .../page-ad-list-advertiser.component.html | 133 ++++++++++++++---- .../page-ad-list-advertiser.component.scss | 79 ++++++++--- .../page-ad-list-advertiser.component.ts | 90 ++++++++++-- .../popup-add-or-update-ad.component.html | 70 ++++++--- .../popup-add-or-update-ad.component.scss | 5 +- .../popup-add-or-update-ad.component.ts | 33 ++--- ...pup-visualize-ad-advertiser.component.html | 2 +- .../navbar-advertiser.component.html | 3 + src/app/app.module.ts | 4 +- src/app/utils/interfaces/advert.ts | 2 +- .../fictitious-adverts.service.ts | 6 +- 22 files changed, 357 insertions(+), 153 deletions(-) rename src/app/advertiser/adList/{input-tags/input-tags.component.html => input-interests-ad/input-interests-ad.component.html} (92%) rename src/app/advertiser/adList/{input-tags/input-tags.component.scss => input-interests-ad/input-interests-ad.component.scss} (100%) rename src/app/advertiser/adList/{input-tags/input-tags.component.spec.ts => input-interests-ad/input-interests-ad.component.spec.ts} (57%) rename src/app/advertiser/adList/{input-tags/input-tags.component.ts => input-interests-ad/input-interests-ad.component.ts} (92%) 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 41e464d..264088f 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 @@ -21,7 +21,7 @@ - +
@@ -30,18 +30,18 @@ non visible
- +
- Tags - + Sujets + - {{formControlTags.value ? formControlTags.value[0] : ''}} - - (+{{formControlTags.value.length - 1}} {{formControlTags.value?.length === 2 ? 'autre' : 'autres'}}) + {{formControlInterests.value ? formControlInterests.value[0] : ''}} + + (+{{formControlInterests.value.length - 1}} {{formControlInterests.value?.length === 2 ? 'autre' : 'autres'}}) - {{topping}} + {{topping}}
-info +
+ info +
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 6fe4a6d..40b9626 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 @@ -9,7 +9,7 @@ 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 durectangle \n • 5 la hauteur du rectangle" ; + 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" ; /** diff --git a/src/app/advertiser/adList/input-tags/input-tags.component.html b/src/app/advertiser/adList/input-interests-ad/input-interests-ad.component.html similarity index 92% rename from src/app/advertiser/adList/input-tags/input-tags.component.html rename to src/app/advertiser/adList/input-interests-ad/input-interests-ad.component.html index f8da61e..8df4522 100644 --- a/src/app/advertiser/adList/input-tags/input-tags.component.html +++ b/src/app/advertiser/adList/input-interests-ad/input-interests-ad.component.html @@ -2,7 +2,7 @@ - Tags + Sujets @@ -20,7 +20,7 @@ { - let component: InputTagsComponent; - let fixture: ComponentFixture; + let component: InputInterestsAdComponent; + let fixture: ComponentFixture; beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [ InputTagsComponent ] + declarations: [ InputInterestsAdComponent ] }) .compileComponents(); }); beforeEach(() => { - fixture = TestBed.createComponent(InputTagsComponent); + fixture = TestBed.createComponent(InputInterestsAdComponent); component = fixture.componentInstance; fixture.detectChanges(); }); diff --git a/src/app/advertiser/adList/input-tags/input-tags.component.ts b/src/app/advertiser/adList/input-interests-ad/input-interests-ad.component.ts similarity index 92% rename from src/app/advertiser/adList/input-tags/input-tags.component.ts rename to src/app/advertiser/adList/input-interests-ad/input-interests-ad.component.ts index 6c54a07..dfc794b 100644 --- a/src/app/advertiser/adList/input-tags/input-tags.component.ts +++ b/src/app/advertiser/adList/input-interests-ad/input-interests-ad.component.ts @@ -11,11 +11,11 @@ import {FictitiousUtilsService} from "../../../utils/services/fictitiousDatas/fi @Component({ - selector: 'app-input-tags', - templateUrl: './input-tags.component.html', - styleUrls: ['./input-tags.component.scss'] + selector: 'app-input-interests-ad', + templateUrl: './input-interests-ad.component.html', + styleUrls: ['./input-interests-ad.component.scss'] }) -export class InputTagsComponent implements OnInit +export class InputInterestsAdComponent implements OnInit { selectable = true; removable = true; diff --git a/src/app/advertiser/adList/page-ad-list-advertiser/page-ad-list-advertiser.component.html b/src/app/advertiser/adList/page-ad-list-advertiser/page-ad-list-advertiser.component.html index 49ae0d2..6b4a16e 100644 --- a/src/app/advertiser/adList/page-ad-list-advertiser/page-ad-list-advertiser.component.html +++ b/src/app/advertiser/adList/page-ad-list-advertiser/page-ad-list-advertiser.component.html @@ -2,26 +2,113 @@
+

- -
- + + + + +
+ + +
+
+ + +
+ Filtre +
+ + + + +
+ +
+ + +
+ + + +
+ visible
+ non visible +
+ + + +
+ + Sujets + + + {{formControlInterests.value ? formControlInterests.value[0] : ''}} + + (+{{formControlInterests.value.length - 1}} {{formControlInterests.value?.length === 2 ? 'autre' : 'autres'}}) + + + {{topping}} + + + +
+ + + +
+ Période de création:   + + Date de début + + +   -   + + Date de fin + + +
+ +
+ +
+
+ + +
+ +
+
-
- - -
- + + + + + + + @@ -30,13 +117,13 @@ - - - + + + @@ -65,15 +152,6 @@ - - - - - - @@ -82,10 +160,7 @@ insert_photo - + + + + + + + + +
+ +
- + +
+ diff --git a/src/app/advertiser/adList/popup-add-or-update-ad/popup-add-or-update-ad.component.scss b/src/app/advertiser/adList/popup-add-or-update-ad/popup-add-or-update-ad.component.scss index 7fb592c..b299124 100644 --- a/src/app/advertiser/adList/popup-add-or-update-ad/popup-add-or-update-ad.component.scss +++ b/src/app/advertiser/adList/popup-add-or-update-ad/popup-add-or-update-ad.component.scss @@ -8,7 +8,10 @@ h1 { text-align: center; font-size: large; - padding-bottom: 10px; +} + +.col-6, .col-8 { + border-left: solid 1px #a4a4a4; } 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 a4af930..5c41b0e 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 @@ -11,7 +11,7 @@ const ADVERT_VIDE: Advert = { title: "", advertiser: "", images: [], - tags: [], + interests: [], comment: "", views: 0, isVisible: true, @@ -47,14 +47,14 @@ export class PopupAddOrUpdateAdComponent implements OnInit if(this.data.action === "add") { this.advert = Object.assign({}, ADVERT_VIDE); - this.advert.tags = []; + this.advert.interests = []; this.urlBackend = "advertiser/add/ad" ; this.title = "Ajouter annonce" ; } else { this.advert = Object.assign({}, this.data.advert); - this.advert.tags = this.data.advert.tags.slice(); + this.advert.interests = this.data.advert.interests.slice(); this.urlBackend = "advertiser/update/ad" ; this.title = "Modifier annonce" ; } @@ -86,32 +86,15 @@ export class PopupAddOrUpdateAdComponent implements OnInit onEventInputTags(myTags: string[]): void { - this.advert.tags = myTags; + this.advert.interests = myTags; } - // Lorsque l'annonceur selectionne des fichiers - onSelectFile(event) + onRemoveImgAlreadyPresent(image) { - const nbFileSelected = event.target.files.length ; - for(let i=0 ; i file); - this.tabSelectedFile.splice(index, 1); + const index = this.advert.images.indexOf(image); + console.log("idx: " + index); + this.advert.images.slice(index, 1); } } 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 4263967..0efdb23 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 @@ -19,7 +19,7 @@
Tags:
-
• {{tag}}
+
• {{tag}}
diff --git a/src/app/advertiser/navbar-advertiser/navbar-advertiser.component.html b/src/app/advertiser/navbar-advertiser/navbar-advertiser.component.html index 8c6d946..e87170e 100644 --- a/src/app/advertiser/navbar-advertiser/navbar-advertiser.component.html +++ b/src/app/advertiser/navbar-advertiser/navbar-advertiser.component.html @@ -15,6 +15,9 @@ + diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 1a5fb3f..aa484b5 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -36,7 +36,7 @@ import { PageAdListAdvertiserComponent } from './advertiser/adList/page-ad-list- import { PopupDeleteAdAdvertiserComponent } from './advertiser/adList/popup-delete-ad-advertiser/popup-delete-ad-advertiser.component'; import { PopupAddOrUpdateAdComponent } from './advertiser/adList/popup-add-or-update-ad/popup-add-or-update-ad.component'; import { PopupVisualizeAdAdvertiserComponent } from './advertiser/adList/popup-visualize-ad-advertiser/popup-visualize-ad-advertiser.component'; -import { InputTagsComponent } from './advertiser/adList/input-tags/input-tags.component'; +import { InputInterestsAdComponent } from './advertiser/adList/input-interests-ad/input-interests-ad.component'; import {MatChipsModule} from "@angular/material/chips"; import {MatAutocompleteModule} from "@angular/material/autocomplete"; import {MatSelectModule} from "@angular/material/select"; @@ -93,7 +93,7 @@ import {MatDatepickerModule} from "@angular/material/datepicker"; PopupDeleteAdAdvertiserComponent, PopupAddOrUpdateAdComponent, PopupVisualizeAdAdvertiserComponent, - InputTagsComponent, + InputInterestsAdComponent, PopupVisualizeImagesAdvertiserComponent, DragAndDropComponent, DragAndDropDirective, diff --git a/src/app/utils/interfaces/advert.ts b/src/app/utils/interfaces/advert.ts index d9d1cb6..e31d6a5 100644 --- a/src/app/utils/interfaces/advert.ts +++ b/src/app/utils/interfaces/advert.ts @@ -8,7 +8,7 @@ export interface Advert url: string, description: string, }[], - tags: string[], + interests: string[], comment: string, views: number, isVisible: boolean, diff --git a/src/app/utils/services/fictitiousDatas/fictitiousAdverts/fictitious-adverts.service.ts b/src/app/utils/services/fictitiousDatas/fictitiousAdverts/fictitious-adverts.service.ts index 1506cf0..aca666f 100644 --- a/src/app/utils/services/fictitiousDatas/fictitiousAdverts/fictitious-adverts.service.ts +++ b/src/app/utils/services/fictitiousDatas/fictitiousAdverts/fictitious-adverts.service.ts @@ -15,7 +15,7 @@ const TAB_ADVERT: Advert[] = [ { url: "nutella_v_2.png", description: "image nutella 2" }, { url: "nutella_v_3.jpg", description: "image nutella 3" } ], - tags: [ "rock", "basket" ], + interests: [ "rock", "basket" ], comment: "pub pour vacances de noêl", views: 5, isVisible: true, @@ -32,7 +32,7 @@ const TAB_ADVERT: Advert[] = [ { url: "rolex_v_1.jpg", description: "rolex 1" }, { url: "rolex_v_2.png", description: "rolex 2" }, ], - tags: [ "rock", "rap" ], + interests: [ "rock", "rap" ], comment: "pub pour cette année", views: 2, isVisible: true, @@ -58,7 +58,7 @@ export class FictitiousAdvertsService const idx = Math.floor(Math.random() * TAB_ADVERT.length); let advert = Object.assign({}, TAB_ADVERT[idx]); advert._id = advert._id + this.fictitiousUtilsService.makeid(5); - advert.tags = advert.tags.slice(); + advert.interests = advert.interests.slice(); advert.isVisible = (Math.random() < 0.5); return advert; } From 1e5b9bd49c80ab3a5defb96320afd42e9d036582 Mon Sep 17 00:00:00 2001 From: MiharyR Date: Wed, 24 Nov 2021 12:07:31 +0100 Subject: [PATCH 2/5] continuation de la partie advertiser --- package.json | 28 ++- .../page-ad-list-admin.component.html | 6 +- .../page-ad-list-admin.component.ts | 50 ++-- .../navbar-admin/navbar-admin.component.html | 0 .../navbar-admin/navbar-admin.component.scss | 0 .../navbar-admin.component.spec.ts | 0 .../navbar-admin/navbar-admin.component.ts | 0 .../page-ad-list-advertiser.component.html | 4 +- .../page-ad-list-advertiser.component.ts | 51 ++-- .../popup-add-or-update-ad.component.ts | 2 +- .../pages-popularity.component.html | 91 +++++++ .../pages-popularity.component.scss | 60 +++++ .../pages-popularity.component.spec.ts | 25 ++ .../pages-popularity.component.ts | 234 ++++++++++++++++++ .../navbar-advertiser.component.html | 4 +- .../navbar-advertiser.component.scss | 30 +-- .../navbar-advertiser.component.spec.ts | 0 .../navbar-advertiser.component.ts | 0 src/app/app-routing.module.ts | 4 +- src/app/app.component.scss | 17 ++ src/app/app.module.ts | 8 +- .../video-list/video-list.component.ts | 2 +- .../page-watching-video.component.ts | 2 +- src/app/utils/interfaces/advert.ts | 23 +- src/app/utils/interfaces/video.ts | 4 +- .../fictitious-adverts.service.ts | 60 ++++- .../fictitious-videos.service.ts | 21 +- src/styles.scss | 21 ++ 28 files changed, 656 insertions(+), 91 deletions(-) rename src/app/admin/{ => utils/components}/navbar-admin/navbar-admin.component.html (100%) rename src/app/admin/{ => utils/components}/navbar-admin/navbar-admin.component.scss (100%) rename src/app/admin/{ => utils/components}/navbar-admin/navbar-admin.component.spec.ts (100%) rename src/app/admin/{ => utils/components}/navbar-admin/navbar-admin.component.ts (100%) create mode 100644 src/app/advertiser/pages-popularity/pages-popularity.component.html create mode 100644 src/app/advertiser/pages-popularity/pages-popularity.component.scss create mode 100644 src/app/advertiser/pages-popularity/pages-popularity.component.spec.ts create mode 100644 src/app/advertiser/pages-popularity/pages-popularity.component.ts rename src/app/advertiser/{ => utils/components}/navbar-advertiser/navbar-advertiser.component.html (84%) rename src/app/advertiser/{ => utils/components}/navbar-advertiser/navbar-advertiser.component.scss (100%) rename src/app/advertiser/{ => utils/components}/navbar-advertiser/navbar-advertiser.component.spec.ts (100%) rename src/app/advertiser/{ => utils/components}/navbar-advertiser/navbar-advertiser.component.ts (100%) diff --git a/package.json b/package.json index dd9a09c..baf5802 100644 --- a/package.json +++ b/package.json @@ -14,8 +14,10 @@ "dependencies": { "@angular/animations": "^12.2.11", "@angular/cdk": "^12.2.11", + "@angular/cli": "~12.2.11", "@angular/common": "^12.2.11", "@angular/compiler": "^12.2.11", + "@angular/compiler-cli": "~12.2.11", "@angular/core": "^12.2.11", "@angular/forms": "^12.2.11", "@angular/material": "^12.2.11", @@ -24,28 +26,27 @@ "@angular/router": "^12.2.11", "@ng-bootstrap/ng-bootstrap": "^10.0.0", "angular-responsive-carousel": "^2.1.2", - "bootstrap": "^5.1.3", - "jquery": "^3.6.0", - "popper": "^1.0.1", - "rxjs": "~6.6.0", - "tslib": "^2.0.0", - "zone.js": "~0.11.3", - "@angular/cli": "~12.2.11", - "@angular/compiler-cli": "~12.2.11", - "typescript": "~4.3.5", "body-parser": "^1.19.0", + "bootstrap": "^5.1.3", + "chart.js": "^2.9.3", "cookie-parser": "^1.4.5", "cors": "^2.8.5", "dotenv": "^10.0.0", "express": "^4.17.1", + "jquery": "^3.6.0", "jsonwebtoken": "^8.5.1", - "mongoose": "^6.0.12" + "mongoose": "^6.0.12", + "ng2-charts": "^2.2.3", + "popper": "^1.0.1", + "rxjs": "~6.6.0", + "tslib": "^2.0.0", + "typescript": "~4.3.5", + "zone.js": "~0.11.3" }, "devDependencies": { + "@angular-devkit/build-angular": "~12.2.11", "@angular/cli": "~12.2.11", "@angular/compiler-cli": "~12.2.11", - "typescript": "~4.3.5", - "@angular-devkit/build-angular": "~12.2.11", "@angular/localize": "^12.2.11", "@types/jasmine": "~3.6.0", "@types/node": "^12.11.1", @@ -59,6 +60,7 @@ "karma-jasmine-html-reporter": "^1.5.0", "protractor": "~7.0.0", "ts-node": "~8.3.0", - "tslint": "~6.1.0" + "tslint": "~6.1.0", + "typescript": "~4.3.5" } } 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 264088f..a5fef57 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 @@ -120,11 +120,11 @@ - - + +
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 d8c950f..3b15694 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 @@ -5,8 +5,7 @@ import {ThemeService} from "../../../utils/services/theme/theme.service"; import {MatDialog} from "@angular/material/dialog"; import {MatSnackBar} from "@angular/material/snack-bar"; import {MatTableDataSource} from "@angular/material/table"; -import {Advert} from "../../../utils/interfaces/advert"; -import {PopupVisualizeAdAdminComponent} from "../popup-visualize-ad-admin/popup-visualize-ad-admin.component"; +import {Advert, AdvertWithCountViews} from "../../../utils/interfaces/advert"; 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 {FictitiousAdvertsService} from "../../../utils/services/fictitiousDatas/fictitiousAdverts/fictitious-adverts.service"; @@ -22,8 +21,8 @@ import {FictitiousUtilsService} from "../../../utils/services/fictitiousDatas/fi }) export class PageAdListAdminComponent implements AfterViewInit { - tabAdvert: Advert[]; - displayedColumns: string[] = [ 'title', 'advertiser', 'interests', 'createdAt', 'updatedAt', 'views', 'isVisible', 'actions' ]; + tabAdvertWithCountViews: AdvertWithCountViews[] = []; + displayedColumns: string[] = [ 'title', 'advertiser', 'interests', 'createdAt', 'updatedAt', 'countViews', 'isVisible', 'actions' ]; dataSource ; @ViewChild(MatSort) sort: MatSort; @ViewChild(MatPaginator) paginator: MatPaginator; @@ -46,9 +45,10 @@ export class PageAdListAdminComponent implements AfterViewInit ngAfterViewInit(): void { // --- FAUX CODE --- - this.tabAdvert = this.fictitiousAdvertsService.getTabAdvert(8); + const tabAdvert = this.fictitiousAdvertsService.getTabAdvert(8); this.allInterests = this.fictitiousUtilsService.getTags(); + for(let advert of tabAdvert) this.tabAdvertWithCountViews.push(this.advertToAdvertWithCountViews(advert)); this.dataSource = new MatTableDataSource(); this.onFilter(); } @@ -61,7 +61,7 @@ export class PageAdListAdminComponent implements AfterViewInit } - onVisualizeImages(advert: Advert) + onVisualizeImages(advert: AdvertWithCountViews) { const config = { width: '30%', @@ -79,20 +79,7 @@ export class PageAdListAdminComponent implements AfterViewInit } - onVisualizeInfo(advert: Advert): void - { - const config = { - width: '50%', - data: { advert: advert } - }; - this.dialog - .open(PopupVisualizeAdAdminComponent, config) - .afterClosed() - .subscribe(retour => {}); - } - - - onDelete(advert: Advert): void + onDelete(advert: AdvertWithCountViews): void { const config = { data: { advert: advert } @@ -121,9 +108,8 @@ export class PageAdListAdminComponent implements AfterViewInit onFilter(): void { - console.log("b:" + this.formControlInterests.value); this.dataSource.data = []; - for(let advert of this.tabAdvert) + for(let advert of this.tabAdvertWithCountViews) { let valide: boolean = true; @@ -173,4 +159,24 @@ export class PageAdListAdminComponent implements AfterViewInit this.endDate = new Date(event); } + + advertToAdvertWithCountViews(advert: Advert): AdvertWithCountViews + { + return { + _id: advert._id, + userId: advert.userId, + title: advert.title, + advertiser: advert.advertiser, + images: advert.images, + interests: advert.interests, + comment: advert.comment, + views: advert.views, + countViews: advert.views.length, + isVisible: advert.isVisible, + isActive: advert.isActive, + createdAt: advert.createdAt, + updatedAt: advert.updatedAt, + } + } + } diff --git a/src/app/admin/navbar-admin/navbar-admin.component.html b/src/app/admin/utils/components/navbar-admin/navbar-admin.component.html similarity index 100% rename from src/app/admin/navbar-admin/navbar-admin.component.html rename to src/app/admin/utils/components/navbar-admin/navbar-admin.component.html diff --git a/src/app/admin/navbar-admin/navbar-admin.component.scss b/src/app/admin/utils/components/navbar-admin/navbar-admin.component.scss similarity index 100% rename from src/app/admin/navbar-admin/navbar-admin.component.scss rename to src/app/admin/utils/components/navbar-admin/navbar-admin.component.scss diff --git a/src/app/admin/navbar-admin/navbar-admin.component.spec.ts b/src/app/admin/utils/components/navbar-admin/navbar-admin.component.spec.ts similarity index 100% rename from src/app/admin/navbar-admin/navbar-admin.component.spec.ts rename to src/app/admin/utils/components/navbar-admin/navbar-admin.component.spec.ts diff --git a/src/app/admin/navbar-admin/navbar-admin.component.ts b/src/app/admin/utils/components/navbar-admin/navbar-admin.component.ts similarity index 100% rename from src/app/admin/navbar-admin/navbar-admin.component.ts rename to src/app/admin/utils/components/navbar-admin/navbar-admin.component.ts diff --git a/src/app/advertiser/adList/page-ad-list-advertiser/page-ad-list-advertiser.component.html b/src/app/advertiser/adList/page-ad-list-advertiser/page-ad-list-advertiser.component.html index 6b4a16e..78dd263 100644 --- a/src/app/advertiser/adList/page-ad-list-advertiser/page-ad-list-advertiser.component.html +++ b/src/app/advertiser/adList/page-ad-list-advertiser/page-ad-list-advertiser.component.html @@ -145,10 +145,10 @@ - + 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 b3b6100..b91408f 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,12 +2,11 @@ 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} from "../../../utils/interfaces/advert"; +import {Advert, 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"; import {PopupDeleteAdAdvertiserComponent} from "../popup-delete-ad-advertiser/popup-delete-ad-advertiser.component"; -import {PopupVisualizeAdAdvertiserComponent} from "../popup-visualize-ad-advertiser/popup-visualize-ad-advertiser.component"; import {MatPaginator} from "@angular/material/paginator"; import {PopupVisualizeImagesAdvertiserComponent} from "../popup-visualize-images-advertiser/popup-visualize-images-advertiser.component"; import {FictitiousAdvertsService} from "../../../utils/services/fictitiousDatas/fictitiousAdverts/fictitious-adverts.service"; @@ -23,8 +22,8 @@ import {FictitiousUtilsService} from "../../../utils/services/fictitiousDatas/fi }) export class PageAdListAdvertiserComponent implements AfterViewInit { - displayedColumns: string[] = [ 'isVisible', 'title', 'interests', 'createdAt', 'updatedAt', 'views', 'actions' ]; - tabAdvert: Advert[] = []; + displayedColumns: string[] = [ 'isVisible', 'title', 'interests', 'createdAt', 'updatedAt', 'countViews', 'actions' ]; + tabAdvertWithCountViews: AdvertWithCountViews[] = []; dataSource ; @ViewChild(MatSort) sort: MatSort; @ViewChild(MatPaginator) paginator: MatPaginator; @@ -47,9 +46,10 @@ export class PageAdListAdvertiserComponent implements AfterViewInit ngAfterViewInit(): void { // --- FAUX CODE --- - this.tabAdvert = this.fictitiousAdvertsService.getTabAdvert(8); + const tabAdvert = this.fictitiousAdvertsService.getTabAdvert(8); this.allInterests = this.fictitiousUtilsService.getTags(); + for(let advert of tabAdvert) this.tabAdvertWithCountViews.push(this.advertToAdvertWithCountViews(advert)); this.dataSource = new MatTableDataSource(); this.onFilter(); } @@ -62,7 +62,7 @@ export class PageAdListAdvertiserComponent implements AfterViewInit } - onVisualizeImages(advert: Advert) + onVisualizeImages(advert: AdvertWithCountViews) { const config = { width: '30%', @@ -80,19 +80,6 @@ export class PageAdListAdvertiserComponent implements AfterViewInit } - onVisualize(advert: Advert): void - { - const config = { - width: '50%', - data: { advert: advert } - }; - this.dialog - .open(PopupVisualizeAdAdvertiserComponent, config) - .afterClosed() - .subscribe(retour => {}); - } - - onAdd(): void { const config = { @@ -120,7 +107,7 @@ export class PageAdListAdvertiserComponent implements AfterViewInit } - onUpdate(advertToUpdate: Advert): void + onUpdate(advertToUpdate: AdvertWithCountViews): void { const config = { width: '75%', @@ -148,7 +135,7 @@ export class PageAdListAdvertiserComponent implements AfterViewInit } - onDelete(advert: Advert): void + onDelete(advert: AdvertWithCountViews): void { const config = { data: { advert: advert } @@ -179,7 +166,7 @@ export class PageAdListAdvertiserComponent implements AfterViewInit { console.log("b:" + this.formControlInterests.value); this.dataSource.data = []; - for(let advert of this.tabAdvert) + for(let advert of this.tabAdvertWithCountViews) { let valide: boolean = true; @@ -235,4 +222,24 @@ export class PageAdListAdvertiserComponent implements AfterViewInit // il faut envoyer la négation de user.isActive } + + advertToAdvertWithCountViews(advert: Advert): AdvertWithCountViews + { + return { + _id: advert._id, + userId: advert.userId, + title: advert.title, + advertiser: advert.advertiser, + images: advert.images, + interests: advert.interests, + comment: advert.comment, + views: advert.views, + countViews: advert.views.length, + isVisible: advert.isVisible, + isActive: advert.isActive, + createdAt: advert.createdAt, + updatedAt: advert.updatedAt, + } + } + } 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 5c41b0e..4b23a23 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 @@ -13,7 +13,7 @@ const ADVERT_VIDE: Advert = { images: [], interests: [], comment: "", - views: 0, + views: [], isVisible: true, isActive: true, createdAt: new Date(), diff --git a/src/app/advertiser/pages-popularity/pages-popularity.component.html b/src/app/advertiser/pages-popularity/pages-popularity.component.html new file mode 100644 index 0000000..1f59267 --- /dev/null +++ b/src/app/advertiser/pages-popularity/pages-popularity.component.html @@ -0,0 +1,91 @@ +
+
+ + + + + + + + +
+ +
Filtre
+ +
+ +
+ +

+ +
+ +
+ +
+ + + + +
+ + +
+ + +
+
+ + + + + + + + + début + + +   -   + + + + fin + + +   -   + + + + pas d'affichage + + +   -   + + + + unité du pas d'affichage + + jour + semaine + mois + + + + + + + + {{coupleNameViews.name}}, + + + {{coupleNameViews.name}} + + + diff --git a/src/app/advertiser/pages-popularity/pages-popularity.component.scss b/src/app/advertiser/pages-popularity/pages-popularity.component.scss new file mode 100644 index 0000000..b6a7b99 --- /dev/null +++ b/src/app/advertiser/pages-popularity/pages-popularity.component.scss @@ -0,0 +1,60 @@ +.myContainer { + font-size: small; + max-width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: scroll; +} + +input { + font-size: small; + width: 140px; +} + +.filtersContainer { + background-color: white; + width: 60%; + margin: 50px 50px 50px 50px; + padding: 20px 20px 20px 20px; +} + +.chartContainer { + background-color: white; + border: solid 1px black; + padding: 10px 10px 10px 10px; + margin: 50px 50px 50px 50px; +} + + +// --------------------------------------------- +// periode + +.periode { + padding: 10px 10px 0px 10px; +} + +.periode .titleContainer { + text-align: right; + border-right: solid 1px #dcdcdc; + font-weight: bold; +} + + +// ------------------------------------------------------------------------- + + +// aura +::ng-deep .mat-checkbox-ripple .mat-ripple-element { + background-color: grey !important; +} + +// contenu coche +::ng-deep .mat-checkbox-checked.mat-accent .mat-checkbox-background { + background-color: black !important; +} + +// indeterminate +::ng-deep .mat-checkbox .mat-checkbox-frame { + border: solid 1px black !important; + background-color: white !important; +} diff --git a/src/app/advertiser/pages-popularity/pages-popularity.component.spec.ts b/src/app/advertiser/pages-popularity/pages-popularity.component.spec.ts new file mode 100644 index 0000000..f9ff236 --- /dev/null +++ b/src/app/advertiser/pages-popularity/pages-popularity.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { PagesPopularityComponent } from './pages-popularity.component'; + +describe('SubjectsPopularityComponent', () => { + let component: PagesPopularityComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ PagesPopularityComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(PagesPopularityComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/advertiser/pages-popularity/pages-popularity.component.ts b/src/app/advertiser/pages-popularity/pages-popularity.component.ts new file mode 100644 index 0000000..76d82fd --- /dev/null +++ b/src/app/advertiser/pages-popularity/pages-popularity.component.ts @@ -0,0 +1,234 @@ +import { Component, OnInit } from '@angular/core'; +import {FormControl} from "@angular/forms"; +import {ChartDataSets} from "chart.js"; +import {Label} from "ng2-charts"; +import { Router} from "@angular/router"; +import {FictitiousAdvertsService} from "../../utils/services/fictitiousDatas/fictitiousAdverts/fictitious-adverts.service"; +import {FictitiousVideosService} from "../../utils/services/fictitiousDatas/fictitiousVideos/fictitious-videos.service"; +import {ThemeService} from "../../utils/services/theme/theme.service"; + + + +interface CoupleNameViews { + name: string, + views: Date[], +} + + + +@Component({ + selector: 'app-subjects-popularity', + templateUrl: './pages-popularity.component.html', + styleUrls: ['./pages-popularity.component.scss'] +}) +export class PagesPopularityComponent implements OnInit +{ + formControl: FormControl; + allCoupleNameViews: CoupleNameViews[] = []; + + startDate: Date = null; + endDate: Date = null; + step: number = 1; + stepUnity: string = "jour" ; + + oneDay: number = 24*60*60*1000; + oneWeek: number = 7*24*60*60*1000; + + lineChartData: ChartDataSets[] = []; + lineChartLabels: Label[] = []; + chartOptions: any = { + responsive: true, + scales: { + yAxes: [{ display: true, scaleLabel: { display: true, labelString: "vues" } }], + xAxes: [{ scaleLabel: { display: true, labelString: "temps" } }], + } + }; + + + constructor( private router: Router, + public themeService: ThemeService, + private fictitiousAdvertsService: FictitiousAdvertsService, + private fictitiousVideosService: FictitiousVideosService ) {} + + + ngOnInit(): void + { + if(this.router.url.includes("ads")) this.ngOnInitAds(); + else if(this.router.url.includes("subjects")) this.ngOnInitSubjects(); + this.formControl = new FormControl(this.allCoupleNameViews); + this.onApplyFilter(); + } + + + // Sera excuté si on est sur la page 'adsPopularity' + // Remplie l'attribut 'allCoupleNameViews' + ngOnInitAds(): void + { + const allAdverts = this.fictitiousAdvertsService.get_TAB_ADVERT(); + for(let advert of allAdverts) + { + let couple = {name: advert.title, views: advert.views } + this.allCoupleNameViews.push(couple); + } + } + + + // Sera excuté si on est sur la page 'subjectsPopularity' + // Remplie l'attribut 'allCoupleNameViews' + ngOnInitSubjects(): void + { + const allVideos = this.fictitiousVideosService.get_TAB_VIDEO(); + let myMap: Map = new Map(); + + for(let video of allVideos) + { + const key = video.interest; + if(!myMap.has(key)) myMap.set(key, video.watchedDates); + else { + let tabDate = myMap.get(key); + for(let date0 of video.watchedDates) tabDate = this.insertInOrder(tabDate, date0); + myMap.set(key, tabDate); + } + } + + for(const [key, value] of myMap.entries()) + { + let couple = {name: key, views: value } + this.allCoupleNameViews.push(couple); + } + } + + + // Applique le filtre + onApplyFilter(): void + { + // --- initialisation --- + this.lineChartData = []; + this.lineChartLabels = []; + + if(this.step <= 0) this.step = 0; + if(this.endDate === null) this.endDate = new Date(); + if(this.startDate === null) this.startDate = new Date(this.endDate.getTime() - this.oneWeek); // date d'il y a une semaine + + const startTime = this.startDate.getTime(); + const endTime = this.endDate.getTime(); + + + // --- remplissage de 'lineChartLabels' --- + let dataWithZeros = []; + let time = startTime; + const intervals = []; + while(time <= endTime) + { + dataWithZeros.push(0); + this.lineChartLabels.push(this.getLabel(new Date(time))); + intervals.push(time); + time = this.addStep(time); + } + intervals.push(time); + + + // --- remplissage de 'lineChartLabels' --- + for(let coupleNameViews of this.formControl.value) + { + let data = dataWithZeros.slice(); + let label = coupleNameViews.name; + let index = 0; + + for(let date0 of coupleNameViews.views) + { + const time0 = date0.getTime(); + + if(time0 > endTime) break; + + if((startTime <= time0) && (time0 <= endTime)) + { + while((index < intervals.length) && (time0 >= intervals[index])) index += 1; + index = index - 1; + data[index] += 1; + } + } + + this.lineChartData.push({"data": data.slice(), "label": label}); + } + } + + + onNewStartDate(event): void { + this.startDate = new Date(event); + } + + + onNewEndDate(event): void { + this.endDate = new Date(event); + } + + + // Renvoie le bon label pour le graph + getLabel(date0: Date): string + { + if((this.stepUnity === 'jour') && (this.step === 1)) + { + return date0.toLocaleDateString(); + } + else { + const time2 = this.addStep(date0.getTime()) - this.oneDay; + let date2 = new Date(time2); + return date0.toLocaleDateString() + " à " + date2.toLocaleDateString(); + } + } + + + // Ajoute le bon pas à la date 'new Date(time)' + addStep(time: number): number + { + let newDate; + + if(this.stepUnity === 'jour') { + newDate = new Date(time + this.step*this.oneDay); + } + else if(this.stepUnity === 'semaine') { + newDate = new Date(time + this.step*this.oneWeek); + } + else + { + const oldDate = new Date(time); + + let newMonth = oldDate.getMonth() + this.step; + const newYear = oldDate.getFullYear() + (newMonth / 12); + newMonth = newMonth % 12; + const day = this.startDate.getDate(); + + if((newMonth === 1) && ([29, 30, 31].includes(day))) { // si fevrier et si jour n'existe pas + newDate = new Date(newYear, newMonth, 28); + } + else if((day === 31) && ([3, 5, 9, 10].includes(newMonth))) { // si 31 et mois à 30 jours + newDate = new Date(newYear, newMonth, 30); + } + else { + newDate = new Date(newYear, newMonth, day); + } + } + + const _1h = 60*60*1000; + if(newDate.getHours() === 23) return newDate.getTime() + _1h; + else if(newDate.getHours() === 1) return newDate.getTime() - _1h; + else return newDate.getTime(); + } + + + // Insere la date0 dans le tableau tabDate par ordre croissant + insertInOrder(tabDate: Date[], date0: Date): Date[] + { + let i = 0; + let n = tabDate.length; + let time0 = date0.getTime(); + + while((i tabDate[i].getTime())) i++; + if(i === n) tabDate.push(date0); + else tabDate.splice(i, 0, date0); + + return tabDate; + } + +} diff --git a/src/app/advertiser/navbar-advertiser/navbar-advertiser.component.html b/src/app/advertiser/utils/components/navbar-advertiser/navbar-advertiser.component.html similarity index 84% rename from src/app/advertiser/navbar-advertiser/navbar-advertiser.component.html rename to src/app/advertiser/utils/components/navbar-advertiser/navbar-advertiser.component.html index e87170e..65a2f5d 100644 --- a/src/app/advertiser/navbar-advertiser/navbar-advertiser.component.html +++ b/src/app/advertiser/utils/components/navbar-advertiser/navbar-advertiser.component.html @@ -13,10 +13,10 @@ Gestion des annonces diff --git a/src/app/advertiser/navbar-advertiser/navbar-advertiser.component.scss b/src/app/advertiser/utils/components/navbar-advertiser/navbar-advertiser.component.scss similarity index 100% rename from src/app/advertiser/navbar-advertiser/navbar-advertiser.component.scss rename to src/app/advertiser/utils/components/navbar-advertiser/navbar-advertiser.component.scss index a78eea8..403a4af 100644 --- a/src/app/advertiser/navbar-advertiser/navbar-advertiser.component.scss +++ b/src/app/advertiser/utils/components/navbar-advertiser/navbar-advertiser.component.scss @@ -23,6 +23,11 @@ } +.monLi { + margin: 0px 10px 0px 10px; +} + + // Recherche, Mes Playlists, Historique .nav-link { color: white; @@ -32,21 +37,6 @@ } -// Bonton deconnexion -.btnDeconnexion { - font-size: medium; - margin: 0px 10px 0px 10px -} -.btnDeconnexion:hover { - color: grey; -} - - -.monLi { - margin: 0px 10px 0px 10px; -} - - img { border: solid 2px white; border-radius: 50px; @@ -59,6 +49,16 @@ img:hover { } +// Bonton deconnexion +.btnDeconnexion { + font-size: medium; + margin: 0px 10px 0px 10px +} +.btnDeconnexion:hover { + color: grey; +} + + // -------------------------------------------------------------------- diff --git a/src/app/advertiser/navbar-advertiser/navbar-advertiser.component.spec.ts b/src/app/advertiser/utils/components/navbar-advertiser/navbar-advertiser.component.spec.ts similarity index 100% rename from src/app/advertiser/navbar-advertiser/navbar-advertiser.component.spec.ts rename to src/app/advertiser/utils/components/navbar-advertiser/navbar-advertiser.component.spec.ts diff --git a/src/app/advertiser/navbar-advertiser/navbar-advertiser.component.ts b/src/app/advertiser/utils/components/navbar-advertiser/navbar-advertiser.component.ts similarity index 100% rename from src/app/advertiser/navbar-advertiser/navbar-advertiser.component.ts rename to src/app/advertiser/utils/components/navbar-advertiser/navbar-advertiser.component.ts diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index db7db74..470c44c 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -12,6 +12,7 @@ import {PageProfilAdminComponent} from "./admin/myProfil/page-profil-admin/page- import {PageAdListAdminComponent} from "./admin/adList/page-ad-list-admin/page-ad-list-admin.component"; import {PageUserListComponent} from "./admin/userList/page-user-list/page-user-list.component"; import {PageWatchingVideoComponent} from "./user/watching/page-watching-video/page-watching-video.component"; +import {PagesPopularityComponent} from "./advertiser/pages-popularity/pages-popularity.component"; const routes: Routes = [ @@ -27,7 +28,6 @@ const routes: Routes = [ { path: 'user/myPlaylists', component: PageMyPlaylistsComponent }, { path: 'user/history', component: PageHistoryUserComponent }, { path: 'user/myProfil', component: PageProfilUserComponent }, - { path: 'user/watching/fromSearch/:videoId/:source/:search', component: PageWatchingVideoComponent }, { path: 'user/watching/fromMyPlaylists/:videoId/:_idPlaylist', component: PageWatchingVideoComponent }, { path: 'user/watching/fromHistory/:videoId/:source', component: PageWatchingVideoComponent }, @@ -36,6 +36,8 @@ const routes: Routes = [ { path: 'advertiser', component: PageAdListAdvertiserComponent }, { path: 'advertiser/adList', component: PageAdListAdvertiserComponent }, { path: 'advertiser/myProfil', component: PageProfilAdvertiserComponent }, + { path: 'advertiser/adsPopularity', component: PagesPopularityComponent }, + { path: 'advertiser/subjectsPopularity', component: PagesPopularityComponent }, // Admin { path: 'admin', component: PageUserListComponent }, diff --git a/src/app/app.component.scss b/src/app/app.component.scss index 14a2c1c..22a5665 100644 --- a/src/app/app.component.scss +++ b/src/app/app.component.scss @@ -5,3 +5,20 @@ //color: green; justify-content: center; } + + +// aura +::ng-deep .mat-checkbox-ripple .mat-ripple-element { + background-color: grey !important; +} + +// contenu coche +::ng-deep .mat-checkbox-checked.mat-accent .mat-checkbox-background { + background-color: black !important; +} + +// indeterminate +::ng-deep .mat-checkbox .mat-checkbox-frame { + border: solid 1px black !important; + background-color: white !important; +} diff --git a/src/app/app.module.ts b/src/app/app.module.ts index aa484b5..821018f 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -46,8 +46,8 @@ import { DragAndDropComponent } from './advertiser/adList/drag-and-drop/drag-and import { DragAndDropDirective } from './utils/directives/dragAndDrop/drag-and-drop.directive'; import { PageProfilUserComponent } from './user/myProfil/page-profil-user/page-profil-user.component'; import { NavbarUserComponent } from './user/utils/components/navbar-user/navbar-user.component'; -import { NavbarAdvertiserComponent } from './advertiser/navbar-advertiser/navbar-advertiser.component'; -import { NavbarAdminComponent } from './admin/navbar-admin/navbar-admin.component'; +import { NavbarAdvertiserComponent } from './advertiser/utils/components/navbar-advertiser/navbar-advertiser.component'; +import { NavbarAdminComponent } from './admin/utils/components/navbar-admin/navbar-admin.component'; import { PageProfilAdvertiserComponent } from './advertiser/myProfil/page-profil-advertiser/page-profil-advertiser.component'; import { PopupUpdateAdvertiserComponent } from './advertiser/myProfil/popup-update-advertiser/popup-update-advertiser.component'; import { PopupUpdateUserComponent } from './user/myProfil/popup-update-user/popup-update-user.component'; @@ -70,6 +70,8 @@ import { PopupCreateUserComponent } from './admin/userList/popup-create-user/pop import { InputInterestsAdminComponent } from './admin/userList/input-interests-admin/input-interests-admin.component'; import { PageWatchingVideoComponent } from './user/watching/page-watching-video/page-watching-video.component'; import {MatDatepickerModule} from "@angular/material/datepicker"; +import { PagesPopularityComponent } from './advertiser/pages-popularity/pages-popularity.component'; +import { ChartsModule } from 'ng2-charts'; @NgModule({ @@ -119,6 +121,7 @@ import {MatDatepickerModule} from "@angular/material/datepicker"; PopupCreateUserComponent, InputInterestsAdminComponent, PageWatchingVideoComponent, + PagesPopularityComponent, ], imports: [ BrowserModule, @@ -148,6 +151,7 @@ import {MatDatepickerModule} from "@angular/material/datepicker"; MatStepperModule, MatPaginatorModule, MatDatepickerModule, + ChartsModule ], providers: [], bootstrap: [AppComponent] diff --git a/src/app/user/myPlaylists/video-list/video-list.component.ts b/src/app/user/myPlaylists/video-list/video-list.component.ts index dce50ad..a98cd24 100644 --- a/src/app/user/myPlaylists/video-list/video-list.component.ts +++ b/src/app/user/myPlaylists/video-list/video-list.component.ts @@ -21,7 +21,7 @@ export class VideoListComponent implements OnChanges { @Input() playlist: PlaylistDB; videosInPlaylist: VideoAll[] = []; - allUserVideos: VideoAll[] = this.fictitiousVideosService.getAllVideoAll(); + allUserVideos: VideoAll[] = this.fictitiousVideosService.get_TAB_VIDEO(); constructor( private messageService: MessageService, diff --git a/src/app/user/watching/page-watching-video/page-watching-video.component.ts b/src/app/user/watching/page-watching-video/page-watching-video.component.ts index 02ec8df..5f4235e 100644 --- a/src/app/user/watching/page-watching-video/page-watching-video.component.ts +++ b/src/app/user/watching/page-watching-video/page-watching-video.component.ts @@ -66,7 +66,7 @@ export class PageWatchingVideoComponent implements OnInit this.from = "myPlaylists"; const _idPlaylist = this.activatedRoute.snapshot.paramMap.get('_idPlaylist'); this.playlist = this.fictitiousVideosService.getPlaylistBy_id(_idPlaylist); - const allVideo = this.fictitiousVideosService.getAllVideoAll(); + const allVideo = this.fictitiousVideosService.get_TAB_VIDEO(); this.videosInPlaylist = []; for(let _idVideo of this.playlist.videoIds) { diff --git a/src/app/utils/interfaces/advert.ts b/src/app/utils/interfaces/advert.ts index e31d6a5..5b17905 100644 --- a/src/app/utils/interfaces/advert.ts +++ b/src/app/utils/interfaces/advert.ts @@ -10,7 +10,28 @@ export interface Advert }[], interests: string[], comment: string, - views: number, + views: Date[], + isVisible: boolean, + isActive: boolean, + createdAt: Date, + updatedAt: Date, +} + + + +export interface AdvertWithCountViews { + _id: string, + userId: string, + title: string, + advertiser: string, + images: { + url: string, + description: string, + }[], + interests: string[], + comment: string, + views: Date[], + countViews: number, isVisible: boolean, isActive: boolean, createdAt: Date, diff --git a/src/app/utils/interfaces/video.ts b/src/app/utils/interfaces/video.ts index 2926449..1c93427 100644 --- a/src/app/utils/interfaces/video.ts +++ b/src/app/utils/interfaces/video.ts @@ -4,7 +4,8 @@ export interface VideoDB userId: string, videoId: string, source: string, - tags: String[], + tags: string[], + interest: string, watchedDates: Date[], createdAt: Date, updatedAt: Date @@ -18,6 +19,7 @@ export interface VideoAll videoId: string, source: string, tags: String[], + interest: string, watchedDates: Date[], createdAt: Date, updatedAt: Date diff --git a/src/app/utils/services/fictitiousDatas/fictitiousAdverts/fictitious-adverts.service.ts b/src/app/utils/services/fictitiousDatas/fictitiousAdverts/fictitious-adverts.service.ts index aca666f..7170d7f 100644 --- a/src/app/utils/services/fictitiousDatas/fictitiousAdverts/fictitious-adverts.service.ts +++ b/src/app/utils/services/fictitiousDatas/fictitiousAdverts/fictitious-adverts.service.ts @@ -17,7 +17,18 @@ const TAB_ADVERT: Advert[] = [ ], interests: [ "rock", "basket" ], comment: "pub pour vacances de noêl", - views: 5, + views: [ + new Date(2021,10,1), + new Date(2021,10,2), + new Date(2021,10,3), + new Date(2021,10,3), + new Date(2021,10,5), + new Date(2021,10,5), + new Date(2021,10,5), + new Date(2021,10,5), + new Date(2021,10,5), + new Date(2021,10,7) + ], isVisible: true, isActive: true, createdAt: new Date(), @@ -34,12 +45,51 @@ const TAB_ADVERT: Advert[] = [ ], interests: [ "rock", "rap" ], comment: "pub pour cette année", - views: 2, + views: [ + new Date(2021,10,5), + new Date(2021,10,6), + new Date(2021,10,7), + new Date(2021,10,8), + new Date(2021,10,8), + new Date(2021,10,8), + new Date(2021,10,25), + new Date(2021,10,25), + new Date(2021,10,25), + new Date(2021,10,27) + ], isVisible: true, isActive: true, createdAt: new Date(), updatedAt: new Date(), }, + { + _id: "idAlbion", + userId: "userId", + title: "Albion new version", + advertiser: "albion", + images: [ + { url: "rolex_v_1.jpg", description: "albion 1" }, + { url: "rolex_v_2.png", description: "albion 2" }, + ], + interests: [ "rock", "rap" ], + comment: "pub pour cette année", + views: [ + new Date(2021,10,3), + new Date(2021,10,4), + new Date(2021,10,4), + new Date(2021,10,5), + new Date(2021,10,5), + new Date(2021,10,6), + new Date(2021,10,6), + new Date(2021,10,8), + new Date(2021,10,8), + new Date(2021,10,8) + ], + isVisible: true, + isActive: true, + createdAt: new Date(), + updatedAt: new Date(), + } ]; @@ -71,4 +121,10 @@ export class FictitiousAdvertsService return tabAdvert; } + + get_TAB_ADVERT(): Advert[] + { + return TAB_ADVERT; + } + } diff --git a/src/app/utils/services/fictitiousDatas/fictitiousVideos/fictitious-videos.service.ts b/src/app/utils/services/fictitiousDatas/fictitiousVideos/fictitious-videos.service.ts index 119e358..e0e0b4a 100644 --- a/src/app/utils/services/fictitiousDatas/fictitiousVideos/fictitious-videos.service.ts +++ b/src/app/utils/services/fictitiousDatas/fictitiousVideos/fictitious-videos.service.ts @@ -13,7 +13,15 @@ const TAB_VIDEO: VideoAll[] = [ userId: "userId", source: "youtube", tags: [ "rap", "musique" ], - watchedDates: [new Date()], + interest: "PNL", + watchedDates: [ + new Date(2021, 10, 15), + new Date(2021, 10, 16), + new Date(2021, 10, 17), + new Date(2021, 10, 18), + new Date(2021, 10, 19), + new Date(2021, 10, 20), + ], createdAt: new Date(), updatedAt: new Date(), @@ -30,6 +38,7 @@ const TAB_VIDEO: VideoAll[] = [ userId: "userId", source: "youtube", tags: [ "rap", "musique" ], + interest: "PNL", watchedDates: [new Date()], createdAt: new Date(), updatedAt: new Date(), @@ -47,6 +56,7 @@ const TAB_VIDEO: VideoAll[] = [ userId: "userId", source: "youtube", tags: [ "rap", "musique" ], + interest: "PNL", watchedDates: [new Date()], createdAt: new Date(), updatedAt: new Date(), @@ -64,6 +74,7 @@ const TAB_VIDEO: VideoAll[] = [ userId: "userId", source: "youtube", tags: [ "rap", "musique" ], + interest: "PNL", watchedDates: [new Date()], createdAt: new Date(), updatedAt: new Date(), @@ -81,6 +92,7 @@ const TAB_VIDEO: VideoAll[] = [ userId: "userId", source: "dailymotion", tags: [ "rap", "musique" ], + interest: "PNL", watchedDates: [new Date()], createdAt: new Date(), updatedAt: new Date(), @@ -98,6 +110,7 @@ const TAB_VIDEO: VideoAll[] = [ userId: "userId", source: "youtube", tags: [ "rap", "musique" ], + interest: "Nekfeu", watchedDates: [new Date()], createdAt: new Date(), updatedAt: new Date(), @@ -115,6 +128,7 @@ const TAB_VIDEO: VideoAll[] = [ userId: "userId", source: "youtube", tags: [ "rap", "musique" ], + interest: "Nekfeu", watchedDates: [new Date()], createdAt: new Date(), updatedAt: new Date(), @@ -132,6 +146,7 @@ const TAB_VIDEO: VideoAll[] = [ userId: "userId", source: "youtube", tags: [ "rap", "musique" ], + interest: "Nekfeu", watchedDates: [new Date()], createdAt: new Date(), updatedAt: new Date(), @@ -149,6 +164,7 @@ const TAB_VIDEO: VideoAll[] = [ userId: "userId", source: "dailymotion", tags: [ "rap", "musique" ], + interest: "Columbine", watchedDates: [new Date()], createdAt: new Date(), updatedAt: new Date(), @@ -166,6 +182,7 @@ const TAB_VIDEO: VideoAll[] = [ userId: "userId", source: "dailymotion", tags: [ "rap", "musique" ], + interest: "Columbine", watchedDates: [new Date()], createdAt: new Date(), updatedAt: new Date(), @@ -210,7 +227,7 @@ export class FictitiousVideosService } - getAllVideoAll(): VideoAll[] + get_TAB_VIDEO(): VideoAll[] { return TAB_VIDEO; } diff --git a/src/styles.scss b/src/styles.scss index 5c44745..8a615cc 100644 --- a/src/styles.scss +++ b/src/styles.scss @@ -29,3 +29,24 @@ body { margin: 0; } -o-background-size: cover; background-size: cover; } + + + +// ------------------------------------------------------------------------- + + +// aura +::ng-deep .mat-checkbox-ripple .mat-ripple-element { + background-color: grey !important; +} + +// contenu coche +::ng-deep .mat-checkbox-checked.mat-accent .mat-checkbox-background { + background-color: black !important; +} + +// indeterminate +::ng-deep .mat-checkbox .mat-checkbox-frame { + border: solid 1px black !important; + background-color: white !important; +} From cd1f323686ab6bd0feda0d33d3c324395d3b3260 Mon Sep 17 00:00:00 2001 From: MiharyR Date: Wed, 24 Nov 2021 21:34:27 +0100 Subject: [PATCH 3/5] ameloriation du style de la partie user --- .../navbar-admin/navbar-admin.component.html | 13 +++-- .../navbar-admin/navbar-admin.component.scss | 17 ++++--- .../navbar-admin/navbar-admin.component.ts | 14 +++++- .../navbar-advertiser.component.html | 16 ++++-- .../navbar-advertiser.component.scss | 25 +++++----- .../navbar-advertiser.component.ts | 13 ++++- src/app/app.module.ts | 2 + .../navbar-before-connexion.component.scss | 2 +- .../page-history-user.component.scss | 1 + .../playlist-list.component.html | 24 ++++++--- .../playlist-list.component.scss | 15 +++++- .../playlist-list/playlist-list.component.ts | 49 ++++++++++++++++--- .../popup-delete-playlist.component.html | 8 +++ .../popup-delete-playlist.component.scss | 0 .../popup-delete-playlist.component.spec.ts | 25 ++++++++++ .../popup-delete-playlist.component.ts | 28 +++++++++++ .../video-list/video-list.component.html | 8 ++- .../video-list/video-list.component.scss | 1 + .../video-grid/video-grid.component.html | 8 +-- .../video-grid/video-grid.component.scss | 33 ++++++++----- .../navbar-user/navbar-user.component.html | 14 ++++-- .../navbar-user/navbar-user.component.scss | 17 ++++--- .../navbar-user/navbar-user.component.ts | 13 ++++- .../page-watching-video.component.html | 17 +++++-- .../page-watching-video.component.scss | 46 ++++++++++++++++- .../page-watching-video.component.ts | 9 ++++ 26 files changed, 333 insertions(+), 85 deletions(-) create mode 100644 src/app/user/myPlaylists/popup-delete-playlist/popup-delete-playlist.component.html create mode 100644 src/app/user/myPlaylists/popup-delete-playlist/popup-delete-playlist.component.scss create mode 100644 src/app/user/myPlaylists/popup-delete-playlist/popup-delete-playlist.component.spec.ts create mode 100644 src/app/user/myPlaylists/popup-delete-playlist/popup-delete-playlist.component.ts diff --git a/src/app/admin/utils/components/navbar-admin/navbar-admin.component.html b/src/app/admin/utils/components/navbar-admin/navbar-admin.component.html index 563792a..6bde92b 100644 --- a/src/app/admin/utils/components/navbar-admin/navbar-admin.component.html +++ b/src/app/admin/utils/components/navbar-admin/navbar-admin.component.html @@ -6,24 +6,29 @@ - + + + + - + + + + + +
+
+
+ {{playlist.name}}
+ {{playlist.videoIds.length}} vidéo + {{playlist.videoIds.length}} vidéos +
+
+ +
+
+ +
- +
diff --git a/src/app/user/myPlaylists/playlist-list/playlist-list.component.scss b/src/app/user/myPlaylists/playlist-list/playlist-list.component.scss index 832cbfb..c1e4491 100644 --- a/src/app/user/myPlaylists/playlist-list/playlist-list.component.scss +++ b/src/app/user/myPlaylists/playlist-list/playlist-list.component.scss @@ -35,23 +35,36 @@ height: 60vh; overflow-y: scroll; padding: 0px; + overflow-x: hidden; } .playlistContainer { max-width: 100%; padding: 0px; + overflow-x: hidden; } + .btnPlaylist { background-color: white; padding: 20px; border-bottom: solid 1px black; - width: 100%; + //width: 100%; + width: 35vw; + overflow-x: hidden; } .btnPlaylist:hover { background-color: #f0f0f0; } +.btnPlaylistFocus { + background-color: #e6e6e6; +} +.btnPlaylistFocus:hover { + background-color: #e6e6e6; +} + + .playListCount { color: gray; font-style: italic; diff --git a/src/app/user/myPlaylists/playlist-list/playlist-list.component.ts b/src/app/user/myPlaylists/playlist-list/playlist-list.component.ts index 191e2e1..1a95744 100644 --- a/src/app/user/myPlaylists/playlist-list/playlist-list.component.ts +++ b/src/app/user/myPlaylists/playlist-list/playlist-list.component.ts @@ -1,11 +1,11 @@ import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core'; import {ThemeService} from "../../../utils/services/theme/theme.service"; import {PlaylistDB} from "../../../utils/interfaces/playlist"; -import {MessageService} from "../../../utils/services/message/message.service"; import {MatDialog} from "@angular/material/dialog"; import {MatSnackBar} from "@angular/material/snack-bar"; import {PopupCreatePlaylistComponent} from "../popup-create-playlist/popup-create-playlist.component"; import {FictitiousVideosService} from "../../../utils/services/fictitiousDatas/fictitiousVideos/fictitious-videos.service"; +import {PopupDeletePlaylistComponent} from "../popup-delete-playlist/popup-delete-playlist.component"; @@ -18,8 +18,9 @@ export class PlaylistListComponent implements OnInit { allPlaylists: PlaylistDB[] = []; // toutes les playlists @Output() eventEmitter = new EventEmitter(); // pour envoyer au parent la playlist selectionner - search: string = "" ; // contenu de la barre de recherche + search: string = "" ; // contenu de la barre de recherche tabPlaylist: PlaylistDB[] = []; // playlist affichées + playlistFocusedOn: PlaylistDB; constructor( public themeService: ThemeService, @@ -30,15 +31,14 @@ export class PlaylistListComponent implements OnInit ngOnInit(): void { - //this.allPlaylists = this.fictitiousVideosService.getRandomTabPlaylistDB(10, 10); this.allPlaylists = this.fictitiousVideosService.getNoRandomTabPlaylistDB(10); this.tabPlaylist = [].concat(this.allPlaylists); } + // s'execute lorsqu'on écrit sur la barre de recherche whileSearch() { - console.log("whileSearch"); this.tabPlaylist = []; for(let playlist of this.allPlaylists) { @@ -47,6 +47,7 @@ export class PlaylistListComponent implements OnInit } + // click sur créer playlist onCreatePlaylist(): void { const config = { data: this.tabPlaylist }; @@ -55,16 +56,52 @@ export class PlaylistListComponent implements OnInit .afterClosed() .subscribe(playlist => { - const config = { duration: 1000, panelClass: "custom-class" }; + const config = { duration: 1500, panelClass: "custom-class" }; if((playlist === null) || (playlist === undefined)) { this.snackBar.open("Opération annulée", "", config); } else { this.allPlaylists.push(playlist); this.tabPlaylist.push(playlist); - this.snackBar.open("La playlist a bien été créée ✔", "", config); + this.snackBar.open(`La playlist '${playlist.name}' a bien été créée ✔`, "", config); } }); } + + // click sur supprimer playlist + onDeletePlaylist(playlist: PlaylistDB): void + { + const config = {data: playlist}; + this.dialog + .open(PopupDeletePlaylistComponent, config) + .afterClosed() + .subscribe(retour => { + + const config = { duration: 1500, panelClass: "custom-class" }; + if((retour === null) || (retour === undefined)) { + this.snackBar.open("Opération annulée", "", config); + } + else { + let index = this.allPlaylists.indexOf(playlist); + if(index >= 0) this.allPlaylists.splice(index, 1); + + index = this.tabPlaylist.indexOf(playlist); + if(index >= 0) this.tabPlaylist.splice(index, 1); + + this.eventEmitter.emit(null); + this.playlistFocusedOn = null; + this.snackBar.open(`La playlist '${playlist.name}' a bien été suprimée ✔`, "", config); + } + }); + } + + + // retourne la class CSS de conteneur de playlist + getClassOfPlaylistContainer(playlist: PlaylistDB): string + { + if(playlist === this.playlistFocusedOn) return "row btnPlaylist btnPlaylistFocus" ; + else return "row btnPlaylist" ; + } + } diff --git a/src/app/user/myPlaylists/popup-delete-playlist/popup-delete-playlist.component.html b/src/app/user/myPlaylists/popup-delete-playlist/popup-delete-playlist.component.html new file mode 100644 index 0000000..0335139 --- /dev/null +++ b/src/app/user/myPlaylists/popup-delete-playlist/popup-delete-playlist.component.html @@ -0,0 +1,8 @@ + + Êtes-vous sûr de vouloir supprimer {{playlist.name}} ? + + + + + + diff --git a/src/app/user/myPlaylists/popup-delete-playlist/popup-delete-playlist.component.scss b/src/app/user/myPlaylists/popup-delete-playlist/popup-delete-playlist.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/user/myPlaylists/popup-delete-playlist/popup-delete-playlist.component.spec.ts b/src/app/user/myPlaylists/popup-delete-playlist/popup-delete-playlist.component.spec.ts new file mode 100644 index 0000000..83d1cf7 --- /dev/null +++ b/src/app/user/myPlaylists/popup-delete-playlist/popup-delete-playlist.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { PopupDeletePlaylistComponent } from './popup-delete-playlist.component'; + +describe('PopupDeletePlaylistComponent', () => { + let component: PopupDeletePlaylistComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ PopupDeletePlaylistComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(PopupDeletePlaylistComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/user/myPlaylists/popup-delete-playlist/popup-delete-playlist.component.ts b/src/app/user/myPlaylists/popup-delete-playlist/popup-delete-playlist.component.ts new file mode 100644 index 0000000..0160eb6 --- /dev/null +++ b/src/app/user/myPlaylists/popup-delete-playlist/popup-delete-playlist.component.ts @@ -0,0 +1,28 @@ +import {Component, Inject, OnInit} from '@angular/core'; +import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog"; +import {MessageService} from "../../../utils/services/message/message.service"; + +@Component({ + selector: 'app-popup-delete-playlist', + templateUrl: './popup-delete-playlist.component.html', + styleUrls: ['./popup-delete-playlist.component.scss'] +}) +export class PopupDeletePlaylistComponent implements OnInit +{ + playlist; + + constructor( public dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public data, + private messageService: MessageService ) { } + + ngOnInit(): void + { + this.playlist = this.data; + } + + onValidate(): void + { + this.dialogRef.close(true); + } + +} diff --git a/src/app/user/myPlaylists/video-list/video-list.component.html b/src/app/user/myPlaylists/video-list/video-list.component.html index e6ee4f5..fa9faf4 100644 --- a/src/app/user/myPlaylists/video-list/video-list.component.html +++ b/src/app/user/myPlaylists/video-list/video-list.component.html @@ -37,26 +37,24 @@ - + - -
+
-
- + diff --git a/src/app/user/myPlaylists/video-list/video-list.component.scss b/src/app/user/myPlaylists/video-list/video-list.component.scss index f38b820..07aeb42 100644 --- a/src/app/user/myPlaylists/video-list/video-list.component.scss +++ b/src/app/user/myPlaylists/video-list/video-list.component.scss @@ -45,6 +45,7 @@ position: relative; width: 20vw; height: 15vh; + cursor: pointer; } .imgPlay { diff --git a/src/app/user/search/video-grid/video-grid.component.html b/src/app/user/search/video-grid/video-grid.component.html index 8dc071a..5b6d46b 100644 --- a/src/app/user/search/video-grid/video-grid.component.html +++ b/src/app/user/search/video-grid/video-grid.component.html @@ -2,7 +2,7 @@ -
+
@@ -19,13 +19,13 @@ - + ytb dlm - +
{{tronquage(tabVideo[indexPage+k].title)}}
@@ -54,7 +54,7 @@ -
+
  diff --git a/src/app/user/search/video-grid/video-grid.component.scss b/src/app/user/search/video-grid/video-grid.component.scss index ae339eb..7f3a7ea 100644 --- a/src/app/user/search/video-grid/video-grid.component.scss +++ b/src/app/user/search/video-grid/video-grid.component.scss @@ -7,12 +7,20 @@ mat-grid-list { mat-grid-tile { margin: 0px 0px 0px 0px; padding: 0px 0px 0px 0px; - border: solid 1px black; + //border: solid 1px black; } .myCell { - margin: 0px 0px 0px 0px; - padding: 7px 0px 0px 0px; + margin: 7px 0px 0px 0px; + padding: 0px 0px 0px 0px; + background-color: #f0f0f0; + border: solid 1px black; + border-bottom-left-radius: 2px; + border-bottom-right-radius: 2px; + cursor: pointer; +} +.myCell:hover { + background-color: #d2d2d2; } @@ -20,22 +28,24 @@ mat-grid-tile { .imgsContainer { - width: 20vw; + //width: 20vw; + width: 18vw; height: 15vh; } .imgPlay { position: absolute; - margin-left: 9vw; - width: 3vw; + margin-left: 8vw; + width: 2.5vw; margin-top: 5vh; - height: 6vh; + height: 5vh; padding: 0px 0px 0px 0px; } .imgVideo { - border: solid 1px black; - width: 20vw; + //border: solid 1px black; + //width: 20vw; + width: 18vw; height: 15vh; padding: 0px 0px 0px 0px; } @@ -57,10 +67,11 @@ mat-icon { // --------------------------------------------------------------------------------------------- -.btnContainer { +.paginatorContainer { margin: 0px 0px 0px 0px; - padding: 0px 0px 0px 0px; + padding: 5px 0px 0px 0px; text-align: center; + background-color: white; } .btnPaginator { diff --git a/src/app/user/utils/components/navbar-user/navbar-user.component.html b/src/app/user/utils/components/navbar-user/navbar-user.component.html index 57153fb..eb7bf23 100644 --- a/src/app/user/utils/components/navbar-user/navbar-user.component.html +++ b/src/app/user/utils/components/navbar-user/navbar-user.component.html @@ -6,27 +6,33 @@ + + +
diff --git a/src/app/admin/adList/page-ad-list-admin/page-ad-list-admin.component.scss b/src/app/admin/adList/page-ad-list-admin/page-ad-list-admin.component.scss index 822f4d0..954f3d0 100644 --- a/src/app/admin/adList/page-ad-list-admin/page-ad-list-admin.component.scss +++ b/src/app/admin/adList/page-ad-list-admin/page-ad-list-admin.component.scss @@ -68,3 +68,7 @@ input { border: solid 1px black !important; background-color: white !important; } + +::ng-deep .mat-pseudo-checkbox-checked { + background-color: black !important; +} 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 3b15694..a98964f 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 @@ -5,12 +5,36 @@ import {ThemeService} from "../../../utils/services/theme/theme.service"; import {MatDialog} from "@angular/material/dialog"; import {MatSnackBar} from "@angular/material/snack-bar"; import {MatTableDataSource} from "@angular/material/table"; -import {Advert, AdvertWithCountViews} from "../../../utils/interfaces/advert"; +import {Advert} from "../../../utils/interfaces/advert"; 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 {FictitiousAdvertsService} from "../../../utils/services/fictitiousDatas/fictitiousAdverts/fictitious-adverts.service"; 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"; + + + +export interface AdvertWithCountViewsAndCompany { + _id: string, + userId: string, + company: string, + title: string, + url: string, + images: { + url: string, + description: string, + }[], + interests: string[], + comment: string, + views: Date[], + countViews: number, + isVisible: boolean, + isActive: boolean, + createdAt: Date, + updatedAt: Date, +} @@ -21,8 +45,9 @@ import {FictitiousUtilsService} from "../../../utils/services/fictitiousDatas/fi }) export class PageAdListAdminComponent implements AfterViewInit { - tabAdvertWithCountViews: AdvertWithCountViews[] = []; - displayedColumns: string[] = [ 'title', 'advertiser', 'interests', 'createdAt', 'updatedAt', 'countViews', 'isVisible', 'actions' ]; + tabAdvertWithCountViews: AdvertWithCountViewsAndCompany[] = []; + tabAdvertiser: User[]; + displayedColumns: string[] = [ 'title', 'company', 'interests', 'createdAt', 'updatedAt', 'countViews', 'isVisible', 'actions' ]; dataSource ; @ViewChild(MatSort) sort: MatSort; @ViewChild(MatPaginator) paginator: MatPaginator; @@ -38,6 +63,7 @@ export class PageAdListAdminComponent implements AfterViewInit constructor( public themeService: ThemeService, private fictitiousAdvertsService: FictitiousAdvertsService, private fictitiousUtilsService: FictitiousUtilsService, + private fictitiousUsersService: FictitiousUsersService, public dialog: MatDialog, private snackBar: MatSnackBar ) { } @@ -47,8 +73,9 @@ export class PageAdListAdminComponent implements AfterViewInit // --- 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.advertToAdvertWithCountViews(advert)); + for(let advert of tabAdvert) this.tabAdvertWithCountViews.push(this.advertToAdvertWithCountViewsAndCompany(advert)); this.dataSource = new MatTableDataSource(); this.onFilter(); } @@ -61,7 +88,7 @@ export class PageAdListAdminComponent implements AfterViewInit } - onVisualizeImages(advert: AdvertWithCountViews) + onVisualizeImages(advert: AdvertWithCountViewsAndCompany) { const config = { width: '30%', @@ -79,7 +106,7 @@ export class PageAdListAdminComponent implements AfterViewInit } - onDelete(advert: AdvertWithCountViews): void + onDelete(advert: AdvertWithCountViewsAndCompany): void { const config = { data: { advert: advert } @@ -160,13 +187,23 @@ export class PageAdListAdminComponent implements AfterViewInit } - advertToAdvertWithCountViews(advert: Advert): AdvertWithCountViews + advertToAdvertWithCountViewsAndCompany(advert: Advert): AdvertWithCountViewsAndCompany { + let company0 = "company" ; + for(let advertiser of this.tabAdvertiser) + { + if(advert.userId === advertiser._id) { + company0 = advertiser.company; + break; + } + } + return { _id: advert._id, userId: advert.userId, title: advert.title, - advertiser: advert.advertiser, + company: company0, + url: advert.url, images: advert.images, interests: advert.interests, comment: advert.comment, 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 c1c6e24..2fae562 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 @@ -34,7 +34,7 @@ export class PopupDeleteAdAdminComponent implements OnInit // --- VRAI CODE --- /* this.messageService - .sendMessage("advertiser/delete/ad", {"advert": this.advert}) + .sendMessage("url/delete/ad", {"advert": this.advert}) .subscribe( retour => { if(retour.status === "error") { diff --git a/src/app/admin/adList/popup-visualize-ad-admin/popup-visualize-ad-admin.component.html b/src/app/admin/adList/popup-visualize-ad-admin/popup-visualize-ad-admin.component.html index 1c1625b..2ff5c54 100644 --- a/src/app/admin/adList/popup-visualize-ad-admin/popup-visualize-ad-admin.component.html +++ b/src/app/admin/adList/popup-visualize-ad-admin/popup-visualize-ad-admin.component.html @@ -7,10 +7,10 @@ - +
Annonceur:
-
{{advert.advertiser}}
+
{{advert.url}}
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 52a7584..5e61893 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 @@ -39,6 +39,7 @@ export class PopupUpdateAdminComponent implements OnInit dateOfBirth: admin0.dateOfBirth, gender: admin0.gender, interests: [], + company: "", isActive: admin0.isActive, isAccepted: admin0.isisAccepted, createdAt: admin0.createdAt, 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 a2260b6..421cb79 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 @@ -35,7 +35,7 @@ Utilisateur
- + Annonceur
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 c281ffc..6b8659d 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 @@ -133,6 +133,11 @@ Login
+ + + Entreprise + +
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 1b88942..5e0470c 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 @@ -38,6 +38,7 @@ export class PopupCreateUserComponent implements OnInit dateOfBirth: null, gender: "man", interests: [], + company: "", isActive: false, isAccepted: false, createdAt: new Date(), @@ -72,12 +73,8 @@ export class PopupCreateUserComponent implements OnInit this.errorMessage = "Veuillez remplir le champ 'email'."; this.hasError = true; } - if((this.user.role.name === 'user') && ((this.user.dateOfBirth === undefined) || (this.user.dateOfBirth === null))) { - this.errorMessage = "Veuillez remplir le champ 'date de naissance'."; - this.hasError = true; - } else if(!this.isValidEmail(this.user.email)) { - this.errorMessage = "Email invalide"; + this.errorMessage = "Email invalide."; this.hasError = true; } else if(this.password.length === 0) { @@ -88,6 +85,14 @@ export class PopupCreateUserComponent implements OnInit this.errorMessage = "Le mot de passe est différent de sa confirmation."; this.hasError = true; } + else if((this.user.role.name === 'user') && ((this.user.dateOfBirth === undefined) || (this.user.dateOfBirth === null))) { + this.errorMessage = "Veuillez remplir le champ 'date de naissance'."; + this.hasError = true; + } + else if((this.user.role.name === 'advertiser') && (this.user.company.length === 0)) { + this.errorMessage = "Veuillez remplir le champ 'entreprise'."; + this.hasError = true; + } else { this.errorMessage = "" ; this.hasError = false; diff --git a/src/app/admin/userList/popup-visualize-user/popup-visualize-user.component.html b/src/app/admin/userList/popup-visualize-user/popup-visualize-user.component.html index 89124e7..3e0bf70 100644 --- a/src/app/admin/userList/popup-visualize-user/popup-visualize-user.component.html +++ b/src/app/admin/userList/popup-visualize-user/popup-visualize-user.component.html @@ -62,7 +62,7 @@
Rôle:
Utilisateur - Annonceur + Annonceur Admin
diff --git a/src/app/advertiser/adList/page-ad-list-advertiser/page-ad-list-advertiser.component.scss b/src/app/advertiser/adList/page-ad-list-advertiser/page-ad-list-advertiser.component.scss index ab19a74..370e312 100644 --- a/src/app/advertiser/adList/page-ad-list-advertiser/page-ad-list-advertiser.component.scss +++ b/src/app/advertiser/adList/page-ad-list-advertiser/page-ad-list-advertiser.component.scss @@ -82,19 +82,6 @@ input { // ------------------------------------------------------------------------- - -// aura -::ng-deep .mat-checkbox-ripple .mat-ripple-element { - background-color: grey !important; -} - -// contenu coche -::ng-deep .mat-checkbox-checked.mat-accent .mat-checkbox-background { +::ng-deep .mat-pseudo-checkbox-checked { background-color: black !important; } - -// indeterminate -::ng-deep .mat-checkbox .mat-checkbox-frame { - border: solid 1px black !important; - background-color: white !important; -} 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 b91408f..826fbe1 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 @@ -229,7 +229,7 @@ export class PageAdListAdvertiserComponent implements AfterViewInit _id: advert._id, userId: advert.userId, title: advert.title, - advertiser: advert.advertiser, + url: advert.url, images: advert.images, interests: advert.interests, comment: advert.comment, 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 a2a5c8d..8e161d2 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 @@ -28,6 +28,12 @@
+ + + URL + +
+ Visible

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 4b23a23..b8e97fa 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 @@ -9,7 +9,7 @@ const ADVERT_VIDE: Advert = { _id: "", userId: "", title: "", - advertiser: "", + url: "", images: [], interests: [], comment: "", @@ -48,14 +48,14 @@ export class PopupAddOrUpdateAdComponent implements OnInit { this.advert = Object.assign({}, ADVERT_VIDE); this.advert.interests = []; - this.urlBackend = "advertiser/add/ad" ; + this.urlBackend = "url/add/ad" ; this.title = "Ajouter annonce" ; } else { this.advert = Object.assign({}, this.data.advert); this.advert.interests = this.data.advert.interests.slice(); - this.urlBackend = "advertiser/update/ad" ; + this.urlBackend = "url/update/ad" ; this.title = "Modifier annonce" ; } } diff --git a/src/app/advertiser/adList/popup-delete-ad-advertiser/popup-delete-ad-advertiser.component.ts b/src/app/advertiser/adList/popup-delete-ad-advertiser/popup-delete-ad-advertiser.component.ts index 48a45e1..e36d92b 100644 --- a/src/app/advertiser/adList/popup-delete-ad-advertiser/popup-delete-ad-advertiser.component.ts +++ b/src/app/advertiser/adList/popup-delete-ad-advertiser/popup-delete-ad-advertiser.component.ts @@ -34,7 +34,7 @@ export class PopupDeleteAdAdvertiserComponent implements OnInit // --- VRAI CODE --- /* this.messageService - .sendMessage("advertiser/delete/ad", {"advert": this.advert}) + .sendMessage("url/delete/ad", {"advert": this.advert}) .subscribe( retour => { if(retour.status === "error") { diff --git a/src/app/advertiser/myProfil/page-profil-advertiser/page-profil-advertiser.component.html b/src/app/advertiser/myProfil/page-profil-advertiser/page-profil-advertiser.component.html index 5900345..9af3317 100644 --- a/src/app/advertiser/myProfil/page-profil-advertiser/page-profil-advertiser.component.html +++ b/src/app/advertiser/myProfil/page-profil-advertiser/page-profil-advertiser.component.html @@ -13,9 +13,15 @@ onerror="this.onerror=null; this.src='assets/profil.png'"> + +
+
Entreprise:
+
{{advertiser.company}}
+
+
-
Login:
+
Pseudo:
{{advertiser.login}}
diff --git a/src/app/advertiser/myProfil/popup-update-advertiser/popup-update-advertiser.component.html b/src/app/advertiser/myProfil/popup-update-advertiser/popup-update-advertiser.component.html index bbbcd85..4951e5c 100644 --- a/src/app/advertiser/myProfil/popup-update-advertiser/popup-update-advertiser.component.html +++ b/src/app/advertiser/myProfil/popup-update-advertiser/popup-update-advertiser.component.html @@ -10,6 +10,12 @@

+ + + Entreprise + +
+ Pseudo 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 76e5e05..26882ac 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 @@ -39,6 +39,7 @@ export class PopupUpdateAdvertiserComponent implements OnInit dateOfBirth: advertiser0.dateOfBirth, gender: advertiser0.gender, interests: [], + company: advertiser0.company, isActive: advertiser0.isActive, isAccepted: advertiser0.isAccepted, createdAt: advertiser0.createdAt, diff --git a/src/app/advertiser/pages-popularity/pages-popularity.component.scss b/src/app/advertiser/pages-popularity/pages-popularity.component.scss index b6a7b99..6030311 100644 --- a/src/app/advertiser/pages-popularity/pages-popularity.component.scss +++ b/src/app/advertiser/pages-popularity/pages-popularity.component.scss @@ -42,19 +42,6 @@ input { // ------------------------------------------------------------------------- - -// aura -::ng-deep .mat-checkbox-ripple .mat-ripple-element { - background-color: grey !important; -} - -// contenu coche -::ng-deep .mat-checkbox-checked.mat-accent .mat-checkbox-background { +::ng-deep .mat-pseudo-checkbox-checked { background-color: black !important; } - -// indeterminate -::ng-deep .mat-checkbox .mat-checkbox-frame { - border: solid 1px black !important; - background-color: white !important; -} diff --git a/src/app/advertiser/utils/components/navbar-advertiser/navbar-advertiser.component.html b/src/app/advertiser/utils/components/navbar-advertiser/navbar-advertiser.component.html index 29fb540..1b16354 100644 --- a/src/app/advertiser/utils/components/navbar-advertiser/navbar-advertiser.component.html +++ b/src/app/advertiser/utils/components/navbar-advertiser/navbar-advertiser.component.html @@ -1,7 +1,7 @@
+ diff --git a/src/app/admin/myProfil/page-profil-admin/page-profil-admin.component.html b/src/app/admin/myProfil/page-profil-admin/page-profil-admin.component.html index 6877336..7e025c5 100644 --- a/src/app/admin/myProfil/page-profil-admin/page-profil-admin.component.html +++ b/src/app/admin/myProfil/page-profil-admin/page-profil-admin.component.html @@ -15,7 +15,7 @@
-
Login:
+
Pseudo:
{{admin.login}}
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 5e61893..6f9eabc 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 @@ -68,7 +68,7 @@ export class PopupUpdateAdminComponent implements OnInit checkField() { if(this.adminCopy.login.length === 0) { - this.errorMessage = "Veuillez remplir le champ 'login'" ; + this.errorMessage = "Veuillez remplir le champ 'pseudo'" ; this.hasError = true; } else if(this.adminCopy.email.length === 0) { @@ -113,4 +113,5 @@ export class PopupUpdateAdminComponent implements OnInit } return hash.toString(); } + } 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 421cb79..212f895 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 @@ -35,7 +35,7 @@ Utilisateur
- + Annonceur
@@ -99,7 +99,7 @@ -
+ 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 6b8659d..2085ccd 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 @@ -58,7 +58,7 @@ - Login + Pseudo
@@ -130,7 +130,7 @@
- Login + Pseudo
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 5e0470c..141fe53 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 @@ -66,7 +66,7 @@ export class PopupCreateUserComponent implements OnInit checkField(): void { if(this.user.login.length === 0) { - this.errorMessage = "Veuillez remplir le champ 'login'."; + this.errorMessage = "Veuillez remplir le champ 'pseudo'."; this.hasError = true; } else if(this.user.email.length === 0) { diff --git a/src/app/admin/utils/components/navbar-admin/navbar-admin.component.html b/src/app/admin/utils/navbar-admin/navbar-admin.component.html similarity index 92% rename from src/app/admin/utils/components/navbar-admin/navbar-admin.component.html rename to src/app/admin/utils/navbar-admin/navbar-admin.component.html index 6bde92b..90f0cbc 100644 --- a/src/app/admin/utils/components/navbar-admin/navbar-admin.component.html +++ b/src/app/admin/utils/navbar-admin/navbar-admin.component.html @@ -15,8 +15,8 @@ Liste des utillisateurs diff --git a/src/app/admin/utils/components/navbar-admin/navbar-admin.component.scss b/src/app/admin/utils/navbar-admin/navbar-admin.component.scss similarity index 100% rename from src/app/admin/utils/components/navbar-admin/navbar-admin.component.scss rename to src/app/admin/utils/navbar-admin/navbar-admin.component.scss diff --git a/src/app/admin/utils/components/navbar-admin/navbar-admin.component.spec.ts b/src/app/admin/utils/navbar-admin/navbar-admin.component.spec.ts similarity index 100% rename from src/app/admin/utils/components/navbar-admin/navbar-admin.component.spec.ts rename to src/app/admin/utils/navbar-admin/navbar-admin.component.spec.ts diff --git a/src/app/admin/utils/components/navbar-admin/navbar-admin.component.ts b/src/app/admin/utils/navbar-admin/navbar-admin.component.ts similarity index 100% rename from src/app/admin/utils/components/navbar-admin/navbar-admin.component.ts rename to src/app/admin/utils/navbar-admin/navbar-admin.component.ts 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 26882ac..23827fe 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 @@ -68,7 +68,7 @@ export class PopupUpdateAdvertiserComponent implements OnInit checkField() { if(this.advertiserCopy.login.length === 0) { - this.errorMessage = "Veuillez remplir le champ 'login'" ; + this.errorMessage = "Veuillez remplir le champ 'pseudo'" ; this.hasError = true; } else if(this.advertiserCopy.email.length === 0) { diff --git a/src/app/utils/directives/dragAndDrop/drag-and-drop.directive.spec.ts b/src/app/advertiser/utils/dragAndDrop/drag-and-drop.directive.spec.ts similarity index 100% rename from src/app/utils/directives/dragAndDrop/drag-and-drop.directive.spec.ts rename to src/app/advertiser/utils/dragAndDrop/drag-and-drop.directive.spec.ts diff --git a/src/app/utils/directives/dragAndDrop/drag-and-drop.directive.ts b/src/app/advertiser/utils/dragAndDrop/drag-and-drop.directive.ts similarity index 100% rename from src/app/utils/directives/dragAndDrop/drag-and-drop.directive.ts rename to src/app/advertiser/utils/dragAndDrop/drag-and-drop.directive.ts diff --git a/src/app/advertiser/utils/components/navbar-advertiser/navbar-advertiser.component.html b/src/app/advertiser/utils/navbar-advertiser/navbar-advertiser.component.html similarity index 100% rename from src/app/advertiser/utils/components/navbar-advertiser/navbar-advertiser.component.html rename to src/app/advertiser/utils/navbar-advertiser/navbar-advertiser.component.html diff --git a/src/app/advertiser/utils/components/navbar-advertiser/navbar-advertiser.component.scss b/src/app/advertiser/utils/navbar-advertiser/navbar-advertiser.component.scss similarity index 100% rename from src/app/advertiser/utils/components/navbar-advertiser/navbar-advertiser.component.scss rename to src/app/advertiser/utils/navbar-advertiser/navbar-advertiser.component.scss diff --git a/src/app/advertiser/utils/components/navbar-advertiser/navbar-advertiser.component.spec.ts b/src/app/advertiser/utils/navbar-advertiser/navbar-advertiser.component.spec.ts similarity index 100% rename from src/app/advertiser/utils/components/navbar-advertiser/navbar-advertiser.component.spec.ts rename to src/app/advertiser/utils/navbar-advertiser/navbar-advertiser.component.spec.ts diff --git a/src/app/advertiser/utils/components/navbar-advertiser/navbar-advertiser.component.ts b/src/app/advertiser/utils/navbar-advertiser/navbar-advertiser.component.ts similarity index 100% rename from src/app/advertiser/utils/components/navbar-advertiser/navbar-advertiser.component.ts rename to src/app/advertiser/utils/navbar-advertiser/navbar-advertiser.component.ts diff --git a/src/app/app.module.ts b/src/app/app.module.ts index d1b563b..28aa609 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -22,7 +22,6 @@ import {MatDividerModule} from "@angular/material/divider"; import {MatCheckboxModule} from "@angular/material/checkbox"; import {MatFormFieldModule} from "@angular/material/form-field"; import {MatSnackBarModule} from "@angular/material/snack-bar"; -import { IframeTrackerDirective } from './utils/directives/iframe-tracker/iframe-tracker.directive'; import {MatGridListModule} from "@angular/material/grid-list"; import { PageMyPlaylistsComponent } from './user/myPlaylists/page-my-playlists/page-my-playlists.component'; import { PlaylistListComponent } from './user/myPlaylists/playlist-list/playlist-list.component'; @@ -43,15 +42,15 @@ import {MatSelectModule} from "@angular/material/select"; import { PopupVisualizeImagesAdvertiserComponent } from './advertiser/adList/popup-visualize-images-advertiser/popup-visualize-images-advertiser.component'; import {IvyCarouselModule} from "angular-responsive-carousel"; import { DragAndDropComponent } from './advertiser/adList/drag-and-drop/drag-and-drop.component'; -import { DragAndDropDirective } from './utils/directives/dragAndDrop/drag-and-drop.directive'; +import { DragAndDropDirective } from './advertiser/utils/dragAndDrop/drag-and-drop.directive'; import { PageProfilUserComponent } from './user/myProfil/page-profil-user/page-profil-user.component'; import { NavbarUserComponent } from './user/utils/components/navbar-user/navbar-user.component'; -import { NavbarAdvertiserComponent } from './advertiser/utils/components/navbar-advertiser/navbar-advertiser.component'; -import { NavbarAdminComponent } from './admin/utils/components/navbar-admin/navbar-admin.component'; +import { NavbarAdvertiserComponent } from './advertiser/utils/navbar-advertiser/navbar-advertiser.component'; +import { NavbarAdminComponent } from './admin/utils/navbar-admin/navbar-admin.component'; import { PageProfilAdvertiserComponent } from './advertiser/myProfil/page-profil-advertiser/page-profil-advertiser.component'; import { PopupUpdateAdvertiserComponent } from './advertiser/myProfil/popup-update-advertiser/popup-update-advertiser.component'; import { PopupUpdateUserComponent } from './user/myProfil/popup-update-user/popup-update-user.component'; -import { NavbarBeforeConnexionComponent } from './beforeConnexion/navbar-before-connexion/navbar-before-connexion.component'; +import { NavbarBeforeConnexionComponent } from './beforeConnexion/utils/navbar-before-connexion/navbar-before-connexion.component'; import {MatRadioModule} from "@angular/material/radio"; import { InputInterestsProfilComponent } from './user/myProfil/input-interests-profil/input-interests-profil.component'; import { PageProfilAdminComponent } from './admin/myProfil/page-profil-admin/page-profil-admin.component'; @@ -85,7 +84,6 @@ import { PopupDeletePlaylistComponent } from './user/myPlaylists/popup-delete-pl AdvertComponent, VideoGridComponent, PopupAddVideoToPlaylistsComponent, - IframeTrackerDirective, PageMyPlaylistsComponent, VideoListComponent, PlaylistListComponent, diff --git a/src/app/beforeConnexion/login/page-login/page-login.component.html b/src/app/beforeConnexion/login/page-login/page-login.component.html index 1404ee9..48258aa 100644 --- a/src/app/beforeConnexion/login/page-login/page-login.component.html +++ b/src/app/beforeConnexion/login/page-login/page-login.component.html @@ -14,8 +14,8 @@ - - + +
{{errorMessage}} diff --git a/src/app/beforeConnexion/login/page-login/page-login.component.ts b/src/app/beforeConnexion/login/page-login/page-login.component.ts index 68130da..008a81f 100644 --- a/src/app/beforeConnexion/login/page-login/page-login.component.ts +++ b/src/app/beforeConnexion/login/page-login/page-login.component.ts @@ -12,7 +12,7 @@ import {ThemeService} from "../../../utils/services/theme/theme.service"; }) export class PageLoginComponent implements OnInit { - pseudo: string = "" ; + email: string = "" ; password: string = "" ; hasError: boolean = false; errorMessage: string = ""; @@ -33,8 +33,8 @@ export class PageLoginComponent implements OnInit if(!this.hasError) { let data = { - login: this.pseudo, - hashPass: this.password + email: this.email, + hashPass: this.hashage(this.password) }; this.messageService .sendMessage('user/auth', data) @@ -58,8 +58,8 @@ export class PageLoginComponent implements OnInit checkError(): void { - if(this.pseudo === "") { - this.errorMessage = "Veuillez remplir le champ login" ; + if(this.email === "") { + this.errorMessage = "Veuillez remplir le champ email" ; this.hasError = true; } else if(this.password === "") { @@ -72,4 +72,16 @@ export class PageLoginComponent implements OnInit } } + // 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(); + } + } diff --git a/src/app/beforeConnexion/register/page-register/page-register.component.html b/src/app/beforeConnexion/register/page-register/page-register.component.html index c3dafab..42ad1a5 100644 --- a/src/app/beforeConnexion/register/page-register/page-register.component.html +++ b/src/app/beforeConnexion/register/page-register/page-register.component.html @@ -63,7 +63,7 @@ - Login + Pseudo
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 db9d8cf..c109478 100644 --- a/src/app/beforeConnexion/register/page-register/page-register.component.ts +++ b/src/app/beforeConnexion/register/page-register/page-register.component.ts @@ -100,7 +100,7 @@ export class PageRegisterComponent this.hasError = true; } else if(this.user.login.length === 0) { - this.errorMessage = "Veuillez remplir le champ 'login'."; + this.errorMessage = "Veuillez remplir le champ 'pseudo'."; this.hasError = true; } else if(this.user.email.length === 0) { diff --git a/src/app/beforeConnexion/navbar-before-connexion/navbar-before-connexion.component.html b/src/app/beforeConnexion/utils/navbar-before-connexion/navbar-before-connexion.component.html similarity index 100% rename from src/app/beforeConnexion/navbar-before-connexion/navbar-before-connexion.component.html rename to src/app/beforeConnexion/utils/navbar-before-connexion/navbar-before-connexion.component.html diff --git a/src/app/beforeConnexion/navbar-before-connexion/navbar-before-connexion.component.scss b/src/app/beforeConnexion/utils/navbar-before-connexion/navbar-before-connexion.component.scss similarity index 100% rename from src/app/beforeConnexion/navbar-before-connexion/navbar-before-connexion.component.scss rename to src/app/beforeConnexion/utils/navbar-before-connexion/navbar-before-connexion.component.scss diff --git a/src/app/beforeConnexion/navbar-before-connexion/navbar-before-connexion.component.spec.ts b/src/app/beforeConnexion/utils/navbar-before-connexion/navbar-before-connexion.component.spec.ts similarity index 100% rename from src/app/beforeConnexion/navbar-before-connexion/navbar-before-connexion.component.spec.ts rename to src/app/beforeConnexion/utils/navbar-before-connexion/navbar-before-connexion.component.spec.ts diff --git a/src/app/beforeConnexion/navbar-before-connexion/navbar-before-connexion.component.ts b/src/app/beforeConnexion/utils/navbar-before-connexion/navbar-before-connexion.component.ts similarity index 100% rename from src/app/beforeConnexion/navbar-before-connexion/navbar-before-connexion.component.ts rename to src/app/beforeConnexion/utils/navbar-before-connexion/navbar-before-connexion.component.ts 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 07ef9dd..d14ad31 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 @@ -33,9 +33,9 @@ -
+ diff --git a/src/app/user/history/page-history-user/page-history-user.component.ts b/src/app/user/history/page-history-user/page-history-user.component.ts index 5f1ff69..6999167 100644 --- a/src/app/user/history/page-history-user/page-history-user.component.ts +++ b/src/app/user/history/page-history-user/page-history-user.component.ts @@ -11,6 +11,15 @@ import {Router} from "@angular/router"; +interface VideoHistory { + imageUrl: string, + title: string, + date: Date, + source: string, +} + + + @Component({ selector: 'app-page-history-user', templateUrl: './page-history-user.component.html', @@ -37,8 +46,10 @@ export class PageHistoryUserComponent implements AfterViewInit this.userHistoryService.clearTabVideoUrlClicked(); // --- FAUX CODE --- - const tabVideo: VideoAll[] = this.fictitiousVideosService.getTabVideoAll(8); - this.dataSource = new MatTableDataSource(tabVideo); + const tabVideoAll: VideoAll[] = this.fictitiousVideosService.getTabVideoAll(8); + let tabVideoHistory: VideoHistory[] = []; + for(let videoAll of tabVideoAll) tabVideoHistory.push(this.videoAllToVideoHistory(videoAll)); + this.dataSource = new MatTableDataSource(tabVideoHistory); this.dataSource.sort = this.sort; this.dataSource.paginator = this.paginator; this.dataSource = this.dataSource; @@ -67,15 +78,6 @@ export class PageHistoryUserComponent implements AfterViewInit } - // Retourne la source de la video en fonction de l'url - getSourceByUrl(url: string): string - { - if(url.includes("youtu")) return "Youtube" ; - else if(url.includes("daily")) return "Dailymotion" ; - else return "???" ; - } - - // Supprime la video onDelete(video: VideoAll): void { @@ -109,4 +111,15 @@ export class PageHistoryUserComponent implements AfterViewInit this.router.navigateByUrl(url); } + + videoAllToVideoHistory(videoAll: VideoAll): VideoHistory + { + return { + imageUrl: videoAll.imageUrl, + title: videoAll.title, + date: videoAll.watchedDates[videoAll.watchedDates.length-1], + source: videoAll.source, + } + } + } diff --git a/src/app/user/myProfil/page-profil-user/page-profil-user.component.html b/src/app/user/myProfil/page-profil-user/page-profil-user.component.html index fa22205..7e69ded 100644 --- a/src/app/user/myProfil/page-profil-user/page-profil-user.component.html +++ b/src/app/user/myProfil/page-profil-user/page-profil-user.component.html @@ -37,7 +37,7 @@
-
Login:
+
Pseudo:
{{user.login}}
diff --git a/src/app/user/myProfil/popup-update-user/popup-update-user.component.html b/src/app/user/myProfil/popup-update-user/popup-update-user.component.html index 6544c05..1e583c7 100644 --- a/src/app/user/myProfil/popup-update-user/popup-update-user.component.html +++ b/src/app/user/myProfil/popup-update-user/popup-update-user.component.html @@ -39,7 +39,7 @@
- +
diff --git a/src/app/user/myProfil/popup-update-user/popup-update-user.component.ts b/src/app/user/myProfil/popup-update-user/popup-update-user.component.ts index c6abfb7..806b6c9 100644 --- a/src/app/user/myProfil/popup-update-user/popup-update-user.component.ts +++ b/src/app/user/myProfil/popup-update-user/popup-update-user.component.ts @@ -68,7 +68,7 @@ export class PopupUpdateUserComponent implements OnInit checkField() { if(this.userCopy.login.length === 0) { - this.errorMessage = "Veuillez remplir le champ 'login'." ; + this.errorMessage = "Veuillez remplir le champ 'pseudo'." ; this.hasError = true; } else if(this.userCopy.email.length === 0) { diff --git a/src/app/utils/directives/iframe-tracker/iframe-tracker.directive.spec.ts b/src/app/utils/directives/iframe-tracker/iframe-tracker.directive.spec.ts deleted file mode 100644 index da22920..0000000 --- a/src/app/utils/directives/iframe-tracker/iframe-tracker.directive.spec.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { IframeTrackerDirective } from './iframe-tracker.directive'; - -describe('IframeTrackerDirective', () => { - it('should create an instance', () => { - const directive = new IframeTrackerDirective(); - expect(directive).toBeTruthy(); - }); -}); diff --git a/src/app/utils/directives/iframe-tracker/iframe-tracker.directive.ts b/src/app/utils/directives/iframe-tracker/iframe-tracker.directive.ts deleted file mode 100644 index c4c5957..0000000 --- a/src/app/utils/directives/iframe-tracker/iframe-tracker.directive.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { - Directive, - ElementRef, - OnInit, - Renderer2, - Input, - Output, - EventEmitter, - HostListener -} from '@angular/core'; - -@Directive({ - selector: '[appIframeTracker]' -}) -export class IframeTrackerDirective implements OnInit { - private iframeMouseOver: boolean; - - @Input() debug: boolean; - - @Output() iframeClick = new EventEmitter(); - - constructor(private el: ElementRef, private renderer: Renderer2) {} - - ngOnInit(): void { - this.renderer.listen(window, 'blur', () => this.onWindowBlur()); - } - - @HostListener('mouseover') - private onIframeMouseOver() { - this.log('Iframe mouse over'); - this.iframeMouseOver = true; - this.resetFocusOnWindow(); - } - - @HostListener('mouseout') - private onIframeMouseOut() { - this.log('Iframe mouse out'); - this.iframeMouseOver = false; - this.resetFocusOnWindow(); - } - - private onWindowBlur() { - if (this.iframeMouseOver) { - this.log('WOW! Iframe click!!!'); - this.resetFocusOnWindow(); - this.iframeClick.emit(this.el); - } - } - - private resetFocusOnWindow() { - setTimeout(() => { - this.log('reset focus to window'); - window.focus(); - }, 100); - } - - private log(message: string) { - if (this.debug) { - console.log(message); - } - } -}
+ power_settings_new + + + Titre Tags Sujets - - {{tag}}, - {{tag}} + + {{interest}}, + {{interest}} Visible - check - - Actions Vues - {{advert.views}} + {{advert.countViews}} Vues - {{advert.views}} + {{advert.countViews}} Annonceur - {{advert.advertiser}} + {{advert.company}} Annonceur Entreprise {{advert.company}} Login Pseudo {{user.login}}
Date Date - {{video.watchedDates[video.watchedDates.length-1] | date:'dd/LL/YYYY à HH:mm:ss'}} + {{video.date | date:'dd/LL/YYYY à HH:mm:ss'}}