ActivityPub-federated video streaming platform using P2P directly in your web browser
Add Drag-and-Drop to Replace File (#6970)
allmiha275c6fd9417f8
diff --git a/client/src/app/+videos-publish-manage/shared-manage/common/video-manage-page-common.scss b/client/src/app/+videos-publish-manage/shared-manage/common/video-manage-page-common.scssindex 335079489e..04fc9c6a4a 100644--- a/client/src/app/+videos-publish-manage/shared-manage/common/video-manage-page-common.scss+++ b/client/src/app/+videos-publish-manage/shared-manage/common/video-manage-page-common.scss@@ -75,6 +75,10 @@ p-calendar {}}+.dragover {+ border: 3px dashed pvar(--primary);+}+.plugin-fields {display: flex;flex-wrap: wrap;diff --git a/client/src/app/+videos-publish-manage/shared-manage/replace-file/video-replace-file.component.html b/client/src/app/+videos-publish-manage/shared-manage/replace-file/video-replace-file.component.htmlindex 1b9a4121d0..bf60885a17 100644--- a/client/src/app/+videos-publish-manage/shared-manage/replace-file/video-replace-file.component.html+++ b/client/src/app/+videos-publish-manage/shared-manage/replace-file/video-replace-file.component.html@@ -7,32 +7,27 @@@if (getUnavailability()) {<my-alert type="primary" i18n>{{ getUnavailability() }}</my-alert>} @else {- <div [formGroup]="form">- <div class="form-columns reverse">- <div>- <div *ngIf="videoEdit.getVideoSource()" class="form-group">- <label i18n for="filename">Current uploaded file</label>+ <div class="root" myDragDrop (fileDropped)="onFileDropped($event)">+ <div class="current-filename">+ <div class="fs-7" i18n>Current uploaded file:</div>- <input type="text" [disabled]="true" id="filename" class="form-control" [value]="videoEdit.getVideoSource().filename" />- </div>- </div>+ <strong class="fs-5">{{ videoEdit.getVideoSource().filename }}</strong>+ </div>- <div>- <div class="form-group">- <label i18n for="videofile">Replace video file</label>+ <div class="mt-3">+ <div class="muted-1">+ <strong>Drag and drop your new video file here</strong> or click on the button below to replace your video:+ </div>- <div i18n class="form-group-description">⚠️ Uploading a new version of your video will completely erase the current version</div>+ <div class="muted-2 fs-7">+ <div i18n class="form-group-description">⚠️ Uploading a new version of your video will completely erase the current version</div>+ </div>- <div>- <my-reactive-file- formControlName="replaceFile"- i18n-inputLabel inputLabel="Select the file to upload"- inputName="videofile" [extensions]="getVideoExtensions()" [displayFilename]="true" [displayReset]="true"- [buttonTooltip]="'(extensions: ' + getVideoExtensions() + ')'"- theme="primary"- ></my-reactive-file>- </div>- </div>+ <div class="d-flex flex-wrap mt-4 justify-content-center gap-3">+ <my-reactive-file #reactiveFileInput class="d-inline-block me-3" inputName="videoFile" i18n-inputLabel+ inputLabel="Upload" (fileChanged)="onFileChanged($event)" [extensions]="getVideoExtensions()"+ [displayFilename]="true" [displayReset]="false" placement="right" theme="secondary" icon="upload">+ </my-reactive-file></div></div></div>diff --git a/client/src/app/+videos-publish-manage/shared-manage/replace-file/video-replace-file.component.scss b/client/src/app/+videos-publish-manage/shared-manage/replace-file/video-replace-file.component.scssnew file mode 100644index 0000000000..604564b783--- /dev/null+++ b/client/src/app/+videos-publish-manage/shared-manage/replace-file/video-replace-file.component.scss@@ -0,0 +1,26 @@+@use 'sass:math';+@use '_variables' as *;+@use '_mixins' as *;+@use '_form-mixins' as *;++.current-filename {+ text-align: center;+ margin-top: 1.5rem;+}++.root {+ min-height: 260px;+ text-align: center;+ padding: 2rem 1.5rem;+ border-radius: 4px;+ border: 1px dashed pvar(--secondary-icon-color);++ @include on-mobile-main-col {+ border: 0;+ }+}++.dragover {+ background-color: pvar(--bg-secondary-400);+ border-color: pvar(--primary);+}diff --git a/client/src/app/+videos-publish-manage/shared-manage/replace-file/video-replace-file.component.ts b/client/src/app/+videos-publish-manage/shared-manage/replace-file/video-replace-file.component.tsindex 39596b889e..80f8c18d26 100644--- a/client/src/app/+videos-publish-manage/shared-manage/replace-file/video-replace-file.component.ts+++ b/client/src/app/+videos-publish-manage/shared-manage/replace-file/video-replace-file.component.ts@@ -1,5 +1,5 @@import { CommonModule } from '@angular/common'-import { Component, inject, OnDestroy, OnInit } from '@angular/core'+import { Component, inject, OnDestroy, OnInit, ViewChild } from '@angular/core'import { FormControl, FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms'import { ServerService } from '@app/core'import { BuildFormArgument } from '@app/shared/form-validators/form-validator.model'@@ -13,6 +13,7 @@ import { getReplaceFileUnavailability } from '../common/unavailable-features'import { VideoEdit } from '../common/video-edit.model'import { VideoUploadService } from '../common/video-upload.service'import { VideoManageController } from '../video-manage-controller.service'+import { DragDropDirective } from '@app/+videos-publish-manage/+video-publish/shared/drag-drop.directive'const debugLogger = debug('peertube:video-manage')@@ -23,7 +24,8 @@ type Form = {@Component({selector: 'my-video-replace-file',styleUrls: [- '../common/video-manage-page-common.scss'+ '../common/video-manage-page-common.scss',+ './video-replace-file.component.scss'],templateUrl: './video-replace-file.component.html',imports: [@@ -32,7 +34,8 @@ type Form = {ReactiveFormsModule,ReactiveFileComponent,AlertComponent,- GlobalIconComponent+ GlobalIconComponent,+ DragDropDirective]})export class VideoReplaceFileComponent implements OnInit, OnDestroy {@@ -92,6 +95,28 @@ export class VideoReplaceFileComponent implements OnInit, OnDestroy {this.updatedSub?.unsubscribe()}+ @ViewChild('reactiveFileInput')+ reactiveFile: ReactiveFileComponent+ onFileDropped (files: FileList) {+ this.reactiveFile.fileChange({ target: { files } })+ // this.onFileChanged(files[0])+ }++ onFileChanged (file: File | Blob) {+ if (!file) return++ if (!(file instanceof File)) {+ // console.error('Received unexpected non-File:', file)+ return+ }++ // Put the file in the form control to activate the save button+ this.form.controls.replaceFile.setValue(file)+ this.form.controls.replaceFile.markAsDirty()+ this.form.markAsDirty()+ this.form.updateValueAndValidity()+ }+getVideoExtensions () {return this.videoUploadService.getVideoExtensions()}