diff options
author | Chocobozzz <me@florianbigard.com> | 2018-08-14 16:38:37 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-08-14 18:01:22 +0200 |
commit | 614d1ae928ec307b708c4a3eb423797353b1df2a (patch) | |
tree | 8281785fc158073e56d31a9e1923906b72622ae2 /client/src/app/+admin/moderation/video-abuse-list/moderation-comment-modal.component.ts | |
parent | 65b247ddc75aa9f131af86dde21c8d958f7f4b39 (diff) | |
download | PeerTube-614d1ae928ec307b708c4a3eb423797353b1df2a.tar.gz PeerTube-614d1ae928ec307b708c4a3eb423797353b1df2a.tar.zst PeerTube-614d1ae928ec307b708c4a3eb423797353b1df2a.zip |
Regroup abuse and blacklisted videos inside "moderation"
Diffstat (limited to 'client/src/app/+admin/moderation/video-abuse-list/moderation-comment-modal.component.ts')
-rw-r--r-- | client/src/app/+admin/moderation/video-abuse-list/moderation-comment-modal.component.ts | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/client/src/app/+admin/moderation/video-abuse-list/moderation-comment-modal.component.ts b/client/src/app/+admin/moderation/video-abuse-list/moderation-comment-modal.component.ts new file mode 100644 index 000000000..34ab384d1 --- /dev/null +++ b/client/src/app/+admin/moderation/video-abuse-list/moderation-comment-modal.component.ts | |||
@@ -0,0 +1,73 @@ | |||
1 | import { Component, EventEmitter, OnInit, Output, ViewChild } from '@angular/core' | ||
2 | import { NotificationsService } from 'angular2-notifications' | ||
3 | import { FormReactive, VideoAbuseService, VideoAbuseValidatorsService } from '../../../shared' | ||
4 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
5 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' | ||
6 | import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' | ||
7 | import { FormValidatorService } from '../../../shared/forms/form-validators/form-validator.service' | ||
8 | import { VideoAbuse } from '../../../../../../shared/models/videos' | ||
9 | |||
10 | @Component({ | ||
11 | selector: 'my-moderation-comment-modal', | ||
12 | templateUrl: './moderation-comment-modal.component.html', | ||
13 | styleUrls: [ './moderation-comment-modal.component.scss' ] | ||
14 | }) | ||
15 | export class ModerationCommentModalComponent extends FormReactive implements OnInit { | ||
16 | @ViewChild('modal') modal: NgbModal | ||
17 | @Output() commentUpdated = new EventEmitter<string>() | ||
18 | |||
19 | private abuseToComment: VideoAbuse | ||
20 | private openedModal: NgbModalRef | ||
21 | |||
22 | constructor ( | ||
23 | protected formValidatorService: FormValidatorService, | ||
24 | private modalService: NgbModal, | ||
25 | private notificationsService: NotificationsService, | ||
26 | private videoAbuseService: VideoAbuseService, | ||
27 | private videoAbuseValidatorsService: VideoAbuseValidatorsService, | ||
28 | private i18n: I18n | ||
29 | ) { | ||
30 | super() | ||
31 | } | ||
32 | |||
33 | ngOnInit () { | ||
34 | this.buildForm({ | ||
35 | moderationComment: this.videoAbuseValidatorsService.VIDEO_ABUSE_REASON | ||
36 | }) | ||
37 | } | ||
38 | |||
39 | openModal (abuseToComment: VideoAbuse) { | ||
40 | this.abuseToComment = abuseToComment | ||
41 | this.openedModal = this.modalService.open(this.modal) | ||
42 | |||
43 | this.form.patchValue({ | ||
44 | moderationComment: this.abuseToComment.moderationComment | ||
45 | }) | ||
46 | } | ||
47 | |||
48 | hideModerationCommentModal () { | ||
49 | this.abuseToComment = undefined | ||
50 | this.openedModal.close() | ||
51 | this.form.reset() | ||
52 | } | ||
53 | |||
54 | async banUser () { | ||
55 | const moderationComment: string = this.form.value['moderationComment'] | ||
56 | |||
57 | this.videoAbuseService.updateVideoAbuse(this.abuseToComment, { moderationComment }) | ||
58 | .subscribe( | ||
59 | () => { | ||
60 | this.notificationsService.success( | ||
61 | this.i18n('Success'), | ||
62 | this.i18n('Comment updated.') | ||
63 | ) | ||
64 | |||
65 | this.commentUpdated.emit(moderationComment) | ||
66 | this.hideModerationCommentModal() | ||
67 | }, | ||
68 | |||
69 | err => this.notificationsService.error(this.i18n('Error'), err.message) | ||
70 | ) | ||
71 | } | ||
72 | |||
73 | } | ||