]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/shared/video/modals/video-report.component.ts
Add miniature quick actions to add video to Watch later playlist
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / video / modals / video-report.component.ts
CommitLineData
df98563e 1import { Component, Input, OnInit, ViewChild } from '@angular/core'
f8b2c1b4 2import { Notifier } from '@app/core'
3a0fb65c 3import { FormReactive } from '../../../shared/forms'
4635f59d 4import { VideoDetails } from '../../../shared/video/video-details.model'
b1d40cff 5import { I18n } from '@ngx-translate/i18n-polyfill'
d18d6478 6import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
e309822b 7import { VideoAbuseValidatorsService } from '@app/shared/forms/form-validators/video-abuse-validators.service'
63347a0f
C
8import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
9import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
3a0fb65c 10import { VideoAbuseService } from '@app/shared/video-abuse'
4f8c0eb0
C
11
12@Component({
13 selector: 'my-video-report',
5f0805d3
C
14 templateUrl: './video-report.component.html',
15 styleUrls: [ './video-report.component.scss' ]
4f8c0eb0
C
16})
17export class VideoReportComponent extends FormReactive implements OnInit {
404b54e1 18 @Input() video: VideoDetails = null
4f8c0eb0 19
f36da21e 20 @ViewChild('modal', { static: true }) modal: NgbModal
4f8c0eb0 21
df98563e 22 error: string = null
4f8c0eb0 23
63347a0f
C
24 private openedModal: NgbModalRef
25
df98563e 26 constructor (
d18d6478 27 protected formValidatorService: FormValidatorService,
63347a0f 28 private modalService: NgbModal,
e309822b 29 private videoAbuseValidatorsService: VideoAbuseValidatorsService,
7ddd02c9 30 private videoAbuseService: VideoAbuseService,
f8b2c1b4 31 private notifier: Notifier,
b1d40cff
C
32 private i18n: I18n
33 ) {
df98563e 34 super()
4f8c0eb0
C
35 }
36
a1b2f876
C
37 get currentHost () {
38 return window.location.host
39 }
40
41 get originHost () {
42 if (this.isRemoteVideo()) {
43 return this.video.account.host
44 }
45
46 return ''
47 }
48
df98563e 49 ngOnInit () {
d18d6478 50 this.buildForm({
e309822b 51 reason: this.videoAbuseValidatorsService.VIDEO_ABUSE_REASON
df98563e 52 })
4f8c0eb0
C
53 }
54
df98563e 55 show () {
63347a0f 56 this.openedModal = this.modalService.open(this.modal, { keyboard: false })
4f8c0eb0
C
57 }
58
df98563e 59 hide () {
63347a0f
C
60 this.openedModal.close()
61 this.openedModal = null
4f8c0eb0
C
62 }
63
df98563e
C
64 report () {
65 const reason = this.form.value['reason']
4f8c0eb0 66
11ac88de 67 this.videoAbuseService.reportVideo(this.video.id, reason)
5769e1db
C
68 .subscribe(
69 () => {
f8b2c1b4 70 this.notifier.success(this.i18n('Video reported.'))
df98563e 71 this.hide()
5769e1db 72 },
4f8c0eb0 73
f8b2c1b4 74 err => this.notifier.error(err.message)
df98563e 75 )
4f8c0eb0 76 }
a1b2f876
C
77
78 isRemoteVideo () {
79 return !this.video.isLocal
80 }
4f8c0eb0 81}