-import { AfterViewInit, Component, EventEmitter, Input, OnChanges, Output, ViewChild } from '@angular/core'
+import { Component, EventEmitter, Input, OnChanges, Output, ViewChild } from '@angular/core'
import { I18n } from '@ngx-translate/i18n-polyfill'
import { DropdownAction, DropdownButtonSize, DropdownDirection } from '@app/shared/buttons/action-dropdown.component'
-import { AuthService, ConfirmService, Notifier, ServerService } from '@app/core'
-import { BlocklistService } from '@app/shared/blocklist'
+import { AuthService, ConfirmService, Notifier } from '@app/core'
import { Video } from '@app/shared/video/video.model'
import { VideoService } from '@app/shared/video/video.service'
import { VideoDetails } from '@app/shared/video/video-details.model'
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
blacklist?: boolean
delete?: boolean
report?: boolean
+ duplicate?: boolean
}
@Component({
styleUrls: [ './video-actions-dropdown.component.scss' ]
})
export class VideoActionsDropdownComponent implements OnChanges {
- @ViewChild('playlistDropdown', { static: false }) playlistDropdown: NgbDropdown
- @ViewChild('playlistAdd', { static: false }) playlistAdd: VideoAddToPlaylistComponent
+ @ViewChild('playlistDropdown') playlistDropdown: NgbDropdown
+ @ViewChild('playlistAdd') playlistAdd: VideoAddToPlaylistComponent
- @ViewChild('videoDownloadModal', { static: false }) videoDownloadModal: VideoDownloadComponent
- @ViewChild('videoReportModal', { static: false }) videoReportModal: VideoReportComponent
- @ViewChild('videoBlacklistModal', { static: false }) videoBlacklistModal: VideoBlacklistComponent
+ @ViewChild('videoDownloadModal') videoDownloadModal: VideoDownloadComponent
+ @ViewChild('videoReportModal') videoReportModal: VideoReportComponent
+ @ViewChild('videoBlacklistModal') videoBlacklistModal: VideoBlacklistComponent
@Input() video: Video | VideoDetails
@Input() videoCaptions: VideoCaption[] = []
update: true,
blacklist: true,
delete: true,
- report: true
+ report: true,
+ duplicate: true
}
@Input() placement = 'left'
private notifier: Notifier,
private confirmService: ConfirmService,
private videoBlacklistService: VideoBlacklistService,
- private serverService: ServerService,
private screenService: ScreenService,
private videoService: VideoService,
- private blocklistService: BlocklistService,
+ private redundancyService: RedundancyService,
private i18n: I18n
) { }
return this.video && this.video instanceof VideoDetails && this.video.downloadEnabled
}
+ canVideoBeDuplicated () {
+ return this.video.canBeDuplicatedBy(this.user)
+ }
+
/* Action handlers */
async unblacklistVideo () {
)
}
+ 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()
}
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(),