]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/videos/+video-watch/modal/video-report.component.ts
Blank instead of null for docker env
[github/Chocobozzz/PeerTube.git] / client / src / app / videos / +video-watch / modal / video-report.component.ts
CommitLineData
df98563e
C
1import { Component, Input, OnInit, ViewChild } from '@angular/core'
2import { FormBuilder, FormGroup } from '@angular/forms'
df98563e 3import { NotificationsService } from 'angular2-notifications'
202f6b6c 4import { ModalDirective } from 'ngx-bootstrap/modal'
4635f59d
C
5import { FormReactive, VIDEO_ABUSE_REASON, VideoAbuseService } from '../../../shared/index'
6import { VideoDetails } from '../../../shared/video/video-details.model'
b1d40cff 7import { I18n } from '@ngx-translate/i18n-polyfill'
d18d6478
C
8import { FormReactiveErrors, FormReactiveValidationMessages } from '@app/shared'
9import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
4f8c0eb0
C
10
11@Component({
12 selector: 'my-video-report',
5f0805d3
C
13 templateUrl: './video-report.component.html',
14 styleUrls: [ './video-report.component.scss' ]
4f8c0eb0
C
15})
16export class VideoReportComponent extends FormReactive implements OnInit {
404b54e1 17 @Input() video: VideoDetails = null
4f8c0eb0 18
df98563e 19 @ViewChild('modal') modal: ModalDirective
4f8c0eb0 20
df98563e 21 error: string = null
4f8c0eb0 22
df98563e 23 constructor (
d18d6478 24 protected formValidatorService: FormValidatorService,
7ddd02c9 25 private videoAbuseService: VideoAbuseService,
b1d40cff
C
26 private notificationsService: NotificationsService,
27 private i18n: I18n
28 ) {
df98563e 29 super()
4f8c0eb0
C
30 }
31
df98563e 32 ngOnInit () {
d18d6478
C
33 this.buildForm({
34 reason: VIDEO_ABUSE_REASON
df98563e 35 })
4f8c0eb0
C
36 }
37
df98563e
C
38 show () {
39 this.modal.show()
4f8c0eb0
C
40 }
41
df98563e
C
42 hide () {
43 this.modal.hide()
4f8c0eb0
C
44 }
45
df98563e
C
46 report () {
47 const reason = this.form.value['reason']
4f8c0eb0 48
11ac88de 49 this.videoAbuseService.reportVideo(this.video.id, reason)
5769e1db
C
50 .subscribe(
51 () => {
b1d40cff 52 this.notificationsService.success(this.i18n('Success'), this.i18n('Video reported.'))
df98563e 53 this.hide()
5769e1db 54 },
4f8c0eb0 55
b1d40cff 56 err => this.notificationsService.error(this.i18n('Error'), err.message)
df98563e 57 )
4f8c0eb0
C
58 }
59}