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