diff --git a/src/locales/en-US/main.ftl b/src/locales/en-US/main.ftl index 4a71df0..7f587e3 100644 --- a/src/locales/en-US/main.ftl +++ b/src/locales/en-US/main.ftl @@ -18,8 +18,8 @@ status = Status error = Error dashboard-header = Status Dashboard never = Never -auto-update-failed = Automatic update failed -update-fail = Failed to update data +auto-update-failed = Automatic update failed: {error} +update-fail = Failed to update data: {error} now = Now uptime = Uptime history = History diff --git a/src/ui/app.rs b/src/ui/app.rs index 5b23c73..144728c 100644 --- a/src/ui/app.rs +++ b/src/ui/app.rs @@ -1,6 +1,6 @@ use crate::api::{UptimeKumaClient, UptimeKumaEndpoints}; use crate::core; -use crate::i18n::t; +use crate::i18n::{t, t_with_args}; use crate::ui::{ components::{render_header, render_monitor_list}, dashboard::model::DashboardViewState, @@ -19,6 +19,7 @@ use ratatui::{ widgets::{Block, Borders, Padding, Paragraph}, }; +use std::collections::HashMap; use std::{ io, time::{Duration, Instant}, @@ -143,7 +144,9 @@ impl App { fn update_if_needed(&mut self) -> io::Result<()> { if self.last_update.elapsed() >= self.update_interval { if let Err(e) = self.refresh_data() { - self.state.error_message = Some(t("auto-update-failed")); + let mut error = HashMap::new(); + error.insert("error", e.to_string()); + self.state.error_message = Some(t_with_args("auto-update-failed", &error)); } self.last_update = Instant::now(); } @@ -155,7 +158,10 @@ impl App { self.render(); if let Err(e) = self.fetch_and_update_data() { - self.state.error_message = Some(t("update-fail")) + let mut error = HashMap::new(); + error.insert("error", e.to_string()); + + self.state.error_message = Some(t_with_args("update-fail", &error)) } self.state.is_loading = false; diff --git a/src/ui/dashboard/model.rs b/src/ui/dashboard/model.rs index a37de09..bab3b78 100644 --- a/src/ui/dashboard/model.rs +++ b/src/ui/dashboard/model.rs @@ -26,7 +26,6 @@ pub struct DashboardViewState { pub title: String, pub descriptions: Option, pub monitors: Vec, - pub selected_index: usize, pub is_loading: bool, pub error_message: Option, } @@ -37,7 +36,6 @@ impl DashboardViewState { title: t("loading").to_string(), descriptions: None, monitors: Vec::new(), - selected_index: 0, is_loading: true, error_message: None, } @@ -91,7 +89,6 @@ impl DashboardViewState { title: data.title, descriptions: data.description, monitors, - selected_index: 0, is_loading: false, error_message: None, }