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