]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/videos/video-list/video-miniature.component.ts
ca4afc451bb7c2fc858b8c82a546b57fc718f4c4
[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 { SortField, Video, VideoService } from '../shared';
6 import { User } from '../../shared';
7
8 @Component({
9 selector: 'my-video-miniature',
10 styleUrls: [ './video-miniature.component.scss' ],
11 templateUrl: './video-miniature.component.html'
12 })
13
14 export class VideoMiniatureComponent {
15 @Output() removed = new EventEmitter<any>();
16
17 @Input() currentSort: SortField;
18 @Input() user: User;
19 @Input() video: Video;
20
21 hovering = false;
22
23 constructor(
24 private notificationsService: NotificationsService,
25 private videoService: VideoService
26 ) {}
27
28 displayRemoveIcon() {
29 return this.hovering && this.video.isRemovableBy(this.user);
30 }
31
32 onBlur() {
33 this.hovering = false;
34 }
35
36 onHover() {
37 this.hovering = true;
38 }
39
40 removeVideo(id: string) {
41 if (confirm('Do you really want to remove this video?')) {
42 this.videoService.removeVideo(id).subscribe(
43 status => this.removed.emit(true),
44
45 error => this.notificationsService.error('Error', error.text)
46 );
47 }
48 }
49 }