1
0
Fork 0
peertube/client/src/app/videos/video-list/video-miniature.component.ts

56 lines
1.3 KiB
TypeScript
Raw Normal View History

import { Component, Input, Output, EventEmitter } from '@angular/core';
import { NotificationsService } from 'angular2-notifications';
import { ConfirmService } from '../../core';
2016-07-18 13:39:10 +00:00
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>();
2016-07-18 13:39:10 +00:00
@Input() currentSort: SortField;
@Input() user: User;
2016-05-27 15:49:18 +00:00
@Input() video: Video;
2016-05-27 15:25:52 +00:00
hovering = false;
constructor(
private notificationsService: NotificationsService,
private confirmService: ConfirmService,
private videoService: VideoService
) {}
2016-05-27 15:49:18 +00:00
displayRemoveIcon() {
return this.hovering && this.video.isRemovableBy(this.user);
}
onBlur() {
this.hovering = false;
}
2016-05-27 15:49:18 +00:00
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)
);
}
);
}
}