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 | |
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')
5 files changed, 118 insertions, 96 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 |
diff --git a/client/src/app/shared/shared-main/video/video.service.ts b/client/src/app/shared/shared-main/video/video.service.ts index b7c563dca..6edcc3fe0 100644 --- a/client/src/app/shared/shared-main/video/video.service.ts +++ b/client/src/app/shared/shared-main/video/video.service.ts | |||
@@ -3,9 +3,8 @@ import { from, Observable } from 'rxjs' | |||
3 | import { catchError, concatMap, map, switchMap, toArray } from 'rxjs/operators' | 3 | import { catchError, concatMap, map, switchMap, toArray } from 'rxjs/operators' |
4 | import { HttpClient, HttpParams, HttpRequest } from '@angular/common/http' | 4 | import { HttpClient, HttpParams, HttpRequest } from '@angular/common/http' |
5 | import { Injectable } from '@angular/core' | 5 | import { Injectable } from '@angular/core' |
6 | import { ComponentPaginationLight, RestExtractor, RestPagination, RestService, ServerService, UserService } from '@app/core' | 6 | import { ComponentPaginationLight, RestExtractor, RestService, ServerService, UserService } from '@app/core' |
7 | import { objectToFormData } from '@app/helpers' | 7 | import { objectToFormData } from '@app/helpers' |
8 | import { AdvancedInputFilter } from '@app/shared/shared-forms' | ||
9 | import { | 8 | import { |
10 | BooleanBothQuery, | 9 | BooleanBothQuery, |
11 | FeedFormat, | 10 | FeedFormat, |
@@ -204,27 +203,6 @@ export class VideoService { | |||
204 | ) | 203 | ) |
205 | } | 204 | } |
206 | 205 | ||
207 | getAdminVideos ( | ||
208 | options: CommonVideoParams & { pagination: RestPagination, search?: string } | ||
209 | ): Observable<ResultList<Video>> { | ||
210 | const { pagination, search } = options | ||
211 | |||
212 | let params = new HttpParams() | ||
213 | params = this.buildCommonVideosParams({ params, ...options }) | ||
214 | |||
215 | params = params.set('start', pagination.start.toString()) | ||
216 | .set('count', pagination.count.toString()) | ||
217 | |||
218 | params = this.buildAdminParamsFromSearch(search, params) | ||
219 | |||
220 | return this.authHttp | ||
221 | .get<ResultList<Video>>(VideoService.BASE_VIDEO_URL, { params }) | ||
222 | .pipe( | ||
223 | switchMap(res => this.extractVideos(res)), | ||
224 | catchError(err => this.restExtractor.handleError(err)) | ||
225 | ) | ||
226 | } | ||
227 | |||
228 | getVideos (parameters: CommonVideoParams): Observable<ResultList<Video>> { | 206 | getVideos (parameters: CommonVideoParams): Observable<ResultList<Video>> { |
229 | let params = new HttpParams() | 207 | let params = new HttpParams() |
230 | params = this.buildCommonVideosParams({ params, ...parameters }) | 208 | params = this.buildCommonVideosParams({ params, ...parameters }) |
@@ -405,21 +383,7 @@ export class VideoService { | |||
405 | : 'both' | 383 | : 'both' |
406 | } | 384 | } |
407 | 385 | ||
408 | private setVideoRate (id: number, rateType: UserVideoRateType) { | 386 | buildCommonVideosParams (options: CommonVideoParams & { params: HttpParams }) { |
409 | const url = `${VideoService.BASE_VIDEO_URL}/${id}/rate` | ||
410 | const body: UserVideoRateUpdate = { | ||
411 | rating: rateType | ||
412 | } | ||
413 | |||
414 | return this.authHttp | ||
415 | .put(url, body) | ||
416 | .pipe( | ||
417 | map(this.restExtractor.extractDataBool), | ||
418 | catchError(err => this.restExtractor.handleError(err)) | ||
419 | ) | ||
420 | } | ||
421 | |||
422 | private buildCommonVideosParams (options: CommonVideoParams & { params: HttpParams }) { | ||
423 | const { | 387 | const { |
424 | params, | 388 | params, |
425 | videoPagination, | 389 | videoPagination, |
@@ -453,60 +417,17 @@ export class VideoService { | |||
453 | return newParams | 417 | return newParams |
454 | } | 418 | } |
455 | 419 | ||
456 | buildAdminInputFilter (): AdvancedInputFilter[] { | 420 | private setVideoRate (id: number, rateType: UserVideoRateType) { |
457 | return [ | 421 | const url = `${VideoService.BASE_VIDEO_URL}/${id}/rate` |
458 | { | 422 | const body: UserVideoRateUpdate = { |
459 | title: $localize`Videos scope`, | 423 | rating: rateType |
460 | children: [ | ||
461 | { | ||
462 | queryParams: { search: 'isLocal:false' }, | ||
463 | label: $localize`Remote videos` | ||
464 | }, | ||
465 | { | ||
466 | queryParams: { search: 'isLocal:true' }, | ||
467 | label: $localize`Local videos` | ||
468 | } | ||
469 | ] | ||
470 | }, | ||
471 | |||
472 | { | ||
473 | title: $localize`Include/Exclude`, | ||
474 | children: [ | ||
475 | { | ||
476 | queryParams: { search: 'excludeMuted' }, | ||
477 | label: $localize`Exclude muted accounts` | ||
478 | } | ||
479 | ] | ||
480 | } | ||
481 | ] | ||
482 | } | ||
483 | |||
484 | private buildAdminParamsFromSearch (search: string, params: HttpParams) { | ||
485 | let include = VideoInclude.BLACKLISTED | | ||
486 | VideoInclude.BLOCKED_OWNER | | ||
487 | VideoInclude.HIDDEN_PRIVACY | | ||
488 | VideoInclude.NOT_PUBLISHED_STATE | | ||
489 | VideoInclude.FILES | ||
490 | |||
491 | if (!search) return this.restService.addObjectParams(params, { include }) | ||
492 | |||
493 | const filters = this.restService.parseQueryStringFilter(search, { | ||
494 | isLocal: { | ||
495 | prefix: 'isLocal:', | ||
496 | isBoolean: true | ||
497 | }, | ||
498 | excludeMuted: { | ||
499 | prefix: 'excludeMuted', | ||
500 | handler: () => true | ||
501 | } | ||
502 | }) | ||
503 | |||
504 | if (filters.excludeMuted) { | ||
505 | include &= ~VideoInclude.BLOCKED_OWNER | ||
506 | |||
507 | filters.excludeMuted = undefined | ||
508 | } | 424 | } |
509 | 425 | ||
510 | return this.restService.addObjectParams(params, { ...filters, include }) | 426 | return this.authHttp |
427 | .put(url, body) | ||
428 | .pipe( | ||
429 | map(this.restExtractor.extractDataBool), | ||
430 | catchError(err => this.restExtractor.handleError(err)) | ||
431 | ) | ||
511 | } | 432 | } |
512 | } | 433 | } |