realisation de la page mesPlaylists

This commit is contained in:
MiharyR 2021-10-29 23:04:43 +02:00
parent 8784c290ca
commit d0ca04aefc
24 changed files with 842 additions and 36 deletions

View file

@ -0,0 +1,38 @@
<div [class]="themeService.getClassTheme()">
<div class="myContainer">
<!-- Navbar -->
<div style="margin-bottom: 50px">
<app-nav-bar pour="user"></app-nav-bar>
</div>
<!-- --------------------------------------------------------------------- -->
<!-- [liste des videos] + [liste des playlist] + [pub] -->
<mat-grid-list cols="10" rowHeight="85vh">
<!-- liste des videos -->
<mat-grid-tile colspan="4" rowspan="1" class="celluleListeVideo">
<div class="videoListContainer">
<app-video-list [playlist]="playlist"></app-video-list>
</div>
</mat-grid-tile>
<!-- liste des playlist -->
<mat-grid-tile colspan="4" rowspan="1" class="celluleListePlaylist">
<div class="playlistListContainer">
<app-playlist-list [allPlaylists]="allPlaylists" (eventEmitter)="transmitToVideoList($event)"></app-playlist-list>
</div>
</mat-grid-tile>
<!-- pub -->
<mat-grid-tile colspan="2" rowspan="1" class="cellulePub">
<div class="conteneurPub">
<app-advert [ad]="ad"></app-advert>
</div>
</mat-grid-tile>
</mat-grid-list>
</div>
</div>

View file

@ -0,0 +1,51 @@
.lightTheme {
border-color: black;
}
.darkTheme {
border-color: white;
}
.myContainer {
text-align: center;
max-width: 100vw;
height: 100vh;
overflow-x: hidden;
}
// Liste des vidéos -------------------------------------------------
.celluleListeVideo {
margin: 0px;
}
// Liste des playlists ---------------------------------------------
.celluleListePlaylist {
margin: 0px;
}
.playlistListContainer {
}
// Pub -------------------------------------------------------------
.cellulePub {
padding: 0px 10px 0px 10px;
width: 100%;
text-align: center;
justify-content: center;
}
.conteneurPub {
height: 85vh;
text-align: center;
justify-content: center;
vertical-align: middle;
display: block;
width: 75%;
margin-left: auto;
margin-right: auto;
position: absolute;
top: 50%;
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}

View file

