perspective_viewer/components/
rows_counter.rs1use yew::prelude::*;
14
15use crate::session::ViewStats;
16use crate::utils::u32Ext;
17
18#[derive(PartialEq, Properties)]
22pub struct RowsCounterProps {
23 pub stats: Option<ViewStats>,
24}
25
26#[function_component]
28pub fn RowsCounter(props: &RowsCounterProps) -> Html {
29 match props.stats {
30 Some(
31 ViewStats {
32 num_table_cells: Some((tr, tc)),
33 num_view_cells: Some((vr, vc)),
34 is_group_by: true,
35 ..
36 }
37 | ViewStats {
38 num_table_cells: Some((tr, tc)),
39 num_view_cells: Some((vr, vc)),
40 is_filtered: true,
41 ..
42 },
43 ) if vc != tc => {
44 let vrows = vr.to_formatted_string();
45 let nrows = tr.to_formatted_string();
46 let vcols = vc.to_formatted_string();
47 let ncols = tc.to_formatted_string();
48 html! {
49 <span id="rows">
50 <span>{ vrows }</span>
51 <span class="total">{ format!(" ({})", nrows) }</span>
52 <span class="x">{ " / " }</span>
53 <span>{ vcols }</span>
54 <span class="total">{ format!(" ({})", ncols) }</span>
55 </span>
56 }
57 },
58
59 Some(
60 ViewStats {
61 num_table_cells: Some((tr, _)),
62 num_view_cells: Some((vr, vc)),
63 is_group_by: true,
64 ..
65 }
66 | ViewStats {
67 num_table_cells: Some((tr, _)),
68 num_view_cells: Some((vr, vc)),
69 is_filtered: true,
70 ..
71 },
72 ) => {
73 let vrows = vr.to_formatted_string();
74 let nrows = tr.to_formatted_string();
75 let vcols = vc.to_formatted_string();
76 html! {
77 <span id="rows">
78 <span>{ vrows }</span>
79 <span class="total">{ format!(" ({})", nrows) }</span>
80 <span class="x">{ " / " }</span>
81 <span>{ vcols }</span>
82 </span>
83 }
84 },
85
86 Some(ViewStats {
87 num_table_cells: Some((_, tc)),
88 num_view_cells: Some((vr, vc)),
89 ..
90 }) if vc != tc => {
91 let vrows = vr.to_formatted_string();
92 let vcols = vc.to_formatted_string();
93 let ncols = tc.to_formatted_string();
94 html! {
95 <span id="rows">
96 <span>{ vrows }</span>
97 <span class="x">{ " / " }</span>
98 <span>{ vcols }</span>
99 <span class="total">{ format!(" ({})", ncols) }</span>
100 </span>
101 }
102 },
103
104 Some(ViewStats {
105 num_table_cells: Some((tr, tc)),
106 ..
107 }) => {
108 let nrows = tr.to_formatted_string();
109 let ncols = tc.to_formatted_string();
110 html! {
111 <span id="rows">
112 <span>{ nrows }</span>
113 <span class="x">{ " / " }</span>
114 <span>{ ncols }</span>
115 </span>
116 }
117 },
118 Some(ViewStats {
119 num_table_cells: None,
120 ..
121 }) => html! { <span /> },
122 None => html! { <span /> },
123 }
124}