GUI round 14: bigger health icons, table zoom, pool config, op progress
Seven items from the round-14 list: #1 Health icons: render bigger (nearly the full row height) and packed tighter so a row of component icons stays large and readable; the icon sizes also scale with the new table zoom. #2 Scan timeout: a per-miner scan timeout (asic-rs identification timeout) is now configurable in the Scan-ranges dialog and persisted, so slow miners can be given longer or fast scans sped up. #3 Table zoom: a slider in the bottom-right of the status bar scales the whole table together -- font, component icons, row height, and column widths -- from 50% to 250% (default 100%). Implemented in the wx bridge (no Rust round-trip); the custom SegmentRenderer draws its text in the control's scaled font so the coloured columns zoom like the native ones, and the zoom is re-applied after a column rebuild so it survives show/ hide/reorder. #4 Operation progress: while an operation runs on a miner (refresh, config/light/power/tuning action, firmware flash, restore-to-stock, access check), its Health cell shows the progress text ("refreshing…", "restarting…", "setting pools…", …) instead of the component icons, and reverts to icons when the operation finishes. #5 Remove the SSH PIC probe: the "Detect PIC (SSH)..." right-click flow and its dialog, background probe, and pic_probe module are removed. PIC state stays a best-effort model-string heuristic in the PIC column. #6 WhatsMiner access: WhatsMiners now show the locked/unlocked padlock in the Access column instead of a blank cell -- since round 12 #8b gave the V1/V2/V3 backends their control commands, the same capability heuristic the other brands use applies to WhatsMiner too (the token access check still refines a read-only unit to "locked"). #7 Configure pools: a right-click "Configure pools..." flow (gated on the new pools capability) with three fields -- pool address and account (required) and an optional worker name. The worker name expands per miner from case-insensitive placeholders scanned from each unit: {ip1}..{ip4}, {serial}, {mac} (colons removed), {nameplate-hr} (rated TH), {brand}, {model}, {submodel}, {cpu}, {cb}, {firmware}, {hostname}. Applied via asic-rs set_pools_config on a background thread reusing the action plumbing. wx-rs bridge patches 0002/0003 regenerated. No vendored asic-rs changes. Unit tests (component health, worker-template expansion) + headless selftest pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Djv3oncM4LxTS5tb61Ako6
This commit is contained in:
+244
-175
@@ -58,7 +58,6 @@ const ID_CTX_RESUME: i32 = 726;
|
||||
const ID_CTX_TUNING: i32 = 727;
|
||||
const ID_CTX_POWER: i32 = 728;
|
||||
const ID_CTX_RESTART: i32 = 729;
|
||||
const ID_CTX_PIC_PROBE: i32 = 730;
|
||||
const ID_CTX_ACCESS_PROBE: i32 = 731;
|
||||
// View a miner's log fetched over its firmware API (round 12 #12).
|
||||
const ID_CTX_VIEW_LOG: i32 = 734;
|
||||
@@ -67,9 +66,10 @@ const ID_LOGVIEW_CLOSE: i32 = 785;
|
||||
const ID_CTX_RESTORE_STOCK: i32 = 735;
|
||||
const ID_RESTORE_OK: i32 = 786;
|
||||
const ID_RESTORE_CANCEL: i32 = 787;
|
||||
// SSH PIC-probe credentials dialog.
|
||||
const ID_PICSSH_OK: i32 = 780;
|
||||
const ID_PICSSH_CANCEL: i32 = 781;
|
||||
// Configure pools (round 14 #7): pool address + account + worker-name template.
|
||||
const ID_CTX_POOLS: i32 = 736;
|
||||
const ID_POOLS_OK: i32 = 788;
|
||||
const ID_POOLS_CANCEL: i32 = 789;
|
||||
// Value-prompt dialog for power-limit / tuning-percent actions.
|
||||
const ID_ACTION_OK: i32 = 740;
|
||||
const ID_ACTION_CANCEL: i32 = 741;
|
||||
@@ -585,6 +585,8 @@ pub struct App {
|
||||
// scan loop (play/pause/stop + auto-rescan)
|
||||
playing: bool,
|
||||
auto_secs: u64,
|
||||
// Per-miner scan timeout in seconds (round 14 #2).
|
||||
scan_timeout_secs: u64,
|
||||
countdown: u64,
|
||||
// selection (replaces the old checkbox column), tracked by IP so it
|
||||
// survives table refreshes during a scan.
|
||||
@@ -621,6 +623,10 @@ pub struct App {
|
||||
// IPs the current config action targets, re-probed after it completes so the
|
||||
// table reflects the change (e.g. the identify light toggling).
|
||||
action_targets: Vec<String>,
|
||||
// Per-miner in-flight operation label (round 14 #4): while a miner has an
|
||||
// operation running (refresh, config action, light, firmware, restore, access
|
||||
// check), its Health cell shows this text instead of the component icons.
|
||||
op_status: std::collections::HashMap<String, String>,
|
||||
// A confirmation dialog for disruptive actions, plus its pending target.
|
||||
confirm_dialog: Widget,
|
||||
pending_confirm: Option<(Vec<String>, scan::ConfigAction)>,
|
||||
@@ -649,9 +655,6 @@ pub struct App {
|
||||
fwcreds_rows: Vec<(String, Widget, Widget)>,
|
||||
// Background access (lock-state) probe.
|
||||
access_probe: Option<scan::AccessProbeHandle>,
|
||||
// Background SSH PIC probe + its credentials dialog.
|
||||
pic_probe: Option<scan::PicProbeHandle>,
|
||||
pending_pic_targets: Vec<(String, String)>,
|
||||
// The API log viewer dialog (round 12 #12).
|
||||
logview_dialog: Widget,
|
||||
// Restore-to-stock (round 12 #8a): background job + its typed-confirm dialog.
|
||||
@@ -659,9 +662,11 @@ pub struct App {
|
||||
restore_dialog: Widget,
|
||||
restore_input: Widget,
|
||||
pending_restore: Vec<restore::RestoreTarget>,
|
||||
picssh_dialog: Widget,
|
||||
picssh_user_input: Widget,
|
||||
picssh_pass_input: Widget,
|
||||
// Configure-pools dialog (round 14 #7).
|
||||
pools_dialog: Widget,
|
||||
pools_url_input: Widget,
|
||||
pools_account_input: Widget,
|
||||
pools_worker_input: Widget,
|
||||
// Saved view presets + the Presets dialog widgets.
|
||||
presets: Vec<crate::presets::Preset>,
|
||||
presets_dialog: Widget,
|
||||
@@ -673,6 +678,7 @@ pub struct App {
|
||||
ranges_dialog: Widget,
|
||||
ranges_edit: Widget,
|
||||
ranges_auto: Widget,
|
||||
ranges_timeout: Widget,
|
||||
columns_dialog: Widget,
|
||||
columns_list: Widget,
|
||||
/// The columns-dialog "hide empty columns" checkbox, read at Apply.
|
||||
@@ -867,6 +873,8 @@ pub fn build(frame: Widget) -> App {
|
||||
// errors (red) and warnings (amber) so they don't overwrite the scan state.
|
||||
wx_rs::create_status_bar();
|
||||
wx_rs::status_indicator_init(frame);
|
||||
// Table-zoom slider in the bottom-right of the status bar (round 14 #3).
|
||||
wx_rs::status_zoom_init(frame);
|
||||
wx_rs::set_status_text("starting scan...");
|
||||
|
||||
// Repaint custom-coloured widgets when the OS switches light/dark.
|
||||
@@ -890,13 +898,14 @@ pub fn build(frame: Widget) -> App {
|
||||
table: None,
|
||||
table_parent,
|
||||
root_sizer: root,
|
||||
scan: Some(scan::start_scan(ranges.clone())),
|
||||
scan: Some(scan::start_scan(ranges.clone(), scan::load_scan_timeout())),
|
||||
scanning: true,
|
||||
scan_total: 0,
|
||||
target_ips: HashSet::new(),
|
||||
refresh: None,
|
||||
playing: true,
|
||||
auto_secs: scan::load_auto_secs(),
|
||||
scan_timeout_secs: scan::load_scan_timeout(),
|
||||
countdown: 0,
|
||||
selected_ips: HashSet::new(),
|
||||
pal,
|
||||
@@ -915,6 +924,7 @@ pub fn build(frame: Widget) -> App {
|
||||
action_total: 0,
|
||||
action_done: 0,
|
||||
action_targets: Vec::new(),
|
||||
op_status: std::collections::HashMap::new(),
|
||||
confirm_dialog: frame,
|
||||
pending_confirm: None,
|
||||
flash_confirm_dialog: frame,
|
||||
@@ -927,16 +937,15 @@ pub fn build(frame: Widget) -> App {
|
||||
fwcreds_dialog: frame,
|
||||
fwcreds_rows: Vec::new(),
|
||||
access_probe: None,
|
||||
pic_probe: None,
|
||||
pending_pic_targets: Vec::new(),
|
||||
logview_dialog: frame,
|
||||
restore: None,
|
||||
restore_dialog: frame,
|
||||
restore_input: frame,
|
||||
pending_restore: Vec::new(),
|
||||
picssh_dialog: frame,
|
||||
picssh_user_input: frame,
|
||||
picssh_pass_input: frame,
|
||||
pools_dialog: frame,
|
||||
pools_url_input: frame,
|
||||
pools_account_input: frame,
|
||||
pools_worker_input: frame,
|
||||
presets: crate::presets::load_presets(),
|
||||
presets_dialog: frame,
|
||||
presets_choice: frame,
|
||||
@@ -946,6 +955,7 @@ pub fn build(frame: Widget) -> App {
|
||||
ranges_dialog: frame,
|
||||
ranges_edit: frame,
|
||||
ranges_auto: frame,
|
||||
ranges_timeout: frame,
|
||||
columns_dialog: frame,
|
||||
columns_list: frame,
|
||||
columns_hide_empty_cb: frame,
|
||||
@@ -1069,6 +1079,9 @@ impl App {
|
||||
self.root_sizer.add(t, 1, sf::EXPAND | sf::BORDER_ALL, 4);
|
||||
self.table = Some(t);
|
||||
self.table_parent.layout();
|
||||
// Re-apply the table zoom so a non-100% zoom survives this rebuild
|
||||
// (round 14 #3); the fresh columns come back at their 100% widths.
|
||||
wx_rs::table_zoom_reapply();
|
||||
self.fill_rows();
|
||||
}
|
||||
|
||||
@@ -1108,7 +1121,12 @@ impl App {
|
||||
encode_combined_cell(&self.pal, actual, expected, "/", ratio)
|
||||
}
|
||||
// Health column: one coloured icon per component (round 13 #3).
|
||||
Column::Health => encode_component_health(&self.pal, r),
|
||||
// While an operation runs on this miner, its Health cell shows
|
||||
// the progress text instead of the component icons (round 14 #4).
|
||||
Column::Health => match self.op_status.get(&r.ip) {
|
||||
Some(op) => encode_segments(&[(Some(self.pal.amber), op.clone())]),
|
||||
None => encode_component_health(&self.pal, r),
|
||||
},
|
||||
// Boards column: per-hashboard health dots (round 11 #10).
|
||||
Column::Hashboards => encode_board_dots(&self.pal, &r.board_status),
|
||||
Column::TotalChips => {
|
||||
@@ -1337,9 +1355,6 @@ impl App {
|
||||
// Refresh is always offered for a non-empty selection, independent of
|
||||
// the capability intersection below.
|
||||
menu.menu_append(ID_CTX_REFRESH, "Refresh");
|
||||
// Real PIC-vs-noPIC detection via an on-board SSH i2c probe (asic-rs
|
||||
// cannot report it over the network); offered for any selection.
|
||||
menu.menu_append(ID_CTX_PIC_PROBE, "Detect PIC (SSH)...");
|
||||
// Real access/lock-state check (credentialed digest GET; uses the saved
|
||||
// scan credentials).
|
||||
menu.menu_append(ID_CTX_ACCESS_PROBE, "Check access (auth)");
|
||||
@@ -1377,6 +1392,9 @@ impl App {
|
||||
if caps.restart {
|
||||
menu.menu_append(ID_CTX_RESTART, &format!("Restart{sfx}"));
|
||||
}
|
||||
if caps.pools {
|
||||
menu.menu_append(ID_CTX_POOLS, &format!("Configure pools...{sfx}"));
|
||||
}
|
||||
}
|
||||
// Firmware flash is offered when AT LEAST ONE selected miner supports
|
||||
// it (not the full intersection) -- flashing a mixed batch simply
|
||||
@@ -1409,6 +1427,141 @@ impl App {
|
||||
self.rows.iter().filter(|r| self.selected_ips.contains(&r.ip)).collect()
|
||||
}
|
||||
|
||||
/// Mark each of `ips` as having an in-flight operation labelled `label`
|
||||
/// (round 14 #4), so its Health cell shows the progress text instead of the
|
||||
/// component icons, and repaint those cells.
|
||||
fn set_op_status(&mut self, ips: &[String], label: &str) {
|
||||
for ip in ips {
|
||||
self.op_status.insert(ip.clone(), label.to_string());
|
||||
}
|
||||
self.fill_rows();
|
||||
}
|
||||
|
||||
/// Clear one miner's in-flight operation label. Repaint is left to the caller
|
||||
/// (usually a single fill_rows after draining a batch of results).
|
||||
fn clear_op_status(&mut self, ip: &str) {
|
||||
self.op_status.remove(ip);
|
||||
}
|
||||
|
||||
/// Build (but do not show) the Configure-pools dialog (round 14 #7): pool
|
||||
/// address + account (both required) + an optional worker-name template that
|
||||
/// is expanded per miner. Returns None when nothing is selected or a flash
|
||||
/// holds the exclusive lock.
|
||||
fn build_pools_dialog(&mut self) -> Option<Widget> {
|
||||
if self.flashing {
|
||||
wx_rs::set_status_text("firmware flash in progress -- wait for it to finish");
|
||||
return None;
|
||||
}
|
||||
if self.selected_rows().is_empty() {
|
||||
return None;
|
||||
}
|
||||
let n = self.selected_ip_list().len();
|
||||
let frame = Widget::main_frame();
|
||||
let dlg = Widget::dialog(frame, "Configure pools");
|
||||
let root = Widget::box_sizer(true);
|
||||
root.add(
|
||||
Widget::static_text(
|
||||
dlg,
|
||||
&format!("Set the primary pool on {n} selected miner(s). Address and account are required."),
|
||||
),
|
||||
0,
|
||||
sf::BORDER_ALL,
|
||||
8,
|
||||
);
|
||||
let mut field = |label: &str, hint: &str| -> Widget {
|
||||
let row = Widget::box_sizer(false);
|
||||
let l = Widget::static_text(dlg, label);
|
||||
l.set_min_size(90, -1);
|
||||
row.add(l, 0, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_ALL, 6);
|
||||
let input = Widget::text_ctrl(dlg, false);
|
||||
input.set_min_size(320, -1);
|
||||
row.add(input, 1, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_ALL, 6);
|
||||
root.add_sizer(row, 0, sf::EXPAND | sf::BORDER_LEFT | sf::BORDER_RIGHT, 4);
|
||||
let _ = hint;
|
||||
input
|
||||
};
|
||||
let url_input = field("Address:", "");
|
||||
url_input.set_value("stratum+tcp://");
|
||||
let account_input = field("Account:", "");
|
||||
let worker_input = field("Worker:", "");
|
||||
root.add(
|
||||
Widget::static_text(
|
||||
dlg,
|
||||
"Worker name may use per-miner placeholders (case-insensitive):\n {ip1}..{ip4} IP octets {serial} {mac} (no ':') {nameplate-hr} rated TH\n {brand} {model} {submodel} {cpu} {cb} control board {firmware} {hostname}\nThe pool user sent is \"account.worker\" (or just the account when Worker is empty).",
|
||||
),
|
||||
0,
|
||||
sf::BORDER_ALL,
|
||||
8,
|
||||
);
|
||||
let btns = Widget::box_sizer(false);
|
||||
btns.add_stretch(1);
|
||||
btns.add(Widget::button(dlg, "Apply", ID_POOLS_OK), 0, sf::BORDER_ALL, 6);
|
||||
btns.add(Widget::button(dlg, "Cancel", ID_POOLS_CANCEL), 0, sf::BORDER_ALL, 6);
|
||||
root.add_sizer(btns, 0, sf::EXPAND | sf::BORDER_ALL, 6);
|
||||
root.set_sizer_on(dlg);
|
||||
dlg.set_min_size(520, 300);
|
||||
dlg.fit(dlg);
|
||||
self.pools_dialog = dlg;
|
||||
self.pools_url_input = url_input;
|
||||
self.pools_account_input = account_input;
|
||||
self.pools_worker_input = worker_input;
|
||||
Some(dlg)
|
||||
}
|
||||
|
||||
/// Validate the pool inputs, expand the worker template per selected miner,
|
||||
/// and start the background pool-config action (round 14 #7).
|
||||
fn apply_pools(&mut self) {
|
||||
let url = self.pools_url_input.get_value().trim().to_string();
|
||||
let account = self.pools_account_input.get_value().trim().to_string();
|
||||
let worker_tpl = self.pools_worker_input.get_value();
|
||||
if url.is_empty() || url == "stratum+tcp://" {
|
||||
wx_rs::set_status_text("enter a pool address");
|
||||
return;
|
||||
}
|
||||
if account.is_empty() {
|
||||
wx_rs::set_status_text("enter a pool account");
|
||||
return;
|
||||
}
|
||||
if self.flashing {
|
||||
wx_rs::set_status_text("firmware flash in progress -- wait for it to finish");
|
||||
return;
|
||||
}
|
||||
let targets: Vec<scan::PoolTarget> = self
|
||||
.selected_rows()
|
||||
.iter()
|
||||
.map(|r| {
|
||||
let worker = r.expand_worker_template(&worker_tpl);
|
||||
let worker = worker.trim();
|
||||
let username = if worker.is_empty() {
|
||||
account.clone()
|
||||
} else {
|
||||
format!("{account}.{worker}")
|
||||
};
|
||||
scan::PoolTarget {
|
||||
ip: r.ip.clone(),
|
||||
url: url.clone(),
|
||||
username,
|
||||
// Most pools ignore the worker password; "x" is the convention.
|
||||
password: "x".to_string(),
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
if targets.is_empty() {
|
||||
self.pools_dialog.close(0);
|
||||
return;
|
||||
}
|
||||
let ips: Vec<String> = targets.iter().map(|t| t.ip.clone()).collect();
|
||||
let n = ips.len();
|
||||
if let Some(old) = self.action.take() {
|
||||
old.stop();
|
||||
}
|
||||
self.pools_dialog.close(1);
|
||||
self.action_targets = ips.clone();
|
||||
self.set_op_status(&ips, "setting pools…");
|
||||
self.action = Some(scan::start_pools_action(targets));
|
||||
wx_rs::set_status_text(&format!("configuring pools on {n} miner(s)..."));
|
||||
}
|
||||
|
||||
/// Start a config action against `ips` on a background thread, cancelling any
|
||||
/// action already in flight so two never run at once.
|
||||
fn start_action(&mut self, ips: Vec<String>, action: scan::ConfigAction) {
|
||||
@@ -1424,6 +1577,7 @@ impl App {
|
||||
}
|
||||
let msg = format!("applying {} to {} miner(s)...", action.label(), ips.len());
|
||||
self.action_targets = ips.clone();
|
||||
self.set_op_status(&ips, &action.progress_label());
|
||||
self.action = Some(scan::start_config_action(ips, action));
|
||||
// Clear any stale error/warning from a previous operation; the new
|
||||
// outcome repopulates the indicator when this action finishes.
|
||||
@@ -1446,6 +1600,8 @@ impl App {
|
||||
old.stop();
|
||||
}
|
||||
let msg = format!("refreshing {} miner(s)...", ips.len());
|
||||
// Show "refreshing…" in each miner's Health cell while it re-probes (#4).
|
||||
self.set_op_status(&ips, "refreshing…");
|
||||
self.refresh = Some(scan::start_refresh(ips));
|
||||
wx_rs::set_status_text(&msg);
|
||||
}
|
||||
@@ -1568,7 +1724,9 @@ impl App {
|
||||
let vnish_pass = if vnish_pass.is_empty() { "admin".to_string() } else { vnish_pass };
|
||||
let (ssh_user, ssh_pass) = credentials::load_ssh_credentials().unwrap_or_default();
|
||||
let n = targets.len();
|
||||
let ips: Vec<String> = targets.iter().map(|t| t.ip.clone()).collect();
|
||||
self.restore_dialog.close(1);
|
||||
self.set_op_status(&ips, "restoring…");
|
||||
self.restore = Some(restore::start_restore(targets, vnish_pass, ssh_user, ssh_pass));
|
||||
wx_rs::set_status_text(&format!("restoring {n} miner(s) to stock..."));
|
||||
}
|
||||
@@ -1579,12 +1737,14 @@ impl App {
|
||||
let mut done = false;
|
||||
let mut oks = 0usize;
|
||||
let mut fails: Vec<String> = Vec::new();
|
||||
let mut op_clear: Vec<String> = Vec::new();
|
||||
while let Ok(msg) = h.rx.try_recv() {
|
||||
match msg {
|
||||
restore::RestoreMsg::Started { total } => {
|
||||
wx_rs::set_status_text(&format!("restoring {total} miner(s) to stock..."));
|
||||
}
|
||||
restore::RestoreMsg::Result { ip, ok, detail } => {
|
||||
op_clear.push(ip.clone());
|
||||
if ok {
|
||||
oks += 1;
|
||||
} else {
|
||||
@@ -1594,8 +1754,17 @@ impl App {
|
||||
restore::RestoreMsg::Done { .. } => done = true,
|
||||
}
|
||||
}
|
||||
for ip in &op_clear {
|
||||
self.op_status.remove(ip);
|
||||
}
|
||||
if done {
|
||||
self.restore = None;
|
||||
self.op_status.retain(|_, v| v != "restoring…");
|
||||
}
|
||||
if !op_clear.is_empty() || done {
|
||||
self.fill_rows();
|
||||
}
|
||||
if done {
|
||||
if fails.is_empty() {
|
||||
wx_rs::set_status_text(&format!("restore-to-stock: {oks} started; miners reboot to stock"));
|
||||
} else {
|
||||
@@ -1609,96 +1778,6 @@ impl App {
|
||||
}
|
||||
}
|
||||
|
||||
/// Build the SSH PIC-probe dialog: captures the selected miners, collects
|
||||
/// SSH credentials (prefilled from the saved SSH login), and on OK runs the
|
||||
/// on-board i2c probe. Returns None (no dialog) if nothing is selected or a
|
||||
/// flash holds the exclusive lock.
|
||||
fn build_pic_probe_dialog(&mut self) -> Option<Widget> {
|
||||
if self.flashing {
|
||||
wx_rs::set_status_text("firmware flash in progress -- wait for it to finish");
|
||||
return None;
|
||||
}
|
||||
if self.pic_probe.is_some() {
|
||||
wx_rs::set_status_text("a PIC probe is already running");
|
||||
return None;
|
||||
}
|
||||
let targets: Vec<(String, String)> = self
|
||||
.selected_rows()
|
||||
.iter()
|
||||
.map(|r| (r.ip.clone(), r.control_board.clone()))
|
||||
.collect();
|
||||
if targets.is_empty() {
|
||||
return None;
|
||||
}
|
||||
self.pending_pic_targets = targets;
|
||||
let (saved_user, _) = credentials::load_ssh_credentials().unwrap_or_default();
|
||||
let frame = Widget::main_frame();
|
||||
let dlg = Widget::dialog(frame, "Detect PIC via SSH");
|
||||
let root = Widget::box_sizer(true);
|
||||
root.add(
|
||||
Widget::static_text(
|
||||
dlg,
|
||||
&format!(
|
||||
"Probe {} miner(s) over SSH (runs i2cdump on the control board). SSH login for the miner (root, etc.):",
|
||||
self.pending_pic_targets.len()
|
||||
),
|
||||
),
|
||||
0,
|
||||
sf::BORDER_ALL,
|
||||
8,
|
||||
);
|
||||
let user_row = Widget::box_sizer(false);
|
||||
user_row.add(Widget::static_text(dlg, "SSH user:"), 0, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_ALL, 6);
|
||||
let user_input = Widget::text_ctrl(dlg, false);
|
||||
user_input.set_value(if saved_user.is_empty() { "root" } else { &saved_user });
|
||||
user_input.set_min_size(180, -1);
|
||||
user_row.add(user_input, 1, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_ALL, 6);
|
||||
root.add_sizer(user_row, 0, sf::EXPAND | sf::BORDER_LEFT | sf::BORDER_RIGHT, 6);
|
||||
let pass_row = Widget::box_sizer(false);
|
||||
pass_row.add(Widget::static_text(dlg, "SSH password:"), 0, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_ALL, 6);
|
||||
let pass_input = Widget::text_ctrl(dlg, false);
|
||||
pass_input.set_min_size(180, -1);
|
||||
pass_row.add(pass_input, 1, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_ALL, 6);
|
||||
root.add_sizer(pass_row, 0, sf::EXPAND | sf::BORDER_LEFT | sf::BORDER_RIGHT, 6);
|
||||
root.add(
|
||||
Widget::static_text(dlg, "(Leave the password blank to use SSH key auth.)"),
|
||||
0,
|
||||
sf::BORDER_ALL,
|
||||
6,
|
||||
);
|
||||
let btns = Widget::box_sizer(false);
|
||||
btns.add_stretch(1);
|
||||
btns.add(Widget::button(dlg, "Probe", ID_PICSSH_OK), 0, sf::BORDER_ALL, 6);
|
||||
btns.add(Widget::button(dlg, "Cancel", ID_PICSSH_CANCEL), 0, sf::BORDER_ALL, 6);
|
||||
root.add_sizer(btns, 0, sf::EXPAND | sf::BORDER_ALL, 6);
|
||||
root.set_sizer_on(dlg);
|
||||
dlg.set_min_size(420, 210);
|
||||
dlg.fit(dlg);
|
||||
self.picssh_dialog = dlg;
|
||||
self.picssh_user_input = user_input;
|
||||
self.picssh_pass_input = pass_input;
|
||||
Some(dlg)
|
||||
}
|
||||
|
||||
/// Start the PIC probe with the SSH credentials just entered.
|
||||
fn apply_pic_probe(&mut self) {
|
||||
let user = self.picssh_user_input.get_value().trim().to_string();
|
||||
if user.is_empty() {
|
||||
wx_rs::set_status_text("enter an SSH user");
|
||||
return;
|
||||
}
|
||||
let pass = self.picssh_pass_input.get_value();
|
||||
let _ = credentials::save_ssh_credentials(&user, &pass);
|
||||
self.picssh_dialog.close(1);
|
||||
let targets = std::mem::take(&mut self.pending_pic_targets);
|
||||
let n = targets.len();
|
||||
self.pic_probe = Some(scan::start_pic_probe(
|
||||
targets,
|
||||
crate::pic_probe::SshCreds { user, pass },
|
||||
));
|
||||
wx_rs::set_status_text(&format!("probing PIC on {n} miner(s) via SSH..."));
|
||||
}
|
||||
|
||||
/// Start the access (lock-state) probe on the selected miners, using the
|
||||
/// saved scan (web) credentials (defaulting to root/root if none are set).
|
||||
fn start_access_probe(&mut self) {
|
||||
@@ -1723,6 +1802,8 @@ impl App {
|
||||
}
|
||||
let creds = credentials::load_credentials().unwrap_or_else(|| ("root".into(), "root".into()));
|
||||
let n = targets.len();
|
||||
let ips: Vec<String> = targets.iter().map(|(ip, _)| ip.clone()).collect();
|
||||
self.set_op_status(&ips, "checking…");
|
||||
self.access_probe = Some(scan::start_access_probe(targets, creds));
|
||||
wx_rs::set_status_text(&format!("checking access on {n} miner(s)..."));
|
||||
}
|
||||
@@ -1734,12 +1815,14 @@ impl App {
|
||||
let mut status: Option<String> = None;
|
||||
let mut done = false;
|
||||
let mut changed = false;
|
||||
let mut op_clear: Vec<String> = Vec::new();
|
||||
loop {
|
||||
match h.rx.try_recv() {
|
||||
Ok(scan::AccessProbeMsg::Started { total }) => {
|
||||
status = Some(format!("access check: 0/{total}..."));
|
||||
}
|
||||
Ok(scan::AccessProbeMsg::Result { ip, locked, error }) => {
|
||||
op_clear.push(ip.clone());
|
||||
if let Some(r) = self.rows.iter_mut().find(|r| r.ip == ip) {
|
||||
if error.is_none() {
|
||||
r.write_locked = locked;
|
||||
@@ -1765,7 +1848,13 @@ impl App {
|
||||
}
|
||||
}
|
||||
}
|
||||
if changed {
|
||||
for ip in &op_clear {
|
||||
self.op_status.remove(ip);
|
||||
}
|
||||
if done {
|
||||
self.op_status.retain(|_, v| v != "checking…");
|
||||
}
|
||||
if changed || !op_clear.is_empty() || done {
|
||||
self.fill_rows();
|
||||
}
|
||||
if done {
|
||||
@@ -1778,57 +1867,6 @@ impl App {
|
||||
}
|
||||
}
|
||||
|
||||
/// Drain the running PIC probe: update each miner's pic_present as its result
|
||||
/// arrives, and refresh the table + status when done.
|
||||
fn drain_pic_probe(&mut self) {
|
||||
let Some(h) = &self.pic_probe else { return };
|
||||
let mut status: Option<String> = None;
|
||||
let mut done = false;
|
||||
let mut changed = false;
|
||||
loop {
|
||||
match h.rx.try_recv() {
|
||||
Ok(scan::PicProbeMsg::Started { total }) => {
|
||||
status = Some(format!("PIC probe: 0/{total}..."));
|
||||
}
|
||||
Ok(scan::PicProbeMsg::Result { ip, pic, error }) => {
|
||||
if let Some(r) = self.rows.iter_mut().find(|r| r.ip == ip) {
|
||||
if error.is_none() {
|
||||
r.pic_present = pic;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
status = Some(match (&pic, &error) {
|
||||
(_, Some(e)) => format!("PIC probe {ip}: {e}"),
|
||||
(Some(true), _) => format!("PIC probe {ip}: PIC"),
|
||||
(Some(false), _) => format!("PIC probe {ip}: noPIC"),
|
||||
(None, _) => format!("PIC probe {ip}: indeterminate"),
|
||||
});
|
||||
}
|
||||
Ok(scan::PicProbeMsg::Done { total }) => {
|
||||
status = Some(format!("PIC probe done ({total} miner(s))"));
|
||||
done = true;
|
||||
break;
|
||||
}
|
||||
Err(std::sync::mpsc::TryRecvError::Empty) => break,
|
||||
Err(std::sync::mpsc::TryRecvError::Disconnected) => {
|
||||
done = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if changed {
|
||||
self.fill_rows();
|
||||
}
|
||||
if done {
|
||||
self.pic_probe = None;
|
||||
self.action_result = status.clone();
|
||||
self.action_result_ticks = ACTION_RESULT_TICKS;
|
||||
}
|
||||
if let Some(s) = status {
|
||||
wx_rs::set_status_text(&s);
|
||||
}
|
||||
}
|
||||
|
||||
/// A menu item was chosen. Direct actions start immediately; the value-input
|
||||
/// actions (power limit / tuning %) return a prompt dialog to show modally.
|
||||
fn on_menu_item(&mut self, id: i32) -> Option<Widget> {
|
||||
@@ -1841,10 +1879,10 @@ impl App {
|
||||
}
|
||||
}
|
||||
ID_CTX_REFRESH => self.start_refresh(self.selected_ip_list()),
|
||||
ID_CTX_PIC_PROBE => return self.build_pic_probe_dialog(),
|
||||
ID_CTX_ACCESS_PROBE => self.start_access_probe(),
|
||||
ID_CTX_VIEW_LOG => return self.build_log_view_dialog(),
|
||||
ID_CTX_RESTORE_STOCK => return self.build_restore_confirm_dialog(),
|
||||
ID_CTX_POOLS => return self.build_pools_dialog(),
|
||||
ID_CTX_FLASH => {
|
||||
// A flash needs exclusive hardware access; don't even prompt if
|
||||
// any scan / refresh / action is running (re-checked at confirm).
|
||||
@@ -2061,6 +2099,8 @@ impl App {
|
||||
}
|
||||
let msg = format!("flashing firmware to {} miner(s)...", ips.len());
|
||||
self.flashing = true;
|
||||
self.action_targets = ips.clone();
|
||||
self.set_op_status(&ips, "flashing…");
|
||||
self.action = Some(scan::start_firmware_flash_action(ips, image));
|
||||
wx_rs::set_status_text(&msg);
|
||||
}
|
||||
@@ -2288,10 +2328,17 @@ impl App {
|
||||
self.action_result_ticks = ACTION_RESULT_TICKS;
|
||||
// Re-probe the miners the action touched so the table reflects the
|
||||
// change (e.g. the identify light). Skip after a flash (the miner is
|
||||
// rebooting and won't answer a refresh yet).
|
||||
// rebooting and won't answer a refresh yet). The follow-up refresh
|
||||
// overwrites each miner's Health op-status ("restarting…" ->
|
||||
// "refreshing…"); with no refresh we clear it back to icons (#4).
|
||||
let targets = std::mem::take(&mut self.action_targets);
|
||||
if !was_flash && !targets.is_empty() {
|
||||
self.start_refresh(targets);
|
||||
} else {
|
||||
for ip in &targets {
|
||||
self.op_status.remove(ip);
|
||||
}
|
||||
self.fill_rows();
|
||||
}
|
||||
}
|
||||
// Apply the captured indicator now the `h` borrow is gone.
|
||||
@@ -2315,16 +2362,21 @@ impl App {
|
||||
let mut status: Option<String> = None;
|
||||
let mut finished = false;
|
||||
let mut changed = false;
|
||||
// IPs whose per-miner refresh completed this tick: clear their Health
|
||||
// op-status back to icons (round 14 #4).
|
||||
let mut op_clear: Vec<String> = Vec::new();
|
||||
loop {
|
||||
match h.rx.try_recv() {
|
||||
Ok(scan::RefreshMsg::Started { total }) => {
|
||||
status = Some(format!("refreshing 0/{total} miner(s)..."));
|
||||
}
|
||||
Ok(scan::RefreshMsg::Row(row)) => {
|
||||
op_clear.push(row.ip.clone());
|
||||
row.upsert_into(&mut self.rows);
|
||||
changed = true;
|
||||
}
|
||||
Ok(scan::RefreshMsg::Failed { ip, detail }) => {
|
||||
op_clear.push(ip.clone());
|
||||
status = Some(format!("refresh failed ({ip}: {detail})"));
|
||||
}
|
||||
Ok(scan::RefreshMsg::Done { ok, total }) => {
|
||||
@@ -2344,13 +2396,18 @@ impl App {
|
||||
}
|
||||
}
|
||||
}
|
||||
for ip in &op_clear {
|
||||
self.op_status.remove(ip);
|
||||
}
|
||||
if finished {
|
||||
self.refresh = None;
|
||||
// Any stragglers still marked "refreshing…" revert to icons.
|
||||
self.op_status.retain(|_, v| v != "refreshing…");
|
||||
}
|
||||
if let Some(s) = status {
|
||||
wx_rs::set_status_text(&s);
|
||||
}
|
||||
if changed {
|
||||
if changed || !op_clear.is_empty() || finished {
|
||||
self.fill_rows();
|
||||
}
|
||||
}
|
||||
@@ -2440,13 +2497,12 @@ impl App {
|
||||
self.drain_scan();
|
||||
self.drain_action();
|
||||
self.drain_refresh();
|
||||
self.drain_pic_probe();
|
||||
self.drain_access_probe();
|
||||
self.drain_restore();
|
||||
if self.scanning {
|
||||
return; // status already shows scan progress
|
||||
}
|
||||
if self.pic_probe.is_some() || self.access_probe.is_some() {
|
||||
if self.access_probe.is_some() {
|
||||
return; // a probe is in flight; keep its status
|
||||
}
|
||||
if self.action.is_some() {
|
||||
@@ -2496,7 +2552,7 @@ impl App {
|
||||
if let Some(old) = self.scan.take() {
|
||||
old.stop();
|
||||
}
|
||||
self.scan = Some(scan::start_scan(lines));
|
||||
self.scan = Some(scan::start_scan(lines, self.scan_timeout_secs));
|
||||
self.scanning = true;
|
||||
self.countdown = 0;
|
||||
}
|
||||
@@ -2721,14 +2777,24 @@ impl App {
|
||||
let edit = Widget::text_ctrl(dlg, true);
|
||||
edit.set_value(&scan::load_ranges().join("\n"));
|
||||
root.add(edit, 1, sf::EXPAND | sf::BORDER_ALL, 6);
|
||||
// Auto-rescan interval (seconds; 0 = off).
|
||||
// Auto-rescan interval (seconds; 0 = off) and per-miner scan timeout.
|
||||
let auto_row = Widget::box_sizer(false);
|
||||
let auto_lbl = Widget::static_text(dlg, "Rescan (s):");
|
||||
auto_row.add(auto_lbl, 0, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_ALL, 6);
|
||||
let auto_edit = Widget::text_ctrl(dlg, false);
|
||||
auto_edit.set_value(&self.auto_secs.to_string());
|
||||
auto_edit.set_min_size(60, -1);
|
||||
auto_row.add(auto_edit, 0, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_ALL, 6);
|
||||
root.add_sizer(auto_row, 0, sf::BORDER_LEFT | sf::BORDER_RIGHT, 6);
|
||||
// Per-miner scan timeout (round 14 #2): how long a responding miner is
|
||||
// given to identify + return data before the scan gives up on it.
|
||||
auto_row.add_stretch(1);
|
||||
let to_lbl = Widget::static_text(dlg, "Timeout (s):");
|
||||
auto_row.add(to_lbl, 0, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_ALL, 6);
|
||||
let to_edit = Widget::text_ctrl(dlg, false);
|
||||
to_edit.set_value(&self.scan_timeout_secs.to_string());
|
||||
to_edit.set_min_size(60, -1);
|
||||
auto_row.add(to_edit, 0, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_ALL, 6);
|
||||
root.add_sizer(auto_row, 0, sf::EXPAND | sf::BORDER_LEFT | sf::BORDER_RIGHT, 6);
|
||||
let btns = Widget::box_sizer(false);
|
||||
let apply = Widget::button(dlg, "Apply", ID_RANGES_APPLY);
|
||||
btns.add(apply, 0, sf::BORDER_ALL, 6);
|
||||
@@ -2739,6 +2805,7 @@ impl App {
|
||||
self.ranges_dialog = dlg;
|
||||
self.ranges_edit = edit;
|
||||
self.ranges_auto = auto_edit;
|
||||
self.ranges_timeout = to_edit;
|
||||
dlg
|
||||
}
|
||||
|
||||
@@ -2764,6 +2831,11 @@ impl App {
|
||||
self.auto_secs = secs;
|
||||
let _ = scan::save_auto_secs(secs);
|
||||
}
|
||||
// Save the per-miner scan timeout (round 14 #2), clamped to >= 1s.
|
||||
if let Ok(secs) = self.ranges_timeout.get_value().trim().parse::<u64>() {
|
||||
self.scan_timeout_secs = secs.max(1);
|
||||
let _ = scan::save_scan_timeout(self.scan_timeout_secs);
|
||||
}
|
||||
let _ = scan::save_ranges(&lines);
|
||||
self.begin_scan(lines);
|
||||
wx_rs::set_status_text("scanning...");
|
||||
@@ -3340,11 +3412,6 @@ impl App {
|
||||
ID_COLS_ALPHA => self.apply_columns_sort(false),
|
||||
ID_COLS_CATEGORIES => self.apply_columns_sort(true),
|
||||
ID_PRESETS => return Some(self.build_presets_dialog()),
|
||||
ID_PICSSH_OK => self.apply_pic_probe(),
|
||||
ID_PICSSH_CANCEL => {
|
||||
self.pending_pic_targets.clear();
|
||||
self.picssh_dialog.close(0);
|
||||
}
|
||||
ID_PRESET_LOAD => self.apply_preset_load(),
|
||||
ID_PRESET_SAVE => self.apply_preset_save(),
|
||||
ID_PRESET_DELETE => self.apply_preset_delete(),
|
||||
@@ -3380,6 +3447,8 @@ impl App {
|
||||
self.pending_restore.clear();
|
||||
self.restore_dialog.close(0);
|
||||
}
|
||||
ID_POOLS_OK => self.apply_pools(),
|
||||
ID_POOLS_CANCEL => self.pools_dialog.close(0),
|
||||
ID_KPI_HASHING => self.toggle_kpi_filter("hashing"),
|
||||
ID_KPI_SLOW => self.toggle_kpi_filter("slow"),
|
||||
ID_KPI_NOT => self.toggle_kpi_filter("not hashing"),
|
||||
|
||||
Reference in New Issue
Block a user