X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=inline;f=client%2Fsrc%2Fapp%2Fvideos%2F%2Bvideo-watch%2Fvideo-watch.component.ts;h=f1f19476483f29455b5f571e388cb21b289c6357;hb=cbca00dfc14fe47260e8d081f4ed0bec7c66fd09;hp=adb698e99ac9149710356298c5920fda8e23a9e7;hpb=15ca2e871aa069e596baf9da22b3d2a1ab1a0b1a;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/videos/+video-watch/video-watch.component.ts b/client/src/app/videos/+video-watch/video-watch.component.ts index adb698e99..f1f194764 100644 --- a/client/src/app/videos/+video-watch/video-watch.component.ts +++ b/client/src/app/videos/+video-watch/video-watch.component.ts @@ -14,9 +14,9 @@ import { VideoDetails } from '../../shared/video/video-details.model' import { Video } from '../../shared/video/video.model' import { VideoService } from '../../shared/video/video.service' import { MarkdownService } from '../shared' -import { VideoDownloadComponent } from './video-download.component' -import { VideoReportComponent } from './video-report.component' -import { VideoShareComponent } from './video-share.component' +import { VideoDownloadComponent } from './modal/video-download.component' +import { VideoReportComponent } from './modal/video-report.component' +import { VideoShareComponent } from './modal/video-share.component' @Component({ selector: 'my-video-watch', @@ -44,6 +44,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { completeVideoDescription: string shortVideoDescription: string videoHTMLDescription = '' + likesBarTooltipText = '' private paramsSub: Subscription @@ -136,7 +137,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { blacklistVideo (event: Event) { event.preventDefault() - this.confirmService.confirm('Do you really want to blacklist this video ?', 'Blacklist').subscribe( + this.confirmService.confirm('Do you really want to blacklist this video?', 'Blacklist').subscribe( res => { if (res === false) return @@ -147,7 +148,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { this.router.navigate(['/videos/list']) }, - error => this.notificationsService.error('Error', error.text) + error => this.notificationsService.error('Error', error.message) ) } ) @@ -184,7 +185,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { error => { this.descriptionLoading = false - this.notificationsService.error('Error', error.text) + this.notificationsService.error('Error', error.message) } ) } @@ -207,12 +208,16 @@ export class VideoWatchComponent implements OnInit, OnDestroy { return this.authService.isLoggedIn() } + isVideoUpdatable () { + return this.video.isUpdatableBy(this.authService.getUser()) + } + isVideoBlacklistable () { return this.video.isBlackistableBy(this.user) } getAvatarPath () { - return Account.GET_ACCOUNT_AVATAR_PATH(this.video.account) + return Account.GET_ACCOUNT_AVATAR_URL(this.video.account) } getVideoTags () { @@ -221,6 +226,33 @@ export class VideoWatchComponent implements OnInit, OnDestroy { return this.video.tags.join(', ') } + isVideoRemovable () { + return this.video.isRemovableBy(this.authService.getUser()) + } + + removeVideo (event: Event) { + event.preventDefault() + + this.confirmService.confirm('Do you really want to delete this video?', 'Delete') + .subscribe( + res => { + if (res === false) return + + this.videoService.removeVideo(this.video.id) + .subscribe( + status => { + this.notificationsService.success('Success', `Video ${this.video.name} deleted.`) + + // Go back to the video-list. + this.router.navigate([ '/videos/list' ]) + }, + + error => this.notificationsService.error('Error', error.message) + ) + } + ) + } + private updateVideoDescription (description: string) { this.video.description = description this.setVideoDescriptionHTML() @@ -235,6 +267,10 @@ export class VideoWatchComponent implements OnInit, OnDestroy { this.videoHTMLDescription = this.markdownService.markdownToHTML(this.video.description) } + private setVideoLikesBarTooltipText () { + this.likesBarTooltipText = `${this.video.likes} likes / ${this.video.dislikes} dislikes` + } + private handleError (err: any) { const errorMessage: string = typeof err === 'string' ? err : err.message let message = '' @@ -320,6 +356,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { } this.setVideoDescriptionHTML() + this.setVideoLikesBarTooltipText() this.setOpenGraphTags() this.checkUserRating()