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:
@@ -246,6 +246,39 @@ pub enum BoardHealth {
|
||||
Missing,
|
||||
}
|
||||
|
||||
/// One component's health for the Health icon column (round 13 #3). Rendered as a
|
||||
/// coloured icon: grey = unreachable / not detected, red = detected but not
|
||||
/// functioning, yellow = functioning sub-optimally, green = fully functioning.
|
||||
/// The `level` ordering (worst first) is also the sort order.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub enum CompHealth {
|
||||
Unreachable,
|
||||
Down,
|
||||
Degraded,
|
||||
Ok,
|
||||
}
|
||||
|
||||
impl CompHealth {
|
||||
/// 0 (worst) .. 3 (best), for the Health column sort keys.
|
||||
pub fn level(self) -> i32 {
|
||||
match self {
|
||||
CompHealth::Unreachable => 0,
|
||||
CompHealth::Down => 1,
|
||||
CompHealth::Degraded => 2,
|
||||
CompHealth::Ok => 3,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Which component the Health column is currently sorted by (round 13 #3).
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum HealthFacet {
|
||||
Overall,
|
||||
Power,
|
||||
Fans,
|
||||
Boards,
|
||||
}
|
||||
|
||||
/// One miner's telemetry snapshot, flattened from asic-rs `MinerData` into the
|
||||
/// scalar fields the table can display. Absent metrics are `None` / empty /
|
||||
/// 0.0 and render as a blank cell.
|
||||
@@ -364,6 +397,127 @@ impl MinerRow {
|
||||
}
|
||||
}
|
||||
|
||||
/// Power-supply health (round 13 #3). Green when the miner is drawing power,
|
||||
/// its PSU fan is spinning, or it is actively mining (all prove the PSU is
|
||||
/// live); grey (unknown) otherwise -- asic-rs has no direct PSU-fault flag, so
|
||||
/// a missing wattage reading is treated as unknown, never a false "down".
|
||||
pub fn power_health(&self) -> CompHealth {
|
||||
if self.power_w > 0.0 || self.psu_fan_rpm > 0.0 || self.is_mining {
|
||||
CompHealth::Ok
|
||||
} else {
|
||||
CompHealth::Unreachable
|
||||
}
|
||||
}
|
||||
|
||||
/// Control-board health (round 13 #3). The miner answered the scan, so its
|
||||
/// control board is reachable and running; there is no network signal for a
|
||||
/// degraded controller, so this is green for any responding miner.
|
||||
pub fn control_health(&self) -> CompHealth {
|
||||
CompHealth::Ok
|
||||
}
|
||||
|
||||
/// Per-fan health (round 13 #3), front-to-back / top-to-bottom in the order
|
||||
/// the miner reports its fans. A spinning fan is green, unless it is running
|
||||
/// well below its fastest sibling (< 50% of the max reported RPM), which is a
|
||||
/// sub-optimal fan (yellow); a reported 0 RPM is a stopped fan (red); a fan the
|
||||
/// miner expects but does not report is grey (not detected). Empty when the
|
||||
/// miner reports no fans at all.
|
||||
pub fn fan_healths(&self) -> Vec<CompHealth> {
|
||||
let expected = self.expected_fans.map(|n| n as usize).unwrap_or(0);
|
||||
let n = expected.max(self.fan_rpms.len());
|
||||
let max_rpm = self.fan_rpms.iter().cloned().fold(0.0_f64, f64::max);
|
||||
(0..n)
|
||||
.map(|i| match self.fan_rpms.get(i) {
|
||||
Some(&rpm) if rpm > 0.0 => {
|
||||
if max_rpm > 0.0 && rpm < 0.5 * max_rpm {
|
||||
CompHealth::Degraded
|
||||
} else {
|
||||
CompHealth::Ok
|
||||
}
|
||||
}
|
||||
Some(_) => CompHealth::Down,
|
||||
None => CompHealth::Unreachable,
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Per-hashboard health (round 13 #3). Uses the per-board status when the
|
||||
/// miner reports it (green ok / red faulted / grey missing); otherwise falls
|
||||
/// back to the present-vs-expected board counts (present green, shortfall
|
||||
/// grey). Empty when neither is known.
|
||||
pub fn board_healths(&self) -> Vec<CompHealth> {
|
||||
if !self.board_status.is_empty() {
|
||||
// A miner that is mining but "slow" is hashing sub-optimally, so its
|
||||
// present-and-hashing boards read yellow rather than green.
|
||||
let ok = if self.slow { CompHealth::Degraded } else { CompHealth::Ok };
|
||||
return self
|
||||
.board_status
|
||||
.iter()
|
||||
.map(|h| match h {
|
||||
BoardHealth::Ok => ok,
|
||||
BoardHealth::Fault => CompHealth::Down,
|
||||
BoardHealth::Missing => CompHealth::Unreachable,
|
||||
})
|
||||
.collect();
|
||||
}
|
||||
let present = self.hashboards.map(|n| n as usize).unwrap_or(0);
|
||||
let expected = self.expected_hashboards.map(|n| n as usize).unwrap_or(present);
|
||||
let n = present.max(expected);
|
||||
(0..n)
|
||||
.map(|i| if i < present { CompHealth::Ok } else { CompHealth::Unreachable })
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// The sort key for the Health column and its facet pseudo-columns (round 13
|
||||
/// #3): higher = healthier, so an ascending sort surfaces the most-broken
|
||||
/// miners first (matching the existing Boards-column behaviour). Encoded as
|
||||
/// `worst-component-level * 1000 + sum-of-levels` so any red/grey component
|
||||
/// dominates, with the healthy-icon count as the tiebreak. A component with no
|
||||
/// data scores as healthy so unknown-but-fine miners don't masquerade as
|
||||
/// broken.
|
||||
pub fn health_score(&self, facet: HealthFacet) -> f64 {
|
||||
let score = |comps: &[CompHealth]| -> i64 {
|
||||
if comps.is_empty() {
|
||||
return CompHealth::Ok.level() as i64 * 1000 + CompHealth::Ok.level() as i64;
|
||||
}
|
||||
let min = comps.iter().map(|c| c.level()).min().unwrap_or(3) as i64;
|
||||
let sum: i64 = comps.iter().map(|c| c.level() as i64).sum();
|
||||
min * 1000 + sum
|
||||
};
|
||||
let val = match facet {
|
||||
HealthFacet::Power => score(&[self.power_health()]),
|
||||
HealthFacet::Fans => score(&self.fan_healths()),
|
||||
HealthFacet::Boards => score(&self.board_healths()),
|
||||
HealthFacet::Overall => {
|
||||
let mut all = vec![self.power_health(), self.control_health()];
|
||||
all.extend(self.fan_healths());
|
||||
all.extend(self.board_healths());
|
||||
score(&all)
|
||||
}
|
||||
};
|
||||
val as f64
|
||||
}
|
||||
|
||||
/// Compact plain-text summary of component health (round 13 #3), used as the
|
||||
/// Health column's filter/sort-fallback text and the base of its hover
|
||||
/// tooltip. e.g. "power ok, fans 3/4, boards 3/3".
|
||||
pub fn health_summary(&self) -> String {
|
||||
let ok = |comps: &[CompHealth]| comps.iter().filter(|c| **c == CompHealth::Ok).count();
|
||||
let fans = self.fan_healths();
|
||||
let boards = self.board_healths();
|
||||
let mut parts = vec![match self.power_health() {
|
||||
CompHealth::Ok => "power ok".to_string(),
|
||||
_ => "power ?".to_string(),
|
||||
}];
|
||||
if !fans.is_empty() {
|
||||
parts.push(format!("fans {}/{}", ok(&fans), fans.len()));
|
||||
}
|
||||
if !boards.is_empty() {
|
||||
parts.push(format!("boards {}/{}", ok(&boards), boards.len()));
|
||||
}
|
||||
parts.join(", ")
|
||||
}
|
||||
|
||||
/// Upsert into `rows` by ip; returns true if the row is new.
|
||||
pub fn upsert_into(self, rows: &mut Vec<MinerRow>) -> bool {
|
||||
if let Some(r) = rows.iter_mut().find(|r| r.ip == self.ip) {
|
||||
@@ -415,6 +569,18 @@ pub enum Column {
|
||||
Model,
|
||||
Brand,
|
||||
Submodel,
|
||||
/// Component-health icon column (round 13 #3): power, control board, each
|
||||
/// fan, and each hashboard drawn as a coloured icon (grey unreachable, red
|
||||
/// down, yellow sub-optimal, green healthy). Replaces the old Errors, Boards
|
||||
/// (hashboard dots) and Status columns.
|
||||
Health,
|
||||
/// Sort-only pseudo-columns (round 13 #3): the Health header left-click cycles
|
||||
/// its sort through these facets so the fleet can be ordered by whichever
|
||||
/// component matters (power, fans, hashboards) instead of overall health.
|
||||
/// Deliberately NOT in `ALL_COLUMNS`, so they never appear in the picker.
|
||||
HealthPower,
|
||||
HealthFans,
|
||||
HealthBoards,
|
||||
Status,
|
||||
Efficiency,
|
||||
FluidTemp,
|
||||
@@ -452,9 +618,10 @@ pub enum Column {
|
||||
|
||||
/// Every column, in registry order. Ip first, then the default-visible set
|
||||
/// (UI-SPEC order), then all remaining metrics.
|
||||
pub const ALL_COLUMNS: [Column; 45] = [
|
||||
pub const ALL_COLUMNS: [Column; 43] = [
|
||||
Column::Ip,
|
||||
Column::Hashrate,
|
||||
Column::Health,
|
||||
Column::Power,
|
||||
Column::ChipTemp,
|
||||
Column::Cooling,
|
||||
@@ -465,7 +632,6 @@ pub const ALL_COLUMNS: [Column; 45] = [
|
||||
Column::Model,
|
||||
Column::Brand,
|
||||
Column::Submodel,
|
||||
Column::Status,
|
||||
Column::Efficiency,
|
||||
Column::FluidTemp,
|
||||
Column::EnvTemp,
|
||||
@@ -474,7 +640,6 @@ pub const ALL_COLUMNS: [Column; 45] = [
|
||||
Column::FanCount,
|
||||
Column::ExpectedFans,
|
||||
Column::TotalChips,
|
||||
Column::Hashboards,
|
||||
Column::Mac,
|
||||
Column::Hostname,
|
||||
Column::Serial,
|
||||
@@ -484,7 +649,6 @@ pub const ALL_COLUMNS: [Column; 45] = [
|
||||
Column::Algorithm,
|
||||
Column::Pic,
|
||||
Column::Locked,
|
||||
Column::Error,
|
||||
Column::Uptime,
|
||||
Column::Light,
|
||||
Column::OperatingState,
|
||||
@@ -501,17 +665,17 @@ pub const ALL_COLUMNS: [Column; 45] = [
|
||||
];
|
||||
|
||||
/// The columns shown by default (UI-SPEC), after the fixed IP column, in display
|
||||
/// order: model, errors, hashrate, power, chip temp, firmware, CPU, boards
|
||||
/// (hashboard health), access.
|
||||
pub const DEFAULT_VISIBLE: [Column; 9] = [
|
||||
/// order: model, health (component icons), hashrate, power, chip temp, firmware,
|
||||
/// CPU, access. The Health column (round 13 #3) folds the old Errors, Boards and
|
||||
/// Status columns into one row of per-component icons.
|
||||
pub const DEFAULT_VISIBLE: [Column; 8] = [
|
||||
Column::Model,
|
||||
Column::Error,
|
||||
Column::Health,
|
||||
Column::Hashrate,
|
||||
Column::Power,
|
||||
Column::ChipTemp,
|
||||
Column::Firmware,
|
||||
Column::Cpu,
|
||||
Column::Hashboards,
|
||||
Column::Locked,
|
||||
];
|
||||
|
||||
@@ -531,6 +695,10 @@ impl Column {
|
||||
Column::Model => "Model",
|
||||
Column::Brand => "Brand",
|
||||
Column::Submodel => "Submodel",
|
||||
Column::Health => "Health",
|
||||
Column::HealthPower => "Health (power)",
|
||||
Column::HealthFans => "Health (fans)",
|
||||
Column::HealthBoards => "Health (boards)",
|
||||
Column::Status => "Status",
|
||||
Column::Efficiency => "Efficiency (J/TH)",
|
||||
Column::FluidTemp => "Fluid temp",
|
||||
@@ -582,6 +750,10 @@ impl Column {
|
||||
Column::Model => 150,
|
||||
Column::Brand => 100,
|
||||
Column::Submodel => 100,
|
||||
// Wide enough for power + control board + several fan and hashboard
|
||||
// icons in a row (round 13 #3).
|
||||
Column::Health => 170,
|
||||
Column::HealthPower | Column::HealthFans | Column::HealthBoards => 170,
|
||||
Column::Status => 95,
|
||||
Column::Efficiency => 120,
|
||||
Column::FanCount | Column::TotalChips | Column::Hashboards => 70,
|
||||
@@ -705,6 +877,12 @@ impl Column {
|
||||
}
|
||||
// IP sorts numerically (u32 fits exactly in f64), not lexically.
|
||||
Column::Ip => SortKey::Num(ip_to_u32(&r.ip) as f64),
|
||||
// Health column + its facet pseudo-columns (round 13 #3): higher =
|
||||
// healthier, so ascending surfaces the most-broken miners.
|
||||
Column::Health => SortKey::Num(r.health_score(HealthFacet::Overall)),
|
||||
Column::HealthPower => SortKey::Num(r.health_score(HealthFacet::Power)),
|
||||
Column::HealthFans => SortKey::Num(r.health_score(HealthFacet::Fans)),
|
||||
Column::HealthBoards => SortKey::Num(r.health_score(HealthFacet::Boards)),
|
||||
_ => SortKey::Str(self.cell(r).to_lowercase()),
|
||||
}
|
||||
}
|
||||
@@ -791,6 +969,12 @@ impl Column {
|
||||
n => n.to_string(),
|
||||
},
|
||||
Column::Status => r.status().to_string(),
|
||||
// The Health column renders as component icons (see fill_rows); this
|
||||
// plain-text summary is its filter/sort-fallback text and tooltip base
|
||||
// (round 13 #3). The facet pseudo-columns are never displayed.
|
||||
Column::Health | Column::HealthPower | Column::HealthFans | Column::HealthBoards => {
|
||||
r.health_summary()
|
||||
}
|
||||
Column::Uptime => format_uptime(r.uptime_secs),
|
||||
Column::Light => match r.light_flashing {
|
||||
Some(true) => "on".to_string(),
|
||||
@@ -811,6 +995,34 @@ impl Column {
|
||||
Column::Pool3Worker => pool_worker(2),
|
||||
}
|
||||
}
|
||||
|
||||
/// The column's category, as a (sort-rank, label) pair, for the column
|
||||
/// picker's "Categories" grouping (round 13 #1). Lower rank sorts first; the
|
||||
/// label heads the group. Columns keep their registry order within a group.
|
||||
pub fn category(self) -> (u8, &'static str) {
|
||||
match self {
|
||||
Column::Ip | Column::Model | Column::Brand | Column::Submodel | Column::Mac
|
||||
| Column::Hostname | Column::Serial => (0, "Identity"),
|
||||
Column::Firmware | Column::FwVersion | Column::ApiVersion | Column::Algorithm
|
||||
| Column::Pic | Column::Cpu | Column::BoardCode => (1, "Firmware & board"),
|
||||
Column::Health | Column::HealthPower | Column::HealthFans | Column::HealthBoards
|
||||
| Column::Status | Column::Error | Column::Locked | Column::Light
|
||||
| Column::OperatingState => (2, "Health & status"),
|
||||
Column::Hashrate | Column::HashrateRel | Column::Power | Column::Efficiency
|
||||
| Column::TuningPercent | Column::BestShare | Column::SessionBestShare
|
||||
| Column::Uptime => (3, "Performance"),
|
||||
Column::ChipTemp | Column::FluidTemp | Column::EnvTemp | Column::OutletTemp => {
|
||||
(4, "Temperature")
|
||||
}
|
||||
Column::Cooling | Column::PsuFan | Column::FanCount | Column::ExpectedFans => {
|
||||
(5, "Cooling")
|
||||
}
|
||||
Column::TotalChips | Column::Hashboards => (6, "Hardware"),
|
||||
Column::Worker | Column::PoolAccount | Column::PoolUrl | Column::Pool1Url
|
||||
| Column::Pool1Worker | Column::Pool2Url | Column::Pool2Worker | Column::Pool3Url
|
||||
| Column::Pool3Worker => (7, "Pools"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub enum SortKey {
|
||||
@@ -1065,6 +1277,63 @@ mod tests {
|
||||
(rows, view, idx)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn component_health_maps_states_to_the_four_levels() {
|
||||
// Round 13 #3: power/control/fan/board health map to the grey/red/yellow/
|
||||
// green four-state model, and the Health column is in the default view.
|
||||
assert!(DEFAULT_VISIBLE.contains(&Column::Health));
|
||||
|
||||
// A healthy mining miner: power ok, fans all spinning near each other,
|
||||
// boards ok.
|
||||
let mut r = MinerRow {
|
||||
is_mining: true,
|
||||
power_w: 3200.0,
|
||||
fan_rpms: vec![6000.0, 6100.0, 5900.0, 6000.0],
|
||||
expected_fans: Some(4),
|
||||
board_status: vec![BoardHealth::Ok, BoardHealth::Ok, BoardHealth::Ok],
|
||||
..Default::default()
|
||||
};
|
||||
assert_eq!(r.power_health(), CompHealth::Ok);
|
||||
assert_eq!(r.control_health(), CompHealth::Ok);
|
||||
assert!(r.fan_healths().iter().all(|h| *h == CompHealth::Ok));
|
||||
assert!(r.board_healths().iter().all(|h| *h == CompHealth::Ok));
|
||||
|
||||
// A stopped fan is red, a fan at <50% of its fastest sibling is yellow.
|
||||
r.fan_rpms = vec![6000.0, 0.0, 2000.0, 6000.0];
|
||||
let fans = r.fan_healths();
|
||||
assert_eq!(fans[0], CompHealth::Ok);
|
||||
assert_eq!(fans[1], CompHealth::Down); // stopped
|
||||
assert_eq!(fans[2], CompHealth::Degraded); // 2000 < 0.5 * 6000
|
||||
assert_eq!(fans[3], CompHealth::Ok);
|
||||
|
||||
// A faulted / missing board is red / grey; a slow miner's ok boards go
|
||||
// yellow.
|
||||
r.board_status = vec![BoardHealth::Ok, BoardHealth::Fault, BoardHealth::Missing];
|
||||
r.slow = true;
|
||||
let boards = r.board_healths();
|
||||
assert_eq!(boards[0], CompHealth::Degraded); // ok but the miner is slow
|
||||
assert_eq!(boards[1], CompHealth::Down);
|
||||
assert_eq!(boards[2], CompHealth::Unreachable);
|
||||
|
||||
// A silent miner (no power, no fan, not mining) reads grey for power.
|
||||
let dark = MinerRow::default();
|
||||
assert_eq!(dark.power_health(), CompHealth::Unreachable);
|
||||
|
||||
// Healthier miners score higher, so an ascending Health sort puts the
|
||||
// most-broken first.
|
||||
let broken = r.health_score(HealthFacet::Overall);
|
||||
let healthy = MinerRow {
|
||||
is_mining: true,
|
||||
power_w: 3200.0,
|
||||
fan_rpms: vec![6000.0, 6000.0],
|
||||
expected_fans: Some(2),
|
||||
board_status: vec![BoardHealth::Ok, BoardHealth::Ok],
|
||||
..Default::default()
|
||||
}
|
||||
.health_score(HealthFacet::Overall);
|
||||
assert!(broken < healthy, "broken {broken} should score below healthy {healthy}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn kpis_match_expected_hardware_output() {
|
||||
// This does not hardcode fixture counts: it independently recomputes
|
||||
|
||||
@@ -12,18 +12,18 @@ use crate::scan::config_path;
|
||||
pub const PRESETS_FILE: &str = "presets.json";
|
||||
|
||||
/// The built-in default profile's visible columns, in display order (Ip first):
|
||||
/// IP, model, errors, hashrate, power, chip temp, firmware, CPU, boards
|
||||
/// (hashboard health), access.
|
||||
const DEFAULT_PROFILE: [Column; 10] = [
|
||||
/// IP, model, health (component icons), hashrate, power, chip temp, firmware,
|
||||
/// CPU, access. The Health column (round 13 #3) replaced the old errors, boards
|
||||
/// (hashboard dots) and status columns.
|
||||
const DEFAULT_PROFILE: [Column; 9] = [
|
||||
Column::Ip,
|
||||
Column::Model,
|
||||
Column::Error,
|
||||
Column::Health,
|
||||
Column::Hashrate,
|
||||
Column::Power,
|
||||
Column::ChipTemp,
|
||||
Column::Firmware,
|
||||
Column::Cpu,
|
||||
Column::Hashboards,
|
||||
Column::Locked,
|
||||
];
|
||||
|
||||
@@ -127,10 +127,12 @@ mod tests {
|
||||
// IP first + the requested default columns visible.
|
||||
assert!(view.visible.contains(&Column::Ip));
|
||||
assert!(view.visible.contains(&Column::Model));
|
||||
assert!(view.visible.contains(&Column::Error));
|
||||
assert!(view.visible.contains(&Column::Health));
|
||||
assert!(view.visible.contains(&Column::Cpu));
|
||||
assert!(view.visible.contains(&Column::Hashboards));
|
||||
assert!(view.visible.contains(&Column::Locked));
|
||||
// The Health column (round 13 #3) replaced these in the default profile.
|
||||
assert!(!view.visible.contains(&Column::Error));
|
||||
assert!(!view.visible.contains(&Column::Hashboards));
|
||||
// Columns dropped from the default profile in round 11.
|
||||
assert!(!view.visible.contains(&Column::BoardCode), "not in the default profile");
|
||||
assert!(!view.visible.contains(&Column::Cooling), "not in the default profile");
|
||||
|
||||
+249
-134
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user