GUI round 13: health-icon column, Z15J algorithm, Credentials + Columns dialogs

Five items from the round-13 list:

#4/#5 Z15 hashrate / unknown algorithm: a Z15J reports its model as
"ANTMINER Z15J", which asic-rs' alias table did not recognise, so it
deserialised to Unknown and its Sol/s hashrate was left un-bucketed as
"unknown hashrate". Add a first-class Z15J model (Equihash) in the makes
crate, plus a family-letter fallback in the v2020 backend so other
un-tabled Antminer models still resolve an algorithm (Z->Equihash,
L->Scrypt, S/T->SHA-256; ambiguous K/DR stay Unknown). Live-verified on
the Z15/Z15J fleet. Carried as vendored patch 0008.

#3 Component-health column: a new Health column (power, control board,
each fan front-to-back, each hashboard) drawn as coloured icons -- grey
unreachable, red down, yellow sub-optimal, green healthy -- replacing the
Errors, Boards and Status columns. Left-clicking the header cycles the
sort through the component facets (overall/power/fans/hashboards); the
active facet shows as a tag beside the chevron. Errors move to the cell
tooltip. Four operator-supplied Font Awesome icons registered via the
existing SVG-in-cell renderer (new SHAPE_BOLT/BRAIN/FAN/CHIP sentinels).

