mirror of https://github.com/ghostfolio/ghostfolio
Browse Source
* Add drop file functionality on import * Update changelog --------- Co-authored-by: Thomas <4159106+dtslvr@users.noreply.github.com>pull/2316/head
Frane Caleta
1 year ago
committed by
GitHub
8 changed files with 207 additions and 99 deletions
@ -0,0 +1,28 @@ |
|||
import { Directive, HostListener, Output, EventEmitter } from '@angular/core'; |
|||
|
|||
@Directive({ |
|||
selector: '[gfFileDrop]' |
|||
}) |
|||
export class FileDropDirective { |
|||
@Output() filesDropped = new EventEmitter<FileList>(); |
|||
|
|||
@HostListener('dragenter', ['$event']) onDragEnter(event: DragEvent) { |
|||
event.preventDefault(); |
|||
event.stopPropagation(); |
|||
} |
|||
|
|||
@HostListener('dragover', ['$event']) onDragOver(event: DragEvent) { |
|||
event.preventDefault(); |
|||
event.stopPropagation(); |
|||
} |
|||
|
|||
@HostListener('drop', ['$event']) onDrop(event: DragEvent) { |
|||
event.preventDefault(); |
|||
event.stopPropagation(); |
|||
|
|||
// Prevent the browser's default behavior for handling the file drop
|
|||
event.dataTransfer.dropEffect = 'copy'; |
|||
|
|||
this.filesDropped.emit(event.dataTransfer.files); |
|||
} |
|||
} |
@ -0,0 +1,9 @@ |
|||
import { NgModule } from '@angular/core'; |
|||
|
|||
import { FileDropDirective } from './file-drop.directive'; |
|||
|
|||
@NgModule({ |
|||
declarations: [FileDropDirective], |
|||
exports: [FileDropDirective] |
|||
}) |
|||
export class GfFileDropModule {} |
Loading…
Reference in new issue