aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+video-channels/video-channel-playlists/video-channel-playlists.component.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-03-14 14:05:36 +0100
committerChocobozzz <chocobozzz@cpy.re>2019-03-18 11:17:59 +0100
commitbce47964f6241ae56f61089d144b29eb9b5da6d3 (patch)
treecad0a5ef17bc7851d483969453f7b8c2e6edad57 /client/src/app/+video-channels/video-channel-playlists/video-channel-playlists.component.ts
parent2a10aab3d7634a252a2acc946974df903e6025be (diff)
downloadPeerTube-bce47964f6241ae56f61089d144b29eb9b5da6d3.tar.gz
PeerTube-bce47964f6241ae56f61089d144b29eb9b5da6d3.tar.zst
PeerTube-bce47964f6241ae56f61089d144b29eb9b5da6d3.zip
Add video channel view
Diffstat (limited to 'client/src/app/+video-channels/video-channel-playlists/video-channel-playlists.component.ts')
-rw-r--r--client/src/app/+video-channels/video-channel-playlists/video-channel-playlists.component.ts67
1 files changed, 67 insertions, 0 deletions
diff --git a/client/src/app/+video-channels/video-channel-playlists/video-channel-playlists.component.ts b/client/src/app/+video-channels/video-channel-playlists/video-channel-playlists.component.ts
new file mode 100644
index 000000000..f878a5a24
--- /dev/null
+++ b/client/src/app/+video-channels/video-channel-playlists/video-channel-playlists.component.ts
@@ -0,0 +1,67 @@
1import { Component, OnDestroy, OnInit } from '@angular/core'
2import { AuthService } from '../../core/auth'
3import { ConfirmService } from '../../core/confirm'
4import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
5import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
6import { flatMap } from 'rxjs/operators'
7import { Subscription } from 'rxjs'
8import { Notifier } from '@app/core'
9import { VideoPlaylist } from '@app/shared/video-playlist/video-playlist.model'
10import { ComponentPagination } from '@app/shared/rest/component-pagination.model'
11import { VideoPlaylistService } from '@app/shared/video-playlist/video-playlist.service'
12
13@Component({
14 selector: 'my-video-channel-playlists',
15 templateUrl: './video-channel-playlists.component.html',
16 styleUrls: [ './video-channel-playlists.component.scss' ]
17})
18export class VideoChannelPlaylistsComponent implements OnInit, OnDestroy {
19 videoPlaylists: VideoPlaylist[] = []
20
21 pagination: ComponentPagination = {
22 currentPage: 1,
23 itemsPerPage: 20,
24 totalItems: null
25 }
26
27 private videoChannelSub: Subscription
28 private videoChannel: VideoChannel
29
30 constructor (
31 private authService: AuthService,
32 private notifier: Notifier,
33 private confirmService: ConfirmService,
34 private videoPlaylistService: VideoPlaylistService,
35 private videoChannelService: VideoChannelService
36 ) {}
37
38 ngOnInit () {
39 // Parent get the video channel for us
40 this.videoChannelSub = this.videoChannelService.videoChannelLoaded
41 .subscribe(videoChannel => {
42 this.videoChannel = videoChannel
43 this.loadVideoPlaylists()
44 })
45 }
46
47 ngOnDestroy () {
48 if (this.videoChannelSub) this.videoChannelSub.unsubscribe()
49 }
50
51 onNearOfBottom () {
52 // Last page
53 if (this.pagination.totalItems <= (this.pagination.currentPage * this.pagination.itemsPerPage)) return
54
55 this.pagination.currentPage += 1
56 this.loadVideoPlaylists()
57 }
58
59 private loadVideoPlaylists () {
60 this.authService.userInformationLoaded
61 .pipe(flatMap(() => this.videoPlaylistService.listChannelPlaylists(this.videoChannel)))
62 .subscribe(res => {
63 this.videoPlaylists = this.videoPlaylists.concat(res.data)
64 this.pagination.totalItems = res.total
65 })
66 }
67}