|
|
@ -1,10 +1,10 @@
|
|
|
|
import {ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, Output} from "@angular/core";
|
|
|
|
import {ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnInit} from "@angular/core";
|
|
|
|
import {ImportService} from "../../../../../services/import/import.service";
|
|
|
|
import {ImportService} from "../../../../../services/import/import.service";
|
|
|
|
import {LoggingService} from "../../../../../services/logging/logging.service";
|
|
|
|
import {LoggingService} from "../../../../../services/logging/logging.service";
|
|
|
|
import {AddFileOptions} from "../../../../../models/AddFileOptions";
|
|
|
|
import {AddFileOptions} from "../../../../../models/AddFileOptions";
|
|
|
|
import {File} from "../../../../../../api/models/File";
|
|
|
|
|
|
|
|
import {DialogFilter} from "@tauri-apps/api/dialog";
|
|
|
|
import {DialogFilter} from "@tauri-apps/api/dialog";
|
|
|
|
import {FileOsMetadata} from "../../../../../../api/api-types/files";
|
|
|
|
import {FileOsMetadata} from "../../../../../../api/api-types/files";
|
|
|
|
|
|
|
|
import {ImportTabState} from "../../../../../models/state/ImportTabState";
|
|
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
@Component({
|
|
|
|
selector: "app-filesystem-import",
|
|
|
|
selector: "app-filesystem-import",
|
|
|
@ -12,10 +12,9 @@ import {FileOsMetadata} from "../../../../../../api/api-types/files";
|
|
|
|
styleUrls: ["./filesystem-import.component.scss"],
|
|
|
|
styleUrls: ["./filesystem-import.component.scss"],
|
|
|
|
changeDetection: ChangeDetectionStrategy.OnPush
|
|
|
|
changeDetection: ChangeDetectionStrategy.OnPush
|
|
|
|
})
|
|
|
|
})
|
|
|
|
export class FilesystemImportComponent {
|
|
|
|
export class FilesystemImportComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
|
|
@Output() fileImported = new EventEmitter<File>();
|
|
|
|
@Input() state!: ImportTabState;
|
|
|
|
@Output() importFinished = new EventEmitter<void>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public fileCount: number = 0;
|
|
|
|
public fileCount: number = 0;
|
|
|
|
public files: FileOsMetadata[] = [];
|
|
|
|
public files: FileOsMetadata[] = [];
|
|
|
@ -45,12 +44,30 @@ export class FilesystemImportComponent {
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ngOnInit(): void {
|
|
|
|
|
|
|
|
this.state.selectedPaths.subscribe(paths => {
|
|
|
|
|
|
|
|
this.files = paths;
|
|
|
|
|
|
|
|
this.fileCount = paths.length;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
this.state.importing.subscribe(importing => {
|
|
|
|
|
|
|
|
this.importing = importing;
|
|
|
|
|
|
|
|
this.changeDetector.markForCheck();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
this.state.importedCount.subscribe(count => {
|
|
|
|
|
|
|
|
this.importingProgressTotal = count;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
this.state.importingProgress.subscribe(prog => {
|
|
|
|
|
|
|
|
this.importingProgress = prog;
|
|
|
|
|
|
|
|
this.changeDetector.markForCheck();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async setSelectedPaths(paths: string[]) {
|
|
|
|
public async setSelectedPaths(paths: string[]) {
|
|
|
|
this.changeDetector.markForCheck();
|
|
|
|
this.changeDetector.markForCheck();
|
|
|
|
this.resolving = true;
|
|
|
|
this.resolving = true;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
this.files = await this.importService.resolvePathsToFiles(paths);
|
|
|
|
const selectedPaths = await this.importService.resolvePathsToFiles(paths);
|
|
|
|
this.fileCount = this.files.length;
|
|
|
|
this.state.selectedPaths.next(selectedPaths);
|
|
|
|
} catch (err: any) {
|
|
|
|
} catch (err: any) {
|
|
|
|
console.log(err);
|
|
|
|
console.log(err);
|
|
|
|
this.errorBroker.error(err);
|
|
|
|
this.errorBroker.error(err);
|
|
|
@ -60,7 +77,7 @@ export class FilesystemImportComponent {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async import() {
|
|
|
|
public async import() {
|
|
|
|
this.importing = true;
|
|
|
|
this.state.importing.next(true);
|
|
|
|
|
|
|
|
|
|
|
|
this.importingProgress = 0;
|
|
|
|
this.importingProgress = 0;
|
|
|
|
let count = 0;
|
|
|
|
let count = 0;
|
|
|
@ -71,17 +88,17 @@ export class FilesystemImportComponent {
|
|
|
|
file,
|
|
|
|
file,
|
|
|
|
this.importOptions
|
|
|
|
this.importOptions
|
|
|
|
);
|
|
|
|
);
|
|
|
|
this.fileImported.emit(resultFile);
|
|
|
|
this.state.addImportedFile(resultFile);
|
|
|
|
} catch (err: any) {
|
|
|
|
} catch (err: any) {
|
|
|
|
console.log(err);
|
|
|
|
console.log(err);
|
|
|
|
this.errorBroker.error(err);
|
|
|
|
this.errorBroker.error(err);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
count++;
|
|
|
|
count++;
|
|
|
|
this.importingProgress = (count / this.fileCount) * 100;
|
|
|
|
this.state.importedCount.next(count);
|
|
|
|
this.importingProgressTotal = count;
|
|
|
|
this.state.importingProgress.next((count / this.fileCount) * 100);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.importing = false;
|
|
|
|
this.state.importing.next(false);
|
|
|
|
this.importFinished.emit();
|
|
|
|
this.state.selectedPaths.next([]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|