use gloo_storage::{LocalStorage, Storage}; use leptos::prelude::*; use leptos::task::spawn_local; use crate::api::client; use crate::components::onboarding::{NextSteps, SystemStatus, WelcomeWizard}; use crate::config::use_config; #[component] pub fn DashboardPage() -> impl IntoView { // Check if onboarding is complete let (show_wizard, set_show_wizard) = signal(false); let (show_onboarding_section, set_show_onboarding_section) = signal(true); // Check onboarding status on mount Effect::new(move |_| { let onboarding_complete = LocalStorage::get::("onboarding_complete").unwrap_or(false); if !onboarding_complete { set_show_wizard.set(true); } set_show_onboarding_section.set(!onboarding_complete); }); // Reactive signals for service status let (orchestrator_status, set_orchestrator_status) = signal(String::from("Loading...")); let (orchestrator_color, set_orchestrator_color) = signal(String::from("#999")); let (control_center_status, set_control_center_status) = signal(String::from("Loading...")); let (control_center_color, set_control_center_color) = signal(String::from("#999")); let (active_tasks, set_active_tasks) = signal(0usize); // Signals for onboarding status checks let (workspace_exists, set_workspace_exists) = signal(false); let (servers_exist, set_servers_exist) = signal(false); let (taskservs_exist, set_taskservs_exist) = signal(false); // Fetch orchestrator health Effect::new(move |_| { spawn_local(async move { match client::fetch_orchestrator_health().await { Ok(health) => { set_orchestrator_status.set(format!("✅ {}", health.status)); set_orchestrator_color.set(String::from("#10b981")); } Err(e) => { set_orchestrator_status.set(format!("❌ Error: {}", e)); set_orchestrator_color.set(String::from("#ef4444")); } } }); }); // Fetch control-center health Effect::new(move |_| { spawn_local(async move { match client::fetch_control_center_health().await { Ok(health) => { set_control_center_status.set(format!("✅ {}", health.status)); set_control_center_color.set(String::from("#10b981")); } Err(e) => { set_control_center_status.set(format!("❌ Error: {}", e)); set_control_center_color.set(String::from("#ef4444")); } } }); }); // Fetch active tasks Effect::new(move |_| { spawn_local(async move { match client::fetch_tasks().await { Ok(tasks_response) => { set_active_tasks.set(tasks_response.tasks.len()); } Err(e) => { web_sys::console::warn_1(&format!("Failed to fetch tasks: {}", e).into()); set_active_tasks.set(0); } } }); }); // Get config for URLs let config = use_config(); view! { // Welcome Wizard (shows on first visit)

"📊 Dashboard"

// Orchestrator Status Card

"Orchestrator Status"

{move || orchestrator_status.get()}

{config.api.orchestrator_url.clone()}

// Control Center Status Card

"Control Center Status"

{move || control_center_status.get()}

{config.api.control_center_url.clone()}

// Workflows Card

"Active Tasks"

{move || active_tasks.get().to_string()}

{move || if active_tasks.get() == 0 { "No tasks running" } else if active_tasks.get() == 1 { "1 task running" } else { "tasks running" }}

"🚀 Quick Actions"

"Manage Servers" "View Workflows" "Task Services"
// Onboarding sections (show if not completed)
"💡"

"New to the platform?"

"Complete the welcome wizard to set up your first infrastructure. You can restart it anytime from Settings."

} }