X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fvideos%2Fvideo-watch%2Fvideo-report.component.ts;h=c4cf936ce93473371c6a79f8cf43d18d24e37430;hb=d38b82810638b9f664c9016fac2684454c273a77;hp=7bc1677abceab356c16809fe9c32db6d32fe19d5;hpb=4f8c0eb0e9356ee2782ea6eb12a92e4dc5f66127;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/videos/video-watch/video-report.component.ts b/client/src/app/videos/video-watch/video-report.component.ts index 7bc1677ab..c4cf936ce 100644 --- a/client/src/app/videos/video-watch/video-report.component.ts +++ b/client/src/app/videos/video-watch/video-report.component.ts @@ -2,8 +2,9 @@ import { Component, Input, OnInit, ViewChild } from '@angular/core'; import { FormBuilder, FormGroup } from '@angular/forms'; import { ModalDirective } from 'ng2-bootstrap/modal'; +import { NotificationsService } from 'angular2-notifications'; -import { FormReactive, VIDEO_REPORT_REASON } from '../../shared'; +import { FormReactive, VideoAbuseService, VIDEO_ABUSE_REASON } from '../../shared'; import { Video, VideoService } from '../shared'; @Component({ @@ -21,12 +22,13 @@ export class VideoReportComponent extends FormReactive implements OnInit { reason: '' }; validationMessages = { - reason: VIDEO_REPORT_REASON.MESSAGES + reason: VIDEO_ABUSE_REASON.MESSAGES }; constructor( private formBuilder: FormBuilder, - private videoService: VideoService + private videoAbuseService: VideoAbuseService, + private notificationsService: NotificationsService ) { super(); } @@ -37,7 +39,7 @@ export class VideoReportComponent extends FormReactive implements OnInit { buildForm() { this.form = this.formBuilder.group({ - reason: [ '', VIDEO_REPORT_REASON.VALIDATORS ] + reason: [ '', VIDEO_ABUSE_REASON.VALIDATORS ] }); this.form.valueChanges.subscribe(data => this.onValueChanged(data)); @@ -52,17 +54,16 @@ export class VideoReportComponent extends FormReactive implements OnInit { } report() { - const reason = this.form.value['reason'] + const reason = this.form.value['reason']; - this.videoService.reportVideo(this.video.id, reason) - .subscribe( - // TODO: move alert to beautiful notifications - ok => { - alert('Video reported.'); - this.hide(); - }, + this.videoAbuseService.reportVideo(this.video.id, reason) + .subscribe( + () => { + this.notificationsService.success('Success', 'Video reported.'); + this.hide(); + }, - err => alert(err.text) - ) + err => this.notificationsService.error('Error', err.text) + ); } }