From 33f6dce136ca6e969fe374efa099bee3f2a3599d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 27 Oct 2021 11:42:05 +0200 Subject: Add videos list admin component --- client/src/app/+admin/overview/index.ts | 1 + client/src/app/+admin/overview/overview.routes.ts | 4 +- client/src/app/+admin/overview/videos/index.ts | 2 + .../overview/videos/video-list.component.html | 86 ++++++++++++++ .../overview/videos/video-list.component.scss | 10 ++ .../+admin/overview/videos/video-list.component.ts | 123 +++++++++++++++++++++ .../src/app/+admin/overview/videos/video.routes.ts | 30 +++++ 7 files changed, 255 insertions(+), 1 deletion(-) create mode 100644 client/src/app/+admin/overview/videos/index.ts create mode 100644 client/src/app/+admin/overview/videos/video-list.component.html create mode 100644 client/src/app/+admin/overview/videos/video-list.component.scss create mode 100644 client/src/app/+admin/overview/videos/video-list.component.ts create mode 100644 client/src/app/+admin/overview/videos/video.routes.ts (limited to 'client/src/app/+admin/overview') diff --git a/client/src/app/+admin/overview/index.ts b/client/src/app/+admin/overview/index.ts index b71a6a45f..a9c46893f 100644 --- a/client/src/app/+admin/overview/index.ts +++ b/client/src/app/+admin/overview/index.ts @@ -1,2 +1,3 @@ export * from './users' +export * from './videos' export * from './overview.routes' diff --git a/client/src/app/+admin/overview/overview.routes.ts b/client/src/app/+admin/overview/overview.routes.ts index cb5986072..1e6686d16 100644 --- a/client/src/app/+admin/overview/overview.routes.ts +++ b/client/src/app/+admin/overview/overview.routes.ts @@ -1,6 +1,8 @@ import { Routes } from '@angular/router' import { UsersRoutes } from './users' +import { VideosRoutes } from './videos' export const OverviewRoutes: Routes = [ - ...UsersRoutes + ...UsersRoutes, + ...VideosRoutes ] diff --git a/client/src/app/+admin/overview/videos/index.ts b/client/src/app/+admin/overview/videos/index.ts new file mode 100644 index 000000000..40c2ffe72 --- /dev/null +++ b/client/src/app/+admin/overview/videos/index.ts @@ -0,0 +1,2 @@ +export * from './video-list.component' +export * from './video.routes' diff --git a/client/src/app/+admin/overview/videos/video-list.component.html b/client/src/app/+admin/overview/videos/video-list.component.html new file mode 100644 index 000000000..1f1e9cc6e --- /dev/null +++ b/client/src/app/+admin/overview/videos/video-list.component.html @@ -0,0 +1,86 @@ +

+ + Videos +

