1 import { Component, Input, OnInit, ViewChild } from '@angular/core'
2 import { Notifier, RedirectService } from '@app/core'
3 import { FormReactive, VideoBlacklistService, VideoBlacklistValidatorsService } from '../../../shared/index'
4 import { VideoDetails } from '../../../shared/video/video-details.model'
5 import { I18n } from '@ngx-translate/i18n-polyfill'
6 import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
7 import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
8 import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
11 selector: 'my-video-blacklist',
12 templateUrl: './video-blacklist.component.html',
13 styleUrls: [ './video-blacklist.component.scss' ]
15 export class VideoBlacklistComponent extends FormReactive implements OnInit {
16 @Input() video: VideoDetails = null
18 @ViewChild('modal') modal: NgbModal
22 private openedModal: NgbModalRef
25 protected formValidatorService: FormValidatorService,
26 private modalService: NgbModal,
27 private videoBlacklistValidatorsService: VideoBlacklistValidatorsService,
28 private videoBlacklistService: VideoBlacklistService,
29 private notifier: Notifier,
30 private redirectService: RedirectService,
37 const defaultValues = { unfederate: 'true' }
40 reason: this.videoBlacklistValidatorsService.VIDEO_BLACKLIST_REASON,
46 this.openedModal = this.modalService.open(this.modal, { keyboard: false })
50 this.openedModal.close()
51 this.openedModal = null
55 const reason = this.form.value[ 'reason' ] || undefined
56 const unfederate = this.video.isLocal ? this.form.value[ 'unfederate' ] : undefined
58 this.videoBlacklistService.blacklistVideo(this.video.id, reason, unfederate)
61 this.notifier.success(this.i18n('Video blacklisted.'))
63 this.redirectService.redirectToHomepage()
66 err => this.notifier.error(err.message)