diff options
Diffstat (limited to 'client/src/app/videos')
7 files changed, 122 insertions, 25 deletions
diff --git a/client/src/app/videos/+video-watch/modal/video-blacklist.component.html b/client/src/app/videos/+video-watch/modal/video-blacklist.component.html new file mode 100644 index 000000000..c436501b4 --- /dev/null +++ b/client/src/app/videos/+video-watch/modal/video-blacklist.component.html | |||
@@ -0,0 +1,31 @@ | |||
1 | <ng-template #modal> | ||
2 | <div class="modal-header"> | ||
3 | <h4 i18n class="modal-title">Blacklist video</h4> | ||
4 | <span class="close" aria-label="Close" role="button" (click)="hide()"></span> | ||
5 | </div> | ||
6 | |||
7 | <div class="modal-body"> | ||
8 | |||
9 | <form novalidate [formGroup]="form" (ngSubmit)="blacklist()"> | ||
10 | <div class="form-group"> | ||
11 | <textarea i18n-placeholder placeholder="Reason..." formControlName="reason" [ngClass]="{ 'input-error': formErrors['reason'] }"> | ||
12 | </textarea> | ||
13 | <div *ngIf="formErrors.reason" class="form-error"> | ||
14 | {{ formErrors.reason }} | ||
15 | </div> | ||
16 | </div> | ||
17 | |||
18 | <div class="form-group inputs"> | ||
19 | <span i18n class="action-button action-button-cancel" (click)="hide()"> | ||
20 | Cancel | ||
21 | </span> | ||
22 | |||
23 | <input | ||
24 | type="submit" i18n-value value="Submit" class="action-button-submit" | ||
25 | [disabled]="!form.valid" | ||
26 | > | ||
27 | </div> | ||
28 | </form> | ||
29 | |||
30 | </div> | ||
31 | </ng-template> | ||
diff --git a/client/src/app/videos/+video-watch/modal/video-blacklist.component.scss b/client/src/app/videos/+video-watch/modal/video-blacklist.component.scss new file mode 100644 index 000000000..afcdb9a16 --- /dev/null +++ b/client/src/app/videos/+video-watch/modal/video-blacklist.component.scss | |||
@@ -0,0 +1,6 @@ | |||
1 | @import 'variables'; | ||
2 | @import 'mixins'; | ||
3 | |||
4 | textarea { | ||
5 | @include peertube-textarea(100%, 100px); | ||
6 | } | ||
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 | } | ||
diff --git a/client/src/app/videos/+video-watch/video-watch.component.html b/client/src/app/videos/+video-watch/video-watch.component.html index dd0d628bd..f82f1c554 100644 --- a/client/src/app/videos/+video-watch/video-watch.component.html +++ b/client/src/app/videos/+video-watch/video-watch.component.html | |||
@@ -90,16 +90,16 @@ | |||
90 | <span class="icon icon-alert"></span> <ng-container i18n>Report</ng-container> | 90 | <span class="icon icon-alert"></span> <ng-container i18n>Report</ng-container> |
91 | </a> | 91 | </a> |
92 | 92 | ||
93 | <a *ngIf="isVideoBlacklistable()" class="dropdown-item" i18n-title title="Blacklist this video" href="#" (click)="blacklistVideo($event)"> | ||
94 | <span class="icon icon-blacklist"></span> <ng-container i18n>Blacklist</ng-container> | ||
95 | </a> | ||
96 | |||
97 | <a *ngIf="isVideoUpdatable()" class="dropdown-item" i18n-title title="Update this video" href="#" [routerLink]="[ '/videos/update', video.uuid ]"> | 93 | <a *ngIf="isVideoUpdatable()" class="dropdown-item" i18n-title title="Update this video" href="#" [routerLink]="[ '/videos/update', video.uuid ]"> |
98 | <span class="icon icon-edit"></span> <ng-container i18n>Update</ng-container> | 94 | <span class="icon icon-edit"></span> <ng-container i18n>Update</ng-container> |
99 | </a> | 95 | </a> |
100 | 96 | ||
97 | <a *ngIf="isVideoBlacklistable()" class="dropdown-item" i18n-title title="Blacklist this video" href="#" (click)="showBlacklistModal($event)"> | ||
98 | <span class="icon icon-blacklist"></span> <ng-container i18n>Blacklist</ng-container> | ||
99 | </a> | ||
100 | |||
101 | <a *ngIf="isVideoRemovable()" class="dropdown-item" i18n-title title="Delete this video" href="#" (click)="removeVideo($event)"> | 101 | <a *ngIf="isVideoRemovable()" class="dropdown-item" i18n-title title="Delete this video" href="#" (click)="removeVideo($event)"> |
102 | <span class="icon icon-blacklist"></span> <ng-container i18n>Delete</ng-container> | 102 | <span class="icon icon-delete"></span> <ng-container i18n>Delete</ng-container> |
103 | </a> | 103 | </a> |
104 | </div> | 104 | </div> |
105 | </div> | 105 | </div> |
@@ -205,4 +205,5 @@ | |||
205 | <my-video-share #videoShareModal [video]="video"></my-video-share> | 205 | <my-video-share #videoShareModal [video]="video"></my-video-share> |
206 | <my-video-download #videoDownloadModal [video]="video"></my-video-download> | 206 | <my-video-download #videoDownloadModal [video]="video"></my-video-download> |
207 | <my-video-report #videoReportModal [video]="video"></my-video-report> | 207 | <my-video-report #videoReportModal [video]="video"></my-video-report> |
208 | <my-video-blacklist #videoBlacklistModal [video]="video"></my-video-blacklist> | ||
208 | </ng-template> | 209 | </ng-template> |
diff --git a/client/src/app/videos/+video-watch/video-watch.component.scss b/client/src/app/videos/+video-watch/video-watch.component.scss index 7d269b31f..e63ab7bbd 100644 --- a/client/src/app/videos/+video-watch/video-watch.component.scss +++ b/client/src/app/videos/+video-watch/video-watch.component.scss | |||
@@ -258,6 +258,10 @@ | |||
258 | &.icon-blacklist { | 258 | &.icon-blacklist { |
259 | background-image: url('../../../assets/images/video/blacklist.svg'); | 259 | background-image: url('../../../assets/images/video/blacklist.svg'); |
260 | } | 260 | } |
261 | |||
262 | &.icon-delete { | ||
263 | background-image: url('../../../assets/images/global/delete-black.svg'); | ||
264 | } | ||
261 | } | 265 | } |
262 | } | 266 | } |
263 | } | 267 | } |
diff --git a/client/src/app/videos/+video-watch/video-watch.component.ts b/client/src/app/videos/+video-watch/video-watch.component.ts index 04bcc6cd1..878655d4a 100644 --- a/client/src/app/videos/+video-watch/video-watch.component.ts +++ b/client/src/app/videos/+video-watch/video-watch.component.ts | |||
@@ -21,6 +21,7 @@ import { MarkdownService } from '../shared' | |||
21 | import { VideoDownloadComponent } from './modal/video-download.component' | 21 | import { VideoDownloadComponent } from './modal/video-download.component' |
22 | import { VideoReportComponent } from './modal/video-report.component' | 22 | import { VideoReportComponent } from './modal/video-report.component' |
23 | import { VideoShareComponent } from './modal/video-share.component' | 23 | import { VideoShareComponent } from './modal/video-share.component' |
24 | import { VideoBlacklistComponent } from './modal/video-blacklist.component' | ||
24 | import { addContextMenu, getVideojsOptions, loadLocale } from '../../../assets/player/peertube-player' | 25 | import { addContextMenu, getVideojsOptions, loadLocale } from '../../../assets/player/peertube-player' |
25 | import { ServerService } from '@app/core' | 26 | import { ServerService } from '@app/core' |
26 | import { I18n } from '@ngx-translate/i18n-polyfill' | 27 | import { I18n } from '@ngx-translate/i18n-polyfill' |
@@ -41,6 +42,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
41 | @ViewChild('videoShareModal') videoShareModal: VideoShareComponent | 42 | @ViewChild('videoShareModal') videoShareModal: VideoShareComponent |
42 | @ViewChild('videoReportModal') videoReportModal: VideoReportComponent | 43 | @ViewChild('videoReportModal') videoReportModal: VideoReportComponent |
43 | @ViewChild('videoSupportModal') videoSupportModal: VideoSupportComponent | 44 | @ViewChild('videoSupportModal') videoSupportModal: VideoSupportComponent |
45 | @ViewChild('videoBlacklistModal') videoBlacklistModal: VideoBlacklistComponent | ||
44 | 46 | ||
45 | otherVideosDisplayed: Video[] = [] | 47 | otherVideosDisplayed: Video[] = [] |
46 | 48 | ||
@@ -156,26 +158,6 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
156 | } | 158 | } |
157 | } | 159 | } |
158 | 160 | ||
159 | async blacklistVideo (event: Event) { | ||
160 | event.preventDefault() | ||
161 | |||
162 | const res = await this.confirmService.confirm(this.i18n('Do you really want to blacklist this video?'), this.i18n('Blacklist')) | ||
163 | if (res === false) return | ||
164 | |||
165 | this.videoBlacklistService.blacklistVideo(this.video.id) | ||
166 | .subscribe( | ||
167 | () => { | ||
168 | this.notificationsService.success( | ||
169 | this.i18n('Success'), | ||
170 | this.i18n('Video {{videoName}} had been blacklisted.', { videoName: this.video.name }) | ||
171 | ) | ||
172 | this.redirectService.redirectToHomepage() | ||
173 | }, | ||
174 | |||
175 | error => this.notificationsService.error(this.i18n('Error'), error.message) | ||
176 | ) | ||
177 | } | ||
178 | |||
179 | showMoreDescription () { | 161 | showMoreDescription () { |
180 | if (this.completeVideoDescription === undefined) { | 162 | if (this.completeVideoDescription === undefined) { |
181 | return this.loadCompleteDescription() | 163 | return this.loadCompleteDescription() |
@@ -230,6 +212,11 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
230 | this.videoDownloadModal.show() | 212 | this.videoDownloadModal.show() |
231 | } | 213 | } |
232 | 214 | ||
215 | showBlacklistModal (event: Event) { | ||
216 | event.preventDefault() | ||
217 | this.videoBlacklistModal.show() | ||
218 | } | ||
219 | |||
233 | isUserLoggedIn () { | 220 | isUserLoggedIn () { |
234 | return this.authService.isLoggedIn() | 221 | return this.authService.isLoggedIn() |
235 | } | 222 | } |
diff --git a/client/src/app/videos/+video-watch/video-watch.module.ts b/client/src/app/videos/+video-watch/video-watch.module.ts index 09d5133e4..7730919fe 100644 --- a/client/src/app/videos/+video-watch/video-watch.module.ts +++ b/client/src/app/videos/+video-watch/video-watch.module.ts | |||
@@ -15,6 +15,7 @@ import { VideoWatchRoutingModule } from './video-watch-routing.module' | |||
15 | import { VideoWatchComponent } from './video-watch.component' | 15 | import { VideoWatchComponent } from './video-watch.component' |
16 | import { NgxQRCodeModule } from 'ngx-qrcode2' | 16 | import { NgxQRCodeModule } from 'ngx-qrcode2' |
17 | import { NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap' | 17 | import { NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap' |
18 | import { VideoBlacklistComponent } from '@app/videos/+video-watch/modal/video-blacklist.component' | ||
18 | 19 | ||
19 | @NgModule({ | 20 | @NgModule({ |
20 | imports: [ | 21 | imports: [ |
@@ -31,6 +32,7 @@ import { NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap' | |||
31 | VideoDownloadComponent, | 32 | VideoDownloadComponent, |
32 | VideoShareComponent, | 33 | VideoShareComponent, |
33 | VideoReportComponent, | 34 | VideoReportComponent, |
35 | VideoBlacklistComponent, | ||
34 | VideoSupportComponent, | 36 | VideoSupportComponent, |
35 | VideoCommentsComponent, | 37 | VideoCommentsComponent, |
36 | VideoCommentAddComponent, | 38 | VideoCommentAddComponent, |