feat: Status, add buttons to hide/show column processes (#67)
Some checks are pending
Lockbud / lockbud (push) Waiting to run
Rust / fmt (push) Waiting to run
Rust / test (push) Waiting to run
Rust / clippy (macos-latest) (push) Waiting to run
Rust / clippy (ubuntu-latest) (push) Waiting to run
Rust / check (macos-latest) (push) Waiting to run
Rust / check (ubuntu-latest) (push) Waiting to run
Rust / doc (push) Waiting to run
Typo / typo (push) Waiting to run

also make code for processes columns more simple
This commit is contained in:
Cyrix126 2025-01-03 12:11:58 +01:00 committed by GitHub
parent cd1f5192b4
commit 1e4b1347aa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 83 additions and 67 deletions

View file

@ -1,4 +1,4 @@
use egui::{Label, ScrollArea, Ui}; use egui::{Label, ScrollArea, Ui, Vec2};
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use crate::app::eframe_impl::ProcessStatesGui; use crate::app::eframe_impl::ProcessStatesGui;
@ -31,82 +31,79 @@ impl Status {
) { ) {
let width_column = ui.text_style_height(&TextStyle::Body) * 16.0; let width_column = ui.text_style_height(&TextStyle::Body) * 16.0;
let height_column = width_column * 2.7; let height_column = width_column * 2.7;
let size_column = Vec2::new(width_column, height_column);
ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Extend); ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Extend);
// let width = ((ui.available_width() / 5.0) - (SPACE * 1.7500)).max(0.0); ScrollArea::vertical()
ScrollArea::vertical().show(ui, |ui| { .id_salt("vertical_processes")
ui.horizontal(|ui| { .show(ui, |ui| {
ScrollArea::horizontal().show(ui, |ui| { ui.horizontal(|ui| {
ui.vertical(|ui| { ScrollArea::horizontal().show(ui, |ui| {
ui.group(|ui| { column_process(ui, size_column, self.show_system, |ui| {
ui.set_width(width_column); gupax(ui, sys);
ui.set_height(height_column);
ui.vertical_centered(|ui| {
gupax(ui, sys);
});
}); });
}); column_process(ui, size_column, self.show_node, |ui| {
ui.vertical(|ui| { node(ui, states.is_alive(ProcessName::Node), node_api);
ui.group(|ui| {
ui.set_width(width_column);
ui.set_height(height_column);
ui.vertical_centered(|ui| {
node(ui, states.is_alive(ProcessName::Node), node_api);
});
}); });
}); column_process(ui, size_column, self.show_p2pool, |ui| {
ui.vertical(|ui| { p2pool(
ui.group(|ui| { ui,
ui.set_width(width_column); states.is_alive(ProcessName::P2pool),
ui.set_height(height_column); p2pool_api,
ui.vertical_centered(|ui| { p2pool_img,
p2pool( );
ui,
states.is_alive(ProcessName::P2pool),
p2pool_api,
p2pool_img,
);
});
}); });
}); column_process(ui, size_column, self.show_xmrig, |ui| {
ui.vertical(|ui| { xmrig(
ui.group(|ui| { ui,
ui.set_width(width_column); states.is_alive(ProcessName::Xmrig),
ui.set_height(height_column); xmrig_api,
ui.vertical_centered(|ui| { xmrig_img,
xmrig( max_threads,
ui, );
states.is_alive(ProcessName::Xmrig),
xmrig_api,
xmrig_img,
max_threads,
);
});
}); });
}); column_process(ui, size_column, self.show_proxy, |ui| {
ui.vertical(|ui| { xmrig_proxy(
ui.group(|ui| { ui,
ui.set_width(width_column); states.is_alive(ProcessName::XmrigProxy),
ui.set_height(height_column); xmrig_proxy_api,
ui.vertical_centered(|ui| { );
xmrig_proxy(
ui,
states.is_alive(ProcessName::XmrigProxy),
xmrig_proxy_api,
);
});
}); });
}); column_process(ui, size_column, self.show_xvb, |ui| {
ui.vertical(|ui| { xvb(ui, states.is_alive(ProcessName::Xvb), xvb_api);
ui.group(|ui| {
ui.set_width(width_column);
ui.set_height(height_column);
ui.vertical_centered(|ui| {
xvb(ui, states.is_alive(ProcessName::Xvb), xvb_api);
});
}); });
}); });
}); });
}); });
// buttons to hide
ScrollArea::horizontal().show(ui, |ui| {
ui.label("Visible columns:");
ui.add_space(SPACE);
ui.horizontal(|ui| {
ui.checkbox(&mut self.show_system, "System");
ui.checkbox(&mut self.show_node, "Node");
ui.checkbox(&mut self.show_p2pool, "P2Pool");
ui.checkbox(&mut self.show_xmrig, "XMRig");
ui.checkbox(&mut self.show_proxy, "XMRig-Proxy");
ui.checkbox(&mut self.show_xvb, "XvB");
});
});
}
}
pub fn column_process<R>(
ui: &mut Ui,
size_column: Vec2,
visible: bool,
add_contents: impl FnOnce(&mut Ui) -> R,
) {
if visible {
ui.vertical(|ui| {
ui.group(|ui| {
ui.set_width(size_column.x);
ui.set_height(size_column.y);
ui.vertical_centered(|ui| add_contents(ui))
});
}); });
} }
} }

View file

@ -179,6 +179,12 @@ pub struct Status {
pub manual_hash: bool, pub manual_hash: bool,
pub hashrate: f64, pub hashrate: f64,
pub hash_metric: Hash, pub hash_metric: Hash,
pub show_system: bool,
pub show_node: bool,
pub show_p2pool: bool,
pub show_xmrig: bool,
pub show_proxy: bool,
pub show_xvb: bool,
} }
#[derive(Clone, PartialEq, Debug, Deserialize, Serialize)] #[derive(Clone, PartialEq, Debug, Deserialize, Serialize)]
@ -580,6 +586,12 @@ impl Default for Status {
manual_hash: false, manual_hash: false,
hashrate: 1.0, hashrate: 1.0,
hash_metric: Hash::default(), hash_metric: Hash::default(),
show_system: true,
show_node: true,
show_p2pool: true,
show_xmrig: true,
show_proxy: true,
show_xvb: true,
} }
} }
} }

View file

@ -65,6 +65,13 @@ mod test {
manual_hash = false manual_hash = false
hashrate = 1241.23 hashrate = 1241.23
hash_metric = "Hash" hash_metric = "Hash"
show_system = true
show_node = true
show_p2pool = true
show_xmrig = true
show_proxy = true
show_xvb = true
[p2pool] [p2pool]
simple = true simple = true