diff --git a/mediarepo-ui/src-tauri/Cargo.lock b/mediarepo-ui/src-tauri/Cargo.lock index cdfa86a..e2ed366 100644 --- a/mediarepo-ui/src-tauri/Cargo.lock +++ b/mediarepo-ui/src-tauri/Cargo.lock @@ -1474,7 +1474,7 @@ checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" [[package]] name = "mediarepo-api" version = "0.12.0" -source = "git+https://github.com/Trivernis/mediarepo-api.git?rev=914292532e562eed389a1a49e0bb802a9f9327e1#914292532e562eed389a1a49e0bb802a9f9327e1" +source = "git+https://github.com/Trivernis/mediarepo-api.git?rev=e5b5158635191af5188e8bee7fd623328b28ab3b#e5b5158635191af5188e8bee7fd623328b28ab3b" dependencies = [ "async-trait", "chrono", diff --git a/mediarepo-ui/src-tauri/Cargo.toml b/mediarepo-ui/src-tauri/Cargo.toml index 2c77783..01f4ab2 100644 --- a/mediarepo-ui/src-tauri/Cargo.toml +++ b/mediarepo-ui/src-tauri/Cargo.toml @@ -25,7 +25,7 @@ features = [ "env-filter" ] [dependencies.mediarepo-api] git = "https://github.com/Trivernis/mediarepo-api.git" -rev = "914292532e562eed389a1a49e0bb802a9f9327e1" +rev = "e5b5158635191af5188e8bee7fd623328b28ab3b" features = [ "tauri-plugin" ] [features] diff --git a/mediarepo-ui/src/app/components/core/repositories-tab/repository-card/repository-card.component.ts b/mediarepo-ui/src/app/components/core/repositories-tab/repository-card/repository-card.component.ts index 66f964b..e4f5abb 100644 --- a/mediarepo-ui/src/app/components/core/repositories-tab/repository-card/repository-card.component.ts +++ b/mediarepo-ui/src/app/components/core/repositories-tab/repository-card/repository-card.component.ts @@ -45,25 +45,46 @@ export class RepositoryCardComponent implements OnInit, OnDestroy { } public async removeRepository() { - await this.dialog.open(ConfirmDialogComponent, { + const confirmation = await this.dialog.open(ConfirmDialogComponent, { data: { title: "Remove repository", message: `Do you really want to remove the repository "${this.repository.name}"?`, confirmAction: "Remove", confirmColor: "warn" } - }).afterClosed().subscribe(async confirmation => { - if (confirmation === true) { - if (this.isSelectedRepository()) { - if (this.repository.local) { - await this.repoService.closeSelectedRepository(); - } else { - await this.repoService.disconnectSelectedRepository(); - } + }).afterClosed().toPromise(); + if (confirmation === true) { + if (this.isSelectedRepository()) { + if (this.repository.local) { + await this.repoService.closeSelectedRepository(); + } else { + await this.repoService.disconnectSelectedRepository(); } + } + await this.promtDeleteRepository(); + } + } + + private async promtDeleteRepository() { + if (this.repository.local) { + const deleteContents = await this.dialog.open( + ConfirmDialogComponent, { + data: { + title: "Delete repository content", + message: "Do you want to remove the contents of the repository as well?", + confirmAction: "Delete", + confirmColor: "warn", + denyAction: "No", + } + }).afterClosed().toPromise(); + if (deleteContents) { + await this.repoService.deleteRepository(this.repository.name); + } else { await this.repoService.removeRepository(this.repository.name); } - }); + } else { + await this.repoService.removeRepository(this.repository.name); + } } public getDaemonStatusText(): string { diff --git a/mediarepo-ui/src/app/services/repository/repository.service.ts b/mediarepo-ui/src/app/services/repository/repository.service.ts index f7e4ebd..c075d33 100644 --- a/mediarepo-ui/src/app/services/repository/repository.service.ts +++ b/mediarepo-ui/src/app/services/repository/repository.service.ts @@ -118,6 +118,16 @@ export class RepositoryService { await this.loadRepositories(); } + /** + * Deletes a local repository from the filesystem + * @param {string} name + * @returns {Promise} + */ + public async deleteRepository(name: string): Promise { + await invoke("plugin:mediarepo|delete_repository", {name}); + await this.removeRepository(name); + } + /** * Starts a daemon for the given repository path * @param {string} repoPath