connexion avec le back pour 'page search' et 'page watching'
This commit is contained in:
parent
d53bc27b7c
commit
5e62d2e4ef
10 changed files with 290 additions and 76 deletions
|
|
@ -62,7 +62,7 @@ export class PageLoginComponent implements OnInit
|
||||||
this.profilService.profileImageUrl = retour.data.profileImageUrl;
|
this.profilService.profileImageUrl = retour.data.profileImageUrl;
|
||||||
if(retour.data.role.name === "user") this.router.navigateByUrl( '/user/search');
|
if(retour.data.role.name === "user") this.router.navigateByUrl( '/user/search');
|
||||||
else if(retour.data.role.name === "advertiser") this.router.navigateByUrl( '/advertiser/adList');
|
else if(retour.data.role.name === "advertiser") this.router.navigateByUrl( '/advertiser/adList');
|
||||||
else if(retour.data.role.name === "admin") this.router.navigateByUrl( '/admin/userList');
|
else if(retour.data.role.name === "admin" || retour.data.role.name === "superAdmin") this.router.navigateByUrl( '/admin/userList');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ export class VideoListComponent implements OnChanges
|
||||||
|
|
||||||
onAdd(video: VideoAll): void
|
onAdd(video: VideoAll): void
|
||||||
{
|
{
|
||||||
this.addVideoToPlaylistService.run(video);
|
//this.addVideoToPlaylistService.run(video);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,7 @@
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import {MessageService} from "../../../utils/services/message/message.service";
|
import {MessageService} from "../../../utils/services/message/message.service";
|
||||||
import {VideoAll} from "../../../utils/interfaces/video";
|
import {VideoAll} from "../../../utils/interfaces/video";
|
||||||
import {Advert} from "../../../utils/interfaces/advert";
|
|
||||||
import {ThemeService} from "../../../utils/services/theme/theme.service";
|
import {ThemeService} from "../../../utils/services/theme/theme.service";
|
||||||
import {FictitiousVideosService} from "../../../utils/services/fictitiousDatas/fictitiousVideos/fictitious-videos.service";
|
|
||||||
import {FictitiousAdvertsService} from "../../../utils/services/fictitiousDatas/fictitiousAdverts/fictitious-adverts.service";
|
|
||||||
import {HttpParams} from "@angular/common/http";
|
import {HttpParams} from "@angular/common/http";
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -26,26 +23,37 @@ export class PageSearchComponent implements OnInit
|
||||||
tabPlateform = TAB_PLATEFORM;
|
tabPlateform = TAB_PLATEFORM;
|
||||||
tabVideo: VideoAll[] = [];
|
tabVideo: VideoAll[] = [];
|
||||||
search: string = "";
|
search: string = "";
|
||||||
ad1: Advert;
|
ad1: any = { title: "", url: "", images: [] };
|
||||||
ad2: Advert;
|
ad2: any = { title: "", url: "", images: [] };
|
||||||
|
|
||||||
|
|
||||||
constructor( private messageService: MessageService,
|
constructor( private messageService: MessageService,
|
||||||
private fictitiousVideosService: FictitiousVideosService,
|
|
||||||
private fictitiousAdvertsService: FictitiousAdvertsService,
|
|
||||||
public themeService: ThemeService ) { }
|
public themeService: ThemeService ) { }
|
||||||
|
|
||||||
|
|
||||||
ngOnInit(): void
|
ngOnInit(): void
|
||||||
{
|
{
|
||||||
// --- FAUX CODE ---
|
let params = new HttpParams();
|
||||||
//this.tabVideo = this.fictitiousVideosService.getTabVideoAll(90);
|
params = params.append("quantity", 2);
|
||||||
this.ad1 = this.fictitiousAdvertsService.getAdvert();
|
this.messageService
|
||||||
this.ad2 = this.fictitiousAdvertsService.getAdvert();
|
.get("user/ad", params)
|
||||||
|
.subscribe(ret => this.adCallback(ret), err => this.adCallback(err));
|
||||||
|
|
||||||
this.onSearch();
|
this.onSearch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
adCallback(retour: any): void
|
||||||
|
{
|
||||||
|
if(retour !== "success") {
|
||||||
|
console.log(retour);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.ad1 = retour.data[0];
|
||||||
|
this.ad2 = retour.data[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
onSearch()
|
onSearch()
|
||||||
{
|
{
|
||||||
|
|
@ -68,11 +76,8 @@ export class PageSearchComponent implements OnInit
|
||||||
|
|
||||||
onSearchCallback(retour: any): void
|
onSearchCallback(retour: any): void
|
||||||
{
|
{
|
||||||
console.log("ngOnInitCallback:");
|
|
||||||
console.log(retour);
|
|
||||||
|
|
||||||
if(retour.status !== "success") {
|
if(retour.status !== "success") {
|
||||||
//console.log(retour);
|
console.log(retour);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.tabVideo = retour.data;
|
this.tabVideo = retour.data;
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ export class VideoGridComponent implements OnChanges
|
||||||
|
|
||||||
onAdd(video: VideoAll): void
|
onAdd(video: VideoAll): void
|
||||||
{
|
{
|
||||||
this.addVideoToPlaylistsService.run(video);
|
this.addVideoToPlaylistsService.run(video.videoId, video.source);
|
||||||
}
|
}
|
||||||
|
|
||||||
tronquage(str: string)
|
tronquage(str: string)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<div *ngIf="from==='search' || from==='myPlaylists'" class="myContainer">
|
<div *ngIf="from==='search' || from==='myPlaylists'" class="myContainer">
|
||||||
<span class="helper"></span>
|
<span class="helper"></span>
|
||||||
<img [src]="'assets/pub/'+ad.images[idxImage].url"
|
<img [src]="'assets/pub/'+ad.images[idxImage].url"
|
||||||
[alt]="ad.images[idxImage].url"
|
[alt]="ad.title"
|
||||||
(click)="onClick()"
|
(click)="onClick()"
|
||||||
id="imgFromSearchOrMyPlaylists">
|
id="imgFromSearchOrMyPlaylists">
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
<img *ngIf="from === 'watchingLeft'"
|
<img *ngIf="from === 'watchingLeft'"
|
||||||
[src]="'assets/pub/'+ad.images[idxImage].url"
|
[src]="'assets/pub/'+ad.images[idxImage].url"
|
||||||
[alt]="ad.images[idxImage].url"
|
[alt]="ad.title"
|
||||||
(click)="onClick()"
|
(click)="onClick()"
|
||||||
id="imgFromWatchingLeft">
|
id="imgFromWatchingLeft">
|
||||||
|
|
||||||
|
|
@ -18,6 +18,6 @@
|
||||||
|
|
||||||
<img *ngIf="from === 'watchingRight'"
|
<img *ngIf="from === 'watchingRight'"
|
||||||
[src]="'assets/pub/'+ad.images[idxImage].url"
|
[src]="'assets/pub/'+ad.images[idxImage].url"
|
||||||
[alt]="ad.images[idxImage].url"
|
[alt]="ad.title"
|
||||||
(click)="onClick()"
|
(click)="onClick()"
|
||||||
id="imgFromWatchingRight">
|
id="imgFromWatchingRight">
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import {Router} from "@angular/router";
|
||||||
})
|
})
|
||||||
export class AdvertComponent implements OnInit
|
export class AdvertComponent implements OnInit
|
||||||
{
|
{
|
||||||
@Input() ad: Advert;
|
@Input() ad: any;
|
||||||
@Input() from: string = "search";
|
@Input() from: string = "search";
|
||||||
idxImage: number = 0;
|
idxImage: number = 0;
|
||||||
|
|
||||||
|
|
@ -20,7 +20,10 @@ export class AdvertComponent implements OnInit
|
||||||
ngOnInit(): void
|
ngOnInit(): void
|
||||||
{
|
{
|
||||||
const nbImages = this.ad.images.length;
|
const nbImages = this.ad.images.length;
|
||||||
|
if(nbImages === 0) this.ad.images.push({url: "img pub"});
|
||||||
this.idxImage = Math.floor(Math.random() * nbImages);
|
this.idxImage = Math.floor(Math.random() * nbImages);
|
||||||
|
|
||||||
|
if(this.ad.title === "") this.ad.title = "--- pub ---" ;
|
||||||
}
|
}
|
||||||
|
|
||||||
onClick(): void
|
onClick(): void
|
||||||
|
|
|
||||||
|
|
@ -12,11 +12,20 @@ import {MessageService} from "../../../../utils/services/message/message.service
|
||||||
})
|
})
|
||||||
export class PopupAddVideoToPlaylistsComponent implements OnInit
|
export class PopupAddVideoToPlaylistsComponent implements OnInit
|
||||||
{
|
{
|
||||||
video: VideoDB;
|
_idVideo: string = "";
|
||||||
|
videoId: string = "";
|
||||||
|
source: string = "";
|
||||||
|
interest: string = "";
|
||||||
|
|
||||||
tabPlaylistAndBool = [];
|
tabPlaylistAndBool = [];
|
||||||
|
|
||||||
goToCreatePlaylist = false;
|
goToCreatePlaylist = false;
|
||||||
newPlaylistName = "";
|
newPlaylistName = "";
|
||||||
|
|
||||||
|
isFinishedForExistingPlaylist: boolean = false;
|
||||||
|
isFinishedForNewPlaylist: boolean = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
constructor( public dialogRef: MatDialogRef<PopupAddVideoToPlaylistsComponent>,
|
constructor( public dialogRef: MatDialogRef<PopupAddVideoToPlaylistsComponent>,
|
||||||
@Inject(MAT_DIALOG_DATA) public data,
|
@Inject(MAT_DIALOG_DATA) public data,
|
||||||
|
|
@ -25,7 +34,18 @@ export class PopupAddVideoToPlaylistsComponent implements OnInit
|
||||||
|
|
||||||
ngOnInit(): void
|
ngOnInit(): void
|
||||||
{
|
{
|
||||||
this.video = this.data.video;
|
this._idVideo = this.data._idVideo;
|
||||||
|
this.videoId = this.data.videoId;
|
||||||
|
this.source = this.data.source;
|
||||||
|
this.interest = this.data.interest;
|
||||||
|
|
||||||
|
console.log("---");
|
||||||
|
console.log(this.data._idVideo);
|
||||||
|
console.log(this.data.videoId);
|
||||||
|
console.log(this.data.source);
|
||||||
|
console.log(this.data.interest);
|
||||||
|
console.log("---");
|
||||||
|
|
||||||
for(let playlist of this.data.playlists)
|
for(let playlist of this.data.playlists)
|
||||||
{
|
{
|
||||||
playlist["isSelected"] = false;
|
playlist["isSelected"] = false;
|
||||||
|
|
@ -34,34 +54,125 @@ export class PopupAddVideoToPlaylistsComponent implements OnInit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
onValider(): void
|
onValider(): void
|
||||||
{
|
{
|
||||||
const tabPlaylist = [];
|
// --- Existing playlists ---
|
||||||
for(let playlist of this.tabPlaylistAndBool)
|
|
||||||
{
|
|
||||||
if(playlist.isSelected) {
|
|
||||||
delete playlist["isSelected"];
|
|
||||||
tabPlaylist.push(playlist);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- FAUX CODE ---
|
let listeDesPlaylists = "" ;
|
||||||
this.dialogRef.close("success");
|
for(let playlist of this.tabPlaylistAndBool) listeDesPlaylists += playlist.id + ","
|
||||||
|
if(listeDesPlaylists.endsWith(",")) listeDesPlaylists = listeDesPlaylists.slice(0, listeDesPlaylists.length-1);
|
||||||
|
|
||||||
// --- VRAI CODE ---
|
console.log(listeDesPlaylists);
|
||||||
/*
|
const data1 = { videoId: this._idVideo }
|
||||||
if(!this.goToCreatePlaylist) this.newPlaylistName = "";
|
|
||||||
const data = { "video": this.video, "playlists": tabPlaylist, "newPlaylistName": this.newPlaylistName };
|
|
||||||
this.messageService
|
this.messageService
|
||||||
.sendMessage("user/add/vidéo", data)
|
.put( "playlist/update/"+ listeDesPlaylists, data1)
|
||||||
.subscribe( retour => { this.dialogRef.close(retour.status) });
|
.subscribe( ret => this.callbackForExistingPlaylists(ret), err => this.callbackForExistingPlaylists(err));
|
||||||
*/
|
|
||||||
|
|
||||||
|
// --- New playlists ---
|
||||||
|
|
||||||
|
if(this.goToCreatePlaylist)
|
||||||
|
{
|
||||||
|
const data2 = {
|
||||||
|
name: this.newPlaylistName,
|
||||||
|
video: {videoId: this.videoId, interest: this.interest, source: this.source}
|
||||||
|
};
|
||||||
|
this.messageService
|
||||||
|
.post("playlist/create", data2)
|
||||||
|
.subscribe( ret => this.callbackForNewPlaylist(ret), err => this.callbackForNewPlaylist(err));
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
this.isFinishedForNewPlaylist = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Attente active
|
||||||
|
while((!this.isFinishedForExistingPlaylist) || (!this.isFinishedForNewPlaylist)) {}
|
||||||
|
this.dialogRef.close("success");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
callbackForExistingPlaylists(retour: any): void
|
||||||
|
{
|
||||||
|
console.log("onValiderCallback");
|
||||||
|
//console.log(retour);
|
||||||
|
|
||||||
|
if(retour.status !== "success") {
|
||||||
|
console.log(retour);
|
||||||
|
this.dialogRef.close(null);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.isFinishedForExistingPlaylist = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
callbackForNewPlaylist(retour: any): void
|
||||||
|
{
|
||||||
|
console.log("callbackForNewPlaylist");
|
||||||
|
|
||||||
|
if(retour.status !== "success") {
|
||||||
|
//console.log(retour);
|
||||||
|
this.dialogRef.close(null);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.isFinishedForNewPlaylist = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
onAnnuler(): void
|
onAnnuler(): void
|
||||||
{
|
{
|
||||||
this.dialogRef.close("annulation")
|
this.dialogRef.close("annulation");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
//nbPlaylistSelected: number = 0;
|
||||||
|
//numPlaylistSelected: number = 0;
|
||||||
|
|
||||||
|
onValider(): void
|
||||||
|
{
|
||||||
|
for(let playlist of this.tabPlaylistAndBool)
|
||||||
|
{
|
||||||
|
if(playlist.isSelected) this.nbPlaylistSelected += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(let playlist of this.tabPlaylistAndBool)
|
||||||
|
{
|
||||||
|
if(playlist.isSelected)
|
||||||
|
{
|
||||||
|
playlist.videoIds.push(this._idVideo);
|
||||||
|
this.messageService
|
||||||
|
.put("playlist/update/"+playlist._id, playlist.videoIds)
|
||||||
|
.subscribe(ret => this.onAddingToExistingPlaylist(ret), err => this.onAddingToExistingPlaylist(err));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onAddingToExistingPlaylist(retour: any): void
|
||||||
|
{
|
||||||
|
console.log("onValiderCallback");
|
||||||
|
console.log(retour);
|
||||||
|
this.numPlaylistSelected += 1;
|
||||||
|
|
||||||
|
if(retour.status !== "success") {
|
||||||
|
this.dialogRef.close("annulation");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(this.numPlaylistSelected === this.numPlaylistSelected)
|
||||||
|
{
|
||||||
|
this.dialogRef.close("success");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,9 @@ import { Injectable } from '@angular/core';
|
||||||
import {MessageService} from "../../../../utils/services/message/message.service";
|
import {MessageService} from "../../../../utils/services/message/message.service";
|
||||||
import {MatDialog} from "@angular/material/dialog";
|
import {MatDialog} from "@angular/material/dialog";
|
||||||
import {PopupAddVideoToPlaylistsComponent} from "../../components/popup-add-video-to-playlists/popup-add-video-to-playlists.component";
|
import {PopupAddVideoToPlaylistsComponent} from "../../components/popup-add-video-to-playlists/popup-add-video-to-playlists.component";
|
||||||
import {VideoAll, VideoDB} from "../../../../utils/interfaces/video";
|
|
||||||
import {MatSnackBar} from "@angular/material/snack-bar";
|
import {MatSnackBar} from "@angular/material/snack-bar";
|
||||||
import {FictitiousVideosService} from "../../../../utils/services/fictitiousDatas/fictitiousVideos/fictitious-videos.service";
|
import {FictitiousVideosService} from "../../../../utils/services/fictitiousDatas/fictitiousVideos/fictitious-videos.service";
|
||||||
|
import {HttpParams} from "@angular/common/http";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -13,7 +13,11 @@ import {FictitiousVideosService} from "../../../../utils/services/fictitiousData
|
||||||
})
|
})
|
||||||
export class AddVideoToPlaylistsService
|
export class AddVideoToPlaylistsService
|
||||||
{
|
{
|
||||||
private _video: VideoDB | VideoAll;
|
private _idVideo: string = "" ;
|
||||||
|
private videoId: string = "" ;
|
||||||
|
private source: string = "" ;
|
||||||
|
private interest: string = "" ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
constructor( private messageService: MessageService,
|
constructor( private messageService: MessageService,
|
||||||
|
|
@ -22,47 +26,89 @@ export class AddVideoToPlaylistsService
|
||||||
private snackBar: MatSnackBar ) { }
|
private snackBar: MatSnackBar ) { }
|
||||||
|
|
||||||
|
|
||||||
// --- FAUX CODE ---
|
|
||||||
run(video0: VideoDB | VideoAll): void
|
|
||||||
{
|
|
||||||
this._video = video0;
|
|
||||||
const retour = {
|
|
||||||
status: "success",
|
|
||||||
data: this.fictitiousVideosService.getRandomTabPlaylistDB(4, 5),
|
|
||||||
}
|
|
||||||
this.afterReceivingPlaylists(retour)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// --- VRAI CODE ---
|
run(videoId: string, source: string): void
|
||||||
/*
|
|
||||||
run(video0: VideoDB): void
|
|
||||||
{
|
{
|
||||||
this._video = video0;
|
this.videoId = videoId;
|
||||||
|
this.source = source;
|
||||||
|
|
||||||
|
let params = new HttpParams();
|
||||||
|
if(source === "Youtube") params = params.append("source", "yt");
|
||||||
|
else params = params.append("source", "dm");
|
||||||
this.messageService
|
this.messageService
|
||||||
.sendMessage('user/get/playlists', null)
|
.get("video/get/"+videoId, params)
|
||||||
.subscribe( retour => { this.afterReceivingPlaylists(retour) });
|
.subscribe(ret => this.afterAskingVideoInfo(ret), err => this.afterAskingVideoInfo(err));
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
private afterReceivingPlaylists(retour): void
|
|
||||||
|
afterAskingVideoInfo(retour: any): void
|
||||||
{
|
{
|
||||||
if(retour.status === "error") console.log(retour.data);
|
console.log("afterAskingVideoInfo");
|
||||||
|
console.log(retour);
|
||||||
|
|
||||||
|
if(retour.status !== "success") {
|
||||||
|
//console.log(retour);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.interest = retour.data.interest;
|
||||||
|
const data = { source: this.source, interest: this.interest };
|
||||||
|
this.messageService
|
||||||
|
.post("video/create/"+this.videoId, data)
|
||||||
|
.subscribe(ret => this.afterCreatingVideo(ret), err => this.afterCreatingVideo(err));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private afterCreatingVideo(retour: any): void
|
||||||
|
{
|
||||||
|
console.log("afterCreatingVideo");
|
||||||
|
console.log(retour);
|
||||||
|
|
||||||
|
if(retour.status !== "success") {
|
||||||
|
//console.log(retour);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this._idVideo = retour.data.id;
|
||||||
|
this.messageService
|
||||||
|
.get('playlist/findAll')
|
||||||
|
.subscribe( ret => this.afterReceivingPlaylists(ret), ret => this.afterReceivingPlaylists(ret) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private afterReceivingPlaylists(retour: any): void
|
||||||
|
{
|
||||||
|
console.log("afterReceivingPlaylists");
|
||||||
|
console.log(retour);
|
||||||
|
|
||||||
|
if(retour.status !== "success") {
|
||||||
|
//console.log(retour);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const config = {
|
const config = {
|
||||||
width: '30%',
|
width: '30%',
|
||||||
data: { video: this._video, playlists: retour.data }
|
data: {
|
||||||
|
_idVideo: this._idVideo,
|
||||||
|
videoId: this.videoId,
|
||||||
|
source: this.source,
|
||||||
|
interest: this.interest,
|
||||||
|
playlists: retour.data.filter(x => x.isActive === true)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
this.dialog
|
this.dialog
|
||||||
.open(PopupAddVideoToPlaylistsComponent, config )
|
.open(PopupAddVideoToPlaylistsComponent, config)
|
||||||
.afterClosed()
|
.afterClosed()
|
||||||
.subscribe(retour => { this.afterClosingDialog(retour); });
|
.subscribe(retour => this.afterClosingDialog(retour));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private afterClosingDialog(retour): void
|
private afterClosingDialog(retour): void
|
||||||
{
|
{
|
||||||
let message = "" ;
|
let message = "" ;
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@
|
||||||
|
|
||||||
<mat-checkbox id="youtube" name="youtube" style="margin-left: 5px" [(ngModel)]="tabPlateform[0].isSelected"></mat-checkbox>
|
<mat-checkbox id="youtube" name="youtube" style="margin-left: 5px" [(ngModel)]="tabPlateform[0].isSelected"></mat-checkbox>
|
||||||
<img src="/assets/logo_plateforms/youtube.png" alt="logo" width="30px" height="25px" style="margin-left: 5px">
|
<img src="/assets/logo_plateforms/youtube.png" alt="logo" width="30px" height="25px" style="margin-left: 5px">
|
||||||
<label for="youtube" style="margin-left: 5px">youtube</label>
|
<label for="youtube" style="margin-left: 5px">Youtube</label>
|
||||||
|
|
||||||
</span>
|
</span>
|
||||||
<!-- dailymotion -->
|
<!-- dailymotion -->
|
||||||
|
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
<mat-checkbox id="dailymotion" name="dailymotion" style="margin-left: 5px" [(ngModel)]="tabPlateform[1].isSelected"></mat-checkbox>
|
<mat-checkbox id="dailymotion" name="dailymotion" style="margin-left: 5px" [(ngModel)]="tabPlateform[1].isSelected"></mat-checkbox>
|
||||||
<img src="/assets/logo_plateforms/dailymotion.png" alt="logo" width="25px" height="25px" style="margin-left: 5px">
|
<img src="/assets/logo_plateforms/dailymotion.png" alt="logo" width="25px" height="25px" style="margin-left: 5px">
|
||||||
<label for="dailymotion" style="margin-left: 5px">dailymotion</label>
|
<label for="dailymotion" style="margin-left: 5px">Dailymotion</label>
|
||||||
|
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import {ActivatedRoute, Router} from "@angular/router";
|
||||||
import {AddVideoToPlaylistsService} from "../../utils/services/addVideoToPlaylists/add-video-to-playlists.service";
|
import {AddVideoToPlaylistsService} from "../../utils/services/addVideoToPlaylists/add-video-to-playlists.service";
|
||||||
import {PlaylistDB} from "../../../utils/interfaces/playlist";
|
import {PlaylistDB} from "../../../utils/interfaces/playlist";
|
||||||
import {DomSanitizer, SafeResourceUrl} from "@angular/platform-browser";
|
import {DomSanitizer, SafeResourceUrl} from "@angular/platform-browser";
|
||||||
|
import {HttpParams} from "@angular/common/http";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -27,10 +28,16 @@ let TAB_PLATEFORM = [
|
||||||
export class PageWatchingVideoComponent implements OnInit
|
export class PageWatchingVideoComponent implements OnInit
|
||||||
{
|
{
|
||||||
tabPlateform = TAB_PLATEFORM;
|
tabPlateform = TAB_PLATEFORM;
|
||||||
video: VideoAll;
|
video = {
|
||||||
|
title: "zzz",
|
||||||
|
views: 0,
|
||||||
|
publishedAt: null,
|
||||||
|
description: "",
|
||||||
|
source: ""
|
||||||
|
};
|
||||||
search: string = "";
|
search: string = "";
|
||||||
ad1: Advert;
|
ad1: any = { title: "", url: "", images: [] };
|
||||||
ad2: Advert;
|
ad2: any = { title: "", url: "", images: [] };
|
||||||
from: string = "";
|
from: string = "";
|
||||||
|
|
||||||
playlist: PlaylistDB;
|
playlist: PlaylistDB;
|
||||||
|
|
@ -54,10 +61,29 @@ export class PageWatchingVideoComponent implements OnInit
|
||||||
ngOnInit(): void
|
ngOnInit(): void
|
||||||
{
|
{
|
||||||
// --- FAUX CODE ---
|
// --- FAUX CODE ---
|
||||||
|
//const videoId = this.activatedRoute.snapshot.paramMap.get('videoId');
|
||||||
|
//this.video = this.fictitiousVideosService.getVideoByVideoId(videoId);
|
||||||
|
//this.ad1 = this.fictitiousAdvertsService.getAdvert();
|
||||||
|
//this.ad2 = this.fictitiousAdvertsService.getAdvert();
|
||||||
|
|
||||||
|
// findVideoCallback
|
||||||
const videoId = this.activatedRoute.snapshot.paramMap.get('videoId');
|
const videoId = this.activatedRoute.snapshot.paramMap.get('videoId');
|
||||||
this.video = this.fictitiousVideosService.getVideoByVideoId(videoId);
|
let params1 = new HttpParams();
|
||||||
this.ad1 = this.fictitiousAdvertsService.getAdvert();
|
let source = "" ;
|
||||||
this.ad2 = this.fictitiousAdvertsService.getAdvert();
|
if(this.activatedRoute.snapshot.paramMap.get('source') === "Youtube") source = "yt" ;
|
||||||
|
else source = "dm"
|
||||||
|
params1 = params1.append("source", source);
|
||||||
|
this.messageService
|
||||||
|
.get("video/get/"+videoId, params1)
|
||||||
|
.subscribe(ret => this.findVideoCallback(ret), err => this.findVideoCallback(err));
|
||||||
|
|
||||||
|
// advert
|
||||||
|
let params2 = new HttpParams();
|
||||||
|
params2 = params2.append("quantity", 2);
|
||||||
|
this.messageService
|
||||||
|
.get("user/ad", params2)
|
||||||
|
.subscribe(ret => this.findAdCallback(ret), err => this.findAdCallback(err));
|
||||||
|
|
||||||
|
|
||||||
if(this.router.url.includes("fromSearch")) this.from = "search" ;
|
if(this.router.url.includes("fromSearch")) this.from = "search" ;
|
||||||
else if(this.router.url.includes("fromHistory")) this.from = "history";
|
else if(this.router.url.includes("fromHistory")) this.from = "history";
|
||||||
|
|
@ -90,6 +116,29 @@ export class PageWatchingVideoComponent implements OnInit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
findVideoCallback(retour: any): void
|
||||||
|
{
|
||||||
|
if(retour.status !== "success") {
|
||||||
|
console.log(retour);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.video = retour.data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
findAdCallback(retour: any): void
|
||||||
|
{
|
||||||
|
if(retour !== "success") {
|
||||||
|
console.log(retour);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.ad1 = retour.data[0];
|
||||||
|
this.ad2 = retour.data[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
onSearch()
|
onSearch()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -98,7 +147,7 @@ export class PageWatchingVideoComponent implements OnInit
|
||||||
|
|
||||||
onAdd(): void
|
onAdd(): void
|
||||||
{
|
{
|
||||||
this.addVideoToPlaylistsService.run(this.video);
|
//this.addVideoToPlaylistsService.run(this.video);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -113,8 +162,8 @@ export class PageWatchingVideoComponent implements OnInit
|
||||||
safeUrl(videoId: string, source: string): SafeResourceUrl
|
safeUrl(videoId: string, source: string): SafeResourceUrl
|
||||||
{
|
{
|
||||||
let videoUrl = "" ;
|
let videoUrl = "" ;
|
||||||
if(source === 'youtube') videoUrl = "https://www.youtube.com/embed/" + videoId;
|
if(source === 'Youtube') videoUrl = "https://www.youtube.com/embed/" + videoId;
|
||||||
else if(source === 'dailymotion') videoUrl = "https://www.dailymotion.com/embed/video/" + videoId;
|
else if(source === 'Dailymotion') videoUrl = "https://www.dailymotion.com/embed/video/" + videoId;
|
||||||
return this._sanitizer.bypassSecurityTrustResourceUrl(videoUrl);
|
return this._sanitizer.bypassSecurityTrustResourceUrl(videoUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Reference in a new issue