aboutsummaryrefslogtreecommitdiffstats
path: root/ui/backend/src/main.rs
diff options
context:
space:
mode:
authorEllie Huxtable <ellie@elliehuxtable.com>2024-04-11 16:59:01 +0100
committerGitHub <noreply@github.com>2024-04-11 16:59:01 +0100
commit6cd4319fcf540ef70f74cc2f10d0d4297ee7b788 (patch)
tree3d24dbf70493c377e162d9941faac65c829623f9 /ui/backend/src/main.rs
parentfeat(bash/blesh): use _ble_exec_time_ata for duration even in bash < 5 (#1940) (diff)
downloadatuin-6cd4319fcf540ef70f74cc2f10d0d4297ee7b788.zip
feat(gui): add base structure (#1935)
* initial * ui things * cargo * update, add history refresh button * history page a bit better, add initial dotfiles page * re-org layout * bye squigglies * add dotfiles ui, show aliases * add default shell detection * put stats in a little drawer, alias import changes * use new table for aliases, add alias deleting * support adding aliases * close drawer when added, no alias autocomplete * clippy, format * attempt to ensure gdk is installed ok * sudo * no linux things on mac ffs * I forgot we build for windows too... end of day * remove tauri backend from workspace
Diffstat (limited to 'ui/backend/src/main.rs')
-rw-r--r--ui/backend/src/main.rs63
1 files changed, 63 insertions, 0 deletions
diff --git a/ui/backend/src/main.rs b/ui/backend/src/main.rs
new file mode 100644
index 00000000..98967562
--- /dev/null
+++ b/ui/backend/src/main.rs
@@ -0,0 +1,63 @@
+// Prevents additional console window on Windows in release, DO NOT REMOVE!!
+#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
+
+use std::path::PathBuf;
+
+use atuin_client::settings::Settings;
+
+mod db;
+mod dotfiles;
+mod store;
+
+use db::{GlobalStats, HistoryDB, UIHistory};
+use dotfiles::aliases::aliases;
+
+#[tauri::command]
+async fn list() -> Result<Vec<UIHistory>, String> {
+ let settings = Settings::new().map_err(|e| e.to_string())?;
+
+ let db_path = PathBuf::from(settings.db_path.as_str());
+ let db = HistoryDB::new(db_path, settings.local_timeout).await?;
+
+ let history = db.list(Some(100), false).await?;
+
+ Ok(history)
+}
+
+#[tauri::command]
+async fn search(query: String) -> Result<Vec<UIHistory>, String> {
+ let settings = Settings::new().map_err(|e| e.to_string())?;
+
+ let db_path = PathBuf::from(settings.db_path.as_str());
+ let db = HistoryDB::new(db_path, settings.local_timeout).await?;
+
+ let history = db.search(query.as_str()).await?;
+
+ Ok(history)
+}
+
+#[tauri::command]
+async fn global_stats() -> Result<GlobalStats, String> {
+ let settings = Settings::new().map_err(|e| e.to_string())?;
+ let db_path = PathBuf::from(settings.db_path.as_str());
+ let db = HistoryDB::new(db_path, settings.local_timeout).await?;
+
+ let stats = db.global_stats().await?;
+
+ Ok(stats)
+}
+
+fn main() {
+ tauri::Builder::default()
+ .invoke_handler(tauri::generate_handler![
+ list,
+ search,
+ global_stats,
+ aliases,
+ dotfiles::aliases::import_aliases,
+ dotfiles::aliases::delete_alias,
+ dotfiles::aliases::set_alias,
+ ])
+ .run(tauri::generate_context!())
+ .expect("error while running tauri application");
+}