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
|
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);
|
console.log(retour);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for(let advert of retour.data) this.tabAdvertWithCountViews.push(this.advertToAdvertWithCountViews(advert));
|
if(retour.data.length !== 0)
|
||||||
this.dataSource = new MatTableDataSource<AdvertWithCountViews>();
|
{
|
||||||
this.onFilter();
|
for(let advert of retour.data) this.tabAdvertWithCountViews.push(this.advertToAdvertWithCountViews(advert));
|
||||||
|
this.dataSource = new MatTableDataSource<AdvertWithCountViews>();
|
||||||
|
this.onFilter();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
|
|
||||||
<!-- chart -->
|
<!-- chart -->
|
||||||
<div class="chartContainer">
|
<div *ngIf="isDisplayable" class="chartContainer">
|
||||||
<canvas baseChart
|
<canvas baseChart
|
||||||
[datasets]="lineChartData"
|
[datasets]="lineChartData"
|
||||||
[labels]="lineChartLabels"
|
[labels]="lineChartLabels"
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ interface CoupleNameViews {
|
||||||
})
|
})
|
||||||
export class PagesPopularityComponent implements OnInit
|
export class PagesPopularityComponent implements OnInit
|
||||||
{
|
{
|
||||||
formControl: FormControl;
|
formControl: FormControl = new FormControl();
|
||||||
allCoupleNameViews: CoupleNameViews[] = [];
|
allCoupleNameViews: CoupleNameViews[] = [];
|
||||||
|
|
||||||
allInterests: string[] = [];
|
allInterests: string[] = [];
|
||||||
|
|
@ -48,6 +48,8 @@ export class PagesPopularityComponent implements OnInit
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
isDisplayable: boolean = false;
|
||||||
|
|
||||||
|
|
||||||
constructor( private router: Router,
|
constructor( private router: Router,
|
||||||
public themeService: ThemeService,
|
public themeService: ThemeService,
|
||||||
|
|
@ -167,8 +169,8 @@ export class PagesPopularityComponent implements OnInit
|
||||||
this.lineChartLabels = [];
|
this.lineChartLabels = [];
|
||||||
|
|
||||||
if(this.step <= 0) this.step = 0;
|
if(this.step <= 0) this.step = 0;
|
||||||
if(this.endDate === null) this.endDate = new Date();
|
if((this.endDate === null) || (this.endDate === undefined)) 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.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 startTime = this.startDate.getTime();
|
||||||
const endTime = this.endDate.getTime();
|
const endTime = this.endDate.getTime();
|
||||||
|
|
@ -211,6 +213,7 @@ export class PagesPopularityComponent implements OnInit
|
||||||
|
|
||||||
this.lineChartData.push({"data": data.slice(), "label": label});
|
this.lineChartData.push({"data": data.slice(), "label": label});
|
||||||
}
|
}
|
||||||
|
this.isDisplayable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -282,9 +285,9 @@ export class PagesPopularityComponent implements OnInit
|
||||||
{
|
{
|
||||||
let i = 0;
|
let i = 0;
|
||||||
let n = tabDate.length;
|
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);
|
if(i === n) tabDate.push(date0);
|
||||||
else tabDate.splice(i, 0, date0);
|
else tabDate.splice(i, 0, date0);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ export class NavbarAdvertiserComponent
|
||||||
|
|
||||||
onDeconnexionCallback(retour: any): void
|
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 {AddVideoToPlaylistsService} from "../../utils/services/addVideoToPlaylists/add-video-to-playlists.service";
|
||||||
import {MessageService} from "../../../utils/services/message/message.service";
|
import {MessageService} from "../../../utils/services/message/message.service";
|
||||||
import {MatSnackBar} from "@angular/material/snack-bar";
|
import {MatSnackBar} from "@angular/material/snack-bar";
|
||||||
import {UserHistoryService} from "../../utils/services/userHistory/userHistory.service";
|
|
||||||
import {Router} from "@angular/router";
|
import {Router} from "@angular/router";
|
||||||
import {ProfilService} from "../../../utils/services/profil/profil.service";
|
import {ProfilService} from "../../../utils/services/profil/profil.service";
|
||||||
|
|
||||||
|
|
@ -24,7 +23,6 @@ export class VideoListComponent implements OnChanges
|
||||||
public themeService: ThemeService,
|
public themeService: ThemeService,
|
||||||
private addVideoToPlaylistsService: AddVideoToPlaylistsService,
|
private addVideoToPlaylistsService: AddVideoToPlaylistsService,
|
||||||
private snackBar: MatSnackBar,
|
private snackBar: MatSnackBar,
|
||||||
private historiqueService: UserHistoryService,
|
|
||||||
private profilService: ProfilService,
|
private profilService: ProfilService,
|
||||||
private router: Router ) { }
|
private router: Router ) { }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,8 @@ export class PageSearchComponent implements OnInit
|
||||||
tabPlateform = TAB_PLATEFORM;
|
tabPlateform = TAB_PLATEFORM;
|
||||||
tabVideo: VideoAll[] = [];
|
tabVideo: VideoAll[] = [];
|
||||||
search: string = "";
|
search: string = "";
|
||||||
ad1: any = { title: "", url: "", images: [] };
|
ad1: any;
|
||||||
ad2: any = { title: "", url: "", images: [] };
|
ad2: any;
|
||||||
|
|
||||||
|
|
||||||
constructor( private messageService: MessageService,
|
constructor( private messageService: MessageService,
|
||||||
|
|
@ -45,8 +45,11 @@ export class PageSearchComponent implements OnInit
|
||||||
|
|
||||||
adCallback(retour: any): void
|
adCallback(retour: any): void
|
||||||
{
|
{
|
||||||
if(retour !== "success") {
|
console.log("adCallback retour:");
|
||||||
console.log(retour);
|
console.log(retour);
|
||||||
|
|
||||||
|
if(retour.status !== "success") {
|
||||||
|
//console.log(retour);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.ad1 = retour.data[0];
|
this.ad1 = retour.data[0];
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
import {Component, Input } from '@angular/core';
|
import {Component, Input } from '@angular/core';
|
||||||
import {VideoAll} from "../../../utils/interfaces/video";
|
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 {AddVideoToPlaylistsService} from "../../utils/services/addVideoToPlaylists/add-video-to-playlists.service";
|
||||||
import {Router} from "@angular/router";
|
import {Router} from "@angular/router";
|
||||||
import {MessageService} from "../../../utils/services/message/message.service";
|
import {MessageService} from "../../../utils/services/message/message.service";
|
||||||
|
|
@ -19,8 +18,7 @@ export class VideoGridComponent
|
||||||
indexPage: number = 0;
|
indexPage: number = 0;
|
||||||
|
|
||||||
|
|
||||||
constructor( private historiqueService: UserHistoryService,
|
constructor( private addVideoToPlaylistsService: AddVideoToPlaylistsService,
|
||||||
private addVideoToPlaylistsService: AddVideoToPlaylistsService,
|
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private messageService: MessageService ) {}
|
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>
|
<span class="helper"></span>
|
||||||
<img [src]="'assets/pub/'+ad.images[idxImage].url"
|
<img [src]="image.base64"
|
||||||
[alt]="ad.title"
|
[alt]="image.description"
|
||||||
(click)="onClick()"
|
(click)="onClick()"
|
||||||
id="imgFromSearchOrMyPlaylists">
|
id="imgFromSearchOrMyPlaylists">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- --------------------------------------------------------------------- -->
|
<!-- --------------------------------------------------------------------- -->
|
||||||
|
|
||||||
<img *ngIf="from === 'watchingLeft'"
|
<img *ngIf="from === 'watchingLeft' && (imageExist)"
|
||||||
[src]="'assets/pub/'+ad.images[idxImage].url"
|
[src]="image.base64"
|
||||||
[alt]="ad.title"
|
[alt]="image.description"
|
||||||
(click)="onClick()"
|
(click)="onClick()"
|
||||||
id="imgFromWatchingLeft">
|
id="imgFromWatchingLeft">
|
||||||
|
|
||||||
<!-- --------------------------------------------------------------------- -->
|
<!-- --------------------------------------------------------------------- -->
|
||||||
|
|
||||||
<img *ngIf="from === 'watchingRight'"
|
<img *ngIf="from === 'watchingRight' && (imageExist)"
|
||||||
[src]="'assets/pub/'+ad.images[idxImage].url"
|
[src]="image.base64"
|
||||||
[alt]="ad.title"
|
[alt]="image.description"
|
||||||
(click)="onClick()"
|
(click)="onClick()"
|
||||||
id="imgFromWatchingRight">
|
id="imgFromWatchingRight">
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
import {Component, Input, OnInit} from '@angular/core';
|
import {Component, Input, OnChanges, SimpleChanges} from '@angular/core';
|
||||||
import {Advert} from "../../../../utils/interfaces/advert";
|
|
||||||
import {Router} from "@angular/router";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -9,26 +7,32 @@ import {Router} from "@angular/router";
|
||||||
templateUrl: './advert.component.html',
|
templateUrl: './advert.component.html',
|
||||||
styleUrls: ['./advert.component.scss']
|
styleUrls: ['./advert.component.scss']
|
||||||
})
|
})
|
||||||
export class AdvertComponent implements OnInit
|
export class AdvertComponent implements OnChanges
|
||||||
{
|
{
|
||||||
@Input() ad: any;
|
@Input() ad: any;
|
||||||
@Input() from: string = "search";
|
@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((this.ad !== null) && (this.ad !== undefined))
|
||||||
if(nbImages === 0) this.ad.images.push({url: "img pub"});
|
{
|
||||||
this.idxImage = Math.floor(Math.random() * nbImages);
|
const nbImages = this.ad.images.length;
|
||||||
|
const indexImage = Math.floor(Math.random() * nbImages);
|
||||||
if(this.ad.title === "") this.ad.title = "--- pub ---" ;
|
this.image = this.ad.images[indexImage];
|
||||||
|
this.imageExist = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
onClick(): void
|
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
|
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: ""
|
interest: ""
|
||||||
};
|
};
|
||||||
search: string = "";
|
search: string = "";
|
||||||
ad1: any = { title: "", url: "", images: [] };
|
ad1: any;
|
||||||
ad2: any = { title: "", url: "", images: [] };
|
ad2: any;
|
||||||
from: string = "";
|
from: string = "";
|
||||||
|
|
||||||
playlist: PlaylistDB;
|
playlist: PlaylistDB;
|
||||||
|
|
|
||||||
Reference in a new issue