mirror of
https://github.com/bleackstorm/SteamFrame-FPV-Control-Center.git
synced 2026-12-03 07:31:57 +01:00
222 lines
10 KiB
Rust
222 lines
10 KiB
Rust
use super::theme::*;
|
|
use super::SteamFrameGpuiApp;
|
|
use crate::logger::LogFilter;
|
|
use gpui::{div, prelude::*, rgb, Context, IntoElement};
|
|
|
|
impl SteamFrameGpuiApp {
|
|
pub(super) fn render_logs_view(&self, cx: &mut Context<Self>) -> impl IntoElement {
|
|
div()
|
|
.flex()
|
|
.flex_col()
|
|
.size_full()
|
|
.bg(rgb(COLOR_SURFACE_CARD))
|
|
.border_1()
|
|
.border_color(rgb(COLOR_BORDER_SUBTLE))
|
|
.rounded_xl()
|
|
.p_4()
|
|
.gap_3()
|
|
.overflow_hidden()
|
|
// Barre d'outils
|
|
.child(
|
|
div()
|
|
.flex()
|
|
.justify_between()
|
|
.items_center()
|
|
.border_b_1()
|
|
.border_color(rgb(COLOR_BORDER_SUBTLE))
|
|
.pb_3()
|
|
.child(
|
|
div()
|
|
.flex()
|
|
.items_center()
|
|
.gap_3()
|
|
.child(
|
|
div()
|
|
.text_sm()
|
|
.font_weight(gpui::FontWeight::BOLD)
|
|
.text_color(rgb(COLOR_CYAN))
|
|
.child("📜 Console de Diagnostic et Journal Système"),
|
|
)
|
|
.child(
|
|
div()
|
|
.text_xs()
|
|
.text_color(if self.log_err_count > 0 {
|
|
rgb(COLOR_RED)
|
|
} else {
|
|
rgb(COLOR_TEXT_MUTED)
|
|
})
|
|
.child(format!("{} Erreurs", self.log_err_count)),
|
|
)
|
|
.child(
|
|
div()
|
|
.text_xs()
|
|
.text_color(if self.log_warn_count > 0 {
|
|
rgb(COLOR_ORANGE)
|
|
} else {
|
|
rgb(COLOR_TEXT_MUTED)
|
|
})
|
|
.child(format!("{} Avertissements", self.log_warn_count)),
|
|
),
|
|
)
|
|
.child(
|
|
div()
|
|
.flex()
|
|
.gap_2()
|
|
.child(
|
|
div()
|
|
.id("filter_all_tab")
|
|
.px_3()
|
|
.py_1()
|
|
.bg(if self.log_filter == LogFilter::All {
|
|
rgb(0x1e3a5f)
|
|
} else {
|
|
rgb(COLOR_SURFACE_ELEVATED)
|
|
})
|
|
.border_1()
|
|
.border_color(if self.log_filter == LogFilter::All {
|
|
rgb(COLOR_CYAN)
|
|
} else {
|
|
rgb(COLOR_BORDER_SUBTLE)
|
|
})
|
|
.rounded_md()
|
|
.text_xs()
|
|
.cursor_pointer()
|
|
.on_click(cx.listener(|this, _, _, cx| {
|
|
this.log_filter = LogFilter::All;
|
|
cx.notify();
|
|
}))
|
|
.child("Tous les logs"),
|
|
)
|
|
.child(
|
|
div()
|
|
.id("filter_warn_tab")
|
|
.px_3()
|
|
.py_1()
|
|
.bg(if self.log_filter == LogFilter::WarningsAndErrors {
|
|
rgb(0x1e3a5f)
|
|
} else {
|
|
rgb(COLOR_SURFACE_ELEVATED)
|
|
})
|
|
.border_1()
|
|
.border_color(if self.log_filter == LogFilter::WarningsAndErrors {
|
|
rgb(COLOR_ORANGE)
|
|
} else {
|
|
rgb(COLOR_BORDER_SUBTLE)
|
|
})
|
|
.rounded_md()
|
|
.text_xs()
|
|
.cursor_pointer()
|
|
.on_click(cx.listener(|this, _, _, cx| {
|
|
this.log_filter = LogFilter::WarningsAndErrors;
|
|
cx.notify();
|
|
}))
|
|
.child("Warn / Erreurs"),
|
|
)
|
|
.child(
|
|
div()
|
|
.id("filter_err_tab")
|
|
.px_3()
|
|
.py_1()
|
|
.bg(if self.log_filter == LogFilter::ErrorsOnly {
|
|
rgb(0x1e3a5f)
|
|
} else {
|
|
rgb(COLOR_SURFACE_ELEVATED)
|
|
})
|
|
.border_1()
|
|
.border_color(if self.log_filter == LogFilter::ErrorsOnly {
|
|
rgb(COLOR_RED)
|
|
} else {
|
|
rgb(COLOR_BORDER_SUBTLE)
|
|
})
|
|
.rounded_md()
|
|
.text_xs()
|
|
.cursor_pointer()
|
|
.on_click(cx.listener(|this, _, _, cx| {
|
|
this.log_filter = LogFilter::ErrorsOnly;
|
|
cx.notify();
|
|
}))
|
|
.child("Erreurs seules"),
|
|
)
|
|
.child(
|
|
div()
|
|
.id("btn_clear_logs_tab")
|
|
.px_3()
|
|
.py_1()
|
|
.bg(rgb(COLOR_SURFACE_ELEVATED))
|
|
.border_1()
|
|
.border_color(rgb(COLOR_BORDER_SUBTLE))
|
|
.rounded_md()
|
|
.text_xs()
|
|
.cursor_pointer()
|
|
.on_click(cx.listener(|this, _, _, cx| {
|
|
let mut lb = this.log_buffer.lock();
|
|
lb.entries.clear();
|
|
lb.error_count = 0;
|
|
lb.warn_count = 0;
|
|
this.log_entries.clear();
|
|
this.log_err_count = 0;
|
|
this.log_warn_count = 0;
|
|
cx.notify();
|
|
}))
|
|
.child("🗑️ Effacer"),
|
|
),
|
|
),
|
|
)
|
|
// Liste scrollable des messages
|
|
.child(
|
|
div()
|
|
.flex()
|
|
.flex_col()
|
|
.flex_1()
|
|
.min_h_0()
|
|
.min_w_0()
|
|
.id("logs_scroll_tab")
|
|
.overflow_y_scroll()
|
|
.px_2()
|
|
.gap_1()
|
|
.children(
|
|
self.log_entries
|
|
.iter()
|
|
.filter(|e| match self.log_filter {
|
|
LogFilter::All => true,
|
|
LogFilter::WarningsAndErrors => {
|
|
matches!(e.level, log::Level::Warn | log::Level::Error)
|
|
}
|
|
LogFilter::ErrorsOnly => matches!(e.level, log::Level::Error),
|
|
})
|
|
.map(|e| {
|
|
let badge_color = match e.level {
|
|
log::Level::Error => COLOR_RED,
|
|
log::Level::Warn => COLOR_ORANGE,
|
|
_ => COLOR_CYAN,
|
|
};
|
|
div()
|
|
.flex()
|
|
.gap_2()
|
|
.text_xs()
|
|
.child(
|
|
div()
|
|
.text_color(rgb(COLOR_TEXT_MUTED))
|
|
.child(e.timestamp.clone()),
|
|
)
|
|
.child(
|
|
div()
|
|
.font_weight(gpui::FontWeight::BOLD)
|
|
.text_color(rgb(badge_color))
|
|
.child(format!("[{:<5}]", e.level)),
|
|
)
|
|
.child(
|
|
div()
|
|
.text_color(rgb(COLOR_TEXT_MAIN))
|
|
.child(e.message.clone()),
|
|
)
|
|
}),
|
|
),
|
|
)
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
// Helpers Composants Graphiques
|
|
// -------------------------------------------------------------------------
|
|
}
|