1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
// ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃
// ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃
// ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃
// ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃
// ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
// ┃ Copyright (c) 2017, the Perspective Authors. ┃
// ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
// ┃ This file is part of the Perspective library, distributed under the terms ┃
// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
use yew::prelude::*;
use crate::session::ViewStats;
use crate::utils::u32Ext;
/// Props are now pure value types: no `Session` handle, no PubSub
/// subscriptions. The parent passes an updated `stats` whenever the
/// underlying data changes (driven by the root's `UpdateSession` message).
#[derive(PartialEq, Properties)]
pub struct StatusBarRowsCounterProps {
pub stats: Option<ViewStats>,
}
/// A component to show the current [`Table`]'s dimensions.
#[function_component]
pub fn StatusBarRowsCounter(props: &StatusBarRowsCounterProps) -> Html {
match props.stats {
Some(
ViewStats {
num_table_cells: Some((tr, tc)),
num_view_cells: Some((vr, vc)),
is_group_by: true,
..
}
| ViewStats {
num_table_cells: Some((tr, tc)),
num_view_cells: Some((vr, vc)),
is_filtered: true,
..
},
) if vc != tc => {
let vrows = vr.to_formatted_string();
let nrows = tr.to_formatted_string();
let vcols = vc.to_formatted_string();
let ncols = tc.to_formatted_string();
html! {
<span id="rows">
<span>{ vrows }</span>
<span class="total">{ format!(" ({})", nrows) }</span>
<span class="x">{ " x " }</span>
<span>{ vcols }</span>
<span class="total">{ format!(" ({})", ncols) }</span>
</span>
}
},
Some(
ViewStats {
num_table_cells: Some((tr, _)),
num_view_cells: Some((vr, vc)),
is_group_by: true,
..
}
| ViewStats {
num_table_cells: Some((tr, _)),
num_view_cells: Some((vr, vc)),
is_filtered: true,
..
},
) => {
let vrows = vr.to_formatted_string();
let nrows = tr.to_formatted_string();
let vcols = vc.to_formatted_string();
html! {
<span id="rows">
<span>{ vrows }</span>
<span class="total">{ format!(" ({})", nrows) }</span>
<span class="x">{ " x " }</span>
<span>{ vcols }</span>
</span>
}
},
Some(ViewStats {
num_table_cells: Some((_, tc)),
num_view_cells: Some((vr, vc)),
..
}) if vc != tc => {
let vrows = vr.to_formatted_string();
let vcols = vc.to_formatted_string();
let ncols = tc.to_formatted_string();
html! {
<span id="rows">
<span>{ vrows }</span>
<span class="x">{ " x " }</span>
<span>{ vcols }</span>
<span class="total">{ format!(" ({})", ncols) }</span>
</span>
}
},
Some(ViewStats {
num_table_cells: Some((tr, tc)),
..
}) => {
let nrows = tr.to_formatted_string();
let ncols = tc.to_formatted_string();
html! {
<span id="rows">
<span>{ nrows }</span>
<span class="x">{ " x " }</span>
<span>{ ncols }</span>
</span>
}
},
Some(ViewStats {
num_table_cells: None,
..
}) => html! { <span /> },
None => html! { <span /> },
}
}