1 import { Component, Input, OnInit, ViewChild } from '@angular/core'
2 import { Notifier } from '@app/core'
3 import { FormReactive } from '../../../shared/forms'
4 import { I18n } from '@ngx-translate/i18n-polyfill'
5 import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
6 import { VideoAbuseValidatorsService } from '@app/shared/forms/form-validators/video-abuse-validators.service'
7 import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
8 import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
9 import { VideoAbuseService } from '@app/shared/video-abuse'
10 import { Video } from '@app/shared/video/video.model'
13 selector: 'my-video-report',
14 templateUrl: './video-report.component.html',
15 styleUrls: [ './video-report.component.scss' ]
17 export class VideoReportComponent extends FormReactive implements OnInit {
18 @Input() video: Video = null
20 @ViewChild('modal', { static: true }) modal: NgbModal
24 private openedModal: NgbModalRef
27 protected formValidatorService: FormValidatorService,
28 private modalService: NgbModal,
29 private videoAbuseValidatorsService: VideoAbuseValidatorsService,
30 private videoAbuseService: VideoAbuseService,
31 private notifier: Notifier,
38 return window.location.host
42 if (this.isRemoteVideo()) {
43 return this.video.account.host
51 reason: this.videoAbuseValidatorsService.VIDEO_ABUSE_REASON
56 this.openedModal = this.modalService.open(this.modal, { centered: true, keyboard: false })
60 this.openedModal.close()
61 this.openedModal = null
65 const reason = this.form.value['reason']
67 this.videoAbuseService.reportVideo(this.video.id, reason)
70 this.notifier.success(this.i18n('Video reported.'))
74 err => this.notifier.error(err.message)
79 return !this.video.isLocal