2020-10-27 01:10:18 +01:00
|
|
|
import { Component, OnInit } from '@angular/core';
|
2020-10-27 17:35:10 +01:00
|
|
|
import { FileSystemDirectoryEntry, FileSystemFileEntry, NgxFileDropEntry } from 'ngx-file-drop';
|
|
|
|
|
import { DocumentService } from 'src/app/services/rest/document.service';
|
2020-10-27 01:10:18 +01:00
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'app-dashboard',
|
|
|
|
|
templateUrl: './dashboard.component.html',
|
|
|
|
|
styleUrls: ['./dashboard.component.css']
|
|
|
|
|
})
|
|
|
|
|
export class DashboardComponent implements OnInit {
|
|
|
|
|
|
2020-10-27 17:35:10 +01:00
|
|
|
constructor(private documentService: DocumentService) { }
|
2020-10-27 01:10:18 +01:00
|
|
|
|
|
|
|
|
ngOnInit(): void {
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-27 17:35:10 +01:00
|
|
|
public fileOver(event){
|
|
|
|
|
console.log(event);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public fileLeave(event){
|
|
|
|
|
console.log(event);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public dropped(files: NgxFileDropEntry[]) {
|
|
|
|
|
for (const droppedFile of files) {
|
|
|
|
|
|
|
|
|
|
// Is it a file?
|
|
|
|
|
if (droppedFile.fileEntry.isFile) {
|
|
|
|
|
const fileEntry = droppedFile.fileEntry as FileSystemFileEntry;
|
|
|
|
|
console.log(fileEntry)
|
|
|
|
|
fileEntry.file((file: File) => {
|
|
|
|
|
console.log(file)
|
|
|
|
|
const formData = new FormData()
|
|
|
|
|
formData.append('document', file, file.name)
|
|
|
|
|
this.documentService.uploadDocument(formData).subscribe(result => {
|
|
|
|
|
console.log(result)
|
|
|
|
|
}, error => {
|
|
|
|
|
console.error(error)
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-10-27 01:10:18 +01:00
|
|
|
}
|