diff options
author | Josh Morel <morel.josh@hotmail.com> | 2019-04-02 05:26:47 -0400 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-04-02 11:26:47 +0200 |
commit | 7ccddd7b5250bd25a917a6e77e58b87b9484a2a4 (patch) | |
tree | e75dc991369c1768804fefa114eb2a832881087f /client/src/app/+admin/moderation/video-auto-blacklist-list/video-auto-blacklist-list.component.ts | |
parent | 12fed49ebab0c414713d57ea316b6488ae6bef99 (diff) | |
download | PeerTube-7ccddd7b5250bd25a917a6e77e58b87b9484a2a4.tar.gz PeerTube-7ccddd7b5250bd25a917a6e77e58b87b9484a2a4.tar.zst PeerTube-7ccddd7b5250bd25a917a6e77e58b87b9484a2a4.zip |
add quarantine videos feature (#1637)
* add quarantine videos feature
* increase Notification settings test timeout
to 20000ms. was completing 7000 locally but timing out
after 10000 on travis
* fix quarantine video test issues
-propagate misspelling
-remove skip from server/tests/client.ts
* WIP use blacklist for moderator video approval
instead of video.quarantine boolean
* finish auto-blacklist feature
Diffstat (limited to 'client/src/app/+admin/moderation/video-auto-blacklist-list/video-auto-blacklist-list.component.ts')
-rw-r--r-- | client/src/app/+admin/moderation/video-auto-blacklist-list/video-auto-blacklist-list.component.ts | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/client/src/app/+admin/moderation/video-auto-blacklist-list/video-auto-blacklist-list.component.ts b/client/src/app/+admin/moderation/video-auto-blacklist-list/video-auto-blacklist-list.component.ts new file mode 100644 index 000000000..b79f574c9 --- /dev/null +++ b/client/src/app/+admin/moderation/video-auto-blacklist-list/video-auto-blacklist-list.component.ts | |||
@@ -0,0 +1,100 @@ | |||
1 | import { Component, OnInit, OnDestroy } from '@angular/core' | ||
2 | import { Location } from '@angular/common' | ||
3 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
4 | import { Router, ActivatedRoute } from '@angular/router' | ||
5 | import { AbstractVideoList } from '@app/shared/video/abstract-video-list' | ||
6 | import { ComponentPagination } from '@app/shared/rest/component-pagination.model' | ||
7 | import { Notifier, AuthService } from '@app/core' | ||
8 | import { Video } from '@shared/models' | ||
9 | import { VideoBlacklistService } from '@app/shared' | ||
10 | import { immutableAssign } from '@app/shared/misc/utils' | ||
11 | import { ScreenService } from '@app/shared/misc/screen.service' | ||
12 | |||
13 | @Component({ | ||
14 | selector: 'my-video-auto-blacklist-list', | ||
15 | templateUrl: './video-auto-blacklist-list.component.html', | ||
16 | styleUrls: [ './video-auto-blacklist-list.component.scss' ] | ||
17 | }) | ||
18 | export class VideoAutoBlacklistListComponent extends AbstractVideoList implements OnInit, OnDestroy { | ||
19 | titlePage: string | ||
20 | currentRoute = '/admin/moderation/video-auto-blacklist/list' | ||
21 | checkedVideos: { [ id: number ]: boolean } = {} | ||
22 | pagination: ComponentPagination = { | ||
23 | currentPage: 1, | ||
24 | itemsPerPage: 5, | ||
25 | totalItems: null | ||
26 | } | ||
27 | |||
28 | protected baseVideoWidth = -1 | ||
29 | protected baseVideoHeight = 155 | ||
30 | |||
31 | constructor ( | ||
32 | protected router: Router, | ||
33 | protected route: ActivatedRoute, | ||
34 | protected i18n: I18n, | ||
35 | protected notifier: Notifier, | ||
36 | protected location: Location, | ||
37 | protected authService: AuthService, | ||
38 | protected screenService: ScreenService, | ||
39 | private videoBlacklistService: VideoBlacklistService, | ||
40 | ) { | ||
41 | super() | ||
42 | |||
43 | this.titlePage = this.i18n('Auto-blacklisted videos') | ||
44 | } | ||
45 | |||
46 | ngOnInit () { | ||
47 | super.ngOnInit() | ||
48 | } | ||
49 | |||
50 | ngOnDestroy () { | ||
51 | super.ngOnDestroy() | ||
52 | } | ||
53 | |||
54 | abortSelectionMode () { | ||
55 | this.checkedVideos = {} | ||
56 | } | ||
57 | |||
58 | isInSelectionMode () { | ||
59 | return Object.keys(this.checkedVideos).some(k => this.checkedVideos[k] === true) | ||
60 | } | ||
61 | |||
62 | getVideosObservable (page: number) { | ||
63 | const newPagination = immutableAssign(this.pagination, { currentPage: page }) | ||
64 | |||
65 | return this.videoBlacklistService.getAutoBlacklistedAsVideoList(newPagination) | ||
66 | } | ||
67 | |||
68 | generateSyndicationList () { | ||
69 | throw new Error('Method not implemented.') | ||
70 | } | ||
71 | |||
72 | removeVideoFromBlacklist (entry: Video) { | ||
73 | this.videoBlacklistService.removeVideoFromBlacklist(entry.id).subscribe( | ||
74 | () => { | ||
75 | this.notifier.success(this.i18n('Video {{name}} removed from blacklist.', { name: entry.name })) | ||
76 | this.reloadVideos() | ||
77 | }, | ||
78 | |||
79 | error => this.notifier.error(error.message) | ||
80 | ) | ||
81 | } | ||
82 | |||
83 | removeSelectedVideosFromBlacklist () { | ||
84 | const toReleaseVideosIds = Object.keys(this.checkedVideos) | ||
85 | .filter(k => this.checkedVideos[ k ] === true) | ||
86 | .map(k => parseInt(k, 10)) | ||
87 | |||
88 | this.videoBlacklistService.removeVideoFromBlacklist(toReleaseVideosIds).subscribe( | ||
89 | () => { | ||
90 | this.notifier.success(this.i18n('{{num}} videos removed from blacklist.', { num: toReleaseVideosIds.length })) | ||
91 | |||
92 | this.abortSelectionMode() | ||
93 | this.reloadVideos() | ||
94 | }, | ||
95 | |||
96 | error => this.notifier.error(error.message) | ||
97 | ) | ||
98 | } | ||
99 | |||
100 | } | ||