+ + + +
+
+ + +
+ +
+ +
+ +
+
+ + + + + + + + + Video + Info + Published + + + + + + + + + + + + + + + + + + + + + + + + {{ video.privacy.label }} + NSFW + NSFW + + + + {{ video.publishedAt | date: 'short' }} + + + + + + + + + + + + +
diff --git a/client/src/app/+admin/overview/videos/video-list.component.scss b/client/src/app/+admin/overview/videos/video-list.component.scss new file mode 100644 index 000000000..fcdb457f2 --- /dev/null +++ b/client/src/app/+admin/overview/videos/video-list.component.scss @@ -0,0 +1,10 @@ +@use '_variables' as *; +@use '_mixins' as *; +my-embed { + display: block; + max-width: 500px; +} + +.badge { + @include table-badge; +} diff --git a/client/src/app/+admin/overview/videos/video-list.component.ts b/client/src/app/+admin/overview/videos/video-list.component.ts new file mode 100644 index 000000000..a445bc209 --- /dev/null +++ b/client/src/app/+admin/overview/videos/video-list.component.ts @@ -0,0 +1,123 @@ +import { SortMeta } from 'primeng/api' +import { Component, OnInit } from '@angular/core' +import { ActivatedRoute, Router } from '@angular/router' +import { AuthService, ConfirmService, Notifier, RestPagination, RestTable } from '@app/core' +import { DropdownAction, Video, VideoService } from '@app/shared/shared-main' +import { UserRight } from '@shared/models' +import { AdvancedInputFilter } from '@app/shared/shared-forms' +import { VideoActionsDisplayType } from '@app/shared/shared-video-miniature' + +@Component({ + selector: 'my-video-list', + templateUrl: './video-list.component.html', + styleUrls: [ './video-list.component.scss' ] +}) +export class VideoListComponent extends RestTable implements OnInit { + videos: Video[] = [] + + totalRecords = 0 + sort: SortMeta = { field: 'publishedAt', order: 1 } + pagination: RestPagination = { count: this.rowsPerPage, start: 0 } + + bulkVideoActions: DropdownAction[][] = [] + + selectedVideos: Video[] = [] + + inputFilters: AdvancedInputFilter[] = [ + { + title: $localize`Advanced filters`, + children: [ + { + queryParams: { search: 'local:true' }, + label: $localize`Only local videos` + } + ] + } + ] + + videoActionsOptions: VideoActionsDisplayType = { + playlist: false, + download: false, + update: true, + blacklist: true, + delete: true, + report: false, + duplicate: true, + mute: true, + liveInfo: false + } + + constructor ( + protected route: ActivatedRoute, + protected router: Router, + private confirmService: ConfirmService, + private auth: AuthService, + private notifier: Notifier, + private videoService: VideoService + ) { + super() + } + + get authUser () { + return this.auth.getUser() + } + + ngOnInit () { + this.initialize() + + this.bulkVideoActions = [ + [ + { + label: $localize`Delete`, + handler: videos => this.removeVideos(videos), + isDisplayed: () => this.authUser.hasRight(UserRight.REMOVE_ANY_VIDEO) + } + ] + ] + } + + getIdentifier () { + return 'VideoListComponent' + } + + isInSelectionMode () { + return this.selectedVideos.length !== 0 + } + + onVideoRemoved () { + this.reloadData() + } + + protected reloadData () { + this.selectedVideos = [] + + this.videoService.getAdminVideos({ + pagination: this.pagination, + sort: this.sort, + search: this.search + }).subscribe({ + next: resultList => { + this.videos = resultList.data + this.totalRecords = resultList.total + }, + + error: err => this.notifier.error(err.message) + }) + } + + private async removeVideos (videos: Video[]) { + const message = $localize`Are you sure you want to delete these ${videos.length} videos?` + const res = await this.confirmService.confirm(message, $localize`Delete`) + if (res === false) return + + this.videoService.removeVideo(videos.map(v => v.id)) + .subscribe({ + next: () => { + this.notifier.success($localize`${videos.length} videos deleted.`) + this.reloadData() + }, + + error: err => this.notifier.error(err.message) + }) + } +} diff --git a/client/src/app/+admin/overview/videos/video.routes.ts b/client/src/app/+admin/overview/videos/video.routes.ts new file mode 100644 index 000000000..984df7b82 --- /dev/null +++ b/client/src/app/+admin/overview/videos/video.routes.ts @@ -0,0 +1,30 @@ +import { Routes } from '@angular/router' +import { UserRightGuard } from '@app/core' +import { UserRight } from '@shared/models' +import { VideoListComponent } from './video-list.component' + +export const VideosRoutes: Routes = [ + { + path: 'videos', + canActivate: [ UserRightGuard ], + data: { + userRight: UserRight.SEE_ALL_VIDEOS + }, + children: [ + { + path: '', + redirectTo: 'list', + pathMatch: 'full' + }, + { + path: 'list', + component: VideoListComponent, + data: { + meta: { + title: $localize`Videos list` + } + } + } + ] + } +] -- cgit v1.2.3