Skip to content

Commit b2b5e1c

Browse files
authored
Merge pull request #6 from openmc-data-storage/adding-clear-button
Adding clear button
2 parents ceda80c + 456f377 commit b2b5e1c

File tree

4 files changed

+28
-7
lines changed

4 files changed

+28
-7
lines changed

src/sauce/home.rs

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ pub struct XsCache {
3333
#[derive(Properties, PartialEq)]
3434
pub struct PlotProps {
3535
pub selected_indexes: HashSet<usize>,
36+
pub clear_plot_callback: Callback<MouseEvent>,
3637
}
3738

3839
#[function_component(App)]
@@ -107,18 +108,28 @@ pub fn plot_component(props: &PlotProps) -> Html {
107108
html! {
108109
<div style="text-align: center;">
109110
<div class="d-flex mb-2">
110-
<button
111+
112+
<button
111113
onclick={onclick_toggle_y_log}
112114
class="btn btn-primary me-2"
113115
>
114-
{if *is_y_log { "Switch Y to Linear Scale" } else { "Switch Y to Log Scale" }}
116+
{if *is_y_log { "Switch Y to Linear Scale" } else { "Switch Y to Log Scale" }}
115117
</button>
116-
<button
118+
119+
<button
117120
onclick={onclick_toggle_x_log}
118-
class="btn btn-primary"
121+
class="btn btn-primary me-2"
122+
>
123+
{if *is_x_log { "Switch X to Linear Scale" } else { "Switch X to Log Scale" }}
124+
</button>
125+
126+
<button
127+
onclick={props.clear_plot_callback.clone()} // <-- Add this button
128+
class="btn btn-primary me-2"
119129
>
120-
{if *is_x_log { "Switch X to Linear Scale" } else { "Switch X to Log Scale" }}
130+
{ "Clear Plot" }
121131
</button>
132+
122133
</div>
123134
<div id="plot-div"></div>
124135
</div>
@@ -231,6 +242,13 @@ pub fn home() -> Html {
231242
orderable_classes: vec!["mx-1".to_string(), "fa-solid".to_string()],
232243
};
233244

245+
let clear_plot_callback = {
246+
let selected_indexes = selected_indexes.clone();
247+
Callback::from(move |_: MouseEvent| {
248+
selected_indexes.clear();
249+
})
250+
};
251+
234252
let callback_sum = {
235253
let selected_indexes = selected_indexes.clone();
236254
Callback::from(move |index: usize| {
@@ -461,7 +479,7 @@ pub fn home() -> Html {
461479
page={current_page}
462480
// search={element_search.clone()}
463481
classes={classes!("table", "table-hover")}
464-
columns={columns.clone()}
482+
columns={columns.clone()}
465483
data={paginated_data}
466484
orderable={true}
467485
/>
@@ -477,7 +495,10 @@ pub fn home() -> Html {
477495
// on_page={Some(handle_page)}
478496
// />
479497
<div class="flex-grow-1" style="width: 100%;">
480-
<App selected_indexes={(*selected_indexes.current()).clone()} />
498+
<App
499+
selected_indexes={(*selected_indexes.current()).clone()}
500+
clear_plot_callback={clear_plot_callback}
501+
/>
481502
</div>
482503
<h5><a href="https://github.com/openmc-data-storage/nuclide_cross_section_plotter.rs/">{"Help improve this website by contributing to the repository,"}</a></h5>
483504
</div>

src/types/favicon.ico

-14.7 KB
Binary file not shown.

static/favicon.ico

-14.7 KB
Binary file not shown.

static/favicon.png

-14.7 KB
Binary file not shown.

0 commit comments

Comments
 (0)