]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/app/videos/video-list/video-miniature.component.ts
Follow the angular styleguide for the directories structure
[github/Chocobozzz/PeerTube.git] / client / app / videos / video-list / video-miniature.component.ts
CommitLineData
501bc6c2 1import { DatePipe } from '@angular/common';
41a2aee3 2import { Component, Input, Output, EventEmitter } from '@angular/core';
501bc6c2
C
3import { ROUTER_DIRECTIVES } from '@angular/router-deprecated';
4
41a2aee3
C
5import { Video, VideoService } from '../shared/index';
6import { User } from '../../users/index';
501bc6c2
C
7
8@Component({
9 selector: 'my-video-miniature',
41a2aee3
C
10 styleUrls: [ 'client/app/videos/video-list/video-miniature.component.css' ],
11 templateUrl: 'client/app/videos/video-list/video-miniature.component.html',
501bc6c2
C
12 directives: [ ROUTER_DIRECTIVES ],
13 pipes: [ DatePipe ]
14})
15
16export class VideoMiniatureComponent {
17 @Output() removed = new EventEmitter<any>();
18
19 @Input() video: Video;
20 @Input() user: User;
21
22 hovering: boolean = false;
23
41a2aee3 24 constructor(private _videoService: VideoService) {}
501bc6c2
C
25
26 onHover() {
27 this.hovering = true;
28 }
29
30 onBlur() {
31 this.hovering = false;
32 }
33
34 displayRemoveIcon(): boolean {
35 return this.hovering && this.video.isRemovableBy(this.user);
36 }
37
38 removeVideo(id: string) {
39 if (confirm('Do you really want to remove this video?')) {
41a2aee3 40 this._videoService.removeVideo(id).subscribe(
501bc6c2
C
41 status => this.removed.emit(true),
42 error => alert(error)
43 );
44 }
45 }
46}