@@ -18,6 +18,7 @@ use crate::gui::styles::types::palette_extension::PaletteExtension;
1818use crate :: gui:: types:: message:: Message ;
1919use crate :: networking:: types:: capture_context:: CaptureSource ;
2020use crate :: networking:: types:: data_info:: DataInfo ;
21+ use crate :: networking:: types:: data_info_host:: DataInfoHost ;
2122use crate :: networking:: types:: filters:: Filters ;
2223use crate :: networking:: types:: host:: Host ;
2324use crate :: report:: get_report_entries:: { get_host_entries, get_service_entries} ;
@@ -256,50 +257,21 @@ fn col_host<'a>(sniffer: &Sniffer) -> Column<'a, Message, StyleType> {
256257 . unwrap_or_default ( ) ;
257258
258259 for ( host, data_info_host) in & entries {
259- let ( incoming_bar_len, outgoing_bar_len) = get_bars_length (
260- chart_type,
261- & first_entry_data_info,
262- & data_info_host. data_info ,
263- ) ;
264-
265260 let star_button = get_star_button ( data_info_host. is_favorite , host. clone ( ) ) ;
266261
267- let host_bar = Column :: new ( )
268- . spacing ( 1 )
269- . push (
270- Row :: new ( )
271- . push ( Text :: new ( host. domain . clone ( ) ) . font ( font) )
272- . push (
273- Text :: new ( if host. asn . name . is_empty ( ) {
274- String :: new ( )
275- } else {
276- format ! ( " - {}" , host. asn. name)
277- } )
278- . font ( font) ,
279- )
280- . push ( horizontal_space ( ) )
281- . push (
282- Text :: new ( if chart_type. eq ( & ChartType :: Packets ) {
283- data_info_host. data_info . tot_packets ( ) . to_string ( )
284- } else {
285- ByteMultiple :: formatted_string ( data_info_host. data_info . tot_bytes ( ) )
286- } )
287- . font ( font) ,
288- ) ,
289- )
290- . push ( get_bars ( incoming_bar_len, outgoing_bar_len) ) ;
262+ let host_bar = host_bar (
263+ host,
264+ data_info_host,
265+ chart_type,
266+ first_entry_data_info,
267+ font,
268+ language,
269+ ) ;
291270
292271 let content = Row :: new ( )
293272 . align_y ( Alignment :: Center )
294273 . spacing ( 5 )
295274 . push ( star_button)
296- . push ( get_flag_tooltip (
297- host. country ,
298- data_info_host,
299- language,
300- font,
301- false ,
302- ) )
303275 . push ( host_bar) ;
304276
305277 scroll_host = scroll_host. push (
@@ -426,6 +398,58 @@ fn col_service<'a>(sniffer: &Sniffer) -> Column<'a, Message, StyleType> {
426398 )
427399}
428400
401+ pub fn host_bar < ' a > (
402+ host : & Host ,
403+ data_info_host : & DataInfoHost ,
404+ chart_type : ChartType ,
405+ first_entry_data_info : DataInfo ,
406+ font : Font ,
407+ language : Language ,
408+ ) -> Row < ' a , Message , StyleType > {
409+ let ( incoming_bar_len, outgoing_bar_len) = get_bars_length (
410+ chart_type,
411+ & first_entry_data_info,
412+ & data_info_host. data_info ,
413+ ) ;
414+
415+ Row :: new ( )
416+ . align_y ( Alignment :: Center )
417+ . spacing ( 5 )
418+ . push ( get_flag_tooltip (
419+ host. country ,
420+ data_info_host,
421+ language,
422+ font,
423+ false ,
424+ ) )
425+ . push (
426+ Column :: new ( )
427+ . spacing ( 1 )
428+ . push (
429+ Row :: new ( )
430+ . push ( Text :: new ( host. domain . clone ( ) ) . font ( font) )
431+ . push (
432+ Text :: new ( if host. asn . name . is_empty ( ) {
433+ String :: new ( )
434+ } else {
435+ format ! ( " - {}" , host. asn. name)
436+ } )
437+ . font ( font) ,
438+ )
439+ . push ( horizontal_space ( ) )
440+ . push (
441+ Text :: new ( if chart_type. eq ( & ChartType :: Packets ) {
442+ data_info_host. data_info . tot_packets ( ) . to_string ( )
443+ } else {
444+ ByteMultiple :: formatted_string ( data_info_host. data_info . tot_bytes ( ) )
445+ } )
446+ . font ( font) ,
447+ ) ,
448+ )
449+ . push ( get_bars ( incoming_bar_len, outgoing_bar_len) ) ,
450+ )
451+ }
452+
429453fn col_info < ' a > ( sniffer : & Sniffer ) -> Container < ' a , Message , StyleType > {
430454 let ConfigSettings {
431455 style, language, ..
0 commit comments