X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fvideos%2Fvideo-list%2Fvideo-miniature.component.ts;h=1cfeacf36192c4e82ca1a7d28b77e06251485b60;hb=d5050d1e097e761685fbaafe6e3d4b8b78d48356;hp=84bab950e450d295b69dd74ca3728fcd3076a9ad;hpb=bddab65ae58e347693b777cccf791201fdbcff4d;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/videos/video-list/video-miniature.component.ts b/client/src/app/videos/video-list/video-miniature.component.ts index 84bab950e..1cfeacf36 100644 --- a/client/src/app/videos/video-list/video-miniature.component.ts +++ b/client/src/app/videos/video-list/video-miniature.component.ts @@ -1,47 +1,38 @@ -import { DatePipe } from '@angular/common'; -import { Component, Input, Output, EventEmitter } from '@angular/core'; -import { ROUTER_DIRECTIVES } from '@angular/router'; +import { Component, Input, Output, EventEmitter } from '@angular/core' -import { SortField, Video, VideoService } from '../shared'; -import { User } from '../../shared'; +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', - styles: [ require('./video-miniature.component.scss') ], - template: require('./video-miniature.component.html'), - directives: [ ROUTER_DIRECTIVES ], - pipes: [ DatePipe ] + styleUrls: [ './video-miniature.component.scss' ], + templateUrl: './video-miniature.component.html' }) export class VideoMiniatureComponent { - @Output() removed = new EventEmitter(); - - @Input() currentSort: SortField; - @Input() user: User; - @Input() video: Video; - - hovering = false; - - constructor(private videoService: VideoService) {} - - displayRemoveIcon() { - return this.hovering && this.video.isRemovableBy(this.user); - } - - onBlur() { - this.hovering = false; - } + @Input() currentSort: SortField + @Input() user: User + @Input() video: Video + + constructor ( + private notificationsService: NotificationsService, + private confirmService: ConfirmService, + private configService: ConfigService, + private videoService: VideoService + ) {} + + getVideoName () { + if (this.isVideoNSFWForThisUser()) { + return 'NSFW' + } - onHover() { - this.hovering = true; + return this.video.name } - removeVideo(id: string) { - if (confirm('Do you really want to remove this video?')) { - this.videoService.removeVideo(id).subscribe( - status => this.removed.emit(true), - error => alert(error) - ); - } + isVideoNSFWForThisUser () { + return this.video.isVideoNSFWForUser(this.user) } }