1 import { Component, Input, OnInit, ViewChild } from '@angular/core'
2 import { FormBuilder, FormGroup } from '@angular/forms'
3 import { NotificationsService } from 'angular2-notifications'
4 import { ModalDirective } from 'ngx-bootstrap/modal'
5 import { FormReactive, VIDEO_ABUSE_REASON, VideoAbuseService } from '../../../shared/index'
6 import { VideoDetails } from '../../../shared/video/video-details.model'
9 selector: 'my-video-report',
10 templateUrl: './video-report.component.html',
11 styleUrls: [ './video-report.component.scss' ]
13 export class VideoReportComponent extends FormReactive implements OnInit {
14 @Input() video: VideoDetails = null
16 @ViewChild('modal') modal: ModalDirective
23 validationMessages = {
24 reason: VIDEO_ABUSE_REASON.MESSAGES
28 private formBuilder: FormBuilder,
29 private videoAbuseService: VideoAbuseService,
30 private notificationsService: NotificationsService
40 this.form = this.formBuilder.group({
41 reason: [ '', VIDEO_ABUSE_REASON.VALIDATORS ]
44 this.form.valueChanges.subscribe(data => this.onValueChanged(data))
56 const reason = this.form.value['reason']
58 this.videoAbuseService.reportVideo(this.video.id, reason)
61 this.notificationsService.success('Success', 'Video reported.')
65 err => this.notificationsService.error('Error', err.message)