]>
Commit | Line | Data |
---|---|---|
41a2aee3 | 1 | import { Component, Input, Output, EventEmitter } from '@angular/core'; |
501bc6c2 | 2 | |
7ddd02c9 C |
3 | import { NotificationsService } from 'angular2-notifications'; |
4 | ||
5769e1db | 5 | import { ConfirmService } from '../../core'; |
bddab65a | 6 | import { SortField, Video, VideoService } from '../shared'; |
4a6995be | 7 | import { User } from '../../shared'; |
501bc6c2 C |
8 | |
9 | @Component({ | |
10 | selector: 'my-video-miniature', | |
ec8d8440 C |
11 | styleUrls: [ './video-miniature.component.scss' ], |
12 | templateUrl: './video-miniature.component.html' | |
501bc6c2 C |
13 | }) |
14 | ||
15 | export class VideoMiniatureComponent { | |
16 | @Output() removed = new EventEmitter<any>(); | |
17 | ||
bddab65a | 18 | @Input() currentSort: SortField; |
501bc6c2 | 19 | @Input() user: User; |
4fd8aa32 | 20 | @Input() video: Video; |
501bc6c2 | 21 | |
ccf6ed16 | 22 | hovering = false; |
501bc6c2 | 23 | |
7ddd02c9 C |
24 | constructor( |
25 | private notificationsService: NotificationsService, | |
5769e1db | 26 | private confirmService: ConfirmService, |
7ddd02c9 C |
27 | private videoService: VideoService |
28 | ) {} | |
501bc6c2 | 29 | |
4fd8aa32 C |
30 | displayRemoveIcon() { |
31 | return this.hovering && this.video.isRemovableBy(this.user); | |
501bc6c2 C |
32 | } |
33 | ||
34 | onBlur() { | |
35 | this.hovering = false; | |
36 | } | |
37 | ||
4fd8aa32 C |
38 | onHover() { |
39 | this.hovering = true; | |
501bc6c2 C |
40 | } |
41 | ||
42 | removeVideo(id: string) { | |
5769e1db C |
43 | this.confirmService.confirm('Do you really want to delete this video?', 'Delete').subscribe( |
44 | res => { | |
45 | if (res === false) return; | |
7ddd02c9 | 46 | |
5769e1db C |
47 | this.videoService.removeVideo(id).subscribe( |
48 | status => this.removed.emit(true), | |
49 | ||
50 | error => this.notificationsService.error('Error', error.text) | |
51 | ); | |
52 | } | |
53 | ); | |
501bc6c2 C |
54 | } |
55 | } |