Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions src-tauri/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,52 @@ pub async fn read_file(path: String) -> Result<String, String> {
/// building a WebView2 window there deadlocks on Windows (tauri-apps/wry#583):
/// the window never appeared, and every other window froze with it, so the
/// app could not even be closed.
/// A dashboard on its own: a window with nothing but that dashboard's cards,
/// for a second screen. One window per dashboard; asking again focuses it.
/// It runs its queries on the connection the app has open, like any window.
#[tauri::command]
pub async fn open_dashboard_window(app: tauri::AppHandle, dashboard_id: String, connection_id: String, title: String) -> Result<(), String> {
let safe = |s: &str| s.chars().all(|c| c.is_ascii_alphanumeric() || c == '-' || c == '_');
if dashboard_id.is_empty() || !safe(&dashboard_id) || !safe(&connection_id) {
return Err("That isn't a dashboard".into());
}
let label = format!("main-dashboard-{}", dashboard_id.chars().filter(|c| c.is_ascii_alphanumeric()).take(40).collect::<String>());
if let Some(w) = app.webview_windows().get(label.as_str()) {
let _ = w.unminimize();
let _ = w.set_focus();
return Ok(());
}
let url = format!("/?view=dashboard&dash={dashboard_id}&conn={connection_id}");
let mut builder = tauri::WebviewWindowBuilder::new(&app, &label, tauri::WebviewUrl::App(url.into()))
.title(if title.trim().is_empty() { "Dashboard".to_string() } else { title })
.inner_size(1440.0, 900.0)
.min_inner_size(640.0, 420.0)
.resizable(true)
.visible(false)
.background_color(tauri::window::Color(8, 8, 8, 255))
.devtools(cfg!(debug_assertions))
.zoom_hotkeys_enabled(false)
.on_navigation(crate::navigation_allowed);
#[cfg(target_os = "macos")]
{
builder = builder
.title_bar_style(tauri::TitleBarStyle::Overlay)
.hidden_title(true)
.traffic_light_position(crate::mac_chrome::traffic_light_position());
}
#[cfg(not(target_os = "macos"))]
{
builder = builder.decorations(false);
}
let window = builder.build().map_err(|e| e.to_string())?;
let surface = crate::surface_for_theme(window.theme().unwrap_or(tauri::Theme::Dark));
let _ = window.set_background_color(Some(surface));
crate::set_webview_backdrop(&window, surface);
crate::guard_webview(&window);
crate::arm_reveal_failsafe(&window);
Ok(())
}

#[tauri::command]
pub async fn open_new_window(app: tauri::AppHandle) -> Result<(), String> {
// Labels must be unique and stable-ish; the counter restarts with the app,
Expand Down
1 change: 1 addition & 0 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,7 @@ pub fn run() {
commands::ai_fetch_page,
commands::read_file,
commands::open_new_window,
commands::open_dashboard_window,
launch::take_open_request,
commands::reveal_window,
commands::restart_app,
Expand Down
11 changes: 10 additions & 1 deletion src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
import { onMount } from 'svelte'
import { Toaster } from '$lib/components/ui/sonner/index.js'
import StudioShell from './lib/components/StudioShell.svelte'
import DashboardWindow from './lib/components/DashboardWindow.svelte'

// A window opened for one dashboard (open_dashboard_window) shows only that.
const params = typeof location !== 'undefined' ? new URLSearchParams(location.search) : new URLSearchParams()
const dashboardView = params.get('view') === 'dashboard' ? { dash: params.get('dash') ?? '', conn: params.get('conn') ?? '' } : null
import LicenseGate from './lib/components/LicenseGate.svelte'
import AppLockGate from './lib/components/AppLockGate.svelte'
import AppErrorBoundary from './lib/components/AppErrorBoundary.svelte'
Expand Down Expand Up @@ -96,7 +101,11 @@
behind it runs - not the license check, not a reconnect. -->
<AppLockGate>
<LicenseGate>
<StudioShell />
{#if dashboardView}
<DashboardWindow dashboardId={dashboardView.dash} connectionId={dashboardView.conn} />
{:else}
<StudioShell />
{/if}
</LicenseGate>
</AppLockGate>
</AppErrorBoundary>
Expand Down
Loading
Loading