1 import { Component, Input, OnInit, ViewChild } from '@angular/core'
2 import { NotificationsService } from 'angular2-notifications'
3 import { FormReactive, VideoAbuseService } from '../../../shared/index'
4 import { VideoDetails } from '../../../shared/video/video-details.model'
5 import { I18n } from '@ngx-translate/i18n-polyfill'
6 import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
7 import { VideoAbuseValidatorsService } from '@app/shared/forms/form-validators/video-abuse-validators.service'
8 import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
9 import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
12 selector: 'my-video-report',
13 templateUrl: './video-report.component.html',
14 styleUrls: [ './video-report.component.scss' ]
16 export class VideoReportComponent extends FormReactive implements OnInit {
17 @Input() video: VideoDetails = null
19 @ViewChild('modal') modal: NgbModal
23 private openedModal: NgbModalRef
26 protected formValidatorService: FormValidatorService,
27 private modalService: NgbModal,
28 private videoAbuseValidatorsService: VideoAbuseValidatorsService,
29 private videoAbuseService: VideoAbuseService,
30 private notificationsService: NotificationsService,
38 reason: this.videoAbuseValidatorsService.VIDEO_ABUSE_REASON
43 this.openedModal = this.modalService.open(this.modal, { keyboard: false })
47 this.openedModal.close()
48 this.openedModal = null
52 const reason = this.form.value['reason']
54 this.videoAbuseService.reportVideo(this.video.id, reason)
57 this.notificationsService.success(this.i18n('Success'), this.i18n('Video reported.'))
61 err => this.notificationsService.error(this.i18n('Error'), err.message)