mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-04 21:49:40 +00:00
Add ERI server assistant (#231)
This commit is contained in:
1 parent
cdf717ad5f
commit
8cbef49d89
76 files changed
+3581
-153
No files matched your search
+1
-1
@@ -9,7 +9,7 @@ authors = ["Thorsten Sommer"]
|
||||
tauri-build = { version = "1.5", features = [] }
|
||||
|
||||
[dependencies]
|
||||
tauri = { version = "1.8", features = [ "http-all", "updater", "shell-sidecar", "shell-open"] }
|
||||
tauri = { version = "1.8", features = [ "http-all", "updater", "shell-sidecar", "shell-open", "dialog"] }
|
||||
tauri-plugin-window-state = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
|
||||
@@ -2,11 +2,13 @@ use std::sync::Mutex;
|
||||
use std::time::Duration;
|
||||
use log::{error, info, warn};
|
||||
use once_cell::sync::Lazy;
|
||||
use rocket::get;
|
||||
use rocket::{get, post};
|
||||
use rocket::serde::json::Json;
|
||||
use rocket::serde::Serialize;
|
||||
use serde::Deserialize;
|
||||
use tauri::updater::UpdateResponse;
|
||||
use tauri::{Manager, Window};
|
||||
use tauri::api::dialog::blocking::FileDialogBuilder;
|
||||
use tokio::time;
|
||||
use crate::api_token::APIToken;
|
||||
use crate::dotnet::stop_dotnet_server;
|
||||
@@ -219,4 +221,53 @@ pub async fn install_update(_token: APIToken) {
|
||||
error!(Source = "Updater"; "No update available to install. Did you check for updates first?");
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/// Let the user select a directory.
|
||||
#[post("/select/directory?<title>", data = "<previous_directory>")]
|
||||
pub fn select_directory(_token: APIToken, title: &str, previous_directory: Option<Json<PreviousDirectory>>) -> Json<DirectorySelectionResponse> {
|
||||
let folder_path = match previous_directory {
|
||||
Some(previous) => {
|
||||
let previous_path = previous.path.as_str();
|
||||
FileDialogBuilder::new()
|
||||
.set_title(title)
|
||||
.set_directory(previous_path)
|
||||
.pick_folder()
|
||||
},
|
||||
|
||||
None => {
|
||||
FileDialogBuilder::new()
|
||||
.set_title(title)
|
||||
.pick_folder()
|
||||
},
|
||||
};
|
||||
|
||||
match folder_path {
|
||||
Some(path) => {
|
||||
info!("User selected directory: {path:?}");
|
||||
Json(DirectorySelectionResponse {
|
||||
user_cancelled: false,
|
||||
selected_directory: path.to_str().unwrap().to_string(),
|
||||
})
|
||||
},
|
||||
|
||||
None => {
|
||||
info!("User cancelled directory selection.");
|
||||
Json(DirectorySelectionResponse {
|
||||
user_cancelled: true,
|
||||
selected_directory: String::from(""),
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize)]
|
||||
pub struct PreviousDirectory {
|
||||
path: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct DirectorySelectionResponse {
|
||||
user_cancelled: bool,
|
||||
selected_directory: String,
|
||||
}
|
||||
@@ -84,6 +84,7 @@ pub fn start_runtime_api() {
|
||||
crate::clipboard::set_clipboard,
|
||||
crate::app_window::check_for_update,
|
||||
crate::app_window::install_update,
|
||||
crate::app_window::select_directory,
|
||||
crate::secret::get_secret,
|
||||
crate::secret::store_secret,
|
||||
crate::secret::delete_secret,
|
||||
|
||||
Reference in new issue
Block a user