diff --git a/mediarepo-ui/src-tauri/Cargo.lock b/mediarepo-ui/src-tauri/Cargo.lock
index 2da5f3f..edc739a 100644
--- a/mediarepo-ui/src-tauri/Cargo.lock
+++ b/mediarepo-ui/src-tauri/Cargo.lock
@@ -1580,8 +1580,8 @@ checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f"
[[package]]
name = "mediarepo-api"
-version = "0.5.3"
-source = "git+https://github.com/Trivernis/mediarepo-api.git?rev=827ae9613d18b773a66c80ee803c4e112ca987b9#827ae9613d18b773a66c80ee803c4e112ca987b9"
+version = "0.6.0"
+source = "git+https://github.com/Trivernis/mediarepo-api.git?rev=ddebf4bf0c3e96ede64182ff52bd84f134acc33a#ddebf4bf0c3e96ede64182ff52bd84f134acc33a"
dependencies = [
"async-trait",
"chrono",
@@ -2524,9 +2524,9 @@ dependencies = [
[[package]]
name = "rmp-ipc"
-version = "0.9.0"
+version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f6e9a9202fb951b3ca3088a4edd351774ef154efabb759d6aac2911cc1ae60c1"
+checksum = "87d2b669d0332e1478b88fdecf4c03cc0c8ce1d977a79eba848f4532213567e6"
dependencies = [
"async-trait",
"byteorder",
diff --git a/mediarepo-ui/src-tauri/Cargo.toml b/mediarepo-ui/src-tauri/Cargo.toml
index b1217cc..c7422e6 100644
--- a/mediarepo-ui/src-tauri/Cargo.toml
+++ b/mediarepo-ui/src-tauri/Cargo.toml
@@ -30,7 +30,7 @@ features = ["env-filter"]
[dependencies.mediarepo-api]
git = "https://github.com/Trivernis/mediarepo-api.git"
-rev = "827ae9613d18b773a66c80ee803c4e112ca987b9"
+rev = "ddebf4bf0c3e96ede64182ff52bd84f134acc33a"
features = ["tauri-plugin"]
[features]
diff --git a/mediarepo-ui/src/app/models/AddFileOptions.ts b/mediarepo-ui/src/app/models/AddFileOptions.ts
new file mode 100644
index 0000000..ef3c71c
--- /dev/null
+++ b/mediarepo-ui/src/app/models/AddFileOptions.ts
@@ -0,0 +1,8 @@
+export class AddFileOptions {
+ public read_tags_from_txt = false;
+ public delete_after_import = false;
+
+ constructor() {
+ }
+
+}
diff --git a/mediarepo-ui/src/app/pages/home/import-tab/import-tab-sidebar/filesystem-import/filesystem-import.component.html b/mediarepo-ui/src/app/pages/home/import-tab/import-tab-sidebar/filesystem-import/filesystem-import.component.html
index 033d485..4e6775f 100644
--- a/mediarepo-ui/src/app/pages/home/import-tab/import-tab-sidebar/filesystem-import/filesystem-import.component.html
+++ b/mediarepo-ui/src/app/pages/home/import-tab/import-tab-sidebar/filesystem-import/filesystem-import.component.html
@@ -7,7 +7,7 @@
@@ -16,14 +16,17 @@
- Import tags from
+ Import tags from
adjacent .txt tag files
-
+
Delete files from original location after import
-
+
+
diff --git a/mediarepo-ui/src/app/pages/home/import-tab/import-tab-sidebar/filesystem-import/filesystem-import.component.ts b/mediarepo-ui/src/app/pages/home/import-tab/import-tab-sidebar/filesystem-import/filesystem-import.component.ts
index fabc183..a470fdc 100644
--- a/mediarepo-ui/src/app/pages/home/import-tab/import-tab-sidebar/filesystem-import/filesystem-import.component.ts
+++ b/mediarepo-ui/src/app/pages/home/import-tab/import-tab-sidebar/filesystem-import/filesystem-import.component.ts
@@ -1,7 +1,9 @@
-import {Component} from '@angular/core';
+import {Component, EventEmitter, Output} from '@angular/core';
import {FileOsMetadata} from "../../../../../models/FileOsMetadata";
import {ImportService} from "../../../../../services/import/import.service";
import {ErrorBrokerService} from "../../../../../services/error-broker/error-broker.service";
+import {AddFileOptions} from "../../../../../models/AddFileOptions";
+import {File} from "../../../../../models/File";
@Component({
selector: 'app-filesystem-import',
@@ -10,12 +12,15 @@ import {ErrorBrokerService} from "../../../../../services/error-broker/error-bro
})
export class FilesystemImportComponent {
+ @Output() fileImported = new EventEmitter();
+
public fileCount: number = 0;
public files: FileOsMetadata[] = [];
- public importTagsFromTxt = true;
- public deleteAfterImport = false;
+ public importOptions = new AddFileOptions();
public resolving = false;
+ public importing = false;
+ public importingProgress = 0;
constructor(private errorBroker: ErrorBrokerService, private importService: ImportService) {
}
@@ -31,4 +36,22 @@ export class FilesystemImportComponent {
}
this.resolving = false;
}
+
+ public async import() {
+ this.importing = true;
+
+ this.importingProgress = 0;
+ for (const file of this.files) {
+ try {
+ const resultFile = await this.importService.addLocalFile(file, this.importOptions);
+ this.fileImported.emit(resultFile);
+ } catch (err) {
+ console.log(err);
+ this.errorBroker.showError(err);
+ }
+ this.importingProgress++;
+ }
+
+ this.importing = false;
+ }
}
diff --git a/mediarepo-ui/src/app/pages/home/import-tab/import-tab-sidebar/import-tab-sidebar.component.html b/mediarepo-ui/src/app/pages/home/import-tab/import-tab-sidebar/import-tab-sidebar.component.html
index f70ab28..66497ec 100644
--- a/mediarepo-ui/src/app/pages/home/import-tab/import-tab-sidebar/import-tab-sidebar.component.html
+++ b/mediarepo-ui/src/app/pages/home/import-tab/import-tab-sidebar/import-tab-sidebar.component.html
@@ -12,7 +12,7 @@
diff --git a/mediarepo-ui/src/app/pages/home/import-tab/import-tab-sidebar/import-tab-sidebar.component.ts b/mediarepo-ui/src/app/pages/home/import-tab/import-tab-sidebar/import-tab-sidebar.component.ts
index e340819..673d98f 100644
--- a/mediarepo-ui/src/app/pages/home/import-tab/import-tab-sidebar/import-tab-sidebar.component.ts
+++ b/mediarepo-ui/src/app/pages/home/import-tab/import-tab-sidebar/import-tab-sidebar.component.ts
@@ -1,5 +1,12 @@
-import {Component, OnInit, ViewChild} from '@angular/core';
+import {
+ Component,
+ EventEmitter,
+ OnInit,
+ Output,
+ ViewChild
+} from '@angular/core';
import {MatTabGroup} from "@angular/material/tabs";
+import {File} from "../../../../models/File";
@Component({
selector: 'app-import-tab-sidebar',
@@ -8,5 +15,6 @@ import {MatTabGroup} from "@angular/material/tabs";
})
export class ImportTabSidebarComponent {
+ @Output() fileImported = new EventEmitter();
constructor() { }
}
diff --git a/mediarepo-ui/src/app/pages/home/import-tab/import-tab.component.html b/mediarepo-ui/src/app/pages/home/import-tab/import-tab.component.html
index 8bf58a9..f9daa0c 100644
--- a/mediarepo-ui/src/app/pages/home/import-tab/import-tab.component.html
+++ b/mediarepo-ui/src/app/pages/home/import-tab/import-tab.component.html
@@ -1,6 +1,6 @@
-
+
diff --git a/mediarepo-ui/src/app/pages/home/import-tab/import-tab.component.scss b/mediarepo-ui/src/app/pages/home/import-tab/import-tab.component.scss
index 3f1ab9e..5eeec16 100644
--- a/mediarepo-ui/src/app/pages/home/import-tab/import-tab.component.scss
+++ b/mediarepo-ui/src/app/pages/home/import-tab/import-tab.component.scss
@@ -16,7 +16,8 @@ mat-drawer {
width: 25%;
}
-app-import-tab-sidebar {
+app-import-tab-sidebar, app-file-gallery {
height: 100%;
width: 100%;
+ margin: 0;
}
diff --git a/mediarepo-ui/src/app/pages/home/import-tab/import-tab.component.ts b/mediarepo-ui/src/app/pages/home/import-tab/import-tab.component.ts
index 4346c41..db9d560 100644
--- a/mediarepo-ui/src/app/pages/home/import-tab/import-tab.component.ts
+++ b/mediarepo-ui/src/app/pages/home/import-tab/import-tab.component.ts
@@ -6,13 +6,15 @@ import {File} from "../../../models/File";
templateUrl: './import-tab.component.html',
styleUrls: ['./import-tab.component.scss']
})
-export class ImportTabComponent implements OnInit {
+export class ImportTabComponent {
public files: File[] = [];
constructor() { }
- ngOnInit(): void {
+ public addFileFromImport(file: File) {
+ this.files.push(file);
+ this.files = [...this.files];
}
}
diff --git a/mediarepo-ui/src/app/services/import/import.service.ts b/mediarepo-ui/src/app/services/import/import.service.ts
index c089b6e..e0c18a2 100644
--- a/mediarepo-ui/src/app/services/import/import.service.ts
+++ b/mediarepo-ui/src/app/services/import/import.service.ts
@@ -1,6 +1,8 @@
import { Injectable } from '@angular/core';
import {FileOsMetadata} from "../../models/FileOsMetadata";
import {invoke} from "@tauri-apps/api/tauri";
+import {AddFileOptions} from "../../models/AddFileOptions";
+import {File} from "../../models/File";
@Injectable({
providedIn: 'root'
@@ -9,7 +11,22 @@ export class ImportService {
constructor() { }
+ /**
+ * Resolves paths from the local file system into a list of files that can be imported
+ * @param {string[]} paths
+ * @returns {Promise}
+ */
public async resolvePathsToFiles(paths: string[]): Promise {
return await invoke("plugin:mediarepo|resolve_paths_to_files", {paths});
}
+
+ /**
+ * Imports a file from the local file system
+ * @param {FileOsMetadata} metadata
+ * @param {AddFileOptions} options
+ * @returns {Promise}
+ */
+ public async addLocalFile(metadata: FileOsMetadata, options: AddFileOptions): Promise {
+ return await invoke("plugin:mediarepo|add_local_file", {metadata, options});
+ }
}