aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/videos/+video-watch/video-report.component.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-10-09 14:28:44 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-10-09 14:28:44 +0200
commita685e25ca05f08ad1b3f7fbaccc8744727bd8d27 (patch)
treee50fbc2f260a0017113c4668c3c0f3d2fd76ab87 /client/src/app/videos/+video-watch/video-report.component.ts
parent2ed6a0aedc2d2f6b1ac2fd9a1ac137772831f713 (diff)
downloadPeerTube-a685e25ca05f08ad1b3f7fbaccc8744727bd8d27.tar.gz
PeerTube-a685e25ca05f08ad1b3f7fbaccc8744727bd8d27.tar.zst
PeerTube-a685e25ca05f08ad1b3f7fbaccc8744727bd8d27.zip
Try to optimize frontend
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.ts69
1 files changed, 69 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..d9c83a640
--- /dev/null
+++ b/client/src/app/videos/+video-watch/video-report.component.ts
@@ -0,0 +1,69 @@
1import { Component, Input, OnInit, ViewChild } from '@angular/core'
2import { FormBuilder, FormGroup } from '@angular/forms'
3
4import { ModalDirective } from 'ngx-bootstrap/modal'
5import { NotificationsService } from 'angular2-notifications'
6
7import { FormReactive, VideoAbuseService, VIDEO_ABUSE_REASON } from '../../shared'
8import { Video, VideoService } from '../shared'
9
10@Component({
11 selector: 'my-video-report',
12 templateUrl: './video-report.component.html'
13})
14export class VideoReportComponent extends FormReactive implements OnInit {
15 @Input() video: Video = null
16
17 @ViewChild('modal') modal: ModalDirective
18
19 error: string = null
20 form: FormGroup
21 formErrors = {
22 reason: ''
23 }
24 validationMessages = {
25 reason: VIDEO_ABUSE_REASON.MESSAGES
26 }
27
28 constructor (
29 private formBuilder: FormBuilder,
30 private videoAbuseService: VideoAbuseService,
31 private notificationsService: NotificationsService
32 ) {
33 super()
34 }
35
36 ngOnInit () {
37 this.buildForm()
38 }
39
40 buildForm () {
41 this.form = this.formBuilder.group({
42 reason: [ '', VIDEO_ABUSE_REASON.VALIDATORS ]
43 })
44
45 this.form.valueChanges.subscribe(data => this.onValueChanged(data))
46 }
47
48 show () {
49 this.modal.show()
50 }
51
52 hide () {
53 this.modal.hide()
54 }
55
56 report () {
57 const reason = this.form.value['reason']
58
59 this.videoAbuseService.reportVideo(this.video.id, reason)
60 .subscribe(
61 () => {
62 this.notificationsService.success('Success', 'Video reported.')
63 this.hide()
64 },
65
66 err => this.notificationsService.error('Error', err.message)
67 )
68 }
69}