@@ -5,7 +5,8 @@ use ratatui::text::{Line, Span, Text};
55use ratatui:: widgets:: { Block , BorderType , Borders , Clear , Gauge , Paragraph , Scrollbar , ScrollbarOrientation , ScrollbarState , Wrap } ;
66
77use super :: detail:: {
8- fit_line, fit_modal_body, modal_info_line, render_detail_lines, render_modal_footer, render_modal_footer_placeholder, render_modal_info_entries,
8+ fit_line, fit_modal_body, format_syslog_timestamp, modal_info_line, render_detail_lines, render_modal_footer, render_modal_footer_placeholder,
9+ render_modal_info_entries, severity_initial, severity_style,
910} ;
1011use super :: text:: { fit_to_width, trim_single_line} ;
1112use super :: types:: { ExportField , Focus , ViewApp } ;
@@ -23,6 +24,8 @@ const EXPORT_RANGE_HELP: &str = "Range: a / all | c / current / 0 | N | N
2324const EXPORT_ORDER_HELP : & str = "Uses the current filtered view order." ;
2425const EXPORT_FORMAT_HELP_WIDTH : u16 = 55 ;
2526const EXPORT_PROMPT_MIN_WIDTH : u16 = EXPORT_FORMAT_HELP_WIDTH + 2 ;
27+ const LIST_TIMESTAMP_WIDTH : usize = 15 ;
28+ const LIST_SEVERITY_WIDTH : usize = 1 ;
2629
2730impl ViewApp {
2831 pub ( super ) fn render ( & mut self , frame : & mut Frame < ' _ > ) {
@@ -109,7 +112,7 @@ impl ViewApp {
109112 let end = ( self . list_offset + visible_rows) . min ( self . entries . len ( ) ) ;
110113 let row_width = area. width . saturating_sub ( 1 ) as usize ;
111114 for index in self . list_offset ..end {
112- let style = if self . tail_mode && self . tail_marker_index == Some ( index) {
115+ let row_style = if self . tail_mode && self . tail_marker_index == Some ( index) {
113116 Style :: default ( ) . fg ( Color :: White ) . bg ( Color :: Red ) . add_modifier ( Modifier :: BOLD )
114117 } else if index == self . selected {
115118 if self . focus == Focus :: Search {
@@ -120,8 +123,14 @@ impl ViewApp {
120123 } else {
121124 Style :: default ( ) . fg ( Color :: White )
122125 } ;
123- let summary = self . summary_for ( index) . unwrap_or_else ( |_| "<failed to render summary>" . to_string ( ) ) ;
124- lines. push ( Line :: from ( Span :: styled ( fit_line ( & summary, row_width) , style) ) ) ;
126+ let summary = self
127+ . summary_for ( index)
128+ . unwrap_or_else ( |_| super :: types:: ListRowSummary { message : "<failed to render summary>" . to_string ( ) , severity : None } ) ;
129+ if self . details_visible {
130+ lines. push ( Line :: from ( Span :: styled ( fit_line ( & summary. message , row_width) , row_style) ) ) ;
131+ } else {
132+ lines. push ( self . render_list_table_row ( index, & summary, row_width, row_style) ) ;
133+ }
125134 }
126135 }
127136
@@ -134,6 +143,24 @@ impl ViewApp {
134143 }
135144 }
136145
146+ fn render_list_table_row ( & self , index : usize , summary : & super :: types:: ListRowSummary , row_width : usize , row_style : Style ) -> Line < ' static > {
147+ let timestamp = format_syslog_timestamp ( self . entries [ index] . ts_unix_ns ) ;
148+ let timestamp = fit_to_width ( & timestamp, LIST_TIMESTAMP_WIDTH ) ;
149+ let severity = summary. severity . as_deref ( ) . unwrap_or ( "" ) ;
150+ let severity_style = severity_style ( severity) . bg ( row_style. bg . unwrap_or ( Color :: Reset ) ) ;
151+ let severity = fit_to_width ( & severity_initial ( severity) , LIST_SEVERITY_WIDTH ) ;
152+ let prefix_width = LIST_TIMESTAMP_WIDTH + 1 + LIST_SEVERITY_WIDTH + 2 ;
153+ let message_width = row_width. saturating_sub ( prefix_width) ;
154+
155+ Line :: from ( vec ! [
156+ Span :: styled( timestamp, row_style. fg( Color :: LightBlue ) ) ,
157+ Span :: styled( " " , row_style) ,
158+ Span :: styled( severity, severity_style) ,
159+ Span :: styled( " " , row_style) ,
160+ Span :: styled( fit_line( & summary. message, message_width) , row_style) ,
161+ ] )
162+ }
163+
137164 fn render_details ( & self , frame : & mut Frame < ' _ > , area : Rect ) {
138165 let block = pane_block ( " Info " , false ) ;
139166 let inner = block. inner ( area) ;
0 commit comments