implementation du bouton 'retour' dans la page 'user/watching'
This commit is contained in:
parent
f2ced83246
commit
ad0397e8ad
9 changed files with 219 additions and 66 deletions
|
|
@ -28,9 +28,7 @@ const routes: Routes = [
|
||||||
{ path: 'user/myPlaylists', component: PageMyPlaylistsComponent },
|
{ path: 'user/myPlaylists', component: PageMyPlaylistsComponent },
|
||||||
{ path: 'user/history', component: PageHistoryUserComponent },
|
{ path: 'user/history', component: PageHistoryUserComponent },
|
||||||
{ path: 'user/myProfil', component: PageProfilUserComponent },
|
{ path: 'user/myProfil', component: PageProfilUserComponent },
|
||||||
{ path: 'user/watching/fromSearch/:videoId/:source/:search', component: PageWatchingVideoComponent },
|
{ path: 'user/watching', component: PageWatchingVideoComponent },
|
||||||
{ path: 'user/watching/fromMyPlaylists/:videoId/:_idPlaylist', component: PageWatchingVideoComponent },
|
|
||||||
{ path: 'user/watching/fromHistory/:videoId/:source', component: PageWatchingVideoComponent },
|
|
||||||
|
|
||||||
// Advertiser
|
// Advertiser
|
||||||
{ path: 'advertiser', component: PageAdListAdvertiserComponent },
|
{ path: 'advertiser', component: PageAdListAdvertiserComponent },
|
||||||
|
|
|
||||||
|
|
@ -99,8 +99,12 @@ export class PageHistoryUserComponent implements AfterViewInit
|
||||||
.put("video/update/"+video._id, {watchedDate: true})
|
.put("video/update/"+video._id, {watchedDate: true})
|
||||||
.subscribe(ret => this.onVideoCallback(ret), err => this.onVideoCallback(err));
|
.subscribe(ret => this.onVideoCallback(ret), err => this.onVideoCallback(err));
|
||||||
|
|
||||||
const url = '/user/watching/fromHistory/'+video.videoId+'/'+video.source ;
|
const params = {
|
||||||
this.router.navigateByUrl(url);
|
videoId: video.videoId,
|
||||||
|
source: video.source,
|
||||||
|
from: "history",
|
||||||
|
};
|
||||||
|
this.router.navigate(['/user/watching'], { queryParams: params });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,8 +70,13 @@ export class VideoListComponent implements OnChanges
|
||||||
|
|
||||||
onVideo(video: any): void
|
onVideo(video: any): void
|
||||||
{
|
{
|
||||||
const url = "user/watching/fromMyPlaylists/" + video.videoId + '/' + this.playlist._id;
|
const params = {
|
||||||
this.router.navigateByUrl(url);
|
videoId: video.videoId,
|
||||||
|
source: video.source,
|
||||||
|
_idPlaylist: this.playlist._id,
|
||||||
|
from: "myPlaylists",
|
||||||
|
};
|
||||||
|
this.router.navigate(['/user/watching'], { queryParams: params });
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@
|
||||||
<!-- Grilles des videos -->
|
<!-- Grilles des videos -->
|
||||||
<mat-grid-tile colspan="7" rowspan="1" class="celluleGrilleVideo">
|
<mat-grid-tile colspan="7" rowspan="1" class="celluleGrilleVideo">
|
||||||
<div class="conteneurVideosGrid">
|
<div class="conteneurVideosGrid">
|
||||||
<app-video-grid [tabVideo]="tabVideo" [search]="search"></app-video-grid>
|
<app-video-grid [tabVideo]="tabVideo" [search]="search" [sources]="sources" [indexPage]="indexPage"></app-video-grid>
|
||||||
</div>
|
</div>
|
||||||
</mat-grid-tile>
|
</mat-grid-tile>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import {MessageService} from "../../../utils/services/message/message.service";
|
||||||
import {VideoAll} from "../../../utils/interfaces/video";
|
import {VideoAll} from "../../../utils/interfaces/video";
|
||||||
import {ThemeService} from "../../../utils/services/theme/theme.service";
|
import {ThemeService} from "../../../utils/services/theme/theme.service";
|
||||||
import {HttpParams} from "@angular/common/http";
|
import {HttpParams} from "@angular/common/http";
|
||||||
|
import {ActivatedRoute} from "@angular/router";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -25,28 +26,55 @@ export class PageSearchComponent implements OnInit
|
||||||
search: string = "";
|
search: string = "";
|
||||||
ad1: any;
|
ad1: any;
|
||||||
ad2: any;
|
ad2: any;
|
||||||
|
sources: string = "" ;
|
||||||
|
indexPage: number = 0;
|
||||||
|
|
||||||
|
|
||||||
constructor( private messageService: MessageService,
|
constructor( private messageService: MessageService,
|
||||||
public themeService: ThemeService ) { }
|
public themeService: ThemeService,
|
||||||
|
private activatedRoute: ActivatedRoute ) { }
|
||||||
|
|
||||||
|
|
||||||
ngOnInit(): void
|
ngOnInit(): void
|
||||||
{
|
{
|
||||||
|
// parametre de la route
|
||||||
|
this.activatedRoute
|
||||||
|
.queryParams
|
||||||
|
.subscribe(paramsFromOldPage => {
|
||||||
|
if(paramsFromOldPage.hasOwnProperty("search")) this.search = paramsFromOldPage.search;
|
||||||
|
if(paramsFromOldPage.hasOwnProperty("sources"))
|
||||||
|
{
|
||||||
|
this.sources = paramsFromOldPage.sources;
|
||||||
|
if(this.sources === "yt") {
|
||||||
|
this.tabPlateform[0].isSelected = true;
|
||||||
|
this.tabPlateform[1].isSelected = false;
|
||||||
|
}
|
||||||
|
else if(this.sources === "dm") {
|
||||||
|
this.tabPlateform[0].isSelected = false;
|
||||||
|
this.tabPlateform[1].isSelected = true;
|
||||||
|
}
|
||||||
|
else if(this.sources === "yt,dm") {
|
||||||
|
this.tabPlateform[0].isSelected = true;
|
||||||
|
this.tabPlateform[1].isSelected = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(paramsFromOldPage.hasOwnProperty("indexPage")) this.indexPage = parseInt(paramsFromOldPage.indexPage, 10);
|
||||||
|
this.onSearch();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Ask for ads
|
||||||
let params = new HttpParams();
|
let params = new HttpParams();
|
||||||
params = params.append("quantity", 2);
|
params = params.append("quantity", 2);
|
||||||
this.messageService
|
this.messageService
|
||||||
.get("user/ad", params)
|
.get("user/ad", params)
|
||||||
.subscribe(ret => this.adCallback(ret), err => this.adCallback(err));
|
.subscribe(ret => this.adCallback(ret), err => this.adCallback(err));
|
||||||
|
|
||||||
this.onSearch();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
adCallback(retour: any): void
|
adCallback(retour: any): void
|
||||||
{
|
{
|
||||||
if(retour.status !== "success") {
|
if(retour.status !== "success") {
|
||||||
//console.log(retour);
|
console.log(retour);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.ad1 = retour.data[0];
|
this.ad1 = retour.data[0];
|
||||||
|
|
@ -60,12 +88,11 @@ export class PageSearchComponent implements OnInit
|
||||||
let params = new HttpParams();
|
let params = new HttpParams();
|
||||||
params = params.append('q', this.search);
|
params = params.append('q', this.search);
|
||||||
|
|
||||||
let sources = "";
|
if(this.tabPlateform[0].isSelected && this.tabPlateform[1].isSelected) this.sources = "yt,dm" ;
|
||||||
if(this.tabPlateform[0].isSelected && this.tabPlateform[1].isSelected) sources += "yt,dm" ;
|
else if((!this.tabPlateform[0].isSelected) && this.tabPlateform[1].isSelected) this.sources = "dm" ;
|
||||||
else if((!this.tabPlateform[0].isSelected) && this.tabPlateform[1].isSelected) sources += "dm" ;
|
else if(this.tabPlateform[0].isSelected && (!this.tabPlateform[1].isSelected)) this.sources = "yt" ;
|
||||||
else if(this.tabPlateform[0].isSelected && (!this.tabPlateform[1].isSelected)) sources += "yt" ;
|
else this.sources = "" ;
|
||||||
else sources += "" ;
|
params = params.append('sources', this.sources);
|
||||||
params = params.append('sources', sources);
|
|
||||||
|
|
||||||
this.messageService
|
this.messageService
|
||||||
.get("video/search", params)
|
.get("video/search", params)
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
|
|
||||||
<!-- Grille -->
|
<!-- Grille -->
|
||||||
<div style="height: 93%; background-color: white; padding-top: 7px;">
|
<div style="height: 93%; background-color: white; padding-top: 7px;" *ngIf="tabVideoExists()">
|
||||||
<mat-grid-list cols="3" rowHeight="33%">
|
<mat-grid-list cols="3" rowHeight="33%">
|
||||||
<mat-grid-tile colspan="1" rowspan="1" *ngFor="let k of [0,1,2,3,4,5,6,7,8]">
|
<mat-grid-tile colspan="1" rowspan="1" *ngFor="let k of [0,1,2,3,4,5,6,7,8]">
|
||||||
<div class="myCell" *ngIf="indexPage+k < tabVideo.length" [title]="tabVideo[indexPage+k].title">
|
<div class="myCell" *ngIf="indexPage+k < tabVideo.length" [title]="tabVideo[indexPage+k].title">
|
||||||
|
|
@ -55,13 +55,13 @@
|
||||||
|
|
||||||
|
|
||||||
<!-- Paginator -->
|
<!-- Paginator -->
|
||||||
<div class="paginatorContainer">
|
<div class="paginatorContainer" *ngIf="tabVideoExists()">
|
||||||
|
|
||||||
<!-- btn précédent -->
|
<!-- btn précédent -->
|
||||||
<button mat-button class="btnPaginator" [disabled]="indexPage<=0" (click)="indexPage=indexPage-9"> < Précédent </button>
|
<button mat-button class="btnPaginator" [disabled]="indexPage<=0" (click)="indexPage=indexPage-9"> < Précédent </button>
|
||||||
|
|
||||||
<!-- numeros de page -->
|
<!-- numeros de page -->
|
||||||
<span *ngFor="let page of [1,2,3,4,5,6,7,8,9,10]" (click)="indexPage=(page-1)*9">
|
<span *ngFor="let page of tabPage" (click)="indexPage=(page-1)*9">
|
||||||
<span *ngIf="page===((indexPage/9)+1)">
|
<span *ngIf="page===((indexPage/9)+1)">
|
||||||
<span style="text-decoration: underline; cursor: pointer;font-weight: bold;">{{page}}</span>
|
<span style="text-decoration: underline; cursor: pointer;font-weight: bold;">{{page}}</span>
|
||||||
</span>
|
</span>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import {Component, Input } from '@angular/core';
|
import {Component, Input, OnChanges, OnInit, SimpleChanges} from '@angular/core';
|
||||||
import {VideoAll} from "../../../utils/interfaces/video";
|
import {VideoAll} from "../../../utils/interfaces/video";
|
||||||
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";
|
||||||
|
|
@ -11,11 +11,13 @@ import {MessageService} from "../../../utils/services/message/message.service";
|
||||||
templateUrl: './video-grid.component.html',
|
templateUrl: './video-grid.component.html',
|
||||||
styleUrls: ['./video-grid.component.scss']
|
styleUrls: ['./video-grid.component.scss']
|
||||||
})
|
})
|
||||||
export class VideoGridComponent
|
export class VideoGridComponent implements OnChanges
|
||||||
{
|
{
|
||||||
@Input() tabVideo: VideoAll[] = [];
|
@Input() tabVideo: VideoAll[] = [];
|
||||||
@Input() search: string = '';
|
@Input() search: string = "";
|
||||||
indexPage: number = 0;
|
@Input() sources: string = "";
|
||||||
|
@Input() indexPage: number = 0;
|
||||||
|
tabPage: number[] = [];
|
||||||
|
|
||||||
|
|
||||||
constructor( private addVideoToPlaylistsService: AddVideoToPlaylistsService,
|
constructor( private addVideoToPlaylistsService: AddVideoToPlaylistsService,
|
||||||
|
|
@ -23,6 +25,19 @@ export class VideoGridComponent
|
||||||
private messageService: MessageService ) {}
|
private messageService: MessageService ) {}
|
||||||
|
|
||||||
|
|
||||||
|
ngOnChanges(changes: SimpleChanges): void
|
||||||
|
{
|
||||||
|
if(this.tabVideoExists())
|
||||||
|
{
|
||||||
|
const nbVideo = this.tabVideo.length;
|
||||||
|
let nbPage = Math.floor(nbVideo/9);
|
||||||
|
if((nbVideo%9) !== 0) nbPage += 1;
|
||||||
|
this.tabPage = [];
|
||||||
|
for(let i=1 ; i<=nbPage ; i++) this.tabPage.push(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
onAddToPlaylist(video: VideoAll): void
|
onAddToPlaylist(video: VideoAll): void
|
||||||
{
|
{
|
||||||
this.addVideoToPlaylistsService.run(video.videoId, video.source, video.interest);
|
this.addVideoToPlaylistsService.run(video.videoId, video.source, video.interest);
|
||||||
|
|
@ -41,16 +56,26 @@ export class VideoGridComponent
|
||||||
const data = { source: video.source, interest: video.interest };
|
const data = { source: video.source, interest: video.interest };
|
||||||
this.messageService
|
this.messageService
|
||||||
.post("video/create/"+video.videoId, data)
|
.post("video/create/"+video.videoId, data)
|
||||||
.subscribe(ret => this.onVideoCallback(ret), err => this.onVideoCallback(err));
|
.subscribe(ret => this.onVideoCallback(ret,video), err => this.onVideoCallback(err,video));
|
||||||
|
|
||||||
const url = '/user/watching/fromSearch/'+video.videoId+'/'+video.source+'/'+this.search;
|
|
||||||
this.router.navigateByUrl(url);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
onVideoCallback(retour: any): void
|
onVideoCallback(retour: any, video: VideoAll): void
|
||||||
{
|
{
|
||||||
if(retour.status !== "success") console.log(retour);
|
if(retour.status !== "success") {
|
||||||
|
console.log(retour);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const params = {
|
||||||
|
videoId: video.videoId,
|
||||||
|
source: video.source,
|
||||||
|
from: "search",
|
||||||
|
search: this.search,
|
||||||
|
sources: this.sources,
|
||||||
|
indexPage: this.indexPage
|
||||||
|
};
|
||||||
|
this.router.navigate(['/user/watching'], { queryParams: params });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -93,4 +118,12 @@ export class VideoGridComponent
|
||||||
else return ellapsedTimeInYears + " ans" ;
|
else return ellapsedTimeInYears + " ans" ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
tabVideoExists(): boolean
|
||||||
|
{
|
||||||
|
if((this.tabVideo === null) || (this.tabVideo === undefined)) return false;
|
||||||
|
else if(this.tabVideo.length === 0) return false;
|
||||||
|
else return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
<!-- Search bar -->
|
<!-- Search bar -->
|
||||||
<div class="input-group" style="width: 100%; margin: 0 auto;">
|
<div class="input-group" style="width: 100%; margin: 0 auto;">
|
||||||
<div class="form-outline" style="width: 100%; margin: 0 auto;">
|
<div class="form-outline" style="width: 100%; margin: 0 auto;">
|
||||||
<input type="search" placeholder="Rechercher..." class="inputSearchBar" (keydown)="onEnterOnSearchBar($event)"/>
|
<input type="search" placeholder="Rechercher..." class="inputSearchBar" [(ngModel)]="search" (keydown)="onEnterOnSearchBar($event)"/>
|
||||||
<button mat-icon-button (click)="onSearch()">
|
<button mat-icon-button (click)="onSearch()">
|
||||||
<mat-icon>search</mat-icon>
|
<mat-icon>search</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
|
|
@ -191,7 +191,7 @@
|
||||||
<!-- NIVEAU 3: playlist -->
|
<!-- NIVEAU 3: playlist -->
|
||||||
|
|
||||||
<ng-template #playlistHTML>
|
<ng-template #playlistHTML>
|
||||||
<div class="playlistContainer">
|
<div class="playlistContainer" *ngIf="playlistExists()">
|
||||||
|
|
||||||
<!-- Bordure haute -->
|
<!-- Bordure haute -->
|
||||||
<div class="topBorder">
|
<div class="topBorder">
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import {VideoAll} from "../../../utils/interfaces/video";
|
import {VideoAll} from "../../../utils/interfaces/video";
|
||||||
import {Advert} from "../../../utils/interfaces/advert";
|
|
||||||
import {MessageService} from "../../../utils/services/message/message.service";
|
import {MessageService} from "../../../utils/services/message/message.service";
|
||||||
import {FictitiousVideosService} from "../../../utils/services/fictitiousDatas/fictitiousVideos/fictitious-videos.service";
|
import {FictitiousVideosService} from "../../../utils/services/fictitiousDatas/fictitiousVideos/fictitious-videos.service";
|
||||||
import {FictitiousAdvertsService} from "../../../utils/services/fictitiousDatas/fictitiousAdverts/fictitious-adverts.service";
|
import {FictitiousAdvertsService} from "../../../utils/services/fictitiousDatas/fictitiousAdverts/fictitious-adverts.service";
|
||||||
|
|
@ -28,6 +27,7 @@ let TAB_PLATEFORM = [
|
||||||
export class PageWatchingVideoComponent implements OnInit
|
export class PageWatchingVideoComponent implements OnInit
|
||||||
{
|
{
|
||||||
tabPlateform = TAB_PLATEFORM;
|
tabPlateform = TAB_PLATEFORM;
|
||||||
|
sources: string = "";
|
||||||
video = {
|
video = {
|
||||||
title: "",
|
title: "",
|
||||||
videoId: "",
|
videoId: "",
|
||||||
|
|
@ -38,13 +38,16 @@ export class PageWatchingVideoComponent implements OnInit
|
||||||
interest: ""
|
interest: ""
|
||||||
};
|
};
|
||||||
search: string = "";
|
search: string = "";
|
||||||
|
|
||||||
ad1: any;
|
ad1: any;
|
||||||
ad2: any;
|
ad2: any;
|
||||||
from: string = "";
|
from: string = "";
|
||||||
|
|
||||||
playlist: PlaylistDB;
|
playlist: any;
|
||||||
videosInPlaylist: any[] = [];
|
videosInPlaylist: any[] = [];
|
||||||
|
|
||||||
|
paramsFromOldPage ;
|
||||||
|
|
||||||
hiddenDescription: boolean = true;
|
hiddenDescription: boolean = true;
|
||||||
iframeStyle: string = "";
|
iframeStyle: string = "";
|
||||||
containerStyle: string = "";
|
containerStyle: string = "";
|
||||||
|
|
@ -60,46 +63,81 @@ export class PageWatchingVideoComponent implements OnInit
|
||||||
private addVideoToPlaylistsService: AddVideoToPlaylistsService ) { }
|
private addVideoToPlaylistsService: AddVideoToPlaylistsService ) { }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ngOnInit(): void
|
ngOnInit(): void
|
||||||
{
|
{
|
||||||
// Ask for videos
|
// Ask for videos
|
||||||
const videoId = this.activatedRoute.snapshot.paramMap.get('videoId');
|
this.activatedRoute
|
||||||
let params1 = new HttpParams();
|
.queryParams
|
||||||
let source = "" ;
|
.subscribe(paramsFromOldPage => {
|
||||||
if(this.activatedRoute.snapshot.paramMap.get('source') === "Youtube") source = "yt" ;
|
|
||||||
else source = "dm"
|
this.paramsFromOldPage = paramsFromOldPage;
|
||||||
params1 = params1.append("source", source);
|
const videoId = paramsFromOldPage.videoId;
|
||||||
|
let source = paramsFromOldPage.source;
|
||||||
|
|
||||||
|
let params = new HttpParams();
|
||||||
|
if(source === "Youtube") source = "yt";
|
||||||
|
else if(source === "Dailymotion") source = "dm" ;
|
||||||
|
params = params.append("source", source);
|
||||||
this.messageService
|
this.messageService
|
||||||
.get("video/get/"+videoId, params1)
|
.get("video/get/"+videoId, params)
|
||||||
.subscribe(ret => this.findVideoCallback(ret), err => this.findVideoCallback(err));
|
.subscribe(ret => this.findVideoCallback(ret), err => this.findVideoCallback(err));
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
// Ask for adverts
|
// Ask for adverts
|
||||||
let params2 = new HttpParams();
|
let params = new HttpParams();
|
||||||
params2 = params2.append("quantity", 2);
|
params = params.append("quantity", 2);
|
||||||
this.messageService
|
this.messageService
|
||||||
.get("user/ad", params2)
|
.get("user/ad", params)
|
||||||
.subscribe(ret => this.findAdCallback(ret), err => this.findAdCallback(err));
|
.subscribe(ret => this.findAdCallback(ret), err => this.findAdCallback(err));
|
||||||
|
|
||||||
|
|
||||||
if(this.router.url.includes("fromSearch")) this.from = "search" ;
|
// Si on vient de la page "search"
|
||||||
else if(this.router.url.includes("fromHistory")) this.from = "history";
|
if(this.router.url.includes("search"))
|
||||||
else if(this.router.url.includes("fromMyPlaylists"))
|
{
|
||||||
|
this.from = "search" ;
|
||||||
|
this.activatedRoute
|
||||||
|
.queryParams
|
||||||
|
.subscribe(paramsFromOldPage => {
|
||||||
|
if(paramsFromOldPage.hasOwnProperty("search")) this.search = paramsFromOldPage.search;
|
||||||
|
if(paramsFromOldPage.hasOwnProperty("sources")) {
|
||||||
|
this.sources = paramsFromOldPage.sources;
|
||||||
|
if(this.sources === "yt") {
|
||||||
|
this.tabPlateform[0].isSelected = true;
|
||||||
|
this.tabPlateform[1].isSelected = false;
|
||||||
|
}
|
||||||
|
else if(this.sources === "dm") {
|
||||||
|
this.tabPlateform[0].isSelected = false;
|
||||||
|
this.tabPlateform[1].isSelected = true;
|
||||||
|
}
|
||||||
|
else if(this.sources === "yt,dm") {
|
||||||
|
this.tabPlateform[0].isSelected = true;
|
||||||
|
this.tabPlateform[1].isSelected = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// si on vient de la page "myPlaylists"
|
||||||
|
else if(this.router.url.includes("myPlaylists"))
|
||||||
{
|
{
|
||||||
this.from = "myPlaylists";
|
this.from = "myPlaylists";
|
||||||
const _idPlaylist = this.activatedRoute.snapshot.paramMap.get('_idPlaylist');
|
this.activatedRoute
|
||||||
this.playlist = this.fictitiousVideosService.getPlaylistBy_id(_idPlaylist);
|
.queryParams
|
||||||
const allVideo = this.fictitiousVideosService.get_TAB_VIDEO();
|
.subscribe(paramsFromOldPage => {
|
||||||
this.videosInPlaylist = [];
|
const _idPlaylist = paramsFromOldPage._idPlaylist;
|
||||||
for(let _idVideo of this.playlist.videoIds)
|
this.messageService
|
||||||
{
|
.get("playlist/findOne/"+_idPlaylist)
|
||||||
const video = allVideo.find(video => video._id === _idVideo);
|
.subscribe(ret => this.afterReceivingPlaylistWithVideo(ret), err => this.afterReceivingPlaylistWithVideo(err));
|
||||||
this.videosInPlaylist.push(video);
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
// si on vient de la page "history"
|
||||||
|
else if(this.router.url.includes("history")) this.from = "history";
|
||||||
|
|
||||||
|
|
||||||
// style
|
// style
|
||||||
if(this.from === 'search' || this.from === 'history')
|
if(this.from === 'search' || this.from === 'history') {
|
||||||
{
|
|
||||||
this.containerStyle = "margin: 0 auto; width: 64vw;"
|
this.containerStyle = "margin: 0 auto; width: 64vw;"
|
||||||
this.iframeStyle = "width: 64vw; height: 60vh;" ;
|
this.iframeStyle = "width: 64vw; height: 60vh;" ;
|
||||||
}
|
}
|
||||||
|
|
@ -110,9 +148,11 @@ export class PageWatchingVideoComponent implements OnInit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
findVideoCallback(retour: any): void
|
findVideoCallback(retour: any): void
|
||||||
{
|
{
|
||||||
if(retour.status !== "success") {
|
if(retour.status !== "success") {
|
||||||
|
console.log("findVideoCallback: ");
|
||||||
console.log(retour);
|
console.log(retour);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -123,7 +163,8 @@ export class PageWatchingVideoComponent implements OnInit
|
||||||
|
|
||||||
findAdCallback(retour: any): void
|
findAdCallback(retour: any): void
|
||||||
{
|
{
|
||||||
if(retour !== "success") {
|
if(retour.status !== "success") {
|
||||||
|
console.log("findAdCallback: ");
|
||||||
console.log(retour);
|
console.log(retour);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -133,9 +174,33 @@ export class PageWatchingVideoComponent implements OnInit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
afterReceivingPlaylistWithVideo(retour: any): void
|
||||||
|
{
|
||||||
|
if(retour.status !== "success") {
|
||||||
|
console.log("afterReceivingPlaylistWithVideo");
|
||||||
|
console.log(retour);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.playlist = retour.data;
|
||||||
|
this.videosInPlaylist = retour.data.videos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
onSearch()
|
onSearch()
|
||||||
{
|
{
|
||||||
|
if(this.tabPlateform[0].isSelected && this.tabPlateform[1].isSelected) this.sources = "yt,dm" ;
|
||||||
|
else if((!this.tabPlateform[0].isSelected) && this.tabPlateform[1].isSelected) this.sources = "dm" ;
|
||||||
|
else if(this.tabPlateform[0].isSelected && (!this.tabPlateform[1].isSelected)) this.sources = "yt" ;
|
||||||
|
else this.sources = "" ;
|
||||||
|
let options = {
|
||||||
|
queryParams: {
|
||||||
|
search: this.search,
|
||||||
|
sources: this.sources,
|
||||||
|
indexPage: 0,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
this.router.navigate(['/user/search'], options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -147,9 +212,24 @@ export class PageWatchingVideoComponent implements OnInit
|
||||||
|
|
||||||
onRetour(): void
|
onRetour(): void
|
||||||
{
|
{
|
||||||
if(this.from === 'search') this.router.navigateByUrl("/user/search");
|
let url: string[] = [];
|
||||||
else if(this.from === 'myPlaylists') this.router.navigateByUrl("/user/myPlaylists");
|
let options = {};
|
||||||
else if(this.from === 'history') this.router.navigateByUrl("/user/history");
|
|
||||||
|
if(this.from === 'search')
|
||||||
|
{
|
||||||
|
url = ['/user/search'];
|
||||||
|
options = {
|
||||||
|
queryParams: {
|
||||||
|
search: this.paramsFromOldPage.search,
|
||||||
|
sources: this.paramsFromOldPage.sources,
|
||||||
|
indexPage: this.paramsFromOldPage.indexPage,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else if(this.from === 'myPlaylists') url = ["/user/myPlaylists"];
|
||||||
|
else if(this.from === 'history') url = ["/user/history"];
|
||||||
|
|
||||||
|
this.router.navigate(url, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -175,4 +255,10 @@ export class PageWatchingVideoComponent implements OnInit
|
||||||
if(event.key === 'Enter') this.onSearch();
|
if(event.key === 'Enter') this.onSearch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
playlistExists(): boolean
|
||||||
|
{
|
||||||
|
return ((this.playlist !== null) && (this.playlist !== undefined));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Reference in a new issue