]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/videos/video-list/video-miniature.component.ts
Server: Add NSFW in user profile
[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 } 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 videoService: VideoService
28 ) {}
29
30 displayRemoveIcon() {
31 return this.hovering && this.video.isRemovableBy(this.user);
32 }
33
34 onBlur() {
35 this.hovering = false;
36 }
37
38 onHover() {
39 this.hovering = true;
40 }
41
42 removeVideo(id: string) {
43 this.confirmService.confirm('Do you really want to delete this video?', 'Delete').subscribe(
44 res => {
45 if (res === false) return;
46
47 this.videoService.removeVideo(id).subscribe(
48 status => this.removed.emit(true),
49
50 error => this.notificationsService.error('Error', error.text)
51 );
52 }
53 );
54 }
55 }