commencement de la 'page search'
This commit is contained in:
parent
5f4ecfc7b3
commit
58d80d1a6b
47 changed files with 889 additions and 84 deletions
38
src/app/utils/components/nav-bar/nav-bar.component.html
Normal file
38
src/app/utils/components/nav-bar/nav-bar.component.html
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<!-- pour les 3 roles -->
|
||||
<div *ngIf="pour === '3roles'">
|
||||
<ul>
|
||||
<li>
|
||||
<a routerLink="/connexion" class="StreamNotFound"> StreamNotFound </a>
|
||||
</li>
|
||||
<li style="float:right; margin-right: 20px;">
|
||||
<mat-slide-toggle></mat-slide-toggle>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- pour User -->
|
||||
<div *ngIf="pour === 'user'">
|
||||
<ul>
|
||||
<li>
|
||||
<a routerLink="/search" class="StreamNotFound"> StreamNotFound </a>
|
||||
</li>
|
||||
<li class="cliquable">
|
||||
<a routerLink="/search"> Rechercher </a>
|
||||
</li>
|
||||
<li class="cliquable">
|
||||
<a routerLink="/search"> Mes playlists </a>
|
||||
</li>
|
||||
<li class="cliquable">
|
||||
<a routerLink="/search"> Historique </a>
|
||||
</li>
|
||||
<li style="float:right; margin-right: 20px;">
|
||||
<a routerLink="/search">
|
||||
<mat-icon>settings</mat-icon>
|
||||
</a>
|
||||
</li>
|
||||
<li style="float:right; margin-right: 20px;">
|
||||
<mat-slide-toggle></mat-slide-toggle>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
68
src/app/utils/components/nav-bar/nav-bar.component.scss
Normal file
68
src/app/utils/components/nav-bar/nav-bar.component.scss
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
.StreamNotFound {
|
||||
font-style: oblique;
|
||||
font-family: cursive;
|
||||
font-size: xx-large;
|
||||
}
|
||||
|
||||
|
||||
mat-icon {
|
||||
margin-top: 2px;
|
||||
font-size: xx-large;
|
||||
}
|
||||
|
||||
|
||||
mat-slide-toggle {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
|
||||
ul {
|
||||
list-style-type: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
background-color: black;
|
||||
height: 70px;
|
||||
color: white;
|
||||
}
|
||||
|
||||
|
||||
li {
|
||||
float: left;
|
||||
font-size: x-large;
|
||||
background-color: black;
|
||||
}
|
||||
|
||||
|
||||
li a {
|
||||
display: block;
|
||||
color: white;
|
||||
text-align: center;
|
||||
padding: 14px 16px;
|
||||
text-decoration: none;
|
||||
background-color: black;
|
||||
}
|
||||
|
||||
|
||||
.cliquable a:hover:not(.active) {
|
||||
background-color: #c8c8c8;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
::ng-deep .mat-slide-toggle-thumb {
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
::ng-deep .mat-slide-toggle-bar {
|
||||
background-color: #c8c8c8;
|
||||
}
|
||||
|
||||
::ng-deep .mat-slide-toggle.mat-checked:not(.mat-disabled) .mat-slide-toggle-thumb {
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
::ng-deep .mat-slide-toggle.mat-checked:not(.mat-disabled) .mat-slide-toggle-bar {
|
||||
background-color: #646464;
|
||||
}
|
||||
|
|
@ -7,7 +7,7 @@ import {Component, Input, OnInit} from '@angular/core';
|
|||
})
|
||||
export class NavBarComponent implements OnInit
|
||||
{
|
||||
@Input() complete = false;
|
||||
@Input() pour = "3roles";
|
||||
|
||||
constructor() { }
|
||||
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
<h3> Ajouter dans </h3>
|
||||
|
||||
|
||||
<mat-divider></mat-divider><!------------------------------------------------------------------------------------------------------------->
|
||||
|
||||
|
||||
<div class="conteneurPlaylists">
|
||||
<div *ngFor="let playlist of tabPlaylistAndBool" style="margin-left: 10px">
|
||||
<mat-checkbox [(ngModel)]="playlist.isSelected"> {{playlist.name}} </mat-checkbox>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<mat-divider></mat-divider><!------------------------------------------------------------------------------------------------------------->
|
||||
|
||||
|
||||
<div class="conteneurBtnCreerPlaylist" *ngIf="!goToCreatePlaylist">
|
||||
<button mat-button (click)="goToCreatePlaylist=true">
|
||||
<mat-label>Creer une playlist</mat-label>
|
||||
<mat-icon>add</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="conteneurInputNewPlaylist" *ngIf="goToCreatePlaylist">
|
||||
<mat-form-field>
|
||||
<mat-label> Nom playlist </mat-label>
|
||||
<input matInput type="text" [(ngModel)]="newPlaylistName">
|
||||
</mat-form-field>
|
||||
<button mat-icon-button (click)="goToCreatePlaylist=false">
|
||||
<mat-icon>close</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
|
||||
<mat-divider></mat-divider><!------------------------------------------------------------------------------------------------------------->
|
||||
|
||||
|
||||
<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>
|
||||
</mat-dialog-actions>
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
h3 {
|
||||
text-align: center;
|
||||
margin-bottom: 10px
|
||||
}
|
||||
|
||||
.conteneurPlaylists {
|
||||
margin-top: 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.conteneurBtnCreerPlaylist {
|
||||
margin-top: 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.conteneurInputNewPlaylist {
|
||||
margin-top: 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { PopupAddVideoToPlaylistsComponent } from './popup-add-video-to-playlists.component';
|
||||
|
||||
describe('PopupAddVideoToPlaylistsComponent', () => {
|
||||
let component: PopupAddVideoToPlaylistsComponent;
|
||||
let fixture: ComponentFixture<PopupAddVideoToPlaylistsComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ PopupAddVideoToPlaylistsComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(PopupAddVideoToPlaylistsComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
import {Component, Inject, OnInit} from '@angular/core';
|
||||
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
|
||||
import {Video} from "../../interfaces/video";
|
||||
|
||||
@Component({
|
||||
selector: 'app-popup-add-video-to-playlists',
|
||||
templateUrl: './popup-add-video-to-playlists.component.html',
|
||||
styleUrls: ['./popup-add-video-to-playlists.component.scss']
|
||||
})
|
||||
export class PopupAddVideoToPlaylistsComponent implements OnInit
|
||||
{
|
||||
video: Video;
|
||||
tabPlaylistAndBool = [];
|
||||
goToCreatePlaylist = false;
|
||||
newPlaylistName = "";
|
||||
|
||||
constructor( public dialogRef: MatDialogRef<PopupAddVideoToPlaylistsComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data ) { }
|
||||
|
||||
|
||||
ngOnInit(): void
|
||||
{
|
||||
this.video = this.data.video;
|
||||
const tabPlaylist = this.data.playlists;
|
||||
for(let playlist of tabPlaylist)
|
||||
{
|
||||
playlist["isSelected"] = false;
|
||||
this.tabPlaylistAndBool.push(playlist);
|
||||
}
|
||||
}
|
||||
|
||||
onValider(): void
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
3
src/app/utils/components/pub/pub.component.html
Normal file
3
src/app/utils/components/pub/pub.component.html
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<div class="conteneur">
|
||||
<h1> Je suis une pub </h1>
|
||||
</div>
|
||||
0
src/app/utils/components/pub/pub.component.scss
Normal file
0
src/app/utils/components/pub/pub.component.scss
Normal file
25
src/app/utils/components/pub/pub.component.spec.ts
Normal file
25
src/app/utils/components/pub/pub.component.spec.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { PubComponent } from './pub.component';
|
||||
|
||||
describe('PubComponent', () => {
|
||||
let component: PubComponent;
|
||||
let fixture: ComponentFixture<PubComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ PubComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(PubComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
19
src/app/utils/components/pub/pub.component.ts
Normal file
19
src/app/utils/components/pub/pub.component.ts
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import { Component, OnInit } from '@angular/core';
|
||||
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-pub',
|
||||
templateUrl: './pub.component.html',
|
||||
styleUrls: ['./pub.component.scss']
|
||||
})
|
||||
export class PubComponent implements OnInit
|
||||
{
|
||||
|
||||
constructor() { }
|
||||
|
||||
|
||||
ngOnInit(): void {
|
||||
}
|
||||
|
||||
}
|
||||
10
src/app/utils/interfaces/playlist.ts
Normal file
10
src/app/utils/interfaces/playlist.ts
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import {Video} from "./video";
|
||||
|
||||
export interface Playlist
|
||||
{
|
||||
_id: string,
|
||||
user: any,
|
||||
name: string,
|
||||
count: number
|
||||
videos: Video[]
|
||||
}
|
||||
8
src/app/utils/interfaces/video.ts
Normal file
8
src/app/utils/interfaces/video.ts
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
export interface Video
|
||||
{
|
||||
_id: string,
|
||||
url: string,
|
||||
title: string,
|
||||
description: string,
|
||||
views: number
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
<div *ngIf="complete">
|
||||
<ul>
|
||||
<li>
|
||||
<a routerLink="/connexion" style="color: white ; background-color: black">
|
||||
StreamNotFound
|
||||
</a>
|
||||
</li>
|
||||
<li style="float:right; margin-right: 20px;">
|
||||
<mat-slide-toggle></mat-slide-toggle>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div *ngIf="!complete">
|
||||
<ul>
|
||||
<li><a href="#home">Home</a></li>
|
||||
<li><a href="#news">News</a></li>
|
||||
<li><a href="#contact">Contact</a></li>
|
||||
<li style="float:right"><a class="active" href="#about">About</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
mat-slide-toggle {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
|
||||
ul {
|
||||
list-style-type: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
background-color: black;
|
||||
height: 70px;
|
||||
}
|
||||
|
||||
li {
|
||||
float: left;
|
||||
font-size: x-large;
|
||||
}
|
||||
|
||||
li a {
|
||||
display: block;
|
||||
color: white;
|
||||
text-align: center;
|
||||
padding: 14px 16px;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
li a:hover:not(.active) {
|
||||
background-color: #5caaff;
|
||||
}
|
||||
|
||||
.active {
|
||||
background-color: #ff0000;
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { FictitiousDatasService } from './fictitious-datas.service';
|
||||
|
||||
describe('FictitiousDatasService', () => {
|
||||
let service: FictitiousDatasService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(FictitiousDatasService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import {Video} from "../../interfaces/video";
|
||||
import {Playlist} from "../../interfaces/playlist";
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class FictitiousDatasService
|
||||
{
|
||||
constructor() { }
|
||||
|
||||
|
||||
load_pageSeach(n: number): Video[]
|
||||
{
|
||||
let tabVideo = [];
|
||||
|
||||
let url0 = "" ;
|
||||
for(let i=0 ; i<n ; i++)
|
||||
{
|
||||
if(i%3 === 0) url0 = "https://www.youtube.com/watch?v=medPORJ8KO0";
|
||||
else if(i%3 === 1) url0 = "https://youtu.be/medPORJ8KO0";
|
||||
else url0 = "https://www.dailymotion.com/video/x7ahxdn";
|
||||
const video: Video = {
|
||||
_id: i.toString(),
|
||||
url: url0,
|
||||
title: "video_" + i,
|
||||
description: "blablabla",
|
||||
views: 59,
|
||||
}
|
||||
tabVideo.push(video)
|
||||
}
|
||||
|
||||
return tabVideo;
|
||||
}
|
||||
|
||||
|
||||
getTabPlaylist()
|
||||
{
|
||||
let tabTabPlaylist: Playlist[] = [];
|
||||
|
||||
for (let i = 0; i < 4; i++)
|
||||
{
|
||||
let playlist: Playlist = {
|
||||
_id: i.toString(),
|
||||
user: null,
|
||||
name: "name_"+i.toString(),
|
||||
count: 3,
|
||||
videos: []
|
||||
}
|
||||
tabTabPlaylist.push(playlist);
|
||||
}
|
||||
|
||||
return tabTabPlaylist
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import {HttpClient} from "@angular/common/http";
|
||||
import {environment} from "../../../environments/environment";
|
||||
import {environment} from "../../../../environments/environment";
|
||||
import {Observable} from "rxjs";
|
||||
|
||||
@Injectable({
|
||||
16
src/app/utils/services/playlist/playlist.service.spec.ts
Normal file
16
src/app/utils/services/playlist/playlist.service.spec.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { PlaylistService } from './playlist.service';
|
||||
|
||||
describe('PlaylistService', () => {
|
||||
let service: PlaylistService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(PlaylistService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
60
src/app/utils/services/playlist/playlist.service.ts
Normal file
60
src/app/utils/services/playlist/playlist.service.ts
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
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 => {});
|
||||
}
|
||||
})
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
16
src/app/utils/services/videoUrl/video-url.service.spec.ts
Normal file
16
src/app/utils/services/videoUrl/video-url.service.spec.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { VideoUrlService } from './video-url.service';
|
||||
|
||||
describe('VideoUrlService', () => {
|
||||
let service: VideoUrlService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(VideoUrlService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
45
src/app/utils/services/videoUrl/video-url.service.ts
Normal file
45
src/app/utils/services/videoUrl/video-url.service.ts
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import {DomSanitizer, SafeResourceUrl} from "@angular/platform-browser";
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class VideoUrlService
|
||||
{
|
||||
|
||||
constructor(private _sanitizer: DomSanitizer) { }
|
||||
|
||||
|
||||
safeUrl(videoUrl: string): SafeResourceUrl
|
||||
{
|
||||
if(videoUrl.includes("youtu")) videoUrl = this.youtubeSafeUrl(videoUrl);
|
||||
if(videoUrl.includes("dailymotion")) videoUrl = this.daylimotionSafeUrl(videoUrl);
|
||||
return this._sanitizer.bypassSecurityTrustResourceUrl(videoUrl);
|
||||
}
|
||||
|
||||
|
||||
youtubeSafeUrl(videoUrl: string): string
|
||||
{
|
||||
if(videoUrl.includes("youtu.be"))
|
||||
{
|
||||
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");
|
||||
const tab = videoUrl.split("youtube.com/watch?v=");
|
||||
videoUrl = tab[0] + "youtube.com/embed/" + tab[1];
|
||||
}
|
||||
return videoUrl;
|
||||
}
|
||||
|
||||
|
||||
daylimotionSafeUrl(videoUrl: string): string
|
||||
{
|
||||
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