From 60140fcd97b31770e0b3c2edca6bb9ec98510dc7 Mon Sep 17 00:00:00 2001 From: Trivernis Date: Mon, 27 Dec 2021 16:16:18 +0100 Subject: [PATCH] Add missing tauri commands Signed-off-by: Trivernis --- mediarepo-api/src/tauri_plugin/commands/file.rs | 9 +++++++++ mediarepo-api/src/tauri_plugin/commands/tag.rs | 10 +++++++++- mediarepo-api/src/tauri_plugin/mod.rs | 4 +++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/mediarepo-api/src/tauri_plugin/commands/file.rs b/mediarepo-api/src/tauri_plugin/commands/file.rs index f3d1c20..86121aa 100644 --- a/mediarepo-api/src/tauri_plugin/commands/file.rs +++ b/mediarepo-api/src/tauri_plugin/commands/file.rs @@ -25,6 +25,15 @@ pub async fn get_all_files(api_state: ApiAccess<'_>) -> PluginResult, ids: Vec) -> PluginResult> { + let api = api_state.api().await?; + let ids = ids.into_iter().map(|id| FileIdentifier::ID(id)).collect(); + let files = api.file.get_files(ids).await?; + + Ok(files) +} + #[tauri::command] pub async fn add_local_file( api_state: ApiAccess<'_>, diff --git a/mediarepo-api/src/tauri_plugin/commands/tag.rs b/mediarepo-api/src/tauri_plugin/commands/tag.rs index d54bfa7..dbd2bdd 100644 --- a/mediarepo-api/src/tauri_plugin/commands/tag.rs +++ b/mediarepo-api/src/tauri_plugin/commands/tag.rs @@ -1,7 +1,7 @@ use crate::tauri_plugin::commands::ApiAccess; use crate::tauri_plugin::error::PluginResult; use crate::types::identifier::FileIdentifier; -use crate::types::tags::TagResponse; +use crate::types::tags::{NamespaceResponse, TagResponse}; #[tauri::command] pub async fn get_all_tags(api_state: ApiAccess<'_>) -> PluginResult> { @@ -11,6 +11,14 @@ pub async fn get_all_tags(api_state: ApiAccess<'_>) -> PluginResult) -> PluginResult> { + let api = api_state.api().await?; + let all_namespaces = api.tag.get_all_namespaces().await?; + + Ok(all_namespaces) +} + #[tauri::command] pub async fn get_tags_for_file( id: i64, diff --git a/mediarepo-api/src/tauri_plugin/mod.rs b/mediarepo-api/src/tauri_plugin/mod.rs index 3254f3a..574408e 100644 --- a/mediarepo-api/src/tauri_plugin/mod.rs +++ b/mediarepo-api/src/tauri_plugin/mod.rs @@ -61,7 +61,9 @@ impl MediarepoPlugin { delete_repository, has_executable, get_frontend_state, - set_frontend_state + set_frontend_state, + get_all_namespaces, + get_files ]), } }