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'
6 import { VideoDetails } from '../../shared/video/video-details.model'
9 selector: 'my-video-report',
10 templateUrl: './video-report.component.html'
12 export class VideoReportComponent extends FormReactive implements OnInit {
13 @Input() video: VideoDetails = null
15 @ViewChild('modal') modal: ModalDirective
22 validationMessages = {
23 reason: VIDEO_ABUSE_REASON.MESSAGES
27 private formBuilder: FormBuilder,
28 private videoAbuseService: VideoAbuseService,
29 private notificationsService: NotificationsService
39 this.form = this.formBuilder.group({
40 reason: [ '', VIDEO_ABUSE_REASON.VALIDATORS ]
43 this.form.valueChanges.subscribe(data => this.onValueChanged(data))
55 const reason = this.form.value['reason']
57 this.videoAbuseService.reportVideo(this.video.id, reason)
60 this.notificationsService.success('Success', 'Video reported.')
64 err => this.notificationsService.error('Error', err.message)