aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/videos/video-watch/video-report.component.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-01-20 19:22:15 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-01-20 19:22:15 +0100
commit4f8c0eb0e9356ee2782ea6eb12a92e4dc5f66127 (patch)
treebcef1232a565ceaf3d43415a0b08e53e30c236d7 /client/src/app/videos/video-watch/video-report.component.ts
parent872a4c7cea861246cf84fa3686bd9d40c684535f (diff)
downloadPeerTube-4f8c0eb0e9356ee2782ea6eb12a92e4dc5f66127.tar.gz
PeerTube-4f8c0eb0e9356ee2782ea6eb12a92e4dc5f66127.tar.zst
PeerTube-4f8c0eb0e9356ee2782ea6eb12a92e4dc5f66127.zip
Client: add ability to report a video
Diffstat (limited to 'client/src/app/videos/video-watch/video-report.component.ts')
-rw-r--r--client/src/app/videos/video-watch/video-report.component.ts68
1 files changed, 68 insertions, 0 deletions
diff --git a/client/src/app/videos/video-watch/video-report.component.ts b/client/src/app/videos/video-watch/video-report.component.ts
new file mode 100644
index 000000000..7bc1677ab
--- /dev/null
+++ b/client/src/app/videos/video-watch/video-report.component.ts
@@ -0,0 +1,68 @@
1import { Component, Input, OnInit, ViewChild } from '@angular/core';
2import { FormBuilder, FormGroup } from '@angular/forms';
3
4import { ModalDirective } from 'ng2-bootstrap/modal';
5
6import { FormReactive, VIDEO_REPORT_REASON } from '../../shared';
7import { Video, VideoService } from '../shared';
8
9@Component({
10 selector: 'my-video-report',
11 templateUrl: './video-report.component.html'
12})
13export class VideoReportComponent extends FormReactive implements OnInit {
14 @Input() video: Video = null;
15
16 @ViewChild('modal') modal: ModalDirective;
17
18 error: string = null;
19 form: FormGroup;
20 formErrors = {
21 reason: ''
22 };
23 validationMessages = {
24 reason: VIDEO_REPORT_REASON.MESSAGES
25 };
26
27 constructor(
28 private formBuilder: FormBuilder,
29 private videoService: VideoService
30 ) {
31 super();
32 }
33
34 ngOnInit() {
35 this.buildForm();
36 }
37
38 buildForm() {
39 this.form = this.formBuilder.group({
40 reason: [ '', VIDEO_REPORT_REASON.VALIDATORS ]
41 });
42
43 this.form.valueChanges.subscribe(data => this.onValueChanged(data));
44 }
45
46 show() {
47 this.modal.show();
48 }
49
50 hide() {
51 this.modal.hide();
52 }
53
54 report() {
55 const reason = this.form.value['reason']
56
57 this.videoService.reportVideo(this.video.id, reason)
58 .subscribe(
59 // TODO: move alert to beautiful notifications
60 ok => {
61 alert('Video reported.');
62 this.hide();
63 },
64
65 err => alert(err.text)
66 )
67 }
68}