From b764380ac23f4e9d4677d08acdc3474c2931a16d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 10 Jan 2020 10:11:28 +0100 Subject: Add ability to list redundancies --- .../video/video-actions-dropdown.component.ts | 28 +++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'client/src/app/shared/video/video-actions-dropdown.component.ts') diff --git a/client/src/app/shared/video/video-actions-dropdown.component.ts b/client/src/app/shared/video/video-actions-dropdown.component.ts index afdeab18d..390d74c52 100644 --- a/client/src/app/shared/video/video-actions-dropdown.component.ts +++ b/client/src/app/shared/video/video-actions-dropdown.component.ts @@ -14,6 +14,7 @@ import { VideoBlacklistComponent } from '@app/shared/video/modals/video-blacklis import { VideoBlacklistService } from '@app/shared/video-blacklist' import { ScreenService } from '@app/shared/misc/screen.service' import { VideoCaption } from '@shared/models' +import { RedundancyService } from '@app/shared/video/redundancy.service' export type VideoActionsDisplayType = { playlist?: boolean @@ -22,6 +23,7 @@ export type VideoActionsDisplayType = { blacklist?: boolean delete?: boolean report?: boolean + duplicate?: boolean } @Component({ @@ -46,7 +48,8 @@ export class VideoActionsDropdownComponent implements OnChanges { update: true, blacklist: true, delete: true, - report: true + report: true, + duplicate: true } @Input() placement = 'left' @@ -74,6 +77,7 @@ export class VideoActionsDropdownComponent implements OnChanges { private screenService: ScreenService, private videoService: VideoService, private blocklistService: BlocklistService, + private redundancyService: RedundancyService, private i18n: I18n ) { } @@ -144,6 +148,10 @@ export class VideoActionsDropdownComponent implements OnChanges { return this.video && this.video instanceof VideoDetails && this.video.downloadEnabled } + canVideoBeDuplicated () { + return this.video.canBeDuplicatedBy(this.user) + } + /* Action handlers */ async unblacklistVideo () { @@ -186,6 +194,18 @@ export class VideoActionsDropdownComponent implements OnChanges { ) } + duplicateVideo () { + this.redundancyService.addVideoRedundancy(this.video) + .subscribe( + () => { + const message = this.i18n('This video will be duplicated by your instance.') + this.notifier.success(message) + }, + + err => this.notifier.error(err.message) + ) + } + onVideoBlacklisted () { this.videoBlacklisted.emit() } @@ -233,6 +253,12 @@ export class VideoActionsDropdownComponent implements OnChanges { iconName: 'undo', isDisplayed: () => this.authService.isLoggedIn() && this.displayOptions.blacklist && this.isVideoUnblacklistable() }, + { + label: this.i18n('Duplicate (redundancy)'), + handler: () => this.duplicateVideo(), + isDisplayed: () => this.authService.isLoggedIn() && this.displayOptions.duplicate && this.canVideoBeDuplicated(), + iconName: 'cloud-download' + }, { label: this.i18n('Delete'), handler: () => this.removeVideo(), -- cgit v1.2.3