Clean Up
This commit is contained in:
parent
b130c4550d
commit
4f9ced3e29
3 changed files with 11 additions and 8 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ pub struct DashboardViewState {
|
|||
pub title: String,
|
||||
pub descriptions: Option<String>,
|
||||
pub monitors: Vec<MonitorViewState>,
|
||||
pub selected_index: usize,
|
||||
pub is_loading: bool,
|
||||
pub error_message: Option<String>,
|
||||
}
|
||||
|
|
@ -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,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue