]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/videos/video-list/video-miniature.component.ts
Client: Handle NSFW video
[github/Chocobozzz/PeerTube.git] / client / src / app / videos / video-list / video-miniature.component.ts
1 import { Component, Input, Output, EventEmitter } from '@angular/core';
2
3 import { NotificationsService } from 'angular2-notifications';
4
5 import { ConfirmService, ConfigService } from '../../core';
6 import { SortField, Video, VideoService } from '../shared';
7 import { User } from '../../shared';
8
9 @Component({
10 selector: 'my-video-miniature',
11 styleUrls: [ './video-miniature.component.scss' ],
12 templateUrl: './video-miniature.component.html'
13 })
14
15 export class VideoMiniatureComponent {
16 @Output() removed = new EventEmitter<any>();
17
18 @Input() currentSort: SortField;
19 @Input() user: User;
20 @Input() video: Video;
21
22 hovering = false;
23
24 constructor(
25 private notificationsService: NotificationsService,
26 private confirmService: ConfirmService,
27 private configService: ConfigService,
28 private videoService: VideoService
29 ) {}
30
31 displayRemoveIcon() {
32 return this.hovering && this.video.isRemovableBy(this.user);
33 }
34
35 getVideoName() {
36 if (this.isVideoNSFWForThisUser())
37 return 'NSFW';
38
39 return this.video.name;
40 }
41
42 onBlur() {
43 this.hovering = false;
44 }
45
46 onHover() {
47 this.hovering = true;
48 }
49
50 removeVideo(id: string) {
51 this.confirmService.confirm('Do you really want to delete this video?', 'Delete').subscribe(
52 res => {
53 if (res === false) return;
54
55 this.videoService.removeVideo(id).subscribe(
56 status => this.removed.emit(true),
57
58 error => this.notificationsService.error('Error', error.text)
59 );
60 }
61 );
62 }
63
64 isVideoNSFWForThisUser() {
65 return this.video.isVideoNSFWForUser(this.user);
66 }
67 }