X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fvideos%2F%2Bvideo-watch%2Fmodal%2Fvideo-report.component.ts;h=911f3b4479e888b0757e324bcf17b7376fa9af51;hb=f8b2c1b4f509c037b9650cca2c5befd21f056df3;hp=050e827e7656141ae18fad55fff249d25ffae50d;hpb=4635f59d7c3fea4b97029f10886c62fdf38b2084;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/videos/+video-watch/modal/video-report.component.ts b/client/src/app/videos/+video-watch/modal/video-report.component.ts index 050e827e7..911f3b447 100644 --- a/client/src/app/videos/+video-watch/modal/video-report.component.ts +++ b/client/src/app/videos/+video-watch/modal/video-report.component.ts @@ -1,9 +1,12 @@ import { Component, Input, OnInit, ViewChild } from '@angular/core' -import { FormBuilder, FormGroup } from '@angular/forms' -import { NotificationsService } from 'angular2-notifications' -import { ModalDirective } from 'ngx-bootstrap/modal' -import { FormReactive, VIDEO_ABUSE_REASON, VideoAbuseService } from '../../../shared/index' +import { Notifier } from '@app/core' +import { FormReactive, VideoAbuseService } from '../../../shared/index' import { VideoDetails } from '../../../shared/video/video-details.model' +import { I18n } from '@ngx-translate/i18n-polyfill' +import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' +import { VideoAbuseValidatorsService } from '@app/shared/forms/form-validators/video-abuse-validators.service' +import { NgbModal } from '@ng-bootstrap/ng-bootstrap' +import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' @Component({ selector: 'my-video-report', @@ -13,43 +16,48 @@ import { VideoDetails } from '../../../shared/video/video-details.model' export class VideoReportComponent extends FormReactive implements OnInit { @Input() video: VideoDetails = null - @ViewChild('modal') modal: ModalDirective + @ViewChild('modal') modal: NgbModal error: string = null - form: FormGroup - formErrors = { - reason: '' - } - validationMessages = { - reason: VIDEO_ABUSE_REASON.MESSAGES - } + + private openedModal: NgbModalRef constructor ( - private formBuilder: FormBuilder, + protected formValidatorService: FormValidatorService, + private modalService: NgbModal, + private videoAbuseValidatorsService: VideoAbuseValidatorsService, private videoAbuseService: VideoAbuseService, - private notificationsService: NotificationsService - ) { + private notifier: Notifier, + private i18n: I18n + ) { super() } - ngOnInit () { - this.buildForm() + get currentHost () { + return window.location.host } - buildForm () { - this.form = this.formBuilder.group({ - reason: [ '', VIDEO_ABUSE_REASON.VALIDATORS ] - }) + get originHost () { + if (this.isRemoteVideo()) { + return this.video.account.host + } - this.form.valueChanges.subscribe(data => this.onValueChanged(data)) + return '' + } + + ngOnInit () { + this.buildForm({ + reason: this.videoAbuseValidatorsService.VIDEO_ABUSE_REASON + }) } show () { - this.modal.show() + this.openedModal = this.modalService.open(this.modal, { keyboard: false }) } hide () { - this.modal.hide() + this.openedModal.close() + this.openedModal = null } report () { @@ -58,11 +66,15 @@ export class VideoReportComponent extends FormReactive implements OnInit { this.videoAbuseService.reportVideo(this.video.id, reason) .subscribe( () => { - this.notificationsService.success('Success', 'Video reported.') + this.notifier.success(this.i18n('Video reported.')) this.hide() }, - err => this.notificationsService.error('Error', err.message) + err => this.notifier.error(err.message) ) } + + isRemoteVideo () { + return !this.video.isLocal + } }