]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+admin/moderation/video-abuse-list/moderation-comment-modal.component.ts
Add ListOverflow component to prevent sub-menu overflow
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / moderation / video-abuse-list / moderation-comment-modal.component.ts
CommitLineData
efc9e845 1import { Component, EventEmitter, OnInit, Output, ViewChild } from '@angular/core'
f8b2c1b4 2import { Notifier } from '@app/core'
efc9e845
C
3import { FormReactive, VideoAbuseService, VideoAbuseValidatorsService } from '../../../shared'
4import { I18n } from '@ngx-translate/i18n-polyfill'
5import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
6import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
614d1ae9 7import { FormValidatorService } from '../../../shared/forms/form-validators/form-validator.service'
efc9e845
C
8import { 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})
15export class ModerationCommentModalComponent extends FormReactive implements OnInit {
f36da21e 16 @ViewChild('modal', { static: true }) modal: NgbModal
efc9e845
C
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,
f8b2c1b4 25 private notifier: Notifier,
efc9e845
C
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
24e7916c 41 this.openedModal = this.modalService.open(this.modal, { centered: true })
efc9e845
C
42
43 this.form.patchValue({
44 moderationComment: this.abuseToComment.moderationComment
45 })
46 }
47
457bb213 48 hide () {
efc9e845
C
49 this.abuseToComment = undefined
50 this.openedModal.close()
51 this.form.reset()
52 }
53
54 async banUser () {
f8b2c1b4 55 const moderationComment: string = this.form.value[ 'moderationComment' ]
efc9e845
C
56
57 this.videoAbuseService.updateVideoAbuse(this.abuseToComment, { moderationComment })
f8b2c1b4
C
58 .subscribe(
59 () => {
60 this.notifier.success(this.i18n('Comment updated.'))
efc9e845 61
f8b2c1b4 62 this.commentUpdated.emit(moderationComment)
457bb213 63 this.hide()
f8b2c1b4 64 },
efc9e845 65
f8b2c1b4
C
66 err => this.notifier.error(err.message)
67 )
efc9e845
C
68 }
69
70}