blob: 8aa9d5e6d18666fe83ae8bc4b25758975140fb8e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
import {Component, OnInit} from '@angular/core';
import {NgxFileDropEntry, FileSystemFileEntry, FileSystemDirectoryEntry} from 'ngx-file-drop';
import {PackageCreationStore} from '../package-creation.store';
@Component({
selector: 'app-imports-tab',
templateUrl: './imports-tab.component.html',
styleUrls: ['./imports-tab.component.css']
})
export class ImportsTabComponent {
constructor(private packageCreationStore: PackageCreationStore) {
}
public files: NgxFileDropEntry[] = [];
public dropped(files: NgxFileDropEntry[]) {
this.files = files;
for (const droppedFile of files) {
// Is it a file?
if (droppedFile.fileEntry.isFile) {
const fileEntry = droppedFile.fileEntry as FileSystemFileEntry;
fileEntry.file((file: File) => {
console.log(droppedFile.relativePath, file);
this.packageCreationStore.addDefinition(droppedFile.relativePath, '');
});
} else {
// It was a directory (empty directories are added, otherwise only files)
const fileEntry = droppedFile.fileEntry as FileSystemDirectoryEntry;
console.log(droppedFile.relativePath, fileEntry);
this.packageCreationStore.addDefinition(droppedFile.relativePath, '');
}
}
}
public fileOver(event) {
console.log(event);
}
public fileLeave(event) {
console.log(event);
}
}
|