From f0a3988066f72a28bb44520af072f18d91d77dde Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 7 Mar 2019 17:06:00 +0100 Subject: Add to playlist dropdown --- .../app/+my-account/my-account-routing.module.ts | 12 +++++ ...account-notification-preferences.component.scss | 2 +- .../my-account-video-playlist-edit.component.html | 1 + ...-account-video-playlist-elements.component.html | 16 ++++++ ...-account-video-playlist-elements.component.scss | 2 + ...my-account-video-playlist-elements.component.ts | 62 ++++++++++++++++++++++ .../my-account-video-playlists.component.html | 4 +- .../my-account-video-playlists.component.ts | 17 +++--- client/src/app/+my-account/my-account.module.ts | 6 ++- 9 files changed, 111 insertions(+), 11 deletions(-) create mode 100644 client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-elements.component.html create mode 100644 client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-elements.component.scss create mode 100644 client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-elements.component.ts (limited to 'client/src/app/+my-account') diff --git a/client/src/app/+my-account/my-account-routing.module.ts b/client/src/app/+my-account/my-account-routing.module.ts index 0193afff7..3f921b13f 100644 --- a/client/src/app/+my-account/my-account-routing.module.ts +++ b/client/src/app/+my-account/my-account-routing.module.ts @@ -22,6 +22,9 @@ import { import { MyAccountVideoPlaylistUpdateComponent } from '@app/+my-account/my-account-video-playlists/my-account-video-playlist-update.component' +import { + MyAccountVideoPlaylistElementsComponent +} from '@app/+my-account/my-account-video-playlists/my-account-video-playlist-elements.component' const myAccountRoutes: Routes = [ { @@ -81,6 +84,15 @@ const myAccountRoutes: Routes = [ } } }, + { + path: 'video-playlists/:videoPlaylistId', + component: MyAccountVideoPlaylistElementsComponent, + data: { + meta: { + title: 'Playlist elements' + } + } + }, { path: 'video-playlists/create', component: MyAccountVideoPlaylistCreateComponent, diff --git a/client/src/app/+my-account/my-account-settings/my-account-notification-preferences/my-account-notification-preferences.component.scss b/client/src/app/+my-account/my-account-settings/my-account-notification-preferences/my-account-notification-preferences.component.scss index 6feb16ab1..0274f47c5 100644 --- a/client/src/app/+my-account/my-account-settings/my-account-notification-preferences/my-account-notification-preferences.component.scss +++ b/client/src/app/+my-account/my-account-settings/my-account-notification-preferences/my-account-notification-preferences.component.scss @@ -4,7 +4,7 @@ .custom-row { display: flex; align-items: center; - border-bottom: 1px solid rgba(0, 0, 0, 0.10); + border-bottom: 1px solid $separator-border-color; &:first-child { font-size: 16px; diff --git a/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-edit.component.html b/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-edit.component.html index b76488c78..5d1184218 100644 --- a/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-edit.component.html +++ b/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-edit.component.html @@ -60,5 +60,6 @@ + diff --git a/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-elements.component.html b/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-elements.component.html new file mode 100644 index 000000000..28ea7a857 --- /dev/null +++ b/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-elements.component.html @@ -0,0 +1,16 @@ +
No videos in this playlist.
+ +
+
+ + +
+
{{ video.playlistElement.position }}
+ + {{ video.name }} + + {{ video.name }} + +
+
+
diff --git a/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-elements.component.scss b/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-elements.component.scss new file mode 100644 index 000000000..5e6774739 --- /dev/null +++ b/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-elements.component.scss @@ -0,0 +1,2 @@ +@import '_variables'; +@import '_mixins'; diff --git a/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-elements.component.ts b/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-elements.component.ts new file mode 100644 index 000000000..8b70a9b1a --- /dev/null +++ b/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-elements.component.ts @@ -0,0 +1,62 @@ +import { Component, OnDestroy, OnInit } from '@angular/core' +import { Notifier } from '@app/core' +import { AuthService } from '../../core/auth' +import { ConfirmService } from '../../core/confirm' +import { ComponentPagination } from '@app/shared/rest/component-pagination.model' +import { Video } from '@app/shared/video/video.model' +import { Subscription } from 'rxjs' +import { ActivatedRoute } from '@angular/router' +import { VideoService } from '@app/shared/video/video.service' + +@Component({ + selector: 'my-account-video-playlist-elements', + templateUrl: './my-account-video-playlist-elements.component.html', + styleUrls: [ './my-account-video-playlist-elements.component.scss' ] +}) +export class MyAccountVideoPlaylistElementsComponent implements OnInit, OnDestroy { + videos: Video[] = [] + + pagination: ComponentPagination = { + currentPage: 1, + itemsPerPage: 10, + totalItems: null + } + + private videoPlaylistId: string | number + private paramsSub: Subscription + + constructor ( + private authService: AuthService, + private notifier: Notifier, + private confirmService: ConfirmService, + private route: ActivatedRoute, + private videoService: VideoService + ) {} + + ngOnInit () { + this.paramsSub = this.route.params.subscribe(routeParams => { + this.videoPlaylistId = routeParams[ 'videoPlaylistId' ] + this.loadElements() + }) + } + + ngOnDestroy () { + if (this.paramsSub) this.paramsSub.unsubscribe() + } + + onNearOfBottom () { + // Last page + if (this.pagination.totalItems <= (this.pagination.currentPage * this.pagination.itemsPerPage)) return + + this.pagination.currentPage += 1 + this.loadElements() + } + + private loadElements () { + this.videoService.getPlaylistVideos(this.videoPlaylistId, this.pagination) + .subscribe(({ totalVideos, videos }) => { + this.videos = this.videos.concat(videos) + this.pagination.totalItems = totalVideos + }) + } +} diff --git a/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlists.component.html b/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlists.component.html index ab5d9cc5a..7d1bed12a 100644 --- a/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlists.component.html +++ b/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlists.component.html @@ -5,10 +5,10 @@ -
+
- +
diff --git a/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlists.component.ts b/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlists.component.ts index 761ce90e8..e30656b92 100644 --- a/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlists.component.ts +++ b/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlists.component.ts @@ -69,17 +69,20 @@ export class MyAccountVideoPlaylistsComponent implements OnInit { return playlist.type.id === VideoPlaylistType.REGULAR } - private loadVideoPlaylists () { - this.authService.userInformationLoaded - .pipe(flatMap(() => this.videoPlaylistService.listAccountPlaylists(this.user.account))) - .subscribe(res => this.videoPlaylists = res.data) - } - - private ofNearOfBottom () { + 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.listAccountPlaylists(this.user.account, '-updatedAt'))) + .subscribe(res => { + this.videoPlaylists = this.videoPlaylists.concat(res.data) + this.pagination.totalItems = res.total + }) + } } diff --git a/client/src/app/+my-account/my-account.module.ts b/client/src/app/+my-account/my-account.module.ts index 3dbce2b92..ba8300111 100644 --- a/client/src/app/+my-account/my-account.module.ts +++ b/client/src/app/+my-account/my-account.module.ts @@ -32,6 +32,9 @@ import { MyAccountVideoPlaylistUpdateComponent } from '@app/+my-account/my-account-video-playlists/my-account-video-playlist-update.component' import { MyAccountVideoPlaylistsComponent } from '@app/+my-account/my-account-video-playlists/my-account-video-playlists.component' +import { + MyAccountVideoPlaylistElementsComponent +} from '@app/+my-account/my-account-video-playlists/my-account-video-playlist-elements.component' @NgModule({ imports: [ @@ -68,7 +71,8 @@ import { MyAccountVideoPlaylistsComponent } from '@app/+my-account/my-account-vi MyAccountVideoPlaylistCreateComponent, MyAccountVideoPlaylistUpdateComponent, - MyAccountVideoPlaylistsComponent + MyAccountVideoPlaylistsComponent, + MyAccountVideoPlaylistElementsComponent ], exports: [ -- cgit v1.2.3