]>
Commit | Line | Data |
---|---|---|
df98563e | 1 | import { Component, Input, OnInit, ViewChild } from '@angular/core' |
df98563e | 2 | import { NotificationsService } from 'angular2-notifications' |
202f6b6c | 3 | import { ModalDirective } from 'ngx-bootstrap/modal' |
e309822b | 4 | import { FormReactive, VideoAbuseService } from '../../../shared/index' |
4635f59d | 5 | import { VideoDetails } from '../../../shared/video/video-details.model' |
b1d40cff | 6 | import { I18n } from '@ngx-translate/i18n-polyfill' |
d18d6478 | 7 | import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' |
e309822b | 8 | import { VideoAbuseValidatorsService } from '@app/shared/forms/form-validators/video-abuse-validators.service' |
4f8c0eb0 C |
9 | |
10 | @Component({ | |
11 | selector: 'my-video-report', | |
5f0805d3 C |
12 | templateUrl: './video-report.component.html', |
13 | styleUrls: [ './video-report.component.scss' ] | |
4f8c0eb0 C |
14 | }) |
15 | export class VideoReportComponent extends FormReactive implements OnInit { | |
404b54e1 | 16 | @Input() video: VideoDetails = null |
4f8c0eb0 | 17 | |
df98563e | 18 | @ViewChild('modal') modal: ModalDirective |
4f8c0eb0 | 19 | |
df98563e | 20 | error: string = null |
4f8c0eb0 | 21 | |
df98563e | 22 | constructor ( |
d18d6478 | 23 | protected formValidatorService: FormValidatorService, |
e309822b | 24 | private videoAbuseValidatorsService: VideoAbuseValidatorsService, |
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 | 33 | this.buildForm({ |
e309822b | 34 | reason: this.videoAbuseValidatorsService.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 | } |