1 import { Component, Input, OnInit, ViewChild } from '@angular/core'
2 import { FormBuilder, FormGroup } from '@angular/forms'
4 import { ModalDirective } from 'ngx-bootstrap/modal'
5 import { NotificationsService } from 'angular2-notifications'
7 import { FormReactive, VideoAbuseService, VIDEO_ABUSE_REASON } from '../../shared'
8 import { VideoDetails, VideoService } from '../shared'
11 selector: 'my-video-report',
12 templateUrl: './video-report.component.html'
14 export class VideoReportComponent extends FormReactive implements OnInit {
15 @Input() video: VideoDetails = null
17 @ViewChild('modal') modal: ModalDirective
24 validationMessages = {
25 reason: VIDEO_ABUSE_REASON.MESSAGES
29 private formBuilder: FormBuilder,
30 private videoAbuseService: VideoAbuseService,
31 private notificationsService: NotificationsService
41 this.form = this.formBuilder.group({
42 reason: [ '', VIDEO_ABUSE_REASON.VALIDATORS ]
45 this.form.valueChanges.subscribe(data => this.onValueChanged(data))
57 const reason = this.form.value['reason']
59 this.videoAbuseService.reportVideo(this.video.id, reason)
62 this.notificationsService.success('Success', 'Video reported.')
66 err => this.notificationsService.error('Error', err.message)