#2 Credentials: rename the "Set scan credentials" button to "Credentials"
and make the per-firmware defaults the main dialog (the global "all
firmwares" login is folded in as the top row).

#1 Columns dialog: narrower; new Alphabetical and Categories sort buttons
(via a Column::category grouping and a wxbr_reorder_set_order bridge fn);
one mouse handler that does both drag-to-reorder and drag-to-rubber-band-
select (the old BEGIN_DRAG binding had silently disabled rubber-band
selection); Ctrl+A select-all and Ctrl/Shift+Up/Down extend-selection.

wx-rs bridge patches 0002/0003 regenerated. Unit tests + 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:
2026-09-21 11:06:05 -06:00
co-authored by Claude Opus 4.8
parent a75fe5ba52
commit ecdb2fab9d
17 changed files with 1135 additions and 285 deletions
+249 -134
View File
@@ -28,6 +28,9 @@ const ID_RANGES_APPLY: i32 = 201;
const ID_RANGES_CANCEL: i32 = 202;
const ID_COLUMNS_OK: i32 = 203;
const ID_COLUMNS_CANCEL: i32 = 204;
// Column-picker sort buttons (round 13 #1).
const ID_COLS_ALPHA: i32 = 231;
const ID_COLS_CATEGORIES: i32 = 232;
const ID_FILTER_OK: i32 = 205;
const ID_FILTER_CANCEL: i32 = 206;
const ID_FILTER_RESET: i32 = 210;
@@ -76,13 +79,8 @@ const ID_CONFIRM_CANCEL: i32 = 743;
// Strong typed-confirmation dialog for flashing firmware.
const ID_FLASH_OK: i32 = 744;
const ID_FLASH_CANCEL: i32 = 745;
// Scan-credentials dialog.
const ID_CREDS_SAVE: i32 = 746;
const ID_CREDS_CLEAR: i32 = 747;
const ID_CREDS_CANCEL: i32 = 748;
// Per-firmware default-credentials editor (round 12 #13), opened from the scan
// credentials dialog.
const ID_FWCREDS_OPEN: i32 = 749;
// Credentials dialog (round 13 #2): a global "all firmwares" login plus a
// per-firmware row for every registry firmware, all in one dialog.
const ID_FWCREDS_SAVE: i32 = 750;
const ID_FWCREDS_RESET: i32 = 751;
const ID_FWCREDS_CANCEL: i32 = 752;
@@ -279,6 +277,13 @@ const SHAPE_PAUSED: &str = "\u{0008}";
/// Locate-light dot that fades in and out (round 12 #6); distinct from the static
/// `SHAPE_DOT` so only the flashing light pulses, not the hashboard health dots.
const SHAPE_PULSE_DOT: &str = "\u{000B}";
// Component-health icons (round 13 #3): one sentinel per component kind, each
// drawn from the operator-supplied Font Awesome SVG and recoloured per component
// state. Registered in `register_cell_icons`.
const SHAPE_BOLT: &str = "\u{000C}"; // power supply
const SHAPE_BRAIN: &str = "\u{000E}"; // control board
const SHAPE_FAN: &str = "\u{000F}"; // cooling fan
const SHAPE_CHIP: &str = "\u{0010}"; // hashboard
/// Register every SVG-backed table-cell icon with the bridge (round 12 #9/#11):
/// the access padlocks and the four status KPI icons. Called once at startup;
@@ -287,13 +292,17 @@ const SHAPE_PULSE_DOT: &str = "\u{000B}";
fn register_cell_icons() {
// (sentinel first char, svg) pairs; the bridge reads the viewBox dims we pass
// to keep each icon's aspect ratio when it rasterises at the cell height.
let icons: [(&str, &str); 6] = [
let icons: [(&str, &str); 10] = [
(SHAPE_LOCK, SVG_LOCK),
(SHAPE_UNLOCK, SVG_UNLOCK),
(SHAPE_HASHING, SVG_RABBIT),
(SHAPE_SLOW, SVG_TURTLE),
(SHAPE_NOTHASHING, SVG_WINE_CRACK),
(SHAPE_PAUSED, SVG_OTTER),
(SHAPE_BOLT, SVG_BOLT_FULL),
(SHAPE_BRAIN, SVG_BRAIN_FULL),
(SHAPE_FAN, SVG_FAN_FULL),
(SHAPE_CHIP, SVG_CHIP_FULL),
];
for (sentinel, svg) in icons {
let cp = sentinel.chars().next().map(|c| c as u32).unwrap_or(0);
@@ -372,6 +381,34 @@ fn encode_status_icon(pal: &Palette, status: &str) -> String {
encode_segments(&[(Some(status_kind_color(pal, status)), shape.to_string())])
}
/// The colour a component-health state renders in (round 13 #3): grey =
/// unreachable, red = detected but down, yellow = sub-optimal, green = healthy.
fn health_color(pal: &Palette, h: crate::model::CompHealth) -> (u8, u8, u8) {
use crate::model::CompHealth;
match h {
CompHealth::Unreachable => pal.label,
CompHealth::Down => pal.red,
CompHealth::Degraded => pal.amber,
CompHealth::Ok => pal.green,
}
}
/// Health column: one coloured icon per component (round 13 #3), in the order
/// power supply, control board, each fan (front-to-back / top-to-bottom), then
/// each hashboard. Replaces the old Errors/Boards/Status columns.
fn encode_component_health(pal: &Palette, r: &crate::model::MinerRow) -> String {
let mut segs: Vec<(Option<(u8, u8, u8)>, String)> = Vec::new();
segs.push((Some(health_color(pal, r.power_health())), SHAPE_BOLT.to_string()));
segs.push((Some(health_color(pal, r.control_health())), SHAPE_BRAIN.to_string()));
for h in r.fan_healths() {
segs.push((Some(health_color(pal, h)), SHAPE_FAN.to_string()));
}
for h in r.board_healths() {
segs.push((Some(health_color(pal, h)), SHAPE_CHIP.to_string()));
}
encode_segments(&segs)
}
// KPI card icons (round 11 #15). The animal/wine-glass SVGs are Font Awesome Pro
// (operator-supplied); bolt/hive are matching in-repo SVGs. All use
// fill="currentColor", recoloured per card at render time.
@@ -385,6 +422,12 @@ const SVG_BOLT: &str = include_str!("../assets/icons/bolt.svg");
// that replace the hand-drawn vector padlocks in the table.
const SVG_LOCK: &str = include_str!("../assets/icons/lock.svg");
const SVG_UNLOCK: &str = include_str!("../assets/icons/unlock.svg");
// Component-health icons (round 13 #3): operator-supplied Font Awesome solid
// glyphs (no fill attribute -- the renderer injects the per-component colour).
const SVG_BOLT_FULL: &str = include_str!("../assets/icons/bolt-solid-full.svg");
const SVG_BRAIN_FULL: &str = include_str!("../assets/icons/brain-solid-full.svg");
const SVG_FAN_FULL: &str = include_str!("../assets/icons/fan-solid-full.svg");
const SVG_CHIP_FULL: &str = include_str!("../assets/icons/microchip-solid-full.svg");
/// KPI card minimum widths. The count cards (Total/Hashing/...) are narrow; the
/// two wide cards (SHA-256 Hashrate, Est. power) need more room so their
@@ -596,12 +639,12 @@ pub struct App {
// The column a header right-click menu targets (remembered across the menu's
// nested event loop until an item is chosen).
header_menu_col: Option<Column>,
// The "Set scan credentials..." dialog.
creds_dialog: Widget,
// The optional global "all firmwares" login shown at the top of the
// Credentials dialog (round 13 #2). Empty when no global credential is set.
creds_user_input: Widget,
creds_pass_input: Widget,
// Per-firmware default-credentials editor (round 12 #13): the dialog plus one
// (firmware name, user field, pass field) per registry firmware.
// The Credentials dialog (round 13 #2): the global login above plus one
// (firmware name, user field, pass field) row per registry firmware.
fwcreds_dialog: Widget,
fwcreds_rows: Vec<(String, Widget, Widget)>,
// Background access (lock-state) probe.
@@ -798,7 +841,7 @@ pub fn build(frame: Widget) -> App {
ctl.add(filter_btn, 0, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_ALL, 4);
let columns_btn = Widget::button(panel, "Columns", ID_COLUMNS);
ctl.add(columns_btn, 0, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_ALL, 4);
let creds_btn = Widget::button(panel, "Set scan credentials...", ID_SCAN_CREDS);
let creds_btn = Widget::button(panel, "Credentials", ID_SCAN_CREDS);
ctl.add(creds_btn, 0, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_ALL, 4);
root.add_sizer(ctl, 0, sf::EXPAND | sf::BORDER_LEFT | sf::BORDER_RIGHT, 4);
@@ -879,7 +922,6 @@ pub fn build(frame: Widget) -> App {
pending_flash: None,
flashing: false,
header_menu_col: None,
creds_dialog: frame,
creds_user_input: frame,
creds_pass_input: frame,
fwcreds_dialog: frame,
@@ -1012,7 +1054,7 @@ impl App {
Some((sc, false)) if sc == c => title.push_str(" v"),
_ => {}
}
if matches!(c, Column::Hashrate | Column::Hashboards | Column::TotalChips | Column::ChipTemp | Column::Cooling | Column::Locked | Column::Light | Column::Error | Column::Status | Column::Firmware) {
if matches!(c, Column::Hashrate | Column::Health | Column::Hashboards | Column::TotalChips | Column::ChipTemp | Column::Cooling | Column::Locked | Column::Light | Column::Error | Column::Status | Column::Firmware) {
// These columns show two-tone / multi-tone text (actual vs.
// expected, or one colour per fan) via a custom renderer that
// parses the segment-encoded cell value fill_rows writes.
@@ -1065,6 +1107,8 @@ impl App {
.flatten();
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),
// Boards column: per-hashboard health dots (round 11 #10).
Column::Hashboards => encode_board_dots(&self.pal, &r.board_status),
Column::TotalChips => {
@@ -1102,6 +1146,17 @@ impl App {
if matches!(c, Column::Error) {
t.dvlc_set_cell_tooltip(disp, ci, &r.errors.join("\n"));
}
// The Health icons carry a hover tooltip: the component summary,
// plus the full error list (which the Health column replaced) so
// no error detail is lost (round 13 #3).
if matches!(c, Column::Health) {
let mut tip = r.health_summary();
if !r.errors.is_empty() {
tip.push('\n');
tip.push_str(&r.errors.join("\n"));
}
t.dvlc_set_cell_tooltip(disp, ci, &tip);
}
}
}
if let Some(row) = top {
@@ -2011,84 +2066,50 @@ impl App {
}
}
/// Build (but do not show) the "Set scan credentials..." dialog: HTTP
/// credentials used for firmware auto-discovery on password-protected
/// miners, prefilled from whatever is already saved on disk.
fn build_creds_dialog(&mut self) -> Widget {
let frame = Widget::main_frame();
let dlg = Widget::dialog(frame, "Set scan credentials");
let root = Widget::box_sizer(true);
let (saved_user, saved_pass) = credentials::load_credentials().unwrap_or_default();
// Never re-display the saved password in plaintext. Leave the field
// blank; a blank password on Save keeps whatever is already stored (see
// apply_creds_save), so opening this dialog to change only the username
// does not require -- or reveal -- the password.
let pass_hint = if saved_pass.is_empty() {
"HTTP credentials for firmware auto-discovery on password-protected miners."
} else {
"HTTP credentials for firmware auto-discovery. A password is already saved; leave Password blank to keep it, or type a new one to replace it."
};
let hint = Widget::static_text(dlg, pass_hint);
root.add(hint, 0, sf::BORDER_ALL, 8);
let user_row = Widget::box_sizer(false);
user_row.add(Widget::static_text(dlg, "Username:"), 0, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_ALL, 6);
let user_input = Widget::text_ctrl(dlg, false);
user_input.set_value(&saved_user);
user_input.set_min_size(200, -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, "Password:"), 0, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_ALL, 6);
let pass_input = Widget::text_ctrl(dlg, false);
pass_input.set_min_size(200, -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);
// The single credential above is applied to every firmware that has no
// per-firmware override; the button below edits those per-firmware default
// logins (round 12 #13).
let fwrow = Widget::box_sizer(false);
fwrow.add(
Widget::static_text(dlg, "Or set a login per firmware:"),
0,
sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_ALL,
6,
);
fwrow.add_stretch(1);
fwrow.add(Widget::button(dlg, "Per-firmware defaults...", ID_FWCREDS_OPEN), 0, sf::BORDER_ALL, 6);
root.add_sizer(fwrow, 0, sf::EXPAND | sf::BORDER_LEFT | sf::BORDER_RIGHT | sf::BORDER_TOP, 6);
let btns = Widget::box_sizer(false);
btns.add_stretch(1);
btns.add(Widget::button(dlg, "Save", ID_CREDS_SAVE), 0, sf::BORDER_ALL, 6);
btns.add(Widget::button(dlg, "Clear", ID_CREDS_CLEAR), 0, sf::BORDER_ALL, 6);
btns.add(Widget::button(dlg, "Cancel", ID_CREDS_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(460, 220);
dlg.fit(dlg);
self.creds_dialog = dlg;
self.creds_user_input = user_input;
self.creds_pass_input = pass_input;
dlg
}
/// Build (but do not show) the per-firmware default-credentials editor
/// (round 12 #13): one row per firmware in the asic-rs registry, each with a
/// username and password field prefilled from the saved override or, failing
/// that, the firmware's shipped default. Editing a field away from the default
/// makes it an override; setting it back to the default clears the override.
/// Build (but do not show) the Credentials dialog (round 13 #2): a single
/// place for every login the scanner uses. The top row is the optional global
/// "all firmwares" login (applied to any firmware without an override); below
/// it is one row per firmware in the asic-rs registry, each prefilled from the
/// saved override or the firmware's shipped default. Editing a firmware row
/// away from its default makes it an override; setting it back clears it.
/// (Formerly a global-login dialog with the per-firmware editor behind a
/// sub-button.)
fn build_firmware_creds_dialog(&mut self) -> Widget {
let frame = Widget::main_frame();
let dlg = Widget::dialog(frame, "Per-firmware default logins");
let dlg = Widget::dialog(frame, "Credentials");
let root = Widget::box_sizer(true);
root.add(
Widget::static_text(
dlg,
"Default login used when auto-discovering each firmware. Blank fields mean no login.\nValues left at the firmware's shipped default are not saved as overrides.",
"Logins used when auto-discovering password-protected miners. The global login\napplies to every firmware without its own row below. Blank fields mean no login;\nfirmware rows left at their shipped default are not saved as overrides.",
),
0,
sf::BORDER_ALL,
8,
);
// Global "all firmwares" login. Never re-display the saved password in
// plaintext: leave it blank, and a blank password on Save keeps whatever
// is already stored (see apply_firmware_creds_save).
let (saved_user, saved_pass) = credentials::load_credentials().unwrap_or_default();
let g_hint = if saved_pass.is_empty() {
"All firmwares"
} else {
"All firmwares (password saved; blank keeps it)"
};
let grow = Widget::box_sizer(false);
let glabel = Widget::static_text(dlg, g_hint);
glabel.set_min_size(150, -1);
grow.add(glabel, 0, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_LEFT | sf::BORDER_RIGHT, 6);
let user_input = Widget::text_ctrl(dlg, false);
user_input.set_min_size(150, -1);
user_input.set_value(&saved_user);
grow.add(user_input, 0, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_LEFT | sf::BORDER_RIGHT, 6);
let pass_input = Widget::text_ctrl(dlg, false);
pass_input.set_min_size(150, -1);
grow.add(pass_input, 1, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_LEFT | sf::BORDER_RIGHT, 6);
root.add_sizer(grow, 0, sf::EXPAND | sf::BORDER_LEFT | sf::BORDER_RIGHT | sf::BORDER_TOP, 6);
self.creds_user_input = user_input;
self.creds_pass_input = pass_input;
// Column headers.
let head = Widget::box_sizer(false);
let h_fw = Widget::static_text(dlg, "Firmware");
@@ -2139,9 +2160,31 @@ impl App {
dlg
}
/// Persist the per-firmware editor: a row that differs from the firmware's
/// shipped default becomes an override; a row equal to the default clears it.
/// Persist the Credentials dialog (round 13 #2): the global "all firmwares"
/// login (top row) plus the per-firmware overrides. A firmware row that
/// differs from its shipped default becomes an override; a row equal to the
/// default clears it.
fn apply_firmware_creds_save(&mut self) {
// Global login first. A blank password means "keep the saved password"
// (the field is never pre-filled in plaintext); a blank user AND password
// clears the global login entirely.
let g_user = self.creds_user_input.get_value();
let mut g_pass = self.creds_pass_input.get_value();
if g_pass.is_empty() {
if let Some((_, saved_pass)) = credentials::load_credentials() {
g_pass = saved_pass;
}
}
let global_result = if g_user.is_empty() && g_pass.is_empty() {
credentials::clear_credentials()
} else {
credentials::save_credentials(&g_user, &g_pass)
};
if let Err(e) = global_result {
wx_rs::set_status_text(&format!("failed to save global login: {e}"));
return;
}
// Per-firmware overrides.
let mut map: std::collections::HashMap<String, (String, String)> = std::collections::HashMap::new();
for (name, user_ctrl, pass_ctrl) in &self.fwcreds_rows {
let user = user_ctrl.get_value();
@@ -2156,54 +2199,29 @@ impl App {
self.fwcreds_dialog.close(1);
let n = map.len();
wx_rs::set_status_text(&format!(
"per-firmware logins saved ({n} override{})",
"credentials saved ({n} firmware override{})",
if n == 1 { "" } else { "s" }
));
}
Err(e) => wx_rs::set_status_text(&format!("failed to save per-firmware logins: {e}")),
}
}
/// Reset every editor row to the firmware's shipped default and clear the
/// saved overrides.
fn apply_firmware_creds_reset(&mut self) {
for (name, user_ctrl, pass_ctrl) in &self.fwcreds_rows {
let (user, pass) = credentials::firmware_default_for(name);
user_ctrl.set_value(&user);
pass_ctrl.set_value(&pass);
}
match credentials::clear_firmware_credentials() {
Ok(()) => wx_rs::set_status_text("per-firmware logins reset to defaults"),
Err(e) => wx_rs::set_status_text(&format!("failed to clear per-firmware logins: {e}")),
}
}
fn apply_creds_save(&mut self) {
let user = self.creds_user_input.get_value();
let mut pass = self.creds_pass_input.get_value();
// A blank password field means "keep the saved password" (the dialog no
// longer pre-fills it in plaintext), so fall back to the stored value.
if pass.is_empty() {
if let Some((_, saved_pass)) = credentials::load_credentials() {
pass = saved_pass;
}
}
match credentials::save_credentials(&user, &pass) {
Ok(()) => {
self.creds_dialog.close(1);
wx_rs::set_status_text("scan credentials saved");
}
Err(e) => wx_rs::set_status_text(&format!("failed to save credentials: {e}")),
}
}
fn apply_creds_clear(&mut self) {
match credentials::clear_credentials() {
Ok(()) => {
self.creds_dialog.close(1);
wx_rs::set_status_text("scan credentials cleared");
}
Err(e) => wx_rs::set_status_text(&format!("failed to clear credentials: {e}")),
/// Reset every firmware row to its shipped default and clear the global login,
/// dropping all saved overrides.
fn apply_firmware_creds_reset(&mut self) {
self.creds_user_input.set_value("");
self.creds_pass_input.set_value("");
for (name, user_ctrl, pass_ctrl) in &self.fwcreds_rows {
let (user, pass) = credentials::firmware_default_for(name);
user_ctrl.set_value(&user);
pass_ctrl.set_value(&pass);
}
let per_fw = credentials::clear_firmware_credentials();
let global = credentials::clear_credentials();
match per_fw.and(global) {
Ok(()) => wx_rs::set_status_text("credentials reset to defaults"),
Err(e) => wx_rs::set_status_text(&format!("failed to reset credentials: {e}")),
}
}
@@ -2537,6 +2555,21 @@ impl App {
Some((Column::HashrateRel, false)) => None,
_ => Some((Column::Hashrate, true)),
}
} else if col == Column::Health {
// The Health header cycles overall health, then each component facet
// (power, fans, hashboards), each asc then desc, then unsorted, so the
// fleet can be ordered by whichever component matters (round 13 #3).
match self.view.sort {
Some((Column::Health, true)) => Some((Column::Health, false)),
Some((Column::Health, false)) => Some((Column::HealthPower, true)),
Some((Column::HealthPower, true)) => Some((Column::HealthPower, false)),
Some((Column::HealthPower, false)) => Some((Column::HealthFans, true)),
Some((Column::HealthFans, true)) => Some((Column::HealthFans, false)),
Some((Column::HealthFans, false)) => Some((Column::HealthBoards, true)),
Some((Column::HealthBoards, true)) => Some((Column::HealthBoards, false)),
Some((Column::HealthBoards, false)) => None,
_ => Some((Column::Health, true)),
}
} else {
match self.view.sort {
Some((c, true)) if c == col => Some((col, false)),
@@ -2632,6 +2665,18 @@ impl App {
Some((Column::HashrateRel, asc)) if *c == Column::Hashrate => {
title.push_str(if asc { " %^" } else { " %v" })
}
// Health facet sorts are pseudo-columns shown on the Health header
// (round 13 #3): a short tag names the active component (Pwr/Fan/
// Brd) beside the chevron, since a native header can't carry an SVG.
Some((Column::HealthPower, asc)) if *c == Column::Health => {
title.push_str(if asc { " Pwr ^" } else { " Pwr v" })
}
Some((Column::HealthFans, asc)) if *c == Column::Health => {
title.push_str(if asc { " Fan ^" } else { " Fan v" })
}
Some((Column::HealthBoards, asc)) if *c == Column::Health => {
title.push_str(if asc { " Brd ^" } else { " Brd v" })
}
_ => {}
}
t.dvlc_set_col_title(i, &title);
@@ -2847,11 +2892,25 @@ impl App {
let frame = Widget::main_frame();
let dlg = Widget::dialog(frame, "Choose columns");
let root = Widget::box_sizer(true);
// Short, two-line hint so it doesn't force the dialog wide (round 13 #1).
let hint = Widget::static_text(
dlg,
"Check to show a metric; drag rows to reorder (IP is always first). Shift/Ctrl-click or drag to select several.",
"Check to show a column; drag rows to reorder (IP stays first).\nDrag or Shift/Ctrl-click to select several; Ctrl+A selects all.",
);
root.add(hint, 0, sf::BORDER_ALL, 6);
// Sort the rows in the picker (round 13 #1): Alphabetical by title, or
// grouped into Categories. These reorder the picker only; nothing applies
// until OK.
let sortrow = Widget::box_sizer(false);
sortrow.add(
Widget::static_text(dlg, "Sort:"),
0,
sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_LEFT | sf::BORDER_RIGHT,
6,
);
sortrow.add(Widget::button(dlg, "Alphabetical", ID_COLS_ALPHA), 0, sf::BORDER_RIGHT, 6);
sortrow.add(Widget::button(dlg, "Categories", ID_COLS_CATEGORIES), 0, sf::BORDER_RIGHT, 6);
root.add_sizer(sortrow, 0, sf::BORDER_LEFT | sf::BORDER_RIGHT | sf::BORDER_BOTTOM, 4);
// Base list is registry order; the wx order array lists items in the
// current arranged order, encoding checked = visible (a negative value
// ~idx means item idx unchecked).
@@ -2876,12 +2935,47 @@ impl App {
btns.add(Widget::button(dlg, "Cancel", ID_COLUMNS_CANCEL), 0, sf::BORDER_ALL, 6);
root.add_sizer(btns, 0, sf::BORDER_ALL, 6);
root.set_sizer_on(dlg);
// Keep the picker compact: the row column is 190px, so ~340px is enough
// (round 13 #1). fit() sizes to content but never below this floor.
dlg.set_min_size(360, 480);
dlg.fit(dlg);
self.columns_dialog = dlg;
self.columns_list = list;
dlg
}
/// Reorder the column picker's rows (round 13 #1) by title (Alphabetical) or
/// by category group, preserving each row's checked state. Applies to the
/// picker only; the view changes on OK.
fn apply_columns_sort(&self, by_category: bool) {
let base = Self::selectable_columns();
let titles: Vec<&str> = base.iter().map(|c| c.title()).collect();
let mut pairs: Vec<(usize, bool)> = self
.columns_list
.reorder_get_order()
.iter()
.map(|&e| if e < 0 { ((!e) as usize, false) } else { (e as usize, true) })
.collect();
if by_category {
// Category rank, then registry order within the group (idx order).
pairs.sort_by_key(|&(idx, _)| {
let (rank, _) = base.get(idx).map(|c| c.category()).unwrap_or((u8::MAX, ""));
(rank, idx)
});
} else {
pairs.sort_by(|&(a, _), &(b, _)| {
let ta = base.get(a).map(|c| c.title()).unwrap_or("");
let tb = base.get(b).map(|c| c.title()).unwrap_or("");
ta.to_lowercase().cmp(&tb.to_lowercase())
});
}
let order: Vec<i32> = pairs
.iter()
.map(|&(idx, checked)| if checked { idx as i32 } else { !(idx as i32) })
.collect();
self.columns_list.reorder_set_order(&order, &titles);
}
fn apply_columns(&mut self) {
// Persist the "hide empty columns" option (round 11 #9); table_columns()
// applies it non-destructively when the table is (re)built below.
@@ -2905,9 +2999,12 @@ impl App {
self.view.order = new_order;
self.view.visible = visible;
}
// Drop the sort if its column was hidden (IP is always shown).
// Drop the sort if its column was hidden (IP is always shown). A sort-only
// pseudo-column (relative hashrate, a Health facet) maps to its display
// column for this check so it survives as long as that column is shown.
if let Some((c, _)) = self.view.sort {
if c != Column::Ip && !self.view.visible.contains(&c) {
let home = Self::sort_home_col(c);
if home != Column::Ip && !self.view.visible.contains(&home) {
self.view.sort = None;
}
}
@@ -2915,6 +3012,16 @@ impl App {
self.rebuild_table();
}
/// Map a sort-only pseudo-column to the visible column that hosts its sort
/// (round 11 #16 / round 13 #3); every other column maps to itself.
fn sort_home_col(c: Column) -> Column {
match c {
Column::HashrateRel => Column::Hashrate,
Column::HealthPower | Column::HealthFans | Column::HealthBoards => Column::Health,
other => other,
}
}
/// Operator labels offered for a column, by type.
fn filter_ops(col: Column) -> &'static [&'static str] {
if col.is_numeric() {
@@ -3230,6 +3337,8 @@ impl App {
ID_COLUMNS => return Some(self.build_columns_dialog()),
ID_COLUMNS_OK => self.apply_columns(),
ID_COLUMNS_CANCEL => self.columns_dialog.close(0),
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 => {
@@ -3261,11 +3370,7 @@ impl App {
self.pending_flash = None;
self.flash_confirm_dialog.close(0);
}
ID_SCAN_CREDS => return Some(self.build_creds_dialog()),
ID_CREDS_SAVE => self.apply_creds_save(),
ID_CREDS_CLEAR => self.apply_creds_clear(),
ID_CREDS_CANCEL => self.creds_dialog.close(0),
ID_FWCREDS_OPEN => return Some(self.build_firmware_creds_dialog()),
ID_SCAN_CREDS => return Some(self.build_firmware_creds_dialog()),
ID_FWCREDS_SAVE => self.apply_firmware_creds_save(),
ID_FWCREDS_RESET => self.apply_firmware_creds_reset(),
ID_FWCREDS_CANCEL => self.fwcreds_dialog.close(0),
@@ -3383,7 +3488,7 @@ impl App {
// Icon/dot columns (round 11 #10/#13) render shape sentinels, not
// text, so they don't round-trip to c.cell(r); they're verified
// structurally in the icon-column spot-check below.
if matches!(c, Column::Hashboards | Column::Locked | Column::Light | Column::Status) {
if matches!(c, Column::Health | Column::Hashboards | Column::Locked | Column::Light | Column::Status) {
continue;
}
let want = c.cell(r);
@@ -3426,11 +3531,21 @@ impl App {
// (dots / padlock), not text -- verify they are present.
let boards_col = cols.iter().position(|c| *c == Column::Hashboards);
let access_col = cols.iter().position(|c| *c == Column::Locked);
let health_col = cols.iter().position(|c| *c == Column::Health);
if let (Some(bc), Some(row)) = (boards_col, find("10.255.1.166")) {
let raw = t.dvlc_get_cell(row, bc).unwrap_or_default();
check("Boards column renders dot sentinels for a mining miner",
raw.contains('\u{0007}'), format!("cell={raw:?}"));
}
// Health column (round 13 #3): the power (bolt) and control-board (brain)
// icons are always emitted, plus a chip icon per hashboard for a mining
// miner; verify the sentinels are present.
if let (Some(hc), Some(row)) = (health_col, find("10.255.1.166")) {
let raw = t.dvlc_get_cell(row, hc).unwrap_or_default();
check("Health column renders the power + control-board + chip sentinels",
raw.contains('\u{000C}') && raw.contains('\u{000E}') && raw.contains('\u{0010}'),
format!("cell={raw:?}"));
}
if let (Some(ac), Some(row)) = (access_col, find("10.255.1.112")) {
let raw = t.dvlc_get_cell(row, ac).unwrap_or_default();
check("Access column renders a closed-padlock sentinel for a locked miner",