@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { PageMyPlaylistsComponent } from './page-my-playlists.component';
describe('PageMesPlaylistsComponent', () => {
let component: PageMyPlaylistsComponent;
let fixture: ComponentFixture<PageMyPlaylistsComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ PageMyPlaylistsComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(PageMyPlaylistsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View file

@ -0,0 +1,52 @@
import { Component, OnInit } from '@angular/core';
import {ThemeService} from "../../../utils/services/theme/theme.service";
import {Advert} from "../../../utils/interfaces/advert";
import {FictitiousDatasService} from "../../../utils/services/fictitiousDatas/fictitious-datas.service";
import {MessageService} from "../../../utils/services/message/message.service";
import {Playlist} from "../../../utils/interfaces/playlist";
@Component({
selector: 'app-page-my-playlists',
templateUrl: './page-my-playlists.component.html',
styleUrls: ['./page-my-playlists.component.scss']
})
export class PageMyPlaylistsComponent implements OnInit
{
allPlaylists: Playlist[]; // toutes les playlists
ad: Advert; // pub
playlist: Playlist; // la playlist sélectionnée
constructor( public themeService: ThemeService,
private messageService: MessageService,
private fictitioousData: FictitiousDatasService ) { }
ngOnInit(): void
{
// --- FAUX CODE ---
this.allPlaylists = this.fictitioousData.getTabPlaylist(10, 10);
this.ad = this.fictitioousData.getAdvert();
// --- VRAI CODE ---
/*
this.messageService
.sendMessage("user/get/playlists", null)
.subscribe( retour => {
if(retour.status === "error") console.log(retour.data);
else {
this.tabPlaylists = retour.data.playlists;
this.ad = retour.data.ad;
}
})
*/
}
transmitToVideoList(playlist: Playlist): void
{
this.playlist = playlist;
}
}

View file

@ -0,0 +1,36 @@
<div [class]="themeService.getClassTheme()">
<div class="myContainer">
<!-- Search bar -->
<div class="row" style="margin: 0px">
<div class="searchBarContainer">
<input type="search" placeholder="recherche..." class="inputSearchBar" [(ngModel)]="search" (ngModelChange)="whileSearch()"> &nbsp;
<!--
<button class="btnRechercher" (click)="onSearch()"> Rechercher </button>
-->
</div>
</div>
<!-- Liste des playlist -->
<div class="row" style="margin: 0px">
<div class="playlistListContainer">
<div *ngFor="let playlist of tabPlaylist" class="playlistContainer">
<button class="btnPlaylist" (click)="eventEmitter.emit(playlist)">
<span class="playlistName"> {{playlist.name}} </span><br>
<span class="playListCount"> {{playlist.videos.length}} vidéos </span>
</button>
</div>
</div>
</div>
<!-- Bouton creer playlist-->
<div class="row" style="margin: 0px">
<div class="btnCreerPlaylistContainer">
<button class="btnCreerPlaylist" (click)="onCreatePlaylist()"> Creer playlist </button>
</div>
</div>
</div>
</div>

View file

@ -0,0 +1,75 @@
.myContainer {
background-color: white ;
text-align: center;
width: 35vw;
height: 79vh;
margin: 3vh 0vh 3vh 0vh;
padding: 0px;
border: solid 2px black;
}
// SearchBar -----------------------------------------------------------
.searchBarContainer {
background-color: #dcdcdc;
border-bottom: solid 2px black;
height: 5vh;
padding: 15px;
}
.inputSearchBar {
width: 50%;
}
.btnRechercher {
border: solid black 1px;
border-radius: 5px;
}
// Liste des playlists -------------------------------------------------
.playlistListContainer {
max-width: 100%;
height: 70vh;
overflow-y: scroll;
padding: 0px;
}
.playlistContainer {
max-width: 100%;
padding: 0px;
}
.btnPlaylist {
background-color: white;
padding: 20px;
border-bottom: solid 2px black;
width: 100%;
}
.btnPlaylist:hover {
background-color: #f0f0f0;
}
.playListCount {
color: gray;
font-style: italic;
}
// Bouton creer playlist -------------------------------------------------
.btnCreerPlaylistContainer {
height: 4vh;
margin: 0px;
padding: 0px;
}
.btnCreerPlaylist {
background-color: #dcdcdc;
border-top: solid 2px black;
border-bottom: solid 2px black;
height: 100%;
width: 100%;
padding: 10px;
}
.btnCreerPlaylist:hover {
background-color: #969696;
}

View file

@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { PlaylistListComponent } from './playlist-list.component';
describe('PlaylistListComponent', () => {
let component: PlaylistListComponent;
let fixture: ComponentFixture<PlaylistListComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ PlaylistListComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(PlaylistListComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View file

@ -0,0 +1,67 @@
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
import {ThemeService} from "../../../utils/services/theme/theme.service";
import {Playlist} from "../../../utils/interfaces/playlist";
import {MessageService} from "../../../utils/services/message/message.service";
import {MatDialog} from "@angular/material/dialog";
import {PopupAddVideoToPlaylistsComponent} from "../../../utils/components/popup-add-video-to-playlists/popup-add-video-to-playlists.component";
import {MatSnackBar} from "@angular/material/snack-bar";
import {PopupCreatePlaylistComponent} from "../../../utils/components/popup-create-playlist/popup-create-playlist.component";
@Component({
selector: 'app-playlist-list',
templateUrl: './playlist-list.component.html',
styleUrls: ['./playlist-list.component.scss']
})
export class PlaylistListComponent implements OnInit
{
@Input() allPlaylists: Playlist[] = []; // toutes les playlists
@Output() eventEmitter = new EventEmitter<Playlist>(); // pour envoyer au parent la playlist selectionner
search: string = "" ; // contenu de la barre de recherche
tabPlaylist: Playlist[] = []; // playlist affichées
constructor( public themeService: ThemeService,
public dialog: MatDialog,
public snackBar: MatSnackBar ) { }
ngOnInit(): void
{
this.tabPlaylist = [].concat(this.allPlaylists);
}
whileSearch()
{
console.log("whileSearch");
this.tabPlaylist = [];
for(let playlist of this.allPlaylists)
{
if(playlist.name.includes(this.search)) this.tabPlaylist.push(playlist);
}
}
onCreatePlaylist(): void
{
const config = { width: '15%', data: this.tabPlaylist };
this.dialog
.open(PopupCreatePlaylistComponent, config )
.afterClosed()
.subscribe(playlist => {
const config = { duration: 1000, panelClass: "custom-class" };
if((playlist === null) || (playlist === undefined)) {
this.snackBar.open("Opération annulée ❌", "", config);
}
else {
this.allPlaylists.push(playlist);
this.tabPlaylist.push(playlist);
this.snackBar.open("La playlist a bien été créée ✔", "", config);
}
});
}
}

View file

@ -0,0 +1,74 @@
<div [class]="themeService.getClassTheme()">
<div class="myContainer">
<!-- Bordure haute -->
<div class="row" style="margin: 0px; padding: 0px">
<div class="topBorder">
<!-- Playlist existe ? -->
<div *ngIf="(playlist !== null) && (playlist !== undefined); then ok1 else nope1"></div>
<!-- oui -->
<ng-template #ok1>
<span class="spanPlayListTitle"> {{playlist.name}} </span>
</ng-template>
<!-- non -->
<ng-template #nope1>
<span class="spanPlayListTitle"> Aucune playlist selectionnée </span>
</ng-template>
</div>
</div>
<!-- --------------------------------------------------------------------------------------------------------------------- -->
<!-- Liste des videos -->
<div class="row" style="margin: 0px; padding: 0px">
<div class="listVideoContainer">
<!-- Playlist existe ? -->
<div *ngIf="(playlist !== null) && (playlist !== undefined); then ok2 else nope2"></div>
<!-- oui -->
<ng-template #ok2>
<div *ngFor="let video of playlist.videos ; let i = index" class="videoContainer">
<!-- bouton add -->
<button mat-icon-button (click)="onAdd(video)">
<mat-icon > add_circle </mat-icon>
</button>
<!-- video -->
<iframe appIframeTracker
[src]=videoUrlService.safeUrl(this.video.url)
allowfullscreen
(iframeClick)="onIframeClick(this.video.url)"></iframe>
<!-- bouton delete -->
<button mat-icon-button (click)="onDelete(video, i)">
<mat-icon>delete</mat-icon>
</button><br/>
<!-- titre video -->
<span>{{video.title}}</span>
</div>
</ng-template>
<!-- non -->
<ng-template #nope2>
<div></div>
</ng-template>
</div>
</div>
<!-- --------------------------------------------------------------------------------------------------------------------- -->
<!-- Bordure basse -->
<div class="row" style="margin: 0px; padding: 0px">
<div class="bottomBorder"></div>
</div>
</div>
</div>

View file

@ -0,0 +1,52 @@
.myContainer {
background-color: white ;
text-align: center;
width: 35vw;
height: 79vh;
margin: 3vh 0vh 3vh 0vh;
padding: 0px;
border: solid 1px black;
}
// TopBorder --------------------------------------------------------
.topBorder {
height: 4vh;
background-color: #dcdcdc;
text-align: left;
padding: 7px;
display: inline-block;
border-bottom: solid 1px black;
}
.spanPlayListTitle {
height: 100%;
padding: 0px;
font-size: x-large;
font-weight: bold;
}
// Liste des videos ------------------------------------------------
.listVideoContainer {
height: 73vh;
background-color: white;
padding: 0px;
overflow-y: scroll;
}
.videoContainer {
border-bottom: solid 2px black;
padding: 25px;
}
// BottomBorder --------------------------------------------------------
.bottomBorder {
height: 2vh;
background-color: #dcdcdc;
border-top: solid 1px black;
border-bottom: solid 1px black;
}

View file

@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { VideoListComponent } from './video-list.component';
describe('VideoListComponent', () => {
let component: VideoListComponent;
let fixture: ComponentFixture<VideoListComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ VideoListComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(VideoListComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View file

@ -0,0 +1,69 @@
import {Component, Input, OnInit} from '@angular/core';
import {ThemeService} from "../../../utils/services/theme/theme.service";
import {FictitiousDatasService} from "../../../utils/services/fictitiousDatas/fictitious-datas.service";
import {Video} from "../../../utils/interfaces/video";
import {VideoUrlService} from "../../../utils/services/videoUrl/video-url.service";
import {AddVideoToPlaylistsService} from "../../../utils/services/addVideoToPlaylists/add-video-to-playlists.service";
import {MessageService} from "../../../utils/services/message/message.service";
import {Playlist} from "../../../utils/interfaces/playlist";
import {MatSnackBar} from "@angular/material/snack-bar";
@Component({
selector: 'app-video-list',
templateUrl: './video-list.component.html',
styleUrls: ['./video-list.component.scss']
})
export class VideoListComponent
{
@Input() playlist: Playlist;
constructor( private messageService: MessageService,
public themeService: ThemeService,
private fictitiousDatasService: FictitiousDatasService,
public videoUrlService: VideoUrlService,
private addVideoToPlaylistService: AddVideoToPlaylistsService,
private snackBar: MatSnackBar ) { }
onAdd(video: Video): void
{
this.addVideoToPlaylistService.run(video);
}
onDelete(video0: Video, indexVideo: number): void
{
// --- FAUX CODE ---
let message = "La video a bien été supprimé de la playlist" ;
this.playlist.videos.splice(indexVideo, 1);
const config = { duration: 1000, panelClass: "custom-class" };
this.snackBar.open( message, "", config);
// --- VRAI CODE ---
/*
this.messageService
.sendMessage("user/delete/video", {video: video0, playlist: this.playlist})
.subscribe( retour => {
let message = "" ;
if(retour.status === "error") message = "Echec de l'opération" ;
else {
message = "La video a bien été supprimé de la playlist" ;
this.playlist.videos.splice(index, 1);
}
const config = { duration: 1000, panelClass: "custom-class" };
this.snackBar.open( message, "", config);
})
*/
}
onIframeClick(videoUrl: string): void
{
console.log(videoUrl)
}
}

View file

@ -1,5 +1,5 @@
<div [class]="themeService.getClassTheme()">
<div class="conteneur">
<div class="myContainer">
<!-- Navbar -->
<div style="margin-bottom: 50px">

View file

@ -6,8 +6,7 @@
color: white;
border-color: white;
}
.conteneur {
.myContainer {
text-align: center;
max-width: 100vw;
height: 100vh;