From bce47964f6241ae56f61089d144b29eb9b5da6d3 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 14 Mar 2019 14:05:36 +0100 Subject: Add video channel view --- .../video-channel-playlists.component.html | 11 ++++ .../video-channel-playlists.component.scss | 9 +++ .../video-channel-playlists.component.ts | 67 ++++++++++++++++++++++ .../video-channels-routing.module.ts | 10 ++++ .../+video-channels/video-channels.component.html | 1 + .../app/+video-channels/video-channels.module.ts | 4 +- 6 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 client/src/app/+video-channels/video-channel-playlists/video-channel-playlists.component.html create mode 100644 client/src/app/+video-channels/video-channel-playlists/video-channel-playlists.component.scss create mode 100644 client/src/app/+video-channels/video-channel-playlists/video-channel-playlists.component.ts (limited to 'client/src/app/+video-channels') diff --git a/client/src/app/+video-channels/video-channel-playlists/video-channel-playlists.component.html b/client/src/app/+video-channels/video-channel-playlists/video-channel-playlists.component.html new file mode 100644 index 000000000..0d9fba375 --- /dev/null +++ b/client/src/app/+video-channels/video-channel-playlists/video-channel-playlists.component.html @@ -0,0 +1,11 @@ +
+ Created {{pagination.totalItems}} playlists +
+ +
This channel does not have playlists.
+ +
+
+ +
+
diff --git a/client/src/app/+video-channels/video-channel-playlists/video-channel-playlists.component.scss b/client/src/app/+video-channels/video-channel-playlists/video-channel-playlists.component.scss new file mode 100644 index 000000000..fe9104794 --- /dev/null +++ b/client/src/app/+video-channels/video-channel-playlists/video-channel-playlists.component.scss @@ -0,0 +1,9 @@ +.video-playlist { + display: flex; + justify-content: center; + + my-video-playlist-miniature { + margin-right: 15px; + margin-bottom: 30px; + } +} 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 @@ +import { Component, OnDestroy, OnInit } from '@angular/core' +import { AuthService } from '../../core/auth' +import { ConfirmService } from '../../core/confirm' +import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' +import { VideoChannel } from '@app/shared/video-channel/video-channel.model' +import { flatMap } from 'rxjs/operators' +import { Subscription } from 'rxjs' +import { Notifier } from '@app/core' +import { VideoPlaylist } from '@app/shared/video-playlist/video-playlist.model' +import { ComponentPagination } from '@app/shared/rest/component-pagination.model' +import { VideoPlaylistService } from '@app/shared/video-playlist/video-playlist.service' + +@Component({ + selector: 'my-video-channel-playlists', + templateUrl: './video-channel-playlists.component.html', + styleUrls: [ './video-channel-playlists.component.scss' ] +}) +export class VideoChannelPlaylistsComponent implements OnInit, OnDestroy { + videoPlaylists: VideoPlaylist[] = [] + + pagination: ComponentPagination = { + currentPage: 1, + itemsPerPage: 20, + totalItems: null + } + + private videoChannelSub: Subscription + private videoChannel: VideoChannel + + constructor ( + private authService: AuthService, + private notifier: Notifier, + private confirmService: ConfirmService, + private videoPlaylistService: VideoPlaylistService, + private videoChannelService: VideoChannelService + ) {} + + ngOnInit () { + // Parent get the video channel for us + this.videoChannelSub = this.videoChannelService.videoChannelLoaded + .subscribe(videoChannel => { + this.videoChannel = videoChannel + this.loadVideoPlaylists() + }) + } + + ngOnDestroy () { + if (this.videoChannelSub) this.videoChannelSub.unsubscribe() + } + + onNearOfBottom () { + // Last page + if (this.pagination.totalItems <= (this.pagination.currentPage * this.pagination.itemsPerPage)) return + + this.pagination.currentPage += 1 + this.loadVideoPlaylists() + } + + private loadVideoPlaylists () { + this.authService.userInformationLoaded + .pipe(flatMap(() => this.videoPlaylistService.listChannelPlaylists(this.videoChannel))) + .subscribe(res => { + this.videoPlaylists = this.videoPlaylists.concat(res.data) + this.pagination.totalItems = res.total + }) + } +} diff --git a/client/src/app/+video-channels/video-channels-routing.module.ts b/client/src/app/+video-channels/video-channels-routing.module.ts index 3ac3533d9..cedd07d39 100644 --- a/client/src/app/+video-channels/video-channels-routing.module.ts +++ b/client/src/app/+video-channels/video-channels-routing.module.ts @@ -4,6 +4,7 @@ import { MetaGuard } from '@ngx-meta/core' import { VideoChannelsComponent } from './video-channels.component' import { VideoChannelVideosComponent } from './video-channel-videos/video-channel-videos.component' import { VideoChannelAboutComponent } from './video-channel-about/video-channel-about.component' +import { VideoChannelPlaylistsComponent } from '@app/+video-channels/video-channel-playlists/video-channel-playlists.component' const videoChannelsRoutes: Routes = [ { @@ -25,6 +26,15 @@ const videoChannelsRoutes: Routes = [ } } }, + { + path: 'video-playlists', + component: VideoChannelPlaylistsComponent, + data: { + meta: { + title: 'Video channel playlists' + } + } + }, { path: 'about', component: VideoChannelAboutComponent, diff --git a/client/src/app/+video-channels/video-channels.component.html b/client/src/app/+video-channels/video-channels.component.html index c65b5713d..600b7a365 100644 --- a/client/src/app/+video-channels/video-channels.component.html +++ b/client/src/app/+video-channels/video-channels.component.html @@ -22,6 +22,7 @@ diff --git a/client/src/app/+video-channels/video-channels.module.ts b/client/src/app/+video-channels/video-channels.module.ts index a09ea6f11..6975d05b2 100644 --- a/client/src/app/+video-channels/video-channels.module.ts +++ b/client/src/app/+video-channels/video-channels.module.ts @@ -4,6 +4,7 @@ import { VideoChannelsRoutingModule } from './video-channels-routing.module' import { VideoChannelsComponent } from './video-channels.component' import { VideoChannelVideosComponent } from './video-channel-videos/video-channel-videos.component' import { VideoChannelAboutComponent } from './video-channel-about/video-channel-about.component' +import { VideoChannelPlaylistsComponent } from '@app/+video-channels/video-channel-playlists/video-channel-playlists.component' @NgModule({ imports: [ @@ -14,7 +15,8 @@ import { VideoChannelAboutComponent } from './video-channel-about/video-channel- declarations: [ VideoChannelsComponent, VideoChannelVideosComponent, - VideoChannelAboutComponent + VideoChannelAboutComponent, + VideoChannelPlaylistsComponent ], exports: [ -- cgit v1.2.3