refactor logviewer

This commit is contained in:
Jana Dönszelmann 2026-02-25 11:34:30 +01:00
parent 7ea9d84228
commit 79639be9da
No known key found for this signature in database
9 changed files with 425 additions and 239 deletions

View file

@ -4,7 +4,9 @@ use crate::tui::{
filter::Filter,
model::LogEntry,
processing::{IntoLogStream, LogStream},
widgets::styled::Styled,
};
use ratatui::{buffer::Buffer, layout::Rect, text::Line, widgets::Widget};
use tui_widget_list::ListState;
pub struct LogView {
@ -77,6 +79,17 @@ pub enum InputState {
Target(InputTarget),
}
impl Widget for Styled<'_, &InputState> {
fn render(self, area: Rect, buf: &mut Buffer)
where
Self: Sized,
{
Line::from(self.inner.show())
.style(self.styles.default)
.render(area, buf)
}
}
impl InputState {
pub fn capture_string(&mut self) -> Option<&mut String> {
match self {
@ -274,13 +287,12 @@ impl LogViewer {
self.last_height = num_visible_items;
}
pub fn footer_fields(&self) -> Vec<(String, serde_json::Value)> {
pub fn footer_fields(&self) -> Vec<(String, String)> {
if let Some((selected, _)) = self.selected() {
let ret = match selected.as_ref() {
LogEntry::Single { .. } => Default::default(),
LogEntry::Sub { sub_entries, .. } => sub_entries.last().and_then(|i| {
i.all_fields()
.fields
.get_key_value("return")
.map(|(k, v)| (k.clone(), v.clone()))
}),