]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Add reset button for file inputs in studio page
authorChocobozzz <me@florianbigard.com>
Tue, 22 Mar 2022 16:41:39 +0000 (17:41 +0100)
committerChocobozzz <me@florianbigard.com>
Tue, 22 Mar 2022 16:41:39 +0000 (17:41 +0100)
client/src/app/+video-studio/edit/video-studio-edit.component.html
client/src/app/+videos/+video-edit/shared/video-caption-add-modal.component.html
client/src/app/+videos/+video-edit/shared/video-caption-add-modal.component.ts
client/src/app/shared/shared-forms/preview-upload.component.html
client/src/app/shared/shared-forms/preview-upload.component.ts
client/src/app/shared/shared-forms/reactive-file.component.html
client/src/app/shared/shared-forms/reactive-file.component.scss
client/src/app/shared/shared-forms/reactive-file.component.ts

index a9f34811ff0b44885a48f5c01c2282420e565b0c..acfc1a452f84b30eabebf3524a6dcbbd43572093 100644 (file)
@@ -28,8 +28,8 @@
         <div class="form-group">
           <my-reactive-file
             formControlName="file" inputName="addIntroFile" i18n-inputLabel inputLabel="Select the intro video file"
-            [extensions]="videoExtensions" [displayFilename]="true"
-            [ngbTooltip]="getIntroOutroTooltip()"
+            [extensions]="videoExtensions" [displayFilename]="true" [displayReset]="true"
+            [buttonTooltip]="getIntroOutroTooltip()"
           ></my-reactive-file>
         </div>
       </div>
@@ -42,8 +42,8 @@
         <div class="form-group">
           <my-reactive-file
             formControlName="file" inputName="addOutroFile" i18n-inputLabel inputLabel="Select the outro video file"
-            [extensions]="videoExtensions" [displayFilename]="true"
-            [ngbTooltip]="getIntroOutroTooltip()"
+            [extensions]="videoExtensions" [displayFilename]="true" [displayReset]="true"
+            [buttonTooltip]="getIntroOutroTooltip()"
           ></my-reactive-file>
         </div>
       </div>
@@ -56,8 +56,8 @@
         <div class="form-group">
           <my-reactive-file
             formControlName="file" inputName="addWatermarkFile" i18n-inputLabel inputLabel="Select watermark image file"
-            [extensions]="imageExtensions" [displayFilename]="true"
-            [ngbTooltip]="getWatermarkTooltip()"
+            [extensions]="imageExtensions" [displayFilename]="true" [displayReset]="true"
+            [buttonTooltip]="getWatermarkTooltip()"
           ></my-reactive-file>
         </div>
       </div>
index 092952204914c6f8445bd6279833b171500a2055..a3f0dbdb5e1793e270aaaae5094f5f6fdef8c1a0 100644 (file)
@@ -23,7 +23,7 @@
         <my-reactive-file
           formControlName="captionfile" inputName="captionfile" i18n-inputLabel inputLabel="Select the caption file"
           [extensions]="videoCaptionExtensions" [maxFileSize]="videoCaptionMaxSize" [displayFilename]="true"
-          i18n-ngbTooltip [ngbTooltip]="'(extensions: ' + videoCaptionExtensions.join(', ') + ')'"
+          [buttonTooltip]="getReactiveFileButtonTooltip()"
         ></my-reactive-file>
       </div>
 
index 6deadfcbed06d51b50660d7844c51cb06fbcbf76..95d83b131d32f61d71b8e725db68dd2a84af5491 100644 (file)
@@ -41,6 +41,10 @@ export class VideoCaptionAddModalComponent extends FormReactive implements OnIni
     return this.serverConfig.videoCaption.file.size.max
   }
 
