This repository has been archived on 2026-05-01. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
PolyNotFound/src/app/user/myPlaylists/page-my-playlists/page-my-playlists.component.ts
2021-12-22 13:39:06 +01:00

68 lines
1.8 KiB
TypeScript

import { Component, OnInit } from '@angular/core';
import {HttpParams} from "@angular/common/http";
import {ThemeService} from "../../../utils/theme/theme.service";
import {MessageService} from "../../../utils/message/message.service";
@Component({
selector: 'app-page-my-playlists',
templateUrl: './page-my-playlists.component.html',
styleUrls: ['./page-my-playlists.component.scss']
})
export class PageMyPlaylistsComponent implements OnInit
{
ad; // pub
playlist: any; // la playlist sélectionnée
constructor( public themeService: ThemeService,
private messageService: MessageService ) { }
ngOnInit(): void
{
let params = new HttpParams();
params = params.append("quantity", 1);
this.messageService
.get("user/ad", params)
.subscribe(ret => this.adCallback(ret), err => this.adCallback(err));
}
adCallback(retour: any): void
{
if(retour.status !== "success") {
console.log(retour);
}
else {
this.ad = retour.data[0];
}
}
transmitPlaylistToVideoList(playlist): void
{
if ((playlist === null) || (playlist === undefined)) {
this.playlist = playlist;
}
else {
this.messageService
.get("playlist/findOne/" + playlist.id)
.subscribe(ret => this.afterReceivingPlaylistWithVideo(ret, playlist), err => this.afterReceivingPlaylistWithVideo(err, playlist));
}
}
afterReceivingPlaylistWithVideo(retour: any, playlist): void
{
if(retour.status !== "success") {
console.log(retour);
this.playlist = playlist;
}
else {
this.playlist = retour.data;
}
}
}