gestion de l'affichage des annonces dans la partie user
This commit is contained in:
parent
7ea0a5eb97
commit
b0b17c062d
14 changed files with 57 additions and 101 deletions
|
|
@ -34,7 +34,7 @@ export class NavbarAdminComponent
|
|||
|
||||
onDeconnexionCallback(retour: any): void
|
||||
{
|
||||
console.log(retour);
|
||||
if(retour.status !== "success") console.log(retour);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,9 +84,12 @@ export class PageAdListAdvertiserComponent implements AfterViewInit
|
|||
console.log(retour);
|
||||
}
|
||||
else {
|
||||
for(let advert of retour.data) this.tabAdvertWithCountViews.push(this.advertToAdvertWithCountViews(advert));
|
||||
this.dataSource = new MatTableDataSource<AdvertWithCountViews>();
|
||||
this.onFilter();
|
||||
if(retour.data.length !== 0)
|
||||
{
|
||||
for(let advert of retour.data) this.tabAdvertWithCountViews.push(this.advertToAdvertWithCountViews(advert));
|
||||
this.dataSource = new MatTableDataSource<AdvertWithCountViews>();
|
||||
this.onFilter();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
|
||||
<!-- chart -->
|
||||
<div class="chartContainer">
|
||||
<div *ngIf="isDisplayable" class="chartContainer">
|
||||
<canvas baseChart
|
||||
[datasets]="lineChartData"
|
||||
[labels]="lineChartLabels"
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ interface CoupleNameViews {
|
|||
})
|
||||
export class PagesPopularityComponent implements OnInit
|
||||
{
|
||||
formControl: FormControl;
|
||||
formControl: FormControl = new FormControl();
|
||||
allCoupleNameViews: CoupleNameViews[] = [];
|
||||
|
||||
allInterests: string[] = [];
|
||||
|
|
@ -48,6 +48,8 @@ export class PagesPopularityComponent implements OnInit
|
|||
}
|
||||
};
|
||||
|
||||
isDisplayable: boolean = false;
|
||||
|
||||
|
||||
constructor( private router: Router,
|
||||
public themeService: ThemeService,
|
||||
|
|
@ -167,8 +169,8 @@ export class PagesPopularityComponent implements OnInit
|
|||
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
|
||||
if((this.endDate === null) || (this.endDate === undefined)) this.endDate = new Date();
|
||||
if((this.startDate === null) || (this.startDate === undefined)) 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();
|
||||
|
|
@ -211,6 +213,7 @@ export class PagesPopularityComponent implements OnInit
|
|||
|
||||
this.lineChartData.push({"data": data.slice(), "label": label});
|
||||
}
|
||||
this.isDisplayable = true;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -282,9 +285,9 @@ export class PagesPopularityComponent implements OnInit
|
|||
{
|
||||
let i = 0;
|
||||
let n = tabDate.length;
|
||||
let time0 = date0.getTime();
|
||||
let time0 = (new Date(date0)).getTime();
|
||||
|
||||
while((i <n) && (time0 > tabDate[i].getTime())) i++;
|
||||
while((i <n) && (time0 > (new Date(tabDate[i])).getTime())) i++;
|
||||
if(i === n) tabDate.push(date0);
|
||||
else tabDate.splice(i, 0, date0);
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ export class NavbarAdvertiserComponent
|
|||
|
||||
onDeconnexionCallback(retour: any): void
|
||||
{
|
||||
console.log(retour);
|
||||
if(retour.status !== "success") console.log(retour);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import {ThemeService} from "../../../utils/services/theme/theme.service";
|
|||
import {AddVideoToPlaylistsService} from "../../utils/services/addVideoToPlaylists/add-video-to-playlists.service";
|
||||
import {MessageService} from "../../../utils/services/message/message.service";
|
||||
import {MatSnackBar} from "@angular/material/snack-bar";
|
||||
import {UserHistoryService} from "../../utils/services/userHistory/userHistory.service";
|
||||
import {Router} from "@angular/router";
|
||||
import {ProfilService} from "../../../utils/services/profil/profil.service";
|
||||
|
||||
|
|
@ -24,7 +23,6 @@ export class VideoListComponent implements OnChanges
|
|||
public themeService: ThemeService,
|
||||
private addVideoToPlaylistsService: AddVideoToPlaylistsService,
|
||||
private snackBar: MatSnackBar,
|
||||
private historiqueService: UserHistoryService,
|
||||
private profilService: ProfilService,
|
||||
private router: Router ) { }
|
||||
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ export class PageSearchComponent implements OnInit
|
|||
tabPlateform = TAB_PLATEFORM;
|
||||
tabVideo: VideoAll[] = [];
|
||||
search: string = "";
|
||||
ad1: any = { title: "", url: "", images: [] };
|
||||
ad2: any = { title: "", url: "", images: [] };
|
||||
ad1: any;
|
||||
ad2: any;
|
||||
|
||||
|
||||
constructor( private messageService: MessageService,
|
||||
|
|
@ -45,8 +45,11 @@ export class PageSearchComponent implements OnInit
|
|||
|
||||
adCallback(retour: any): void
|
||||
{
|
||||
if(retour !== "success") {
|
||||
console.log(retour);
|
||||
console.log("adCallback retour:");
|
||||
console.log(retour);
|
||||
|
||||
if(retour.status !== "success") {
|
||||
//console.log(retour);
|
||||
}
|
||||
else {
|
||||
this.ad1 = retour.data[0];
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import {Component, Input } from '@angular/core';
|
||||
import {VideoAll} from "../../../utils/interfaces/video";
|
||||
import {UserHistoryService} from "../../utils/services/userHistory/userHistory.service";
|
||||
import {AddVideoToPlaylistsService} from "../../utils/services/addVideoToPlaylists/add-video-to-playlists.service";
|
||||
import {Router} from "@angular/router";
|
||||
import {MessageService} from "../../../utils/services/message/message.service";
|
||||
|
|
@ -19,8 +18,7 @@ export class VideoGridComponent
|
|||
indexPage: number = 0;
|
||||
|
||||
|
||||
constructor( private historiqueService: UserHistoryService,
|
||||
private addVideoToPlaylistsService: AddVideoToPlaylistsService,
|
||||
constructor( private addVideoToPlaylistsService: AddVideoToPlaylistsService,
|
||||
private router: Router,
|
||||
private messageService: MessageService ) {}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,23 +1,26 @@
|
|||
<div *ngIf="from==='search' || from==='myPlaylists'" class="myContainer">
|
||||
<div *ngIf="(from==='search' || from==='myPlaylists') && (imageExist)"
|
||||
class="myContainer">
|
||||
|
||||
<span class="helper"></span>
|
||||
<img [src]="'assets/pub/'+ad.images[idxImage].url"
|
||||
[alt]="ad.title"
|
||||
<img [src]="image.base64"
|
||||
[alt]="image.description"
|
||||
(click)="onClick()"
|
||||
id="imgFromSearchOrMyPlaylists">
|
||||
|
||||
</div>
|
||||
|
||||
<!-- --------------------------------------------------------------------- -->
|
||||
|
||||
<img *ngIf="from === 'watchingLeft'"
|
||||
[src]="'assets/pub/'+ad.images[idxImage].url"
|
||||
[alt]="ad.title"
|
||||
<img *ngIf="from === 'watchingLeft' && (imageExist)"
|
||||
[src]="image.base64"
|
||||
[alt]="image.description"
|
||||
(click)="onClick()"
|
||||
id="imgFromWatchingLeft">
|
||||
|
||||
<!-- --------------------------------------------------------------------- -->
|
||||
|
||||
<img *ngIf="from === 'watchingRight'"
|
||||
[src]="'assets/pub/'+ad.images[idxImage].url"
|
||||
[alt]="ad.title"
|
||||
<img *ngIf="from === 'watchingRight' && (imageExist)"
|
||||
[src]="image.base64"
|
||||
[alt]="image.description"
|
||||
(click)="onClick()"
|
||||
id="imgFromWatchingRight">
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
import {Component, Input, OnInit} from '@angular/core';
|
||||
import {Advert} from "../../../../utils/interfaces/advert";
|
||||
import {Router} from "@angular/router";
|
||||
import {Component, Input, OnChanges, SimpleChanges} from '@angular/core';
|
||||
|
||||
|
||||
|
||||
|
|
@ -9,26 +7,32 @@ import {Router} from "@angular/router";
|
|||
templateUrl: './advert.component.html',
|
||||
styleUrls: ['./advert.component.scss']
|
||||
})
|
||||
export class AdvertComponent implements OnInit
|
||||
export class AdvertComponent implements OnChanges
|
||||
{
|
||||
@Input() ad: any;
|
||||
@Input() from: string = "search";
|
||||
idxImage: number = 0;
|
||||
image: any;
|
||||
imageExist: boolean = false;
|
||||
|
||||
constructor(private router: Router) { }
|
||||
|
||||
ngOnInit(): void
|
||||
constructor() { }
|
||||
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void
|
||||
{
|
||||
const nbImages = this.ad.images.length;
|
||||
if(nbImages === 0) this.ad.images.push({url: "img pub"});
|
||||
this.idxImage = Math.floor(Math.random() * nbImages);
|
||||
|
||||
if(this.ad.title === "") this.ad.title = "--- pub ---" ;
|
||||
if((this.ad !== null) && (this.ad !== undefined))
|
||||
{
|
||||
const nbImages = this.ad.images.length;
|
||||
const indexImage = Math.floor(Math.random() * nbImages);
|
||||
this.image = this.ad.images[indexImage];
|
||||
this.imageExist = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
onClick(): void
|
||||
{
|
||||
document.location.href = this.ad.url;
|
||||
if(this.ad.url !== "") document.location.href = this.ad.url;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ export class NavbarUserComponent
|
|||
|
||||
onDeconnexionCallback(retour: any): void
|
||||
{
|
||||
console.log(retour);
|
||||
if(retour.status !== "success") console.log(retour);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +0,0 @@
|
|||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { UserHistoryService } from './userHistory.service';
|
||||
|
||||
describe('HistoriqueService', () => {
|
||||
let service: UserHistoryService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(UserHistoryService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import {VideoDB} from "../../../../utils/interfaces/video";
|
||||
import {MessageService} from "../../../../utils/services/message/message.service";
|
||||
|
||||
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class UserHistoryService
|
||||
{
|
||||
private tabVideoUrlClicked: string[] = [];
|
||||
|
||||
|
||||
constructor(private messageService: MessageService) { }
|
||||
|
||||
|
||||
public addVideoToHistoque(video: VideoDB): void
|
||||
{
|
||||
if (!this.tabVideoUrlClicked.includes(video.videoId))
|
||||
{
|
||||
this.tabVideoUrlClicked.push(video.videoId);
|
||||
video.watchedDates.push(new Date());
|
||||
|
||||
// --- VRAI CODE ---
|
||||
/*
|
||||
this.messageService
|
||||
.sendMessage("user/add/watchedVideo", {watchedVideo: watchedVideo0})
|
||||
.subscribe(retour => {});
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public clearTabVideoUrlClicked()
|
||||
{
|
||||
this.tabVideoUrlClicked = [];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -38,8 +38,8 @@ export class PageWatchingVideoComponent implements OnInit
|
|||
interest: ""
|
||||
};
|
||||
search: string = "";
|
||||
ad1: any = { title: "", url: "", images: [] };
|
||||
ad2: any = { title: "", url: "", images: [] };
|
||||
ad1: any;
|
||||
ad2: any;
|
||||
from: string = "";
|
||||
|
||||
playlist: PlaylistDB;
|
||||
|
|
|
|||
Reference in a new issue