+  getReactiveFileButtonTooltip () {
+    return `(extensions: ${this.videoCaptionExtensions.join(', ')})`
+  }
+
   ngOnInit () {
     this.serverService.getVideoLanguages()
         .subscribe(languages => this.videoCaptionLanguages = languages)
index 7c3a2b588b0d034efd4912255e3df93d5e1b1fe3..11e7bdf7f61ab15a6e4b498ca74e18dad9c4b0c5 100644 (file)
@@ -2,7 +2,7 @@
   <div class="preview-container">
     <my-reactive-file
       [inputName]="inputName" [inputLabel]="inputLabel" [extensions]="videoImageExtensions" [maxFileSize]="maxVideoImageSize" placement="right"
-      icon="edit" (fileChanged)="onFileChanged($event)" [ngbTooltip]="'(extensions: '+ videoImageExtensions +', '+ maxSizeText +': '+ maxVideoImageSizeInBytes +')'"
+      icon="edit" (fileChanged)="onFileChanged($event)" [buttonTooltip]="getReactiveFileButtonTooltip()"
     ></my-reactive-file>
 
     <img *ngIf="imageSrc" [ngStyle]="{ width: previewWidth, height: previewHeight }" [src]="imageSrc" class="preview" />
index a857b0a4f975648dbf798905494dc8c32e837890..46920dd27f7adbeeb24991cafdffe43f48ba27ca 100644 (file)
@@ -50,6 +50,10 @@ export class PreviewUploadComponent implements OnInit, ControlValueAccessor {
     return this.bytesPipe.transform(this.maxVideoImageSize)
   }
 
+  getReactiveFileButtonTooltip () {
+    return $localize`(extensions: ${this.videoImageExtensions}, ${this.maxSizeText}: ${this.maxVideoImageSizeInBytes})`
+  }
+
   ngOnInit () {
     this.serverConfig = this.serverService.getHTMLConfig()
 
index f6bf5f9aeee207a3812380d717cd8d9c4abd4260..d18a99d4600634d07b3be1ed9961e815e58b309c 100644 (file)
@@ -1,5 +1,5 @@
 <div class="root">
-  <div class="button-file" [ngClass]="{ 'with-icon': !!icon }">
+  <div class="button-file" [ngClass]="{ 'with-icon': !!icon }" [ngbTooltip]="buttonTooltip">
     <my-global-icon *ngIf="icon" [iconName]="icon"></my-global-icon>
 
     <span>{{ inputLabel }}</span>
@@ -12,4 +12,8 @@
   </div>
 
   <div class="filename" *ngIf="displayFilename === true && filename">{{ filename }}</div>
+
+  <button *ngIf="displayReset && filename" i18n class="reset-button" (click)="reset()">
+    Reset
+  </button>
 </div>
index f8db1aa25adf76303d4f519da09d15098e3335fc..7643f29afe04165b43aa69a4fda86ca774deeaa1 100644 (file)
 
     font-weight: $font-semibold;
   }
+
+  .reset-button {
+    @include peertube-button;
+    @include grey-button;
+
+    font-size: 80%;
+    margin-left: 5px;
+    line-height: initial;
+    padding: 2px 5px;
+    height: auto;
+  }
 }
index 9d27ad07a2b3be15a61bc78e924d9ad944df8501..50b7d4c3e797f2261c008e021947eb5337f2d327 100644 (file)
@@ -20,8 +20,12 @@ export class ReactiveFileComponent implements OnInit, ControlValueAccessor {
   @Input() inputName: string
   @Input() extensions: string[] = []
   @Input() maxFileSize: number
+
   @Input() displayFilename = false
+  @Input() displayReset = false
+
   @Input() icon: GlobalIconName
+  @Input() buttonTooltip: string
 
   @Output() fileChanged = new EventEmitter<Blob>()
 
@@ -62,8 +66,14 @@ export class ReactiveFileComponent implements OnInit, ControlValueAccessor {
       this.file = file
 
       this.propagateChange(this.file)
-      this.fileChanged.emit(this.file)
     }
+    this.fileChanged.emit(this.file)
+  }
+
+  reset () {
+    this.writeValue(undefined)
+    this.propagateChange(undefined)
+    this.fileChanged.emit(undefined)
   }
 
   propagateChange = (_: any) => { /* empty */ }