1 import { Component, OnDestroy, OnInit } from '@angular/core'
2 import { Notifier } from '@app/core'
3 import { AuthService } from '../../core/auth'
4 import { ConfirmService } from '../../core/confirm'
5 import { ComponentPagination } from '@app/shared/rest/component-pagination.model'
6 import { Video } from '@app/shared/video/video.model'
7 import { Subscription } from 'rxjs'
8 import { ActivatedRoute } from '@angular/router'
9 import { VideoService } from '@app/shared/video/video.service'
12 selector: 'my-account-video-playlist-elements',
13 templateUrl: './my-account-video-playlist-elements.component.html',
14 styleUrls: [ './my-account-video-playlist-elements.component.scss' ]
16 export class MyAccountVideoPlaylistElementsComponent implements OnInit, OnDestroy {
19 pagination: ComponentPagination = {
25 private videoPlaylistId: string | number
26 private paramsSub: Subscription
29 private authService: AuthService,
30 private notifier: Notifier,
31 private confirmService: ConfirmService,
32 private route: ActivatedRoute,
33 private videoService: VideoService
37 this.paramsSub = this.route.params.subscribe(routeParams => {
38 this.videoPlaylistId = routeParams[ 'videoPlaylistId' ]
44 if (this.paramsSub) this.paramsSub.unsubscribe()
49 if (this.pagination.totalItems <= (this.pagination.currentPage * this.pagination.itemsPerPage)) return
51 this.pagination.currentPage += 1
55 private loadElements () {
56 this.videoService.getPlaylistVideos(this.videoPlaylistId, this.pagination)
57 .subscribe(({ totalVideos, videos }) => {
58 this.videos = this.videos.concat(videos)
59 this.pagination.totalItems = totalVideos