diff options
author | Chocobozzz <me@florianbigard.com> | 2021-11-02 14:14:26 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-11-02 14:14:26 +0100 |
commit | 05ac4ac7ed5107ac8ef1d0d1f9fd5009bf29bedc (patch) | |
tree | 7607cfb6856c279b50f38e92d9060ee687719409 /client/src/app/+admin | |
parent | 047f9585dd91d7765d78522edebfb64107450512 (diff) | |
download | PeerTube-05ac4ac7ed5107ac8ef1d0d1f9fd5009bf29bedc.tar.gz PeerTube-05ac4ac7ed5107ac8ef1d0d1f9fd5009bf29bedc.tar.zst PeerTube-05ac4ac7ed5107ac8ef1d0d1f9fd5009bf29bedc.zip |
Move admin stuff in +admin
Diffstat (limited to 'client/src/app/+admin')
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 | |||
33 | import { AbuseListComponent, VideoBlockListComponent } from './moderation' | 33 | import { AbuseListComponent, VideoBlockListComponent } from './moderation' |
34 | import { InstanceAccountBlocklistComponent, InstanceServerBlocklistComponent } from './moderation/instance-blocklist' | 34 | import { InstanceAccountBlocklistComponent, InstanceServerBlocklistComponent } from './moderation/instance-blocklist' |
35 | import { VideoCommentListComponent } from './moderation/video-comment-list' | 35 | import { VideoCommentListComponent } from './moderation/video-comment-list' |
36 | import { UserCreateComponent, UserListComponent, UserPasswordComponent, UserUpdateComponent, VideoListComponent } from './overview' | 36 | import { UserCreateComponent, UserListComponent, UserPasswordComponent, UserUpdateComponent, VideoAdminService, VideoListComponent } from './overview' |
37 | import { PluginListInstalledComponent } from './plugins/plugin-list-installed/plugin-list-installed.component' | 37 | import { PluginListInstalledComponent } from './plugins/plugin-list-installed/plugin-list-installed.component' |
38 | import { PluginSearchComponent } from './plugins/plugin-search/plugin-search.component' | 38 | import { PluginSearchComponent } from './plugins/plugin-search/plugin-search.component' |
39 | import { PluginShowInstalledComponent } from './plugins/plugin-show-installed/plugin-show-installed.component' | 39 | import { 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 | }) |
122 | export class AdminModule { } | 123 | export 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 @@ | |||
1 | export * from './video-admin.service' | ||
1 | export * from './video-list.component' | 2 | export * from './video-list.component' |
2 | export * from './video.routes' | 3 | export * 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 @@ | |||
1 | import { Observable } from 'rxjs' | ||
2 | import { catchError, switchMap } from 'rxjs/operators' | ||
3 | import { HttpClient, HttpParams } from '@angular/common/http' | ||
4 | import { Injectable } from '@angular/core' | ||
5 | import { RestExtractor, RestPagination, RestService } from '@app/core' | ||
6 | import { AdvancedInputFilter } from '@app/shared/shared-forms' | ||
7 | import { CommonVideoParams, Video, VideoService } from '@app/shared/shared-main' | ||
8 | import { ResultList, VideoInclude } from '@shared/models' | ||
9 | |||
10 | @Injectable() | ||
11 | export 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' | |||
7 | import { DropdownAction, Video, VideoService } from '@app/shared/shared-main' | 7 | import { DropdownAction, Video, VideoService } from '@app/shared/shared-main' |
8 | import { VideoActionsDisplayType } from '@app/shared/shared-video-miniature' | 8 | import { VideoActionsDisplayType } from '@app/shared/shared-video-miniature' |
9 | import { UserRight, VideoPrivacy, VideoState, VideoStreamingPlaylistType } from '@shared/models' | 9 | import { UserRight, VideoPrivacy, VideoState, VideoStreamingPlaylistType } from '@shared/models' |
10 | import { 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 |