<div class="modal-body">
<label i18n for="language">Language</label>
<div class="peertube-select-container">
- <select id="language" formControlName="language">
+ <select id="language" formControlName="language" class="form-control">
<option></option>
<option *ngFor="let language of videoCaptionLanguages" [value]="language.id">{{ language.label }}</option>
</select>
--- /dev/null
+import { Directive, Output, EventEmitter, HostBinding, HostListener } from '@angular/core'
+
+@Directive({
+ selector: '[dragDrop]'
+})
+export class DragDropDirective {
+ @Output() onFileDropped = new EventEmitter<FileList>()
+
+ @HostBinding('class.dragover') dragover = false
+
+ @HostListener('dragover', ['$event']) onDragOver(e: Event) {
+ e.preventDefault()
+ e.stopPropagation()
+ this.dragover = true
+ }
+
+ @HostListener('dragleave', ['$event']) public onDragLeave(e: Event) {
+ e.preventDefault()
+ e.stopPropagation()
+ this.dragover = false
+ }
+
+ @HostListener('drop', ['$event']) public ondrop(e: DragEvent) {
+ e.preventDefault()
+ e.stopPropagation()
+ this.dragover = false
+ let files = e.dataTransfer.files
+ if (files.length > 0) this.onFileDropped.emit(files)
+ }
+}
-<div *ngIf="!hasImportedVideo" class="upload-video-container">
+<div *ngIf="!hasImportedVideo" class="upload-video-container" dragDrop (onFileDropped)="setTorrentFile($event)">
<div class="first-step-block">
<my-global-icon class="upload-icon" iconName="upload"></my-global-icon>
- <div class="button-file">
+ <div class="button-file form-control" [ngbTooltip]="'(extensions: .torrent)'">
<span i18n>Select the torrent to import</span>
<input #torrentfileInput type="file" name="torrentfile" id="torrentfile" accept=".torrent" (change)="fileChange()" />
</div>
- <span class="button-file-extension">(.torrent)</span>
- <div class="torrent-or-magnet" i18n>Or</div>
+ <div class="torrent-or-magnet" i18n-data-content data-content="OR"></div>
<div class="form-group form-group-magnet-uri">
<label i18n for="magnetUri">Paste magnet URI</label>
</ng-template>
</my-help>
- <input type="text" id="magnetUri" [(ngModel)]="magnetUri" />
+ <input type="text" id="magnetUri" [(ngModel)]="magnetUri" class="form-control" />
</div>
<div class="form-group">
<label i18n for="first-step-channel">Channel</label>
<div class="peertube-select-container">
- <select id="first-step-channel" [(ngModel)]="firstStepChannelId">
+ <select id="first-step-channel" [(ngModel)]="firstStepChannelId" class="form-control">
<option *ngFor="let channel of userVideoChannels" [value]="channel.id">{{ channel.label }}</option>
</select>
</div>
<div class="form-group">
<label i18n for="first-step-privacy">Privacy</label>
<div class="peertube-select-container">
- <select id="first-step-privacy" [(ngModel)]="firstStepPrivacyId">
+ <select id="first-step-privacy" [(ngModel)]="firstStepPrivacyId" class="form-control">
<option *ngFor="let privacy of videoPrivacies" [value]="privacy.id">{{ privacy.label }}</option>
</select>
</div>
this.importVideo(torrentfile)
}
+ setTorrentFile (files: FileList) {
+ this.torrentfileInput.nativeElement.files = files
+ this.fileChange()
+ }
+
importVideo (torrentfile?: Blob) {
this.isImportingVideo = true
</ng-template>
</my-help>
- <input type="text" id="targetUrl" [(ngModel)]="targetUrl" />
+ <input type="text" id="targetUrl" [(ngModel)]="targetUrl" class="form-control" />
</div>
<div class="form-group">
<label i18n for="first-step-channel">Channel</label>
<div class="peertube-select-container">
- <select id="first-step-channel" [(ngModel)]="firstStepChannelId">
+ <select id="first-step-channel" [(ngModel)]="firstStepChannelId" class="form-control">
<option *ngFor="let channel of userVideoChannels" [value]="channel.id">{{ channel.label }}</option>
</select>
</div>
<div class="form-group">
<label i18n for="first-step-privacy">Privacy</label>
<div class="peertube-select-container">
- <select id="first-step-privacy" [(ngModel)]="firstStepPrivacyId">
+ <select id="first-step-privacy" [(ngModel)]="firstStepPrivacyId" class="form-control">
<option *ngFor="let privacy of videoPrivacies" [value]="privacy.id">{{ privacy.label }}</option>
</select>
</div>
-<div *ngIf="!isUploadingVideo" class="upload-video-container">
+<div *ngIf="!isUploadingVideo" class="upload-video-container" dragDrop (onFileDropped)="setVideoFile($event)">
<div class="first-step-block">
<my-global-icon class="upload-icon" iconName="upload"></my-global-icon>
- <div class="button-file form-control" [ngbTooltip]="'(extensions: ' + videoExtensions + ')'" container="body">
+ <div class="button-file form-control" [ngbTooltip]="'(extensions: ' + videoExtensions + ')'">
<span i18n>Select the file to upload</span>
<input #videofileInput type="file" name="videofile" id="videofile" [accept]="videoExtensions" (change)="fileChange()" autofocus />
</div>
return this.videofileInput.nativeElement.files[0]
}
+ setVideoFile (files: FileList) {
+ this.videofileInput.nativeElement.files = files
+ this.fileChange()
+ }
+
getAudioUploadLabel () {
const videofile = this.getVideoFile()
if (!videofile) return this.i18n('Upload')
::ng-deep .upload-video-container {
border: $border-width $border-type $border-color;
- border-top: none;
+ border-top: transparent;
background-color: var(--submenuColor);
- border-radius: 3px;
+ border-bottom-left-radius: 3px;
+ border-bottom-right-radius: 3px;
width: 100%;
min-height: 440px;
padding-bottom: 20px;
display: flex;
justify-content: center;
align-items: center;
+
+ &.dragover {
+ border: 3px dashed var(--mainColor);
+ }
}
import { VideoEditModule } from './shared/video-edit.module'
import { VideoAddRoutingModule } from './video-add-routing.module'
import { VideoAddComponent } from './video-add.component'
+import { DragDropDirective } from './video-add-components/drag-drop.directive'
import { CanDeactivateGuard } from '../../shared/guards/can-deactivate-guard.service'
import { VideoUploadComponent } from '@app/videos/+video-edit/video-add-components/video-upload.component'
import { VideoImportUrlComponent } from '@app/videos/+video-edit/video-add-components/video-import-url.component'
VideoAddComponent,
VideoUploadComponent,
VideoImportUrlComponent,
- VideoImportTorrentComponent
+ VideoImportTorrentComponent,
+ DragDropDirective
],
exports: [
- VideoAddComponent
+ VideoAddComponent,
+ DragDropDirective
],
providers: [
CanDeactivateGuard