diff options
author | Chocobozzz <me@florianbigard.com> | 2018-08-13 16:57:13 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-08-14 09:27:18 +0200 |
commit | 26b7305a232e547709f433a6edf700bf495935d8 (patch) | |
tree | b5676090c61df72f864735bcc881d5ee256cffbd /client/src/app/videos/+video-watch/modal/video-blacklist.component.ts | |
parent | efc9e8450a8bbeeef9cd18e3ad6037abc0f815c3 (diff) | |
download | PeerTube-26b7305a232e547709f433a6edf700bf495935d8.tar.gz PeerTube-26b7305a232e547709f433a6edf700bf495935d8.tar.zst PeerTube-26b7305a232e547709f433a6edf700bf495935d8.zip |
Add blacklist reason field
Diffstat (limited to 'client/src/app/videos/+video-watch/modal/video-blacklist.component.ts')
-rw-r--r-- | client/src/app/videos/+video-watch/modal/video-blacklist.component.ts | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/client/src/app/videos/+video-watch/modal/video-blacklist.component.ts b/client/src/app/videos/+video-watch/modal/video-blacklist.component.ts new file mode 100644 index 000000000..2c123ebed --- /dev/null +++ b/client/src/app/videos/+video-watch/modal/video-blacklist.component.ts | |||
@@ -0,0 +1,66 @@ | |||
1 | import { Component, Input, OnInit, ViewChild } from '@angular/core' | ||
2 | import { NotificationsService } from 'angular2-notifications' | ||
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' | ||
9 | import { RedirectService } from '@app/core' | ||
10 | |||
11 | @Component({ | ||
12 | selector: 'my-video-blacklist', | ||
13 | templateUrl: './video-blacklist.component.html', | ||
14 | styleUrls: [ './video-blacklist.component.scss' ] | ||
15 | }) | ||
16 | export class VideoBlacklistComponent extends FormReactive implements OnInit { | ||
17 | @Input() video: VideoDetails = null | ||
18 | |||
19 | @ViewChild('modal') modal: NgbModal | ||
20 | |||
21 | error: string = null | ||
22 | |||
23 | private openedModal: NgbModalRef | ||
24 | |||
25 | constructor ( | ||
26 | protected formValidatorService: FormValidatorService, | ||
27 | private modalService: NgbModal, | ||
28 | private videoBlacklistValidatorsService: VideoBlacklistValidatorsService, | ||
29 | private videoBlacklistService: VideoBlacklistService, | ||
30 | private notificationsService: NotificationsService, | ||
31 | private redirectService: RedirectService, | ||
32 | private i18n: I18n | ||
33 | ) { | ||
34 | super() | ||
35 | } | ||
36 | |||
37 | ngOnInit () { | ||
38 | this.buildForm({ | ||
39 | reason: this.videoBlacklistValidatorsService.VIDEO_BLACKLIST_REASON | ||
40 | }) | ||
41 | } | ||
42 | |||
43 | show () { | ||
44 | this.openedModal = this.modalService.open(this.modal, { keyboard: false }) | ||
45 | } | ||
46 | |||
47 | hide () { | ||
48 | this.openedModal.close() | ||
49 | this.openedModal = null | ||
50 | } | ||
51 | |||
52 | blacklist () { | ||
53 | const reason = this.form.value[ 'reason' ] || undefined | ||
54 | |||
55 | this.videoBlacklistService.blacklistVideo(this.video.id, reason) | ||
56 | .subscribe( | ||
57 | () => { | ||
58 | this.notificationsService.success(this.i18n('Success'), this.i18n('Video blacklisted.')) | ||
59 | this.hide() | ||
60 | this.redirectService.redirectToHomepage() | ||
61 | }, | ||
62 | |||
63 | err => this.notificationsService.error(this.i18n('Error'), err.message) | ||
64 | ) | ||
65 | } | ||
66 | } | ||