continuation de la page search
This commit is contained in:
parent
aaf020fa2b
commit
bec9ff6c0d
15 changed files with 171 additions and 93 deletions
|
|
@ -36,6 +36,6 @@
|
|||
|
||||
|
||||
<mat-dialog-actions style="justify-content: flex-end;">
|
||||
<button mat-button mat-dialog-close>Cancel</button>
|
||||
<button mat-button [mat-dialog-close]="true" cdkFocusInitial (click)="onValider">Valider</button>
|
||||
<button mat-button mat-dialog-close (click)="onAnnuler()">Annuler</button>
|
||||
<button mat-button [mat-dialog-close]="true" cdkFocusInitial (click)="onValider()">Valider</button>
|
||||
</mat-dialog-actions>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
import {Component, Inject, OnInit} from '@angular/core';
|
||||
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
|
||||
import {Video} from "../../interfaces/video";
|
||||
import {MessageService} from "../../services/message/message.service";
|
||||
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-popup-add-video-to-playlists',
|
||||
|
|
@ -14,23 +17,51 @@ export class PopupAddVideoToPlaylistsComponent implements OnInit
|
|||
goToCreatePlaylist = false;
|
||||
newPlaylistName = "";
|
||||
|
||||
|
||||
constructor( public dialogRef: MatDialogRef<PopupAddVideoToPlaylistsComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data ) { }
|
||||
@Inject(MAT_DIALOG_DATA) public data,
|
||||
private messageService: MessageService) { }
|
||||
|
||||
|
||||
ngOnInit(): void
|
||||
{
|
||||
this.video = this.data.video;
|
||||
const tabPlaylist = this.data.playlists;
|
||||
for(let playlist of tabPlaylist)
|
||||
for(let playlist of this.data.playlists)
|
||||
{
|
||||
playlist["isSelected"] = false;
|
||||
this.tabPlaylistAndBool.push(playlist);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
onValider(): void
|
||||
{
|
||||
const tabPlaylist = [];
|
||||
for(let playlist of this.tabPlaylistAndBool)
|
||||
{
|
||||
if(playlist.isSelected) {
|
||||
delete playlist["isSelected"];
|
||||
tabPlaylist.push(playlist);
|
||||
}
|
||||
}
|
||||
|
||||
// --- FAUX CODE ---
|
||||
this.dialogRef.close("success");
|
||||
|
||||
// --- VRAI CODE ---
|
||||
/*
|
||||
if(!this.goToCreatePlaylist) this.newPlaylistName = "";
|
||||
const data = { "video": this.video, "playlists": tabPlaylist, "newPlaylistName": this.newPlaylistName };
|
||||
this.messageService
|
||||
.sendMessage("user/add/vidéo", data)
|
||||
.subscribe( retour => { this.dialogRef.close(retour.status) });
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
onAnnuler(): void
|
||||
{
|
||||
this.dialogRef.close("annulation")
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
<div class="conteneur">
|
||||
<h1> Je suis une pub </h1>
|
||||
<span>debut</span>
|
||||
<img src="assets/logo_plateforms/Youtube.png" width="40px" height="40px">
|
||||
<img src="assets/ads/Youtube.png" width="40px" height="40px">
|
||||
<span>fin</span>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { PlaylistService } from './playlist.service';
|
||||
import { AddVideoToPlaylistsService } from './add-video-to-playlists.service';
|
||||
|
||||
describe('PlaylistService', () => {
|
||||
let service: PlaylistService;
|
||||
let service: AddVideoToPlaylistsService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(PlaylistService);
|
||||
service = TestBed.inject(AddVideoToPlaylistsService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import {MessageService} from "../message/message.service";
|
||||
import {MatDialog} from "@angular/material/dialog";
|
||||
import {PopupAddVideoToPlaylistsComponent} from "../../components/popup-add-video-to-playlists/popup-add-video-to-playlists.component";
|
||||
import {FictitiousDatasService} from "../fictitiousDatas/fictitious-datas.service";
|
||||
import {Video} from "../../interfaces/video";
|
||||
import {MatSnackBar} from "@angular/material/snack-bar";
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class AddVideoToPlaylistsService
|
||||
{
|
||||
private _video: Video;
|
||||
|
||||
|
||||
constructor( private messageService: MessageService,
|
||||
public dialog: MatDialog,
|
||||
private fictitiousDatasService: FictitiousDatasService,
|
||||
private snackBar: MatSnackBar ) { }
|
||||
|
||||
|
||||
// --- FAUX CODE ---
|
||||
run(video0: Video): void
|
||||
{
|
||||
this._video = video0;
|
||||
const retour = {
|
||||
status: "success",
|
||||
data: this.fictitiousDatasService.getTabPlaylist(4),
|
||||
}
|
||||
this.afterReceivingPlaylists(retour)
|
||||
}
|
||||
|
||||
|
||||
// --- VRAI CODE ---
|
||||
/*
|
||||
run(video0: Video): void
|
||||
{
|
||||
this._video = video0;
|
||||
this.messageService
|
||||
.sendMessage('user/get/playlists', null)
|
||||
.subscribe( retour => { this.afterReceivingPlaylists(retour) });
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
private afterReceivingPlaylists(retour): void
|
||||
{
|
||||
if(retour.status === "error") console.log(retour.data);
|
||||
else
|
||||
{
|
||||
const config = {
|
||||
width: '30%',
|
||||
data: { video: this._video, playlists: retour.data }
|
||||
};
|
||||
this.dialog
|
||||
.open(PopupAddVideoToPlaylistsComponent, config )
|
||||
.afterClosed()
|
||||
.subscribe(retour => { this.afterClosingDialog(retour); });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private afterClosingDialog(retour): void
|
||||
{
|
||||
let message = "" ;
|
||||
switch (retour)
|
||||
{
|
||||
case "error":
|
||||
message = "Echec de l'opération ❌" ;
|
||||
break;
|
||||
case "success":
|
||||
message = "La vidéo a bien été ajoutée ✔" ;
|
||||
break;
|
||||
case "annulation":
|
||||
case null:
|
||||
case undefined:
|
||||
message = "Annulation de l'opération" ;
|
||||
break;
|
||||
}
|
||||
const config = { duration: 1000, panelClass: "custom-class" };
|
||||
this.snackBar.open( message, "", config);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -10,7 +10,7 @@ export class FictitiousDatasService
|
|||
constructor() { }
|
||||
|
||||
|
||||
load_pageSeach(n: number): Video[]
|
||||
getTabVideo(n: number): Video[]
|
||||
{
|
||||
let tabVideo = [];
|
||||
|
||||
|
|
@ -34,16 +34,16 @@ export class FictitiousDatasService
|
|||
}
|
||||
|
||||
|
||||
getTabPlaylist()
|
||||
getTabPlaylist(n: number)
|
||||
{
|
||||
let tabTabPlaylist: Playlist[] = [];
|
||||
|
||||
for (let i = 0; i < 4; i++)
|
||||
for (let i = 0; i < n; i++)
|
||||
{
|
||||
let playlist: Playlist = {
|
||||
_id: i.toString(),
|
||||
user: null,
|
||||
name: "name_"+i.toString(),
|
||||
name: "playlist_"+i.toString(),
|
||||
count: 3,
|
||||
videos: []
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,60 +0,0 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import {MessageService} from "../message/message.service";
|
||||
import {MatDialog} from "@angular/material/dialog";
|
||||
import {PopupAddVideoToPlaylistsComponent} from "../../components/popup-add-video-to-playlists/popup-add-video-to-playlists.component";
|
||||
import {FictitiousDatasService} from "../fictitiousDatas/fictitious-datas.service";
|
||||
import {Video} from "../../interfaces/video";
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class PlaylistService
|
||||
{
|
||||
|
||||
constructor( private messageService: MessageService,
|
||||
public dialog: MatDialog,
|
||||
private fictitiousDatasService: FictitiousDatasService ) { }
|
||||
|
||||
|
||||
addVideoToPlaylists(video0: Video): void
|
||||
{
|
||||
// --- DONNEES FICTIVES ---
|
||||
const config = {
|
||||
width: '30%',
|
||||
data: {
|
||||
video: video0,
|
||||
playlists: this.fictitiousDatasService.getTabPlaylist()
|
||||
}
|
||||
}
|
||||
this.dialog
|
||||
.open(PopupAddVideoToPlaylistsComponent, config)
|
||||
.afterClosed()
|
||||
.subscribe(result => {});
|
||||
|
||||
|
||||
// --- VRAI CODE ---
|
||||
/*
|
||||
this.messageService
|
||||
.sendMessage('user/get/playlists', null)
|
||||
.subscribe( retour => {
|
||||
|
||||
if(retour.status === "error") console.log(retour.data);
|
||||
else
|
||||
{
|
||||
const config = {
|
||||
width: '30%',
|
||||
data: {
|
||||
video: video0,
|
||||
playlists: retour.data,
|
||||
}
|
||||
};
|
||||
this.dialog
|
||||
.open(PopupAddVideoToPlaylistsComponent, config )
|
||||
.afterClosed()
|
||||
.subscribe(result => {});
|
||||
}
|
||||
})
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -22,13 +22,13 @@ export class VideoUrlService
|
|||
{
|
||||
if(videoUrl.includes("youtu.be"))
|
||||
{
|
||||
console.log("de la forme: https://youtu.be/blablabla");
|
||||
//console.log("de la forme: https://youtu.be/blablabla");
|
||||
const tab = videoUrl.split("youtu.be/");
|
||||
videoUrl = tab[0] + "www.youtube.com/embed/" + tab[1];
|
||||
}
|
||||
else if(videoUrl.includes("youtube.com/watch?v="))
|
||||
{
|
||||
console.log("de la forme: https://www.youtube.com/watch?v=blablabla");
|
||||
//console.log("de la forme: https://www.youtube.com/watch?v=blablabla");
|
||||
const tab = videoUrl.split("youtube.com/watch?v=");
|
||||
videoUrl = tab[0] + "youtube.com/embed/" + tab[1];
|
||||
}
|
||||
|
|
@ -38,7 +38,7 @@ export class VideoUrlService
|
|||
|
||||
daylimotionSafeUrl(videoUrl: string): string
|
||||
{
|
||||
console.log("de la forme: https://www.dailymotion.com/video/blablabla");
|
||||
//console.log("de la forme: https://www.dailymotion.com/video/blablabla");
|
||||
const n = "https://www.dailymotion.com/".length;
|
||||
return videoUrl.slice(0, n) + "embed/" + videoUrl.slice(n);
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue