aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-11-02 14:14:26 +0100
committerChocobozzz <me@florianbigard.com>2021-11-02 14:14:26 +0100
commit05ac4ac7ed5107ac8ef1d0d1f9fd5009bf29bedc (patch)
tree7607cfb6856c279b50f38e92d9060ee687719409 /client/src/app/+admin
parent047f9585dd91d7765d78522edebfb64107450512 (diff)
downloadPeerTube-05ac4ac7ed5107ac8ef1d0d1f9fd5009bf29bedc.tar.gz
PeerTube-05ac4ac7ed5107ac8ef1d0d1f9fd5009bf29bedc.tar.zst
PeerTube-05ac4ac7ed5107ac8ef1d0d1f9fd5009bf29bedc.zip
Move admin stuff in +admin
Diffstat (limited to 'client/src/app/+admin')
-rw-r--r--client/src/app/+admin/admin.module.ts5
-rw-r--r--client/src/app/+admin/overview/videos/index.ts1
-rw-r--r--client/src/app/+admin/overview/videos/video-admin.service.ts97
-rw-r--r--client/src/app/+admin/overview/videos/video-list.component.ts8
4 files changed, 106 insertions, 5 deletions
diff --git a/client/src/app/+admin/admin.module.ts b/client/src/app/+admin/admin.module.ts
index 0cb4d1056..3606fc6ea 100644
--- a/client/src/app/+admin/admin.module.ts
+++ b/client/src/app/+admin/admin.module.ts
@@ -33,7 +33,7 @@ import { VideoRedundancyInformationComponent } from './follows/video-redundancie
33import { AbuseListComponent, VideoBlockListComponent } from './moderation' 33import { AbuseListComponent, VideoBlockListComponent } from './moderation'
34import { InstanceAccountBlocklistComponent, InstanceServerBlocklistComponent } from './moderation/instance-blocklist' 34import { InstanceAccountBlocklistComponent, InstanceServerBlocklistComponent } from './moderation/instance-blocklist'
35import { VideoCommentListComponent } from './moderation/video-comment-list' 35import { VideoCommentListComponent } from './moderation/video-comment-list'
36import { UserCreateComponent, UserListComponent, UserPasswordComponent, UserUpdateComponent, VideoListComponent } from './overview' 36import { UserCreateComponent, UserListComponent, UserPasswordComponent, UserUpdateComponent, VideoAdminService, VideoListComponent } from './overview'
37import { PluginListInstalledComponent } from './plugins/plugin-list-installed/plugin-list-installed.component' 37import { PluginListInstalledComponent } from './plugins/plugin-list-installed/plugin-list-installed.component'
38import { PluginSearchComponent } from './plugins/plugin-search/plugin-search.component' 38import { PluginSearchComponent } from './plugins/plugin-search/plugin-search.component'
39import { PluginShowInstalledComponent } from './plugins/plugin-show-installed/plugin-show-installed.component' 39import { PluginShowInstalledComponent } from './plugins/plugin-show-installed/plugin-show-installed.component'
@@ -116,7 +116,8 @@ import { JobsComponent } from './system/jobs/jobs.component'
116 DebugService, 116 DebugService,
117 ConfigService, 117 ConfigService,
118 PluginApiService, 118 PluginApiService,
119 EditConfigurationService 119 EditConfigurationService,
120 VideoAdminService
120 ] 121 ]
121}) 122})
122export class AdminModule { } 123export class AdminModule { }
diff --git a/client/src/app/+admin/overview/videos/index.ts b/client/src/app/+admin/overview/videos/index.ts
index 40c2ffe72..7398b1663 100644
--- a/client/src/app/+admin/overview/videos/index.ts
+++ b/client/src/app/+admin/overview/videos/index.ts
@@ -1,2 +1,3 @@
1export * from './video-admin.service'
1export * from './video-list.component' 2export * from './video-list.component'
2export * from './video.routes' 3export * from './video.routes'
diff --git a/client/src/app/+admin/overview/videos/video-admin.service.ts b/client/src/app/+admin/overview/videos/video-admin.service.ts
new file mode 100644
index 000000000..696609cb2
--- /dev/null
+++ b/client/src/app/+admin/overview/videos/video-admin.service.ts
@@ -0,0 +1,97 @@
1import { Observable } from 'rxjs'
2import { catchError, switchMap } from 'rxjs/operators'
3import { HttpClient, HttpParams } from '@angular/common/http'
4import { Injectable } from '@angular/core'
5import { RestExtractor, RestPagination, RestService } from '@app/core'
6import { AdvancedInputFilter } from '@app/shared/shared-forms'
7import { CommonVideoParams, Video, VideoService } from '@app/shared/shared-main'
8import { ResultList, VideoInclude } from '@shared/models'
9
10@Injectable()
11export class VideoAdminService {
12
13 constructor (
14 private videoService: VideoService,
15 private authHttp: HttpClient,
16 private restExtractor: RestExtractor,
17 private restService: RestService
18 ) {}
19
20 getAdminVideos (
21 options: CommonVideoParams & { pagination: RestPagination, search?: string }
22 ): Observable<ResultList<Video>> {
23 const { pagination, search } = options
24
25 let params = new HttpParams()
26 params = this.videoService.buildCommonVideosParams({ params, ...options })
27
28 params = params.set('start', pagination.start.toString())
29 .set('count', pagination.count.toString())
30
31 params = this.buildAdminParamsFromSearch(search, params)
32
33 return this.authHttp
34 .get<ResultList<Video>>(VideoService.BASE_VIDEO_URL, { params })
35 .pipe(
36 switchMap(res => this.videoService.extractVideos(res)),
37 catchError(err => this.restExtractor.handleError(err))
38 )
39 }
40
41 buildAdminInputFilter (): AdvancedInputFilter[] {
42 return [
43 {
44 title: $localize`Videos scope`,
45 children: [
46 {
47 queryParams: { search: 'isLocal:false' },
48 label: $localize`Remote videos`
49 },
50 {
51 queryParams: { search: 'isLocal:true' },
52 label: $localize`Local videos`
53 }
54 ]
55 },
56
57 {
58 title: $localize`Include/Exclude`,
59 children: [
60 {
61 queryParams: { search: 'excludeMuted' },
62 label: $localize`Exclude muted accounts`
63 }
64 ]
65 }
66 ]
67 }
68
69 private buildAdminParamsFromSearch (search: string, params: HttpParams) {
70 let include = VideoInclude.BLACKLISTED |
71 VideoInclude.BLOCKED_OWNER |
72 VideoInclude.HIDDEN_PRIVACY |
73 VideoInclude.NOT_PUBLISHED_STATE |
74 VideoInclude.FILES
75
76 if (!search) return this.restService.addObjectParams(params, { include })
77
78 const filters = this.restService.parseQueryStringFilter(search, {
79 isLocal: {
80 prefix: 'isLocal:',
81 isBoolean: true
82 },
83 excludeMuted: {
84 prefix: 'excludeMuted',
85 handler: () => true
86 }
87 })
88
89 if (filters.excludeMuted) {
90 include &= ~VideoInclude.BLOCKED_OWNER
91
92 filters.excludeMuted = undefined
93 }
94
95 return this.restService.addObjectParams(params, { ...filters, include })
96 }
97}
diff --git a/client/src/app/+admin/overview/videos/video-list.component.ts b/client/src/app/+admin/overview/videos/video-list.component.ts
index 31bf1707b..b0e476569 100644
--- a/client/src/app/+admin/overview/videos/video-list.component.ts
+++ b/client/src/app/+admin/overview/videos/video-list.component.ts
@@ -7,6 +7,7 @@ import { AdvancedInputFilter } from '@app/shared/shared-forms'
7import { DropdownAction, Video, VideoService } from '@app/shared/shared-main' 7import { DropdownAction, Video, VideoService } from '@app/shared/shared-main'
8import { VideoActionsDisplayType } from '@app/shared/shared-video-miniature' 8import { VideoActionsDisplayType } from '@app/shared/shared-video-miniature'
9import { UserRight, VideoPrivacy, VideoState, VideoStreamingPlaylistType } from '@shared/models' 9import { UserRight, VideoPrivacy, VideoState, VideoStreamingPlaylistType } from '@shared/models'
10import { VideoAdminService } from './video-admin.service'
10 11
11@Component({ 12@Component({
12 selector: 'my-video-list', 13 selector: 'my-video-list',
@@ -46,7 +47,8 @@ export class VideoListComponent extends RestTable implements OnInit {
46 private confirmService: ConfirmService, 47 private confirmService: ConfirmService,
47 private auth: AuthService, 48 private auth: AuthService,
48 private notifier: Notifier, 49 private notifier: Notifier,
49 private videoService: VideoService 50 private videoService: VideoService,
51 private videoAdminService: VideoAdminService
50 ) { 52 ) {
51 super() 53 super()
52 } 54 }
@@ -58,7 +60,7 @@ export class VideoListComponent extends RestTable implements OnInit {
58 ngOnInit () { 60 ngOnInit () {
59 this.initialize() 61 this.initialize()
60 62
61 this.inputFilters = this.videoService.buildAdminInputFilter() 63 this.inputFilters = this.videoAdminService.buildAdminInputFilter()
62 64
63 this.bulkVideoActions = [ 65 this.bulkVideoActions = [
64 [ 66 [
@@ -128,7 +130,7 @@ export class VideoListComponent extends RestTable implements OnInit {
128 130
129 this.loading = true 131 this.loading = true
130 132
131 this.videoService.getAdminVideos({ 133 this.videoAdminService.getAdminVideos({
132 pagination: this.pagination, 134 pagination: this.pagination,
133 sort: this.sort, 135 sort: this.sort,
134 search: this.search 136 search: this.search