continuation de la partie advertiser
This commit is contained in:
parent
01c0e137e0
commit
1e5b9bd49c
28 changed files with 656 additions and 91 deletions
|
|
@ -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<Advert>();
|
||||
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,
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue