1 import { Component, Input, OnInit, ViewChild } from '@angular/core';
2 import { FormBuilder, FormGroup } from '@angular/forms';
4 import { ModalDirective } from 'ng2-bootstrap/modal';
6 import { FormReactive, VideoAbuseService, VIDEO_ABUSE_REASON } from '../../shared';
7 import { Video, VideoService } from '../shared';
10 selector: 'my-video-report',
11 templateUrl: './video-report.component.html'
13 export class VideoReportComponent extends FormReactive implements OnInit {
14 @Input() video: Video = null;
16 @ViewChild('modal') modal: ModalDirective;
23 validationMessages = {
24 reason: VIDEO_ABUSE_REASON.MESSAGES
28 private formBuilder: FormBuilder,
29 private videoAbuseService: VideoAbuseService
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)
59 // TODO: move alert to beautiful notifications
61 alert('Video reported.');
65 err => alert(err.text)