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
|
|
@ -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 = [];
|
||||
}
|
||||
|
||||
}
|
||||
Reference in a new issue