,
@Inject(MAT_DIALOG_DATA) public data,
@@ -39,12 +34,10 @@ export class PopupAddVideoToPlaylistsComponent implements OnInit
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("---");
+ console.log("_id: " + this._idVideo);
+ console.log("videoId: " + this.videoId);
+ console.log("source: " + this.source);
+ console.log("interest: " + this.interest);
for(let playlist of this.data.playlists)
{
@@ -58,20 +51,24 @@ export class PopupAddVideoToPlaylistsComponent implements OnInit
onValider(): void
{
// --- Existing playlists ---
-
let listeDesPlaylists = "" ;
- for(let playlist of this.tabPlaylistAndBool) listeDesPlaylists += playlist.id + ","
+ for(let playlist of this.tabPlaylistAndBool)
+ {
+ if(playlist.isSelected) listeDesPlaylists += playlist.id + "," ;
+ }
if(listeDesPlaylists.endsWith(",")) listeDesPlaylists = listeDesPlaylists.slice(0, listeDesPlaylists.length-1);
console.log(listeDesPlaylists);
- const data1 = { videoId: this._idVideo }
- this.messageService
- .put( "playlist/update/"+ listeDesPlaylists, data1)
- .subscribe( ret => this.callbackForExistingPlaylists(ret), err => this.callbackForExistingPlaylists(err));
+ if(listeDesPlaylists !== "")
+ {
+ const data1 = { videoId: this._idVideo };
+ this.messageService
+ .put( "playlist/update/"+listeDesPlaylists, data1)
+ .subscribe( ret => this.callbackForExistingPlaylists(ret), err => this.callbackForExistingPlaylists(err));
+ }
// --- New playlists ---
-
if(this.goToCreatePlaylist)
{
const data2 = {
@@ -82,14 +79,6 @@ export class PopupAddVideoToPlaylistsComponent implements OnInit
.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");
}
@@ -97,16 +86,12 @@ export class PopupAddVideoToPlaylistsComponent implements OnInit
callbackForExistingPlaylists(retour: any): void
{
console.log("onValiderCallback");
- //console.log(retour);
+ console.log(retour);
if(retour.status !== "success") {
- console.log(retour);
+ //console.log(retour);
this.dialogRef.close(null);
}
- else {
- this.isFinishedForExistingPlaylist = true;
- console.log("isFinishedForExistingPlaylist: true");
- }
}
@@ -114,15 +99,12 @@ export class PopupAddVideoToPlaylistsComponent implements OnInit
callbackForNewPlaylist(retour: any): void
{
console.log("callbackForNewPlaylist");
+ console.log(retour);
if(retour.status !== "success") {
- //console.log(retour);
+ console.log(retour);
this.dialogRef.close(null);
}
- else {
- this.isFinishedForNewPlaylist = true;
- console.log("isFinishedForNewPlaylist: true");
- }
}
@@ -132,49 +114,4 @@ export class PopupAddVideoToPlaylistsComponent implements OnInit
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");
- }
- }
- }
- */
-
-
-
}
diff --git a/src/app/user/utils/services/addVideoToPlaylists/add-video-to-playlists.service.ts b/src/app/user/utils/services/addVideoToPlaylists/add-video-to-playlists.service.ts
index 11e96a7..33b8aa6 100644
--- a/src/app/user/utils/services/addVideoToPlaylists/add-video-to-playlists.service.ts
+++ b/src/app/user/utils/services/addVideoToPlaylists/add-video-to-playlists.service.ts
@@ -19,49 +19,25 @@ export class AddVideoToPlaylistsService
private interest: string = "" ;
-
constructor( private messageService: MessageService,
public dialog: MatDialog,
private fictitiousVideosService: FictitiousVideosService,
private snackBar: MatSnackBar ) { }
-
-
- run(videoId: string, source: string): void
+ run(videoId: string, source: string, interest: string): void
{
this.videoId = videoId;
this.source = source;
+ this.interest = interest;
- let params = new HttpParams();
- if(source === "Youtube") params = params.append("source", "yt");
- else params = params.append("source", "dm");
+ const data = { source: this.source, interest: this.interest };
this.messageService
- .get("video/get/"+videoId, params)
- .subscribe(ret => this.afterAskingVideoInfo(ret), err => this.afterAskingVideoInfo(err));
+ .post("video/create/"+this.videoId, data)
+ .subscribe(ret => this.afterCreatingVideo(ret), err => this.afterCreatingVideo(err));
}
-
- afterAskingVideoInfo(retour: any): void
- {
- 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");
diff --git a/src/app/user/watching/page-watching-video/page-watching-video.component.html b/src/app/user/watching/page-watching-video/page-watching-video.component.html
index f16432f..b7e4332 100644
--- a/src/app/user/watching/page-watching-video/page-watching-video.component.html
+++ b/src/app/user/watching/page-watching-video/page-watching-video.component.html
@@ -132,7 +132,7 @@
-
diff --git a/src/app/user/watching/page-watching-video/page-watching-video.component.ts b/src/app/user/watching/page-watching-video/page-watching-video.component.ts
index 58d6c8a..10ce73a 100644
--- a/src/app/user/watching/page-watching-video/page-watching-video.component.ts
+++ b/src/app/user/watching/page-watching-video/page-watching-video.component.ts
@@ -29,7 +29,8 @@ export class PageWatchingVideoComponent implements OnInit
{
tabPlateform = TAB_PLATEFORM;
video = {
- title: "zzz",
+ title: "",
+ videoId: "",
views: 0,
publishedAt: null,
description: "",
@@ -41,7 +42,7 @@ export class PageWatchingVideoComponent implements OnInit
from: string = "";
playlist: PlaylistDB;
- videosInPlaylist: VideoAll[] = [];
+ videosInPlaylist: any[] = [];
hiddenDescription: boolean = true;
iframeStyle: string = "";
@@ -54,19 +55,12 @@ export class PageWatchingVideoComponent implements OnInit
public themeService: ThemeService,
private activatedRoute: ActivatedRoute,
private router: Router,
- private _sanitizer: DomSanitizer,
- private addVideoToPlaylistsService: AddVideoToPlaylistsService ) { }
+ private _sanitizer: DomSanitizer ) { }
ngOnInit(): void
{
- // --- 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
+ // Ask for videos
const videoId = this.activatedRoute.snapshot.paramMap.get('videoId');
let params1 = new HttpParams();
let source = "" ;
@@ -77,7 +71,7 @@ export class PageWatchingVideoComponent implements OnInit
.get("video/get/"+videoId, params1)
.subscribe(ret => this.findVideoCallback(ret), err => this.findVideoCallback(err));
- // advert
+ // Ask for adverts
let params2 = new HttpParams();
params2 = params2.append("quantity", 2);
this.messageService
@@ -101,6 +95,7 @@ export class PageWatchingVideoComponent implements OnInit
}
}
+ // style
if(this.from === 'search' || this.from === 'history')
{
this.containerStyle = "margin: 0 auto; width: 64vw;"
@@ -110,9 +105,6 @@ export class PageWatchingVideoComponent implements OnInit
this.containerStyle = "margin: 0 auto; width: 48vw;"
this.iframeStyle = "width: 48vw; height: 45vh;" ;
}
-
- // --- VRAI CODE ---
- // ...
}
@@ -145,7 +137,7 @@ export class PageWatchingVideoComponent implements OnInit
}
- onAdd(): void
+ onAddToPlaylist(): void
{
//this.addVideoToPlaylistsService.run(this.video);
}
@@ -162,8 +154,8 @@ export class PageWatchingVideoComponent implements OnInit
safeUrl(videoId: string, source: string): SafeResourceUrl
{
let videoUrl = "" ;
- if(source === 'Youtube') videoUrl = "https://www.youtube.com/embed/" + videoId;
- else if(source === 'Dailymotion') videoUrl = "https://www.dailymotion.com/embed/video/" + videoId;
+ if(source === 'Youtube') videoUrl = "https://www.youtube.com/embed/" + videoId + "?autoplay=1";
+ else if(source === 'Dailymotion') videoUrl = "https://www.dailymotion.com/embed/video/" + videoId + "?autoplay=true";
return this._sanitizer.bypassSecurityTrustResourceUrl(videoUrl);
}