]>
Commit | Line | Data |
---|---|---|
501bc6c2 | 1 | import { DatePipe } from '@angular/common'; |
41a2aee3 | 2 | import { Component, Input, Output, EventEmitter } from '@angular/core'; |
501bc6c2 C |
3 | import { ROUTER_DIRECTIVES } from '@angular/router-deprecated'; |
4 | ||
41a2aee3 C |
5 | import { Video, VideoService } from '../shared/index'; |
6 | import { 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 | ||
16 | export class VideoMiniatureComponent { | |
17 | @Output() removed = new EventEmitter<any>(); | |
18 | ||
501bc6c2 | 19 | @Input() user: User; |
4fd8aa32 | 20 | @Input() video: Video; |
501bc6c2 | 21 | |
ccf6ed16 | 22 | hovering = false; |
501bc6c2 | 23 | |
ccf6ed16 | 24 | constructor(private videoService: VideoService) {} |
501bc6c2 | 25 | |
4fd8aa32 C |
26 | displayRemoveIcon() { |
27 | return this.hovering && this.video.isRemovableBy(this.user); | |
501bc6c2 C |
28 | } |
29 | ||
30 | onBlur() { | |
31 | this.hovering = false; | |
32 | } | |
33 | ||
4fd8aa32 C |
34 | onHover() { |
35 | this.hovering = true; | |
501bc6c2 C |
36 | } |
37 | ||
38 | removeVideo(id: string) { | |
39 | if (confirm('Do you really want to remove this video?')) { | |
ccf6ed16 | 40 | this.videoService.removeVideo(id).subscribe( |
501bc6c2 C |
41 | status => this.removed.emit(true), |
42 | error => alert(error) | |
43 | ); | |
44 | } | |
45 | } | |
46 | } |