Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Add ability to delete video in main info page

Chocobozzz3cce7ec1a082
diff --git a/client/src/app/+videos-publish-manage/shared-manage/main-info/video-main-info.component.html b/client/src/app/+videos-publish-manage/shared-manage/main-info/video-main-info.component.html
index bc3fa254e2..f693729313 100644
--- a/client/src/app/+videos-publish-manage/shared-manage/main-info/video-main-info.component.html
+++ b/client/src/app/+videos-publish-manage/shared-manage/main-info/video-main-info.component.html
@@ -163,5 +163,12 @@
<ng-container i18n>The video may be unplayable during the transcoding process. It's the reason why we prefer to publish publicly the video after transcoding.</ng-container>
</ng-template>
</my-peertube-checkbox>
+
+ <div *ngIf="canBeDeleted()" class="form-group">
+ <label i18n for="deleteVideo">Delete your video</label>
+ <div class="form-group-description" i18n>Warning: this is a definitive action!l!</div>
+
+ <button class="peertube-button danger-button" (click)="deleteVideo()" i18n>Delete</button>
+ </div>
</div>
</div>
diff --git a/client/src/app/+videos-publish-manage/shared-manage/main-info/video-main-info.component.ts b/client/src/app/+videos-publish-manage/shared-manage/main-info/video-main-info.component.ts
index 6ea3bdeed2..18e9052794 100644
--- a/client/src/app/+videos-publish-manage/shared-manage/main-info/video-main-info.component.ts
+++ b/client/src/app/+videos-publish-manage/shared-manage/main-info/video-main-info.component.ts
@@ -1,8 +1,8 @@
import { CommonModule } from '@angular/common'
import { ChangeDetectorRef, Component, inject, NgZone, OnDestroy, OnInit } from '@angular/core'
import { AbstractControl, FormArray, FormControl, FormGroup, FormsModule, ReactiveFormsModule, Validators } from '@angular/forms'
-import { RouterLink } from '@angular/router'
-import { HooksService, PluginService, ServerService } from '@app/core'
+import { Router, RouterLink } from '@angular/router'
+import { ConfirmService, HooksService, Notifier, PluginService, ServerService } from '@app/core'
import { BuildFormArgument, BuildFormValidator } from '@app/shared/form-validators/form-validator.model'
import {
VIDEO_CATEGORY_VALIDATOR,
@@ -45,6 +45,7 @@ import { forkJoin, Subscription } from 'rxjs'
import { map } from 'rxjs/operators'
import { SelectChannelItem } from 'src/types/select-options-item.model'
import { GlobalIconComponent } from '../../../shared/shared-icons/global-icon.component'
+import { DeleteButtonComponent } from '../../../shared/shared-main/buttons/delete-button.component'
import { MarkdownHintComponent } from '../../../shared/shared-main/text/markdown-hint.component'
import { I18nPrimengCalendarService } from '../common/i18n-primeng-calendar.service'
import { ThumbnailManagerComponent } from '../common/thumbnail-manager.component'
@@ -99,7 +100,8 @@ type Form = {
ThumbnailManagerComponent,
GlobalIconComponent,
MarkdownHintComponent,
- RouterLink
+ RouterLink,
+ DeleteButtonComponent
]
})
export class VideoMainInfoComponent implements OnInit, OnDestroy {
@@ -114,6 +116,9 @@ export class VideoMainInfoComponent implements OnInit, OnDestroy {
private hooks = inject(HooksService)
private cd = inject(ChangeDetectorRef)
private manageController = inject(VideoManageController)
+ private confirmService = inject(ConfirmService)
+ private notifier = inject(Notifier)
+ private router = inject(Router)
form: FormGroup<Form>
formErrors: FormReactiveErrors = {}
@@ -463,4 +468,29 @@ export class VideoMainInfoComponent implements OnInit, OnDestroy {
private updateSupportField (support: string) {
return this.form.patchValue({ support: support || '' })
}
+
+ // ---------------------------------------------------------------------------
+
+ canBeDeleted () {
+ return !!this.videoEdit.getVideoAttributes().id
+ }
+
+ async deleteVideo () {
+ const video = this.videoEdit.getVideoAttributes()
+ const message = $localize`Are you sure you want to delete your video "${video.name}?`
+
+ const res = await this.confirmService.confirm(message, $localize`Delete`)
+ if (res === false) return
+
+ this.videoService.removeVideo(video.id)
+ .subscribe({
+ next: () => {
+ this.notifier.success($localize`"${video.name}" deleted`)
+
+ this.router.navigate([ '/my-library/videos' ])
+ },
+
+ error: err => this.notifier.error(err.message)
+ })
+ }
}