1 import { Component, Input, OnInit, ViewChild } from '@angular/core'
2 import { NotificationsService } from 'angular2-notifications'
3 import { ModalDirective } from 'ngx-bootstrap/modal'
4 import { FormReactive, VideoAbuseService } from '../../../shared/index'
5 import { VideoDetails } from '../../../shared/video/video-details.model'
6 import { I18n } from '@ngx-translate/i18n-polyfill'
7 import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
8 import { VideoAbuseValidatorsService } from '@app/shared/forms/form-validators/video-abuse-validators.service'
11 selector: 'my-video-report',
12 templateUrl: './video-report.component.html',
13 styleUrls: [ './video-report.component.scss' ]
15 export class VideoReportComponent extends FormReactive implements OnInit {
16 @Input() video: VideoDetails = null
18 @ViewChild('modal') modal: ModalDirective
23 protected formValidatorService: FormValidatorService,
24 private videoAbuseValidatorsService: VideoAbuseValidatorsService,
25 private videoAbuseService: VideoAbuseService,
26 private notificationsService: NotificationsService,
34 reason: this.videoAbuseValidatorsService.VIDEO_ABUSE_REASON
47 const reason = this.form.value['reason']
49 this.videoAbuseService.reportVideo(this.video.id, reason)
52 this.notificationsService.success(this.i18n('Success'), this.i18n('Video reported.'))
56 err => this.notificationsService.error(this.i18n('Error'), err.message)