GUI round 15 (part 1): pool dropdowns, aligned health icons, export, more
build-test-release / release (push) Successful in 7m29s
build-test-release / release (push) Successful in 7m29s
Twelve of the round-15 items (the code items; the live-hardware flashing/ testing and the settings/localization/logs work follow separately): #1 Configure-pools: three pool rows (address, account, worker, password), each field with a "+" dropdown of presets (top-11 BTC pool stratums; worker-name placeholders) plus user-addable, persisted entries. Worker picks insert at the cursor rather than replacing. Writes up to three pools per miner via set_pools_config, worker expanded per unit. #2 PIC detection: replace the broken SSH i2cdump (it read 0x48, the temp sensor, not the PIC) with a model lookup -- no firmware exposes PIC over the network, so infer it from the model (noPIC: S19k Pro, S21 family, T21, explicit noPIC; PIC: rest of the S19 line). #4 Zoom: an editable percent field in the status bar (type an exact scale) and Ctrl +/- / Ctrl+0 to zoom in/out/reset. #5 Health icons align in fixed slots (power, control, fans, hashboards); miners with fewer fans/boards leave a gap so hashboards still line up. The max fan/board counts are computed parametrically from the fleet. #6 Light: the locate-light column is on by default (last), shown as a green-over-red beacon flashing quickly instead of a single amber dot. #8 The bottom-left status line is now scan-only; operation progress lives in the Health column (per miner) and failures in the bottom-right indicator. #9 / #10 / #11: drop the Credentials-dialog blurb; move the scan-ranges format help to a tooltip; make Restore-to-stock a plain confirmation (no typed keyword, no warning wall). #12 Z15 fans: the v2020 backend now reads fans from higher fan slots (the Z15 reports fan3/fan4 with fan1/fan2 = 0). Vendored patch 0009. #14 Export: an Export button writes every scanned data point to a CSV, one value per cell (lists expanded to indexed columns) -- complete and machine-readable, unlike the on-screen table. #15 Health tooltips are per-icon: hovering a specific fan or hashboard shows just that component's state, with errors attributed to the board that names them in the message. New wx-rs bridge surface: widget tooltips, save-file dialog, insert-at-cursor, status-bar zoom entry + Ctrl+/-, the light beacon + alignment-gap sentinels, and per-icon cell tooltips (bridge patches 0002/0003 regenerated). Unit tests (worker templates, PIC map, CSV export, health) + 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:
@@ -0,0 +1,187 @@
|
||||
//! CSV export of the full scan data (round 15 #14).
|
||||
//!
|
||||
//! Unlike the on-screen table (which packs several values into one cell, e.g.
|
||||
//! "95T/96T" or a row of health icons), the export is one value per cell and
|
||||
//! covers every scanned data point, so it is complete and machine-readable.
|
||||
//! Variable-length fields (per-board temps, per-fan RPMs, per-board health, the
|
||||
//! pool list) are expanded into indexed columns out to the widest miner in the
|
||||
//! set, so every row has the same columns.
|
||||
|
||||
use crate::model::{BoardHealth, MinerRow};
|
||||
|
||||
/// Escape one CSV field: quote it when it contains a comma, quote, CR or LF, and
|
||||
/// double any embedded quotes.
|
||||
fn esc(s: &str) -> String {
|
||||
if s.contains([',', '"', '\n', '\r']) {
|
||||
format!("\"{}\"", s.replace('"', "\"\""))
|
||||
} else {
|
||||
s.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
fn num(v: f64) -> String {
|
||||
if v == 0.0 {
|
||||
String::new()
|
||||
} else if v.fract() == 0.0 {
|
||||
format!("{v:.0}")
|
||||
} else {
|
||||
format!("{v:.3}")
|
||||
}
|
||||
}
|
||||
|
||||
fn opt_bool(v: Option<bool>, yes: &str, no: &str) -> String {
|
||||
match v {
|
||||
Some(true) => yes.to_string(),
|
||||
Some(false) => no.to_string(),
|
||||
None => String::new(),
|
||||
}
|
||||
}
|
||||
|
||||
fn board_health_str(h: &BoardHealth) -> &'static str {
|
||||
match h {
|
||||
BoardHealth::Ok => "ok",
|
||||
BoardHealth::Fault => "fault",
|
||||
BoardHealth::Missing => "missing",
|
||||
}
|
||||
}
|
||||
|
||||
/// The fixed scalar columns, in order: (header, extractor).
|
||||
type Col = (&'static str, fn(&MinerRow) -> String);
|
||||
|
||||
fn scalar_columns() -> Vec<Col> {
|
||||
vec![
|
||||
("ip", |r| r.ip.clone()),
|
||||
("model", |r| r.model.clone()),
|
||||
("brand", |r| r.brand.clone()),
|
||||
("submodel", |r| r.submodel.clone()),
|
||||
("mac", |r| r.mac.clone()),
|
||||
("hostname", |r| r.hostname.clone()),
|
||||
("serial", |r| r.serial.clone()),
|
||||
("firmware", |r| r.firmware.clone()),
|
||||
("fw_version", |r| r.fw_version.clone()),
|
||||
("api_version", |r| r.api_version.clone()),
|
||||
("control_board", |r| r.control_board.clone()),
|
||||
("cpu", |r| r.cpu.clone()),
|
||||
("board_code", |r| r.board_code.clone()),
|
||||
("algorithm", |r| r.algorithm.clone()),
|
||||
("status", |r| r.status().to_string()),
|
||||
("operating_state", |r| r.operating_state.clone()),
|
||||
("is_mining", |r| r.is_mining.to_string()),
|
||||
("slow", |r| r.slow.to_string()),
|
||||
("paused", |r| r.paused.to_string()),
|
||||
("pic", |r| opt_bool(r.pic_present, "PIC", "noPIC")),
|
||||
("write_locked", |r| opt_bool(r.write_locked, "locked", "unlocked")),
|
||||
("light_flashing", |r| opt_bool(r.light_flashing, "on", "off")),
|
||||
("hashrate_ths", |r| num(r.hashrate_ths)),
|
||||
("expected_ths", |r| num(r.expected_ths)),
|
||||
("efficiency_j_th", |r| num(r.efficiency)),
|
||||
("power_w", |r| num(r.power_w)),
|
||||
("tuning_percent", |r| r.tuning_percent.map(|v| v.to_string()).unwrap_or_default()),
|
||||
("chip_temp_c", |r| num(r.chip_temp_c)),
|
||||
("fluid_temp_c", |r| num(r.fluid_temp_c)),
|
||||
("env_temp_c", |r| num(r.env_temp_c)),
|
||||
("outlet_temp_c", |r| num(r.outlet_temp_c)),
|
||||
("psu_fan_rpm", |r| num(r.psu_fan_rpm)),
|
||||
("fan_count", |r| r.fan_count.map(|v| v.to_string()).unwrap_or_default()),
|
||||
("expected_fans", |r| r.expected_fans.map(|v| v.to_string()).unwrap_or_default()),
|
||||
("total_chips", |r| r.total_chips.map(|v| v.to_string()).unwrap_or_default()),
|
||||
("expected_chips", |r| r.expected_chips.map(|v| v.to_string()).unwrap_or_default()),
|
||||
("hashboards", |r| r.hashboards.map(|v| v.to_string()).unwrap_or_default()),
|
||||
("expected_hashboards", |r| r.expected_hashboards.map(|v| v.to_string()).unwrap_or_default()),
|
||||
("uptime_secs", |r| if r.uptime_secs > 0 { r.uptime_secs.to_string() } else { String::new() }),
|
||||
("best_share", |r| r.best_share.map(num).unwrap_or_default()),
|
||||
("session_best_share", |r| r.session_best_share.map(num).unwrap_or_default()),
|
||||
("pool_account", |r| r.worker.split_once('.').map(|(a, _)| a).unwrap_or(&r.worker).to_string()),
|
||||
("pool_url", |r| r.pool_url.clone()),
|
||||
("errors", |r| r.errors.join("; ")),
|
||||
]
|
||||
}
|
||||
|
||||
/// Build the full CSV for `rows`. Empty rows still emit a header line.
|
||||
pub fn rows_to_csv(rows: &[MinerRow]) -> String {
|
||||
let cols = scalar_columns();
|
||||
// Widest variable-length fields across the set.
|
||||
let max_board_temps = rows.iter().map(|r| r.board_temps.len()).max().unwrap_or(0);
|
||||
let max_fans = rows.iter().map(|r| r.fan_rpms.len()).max().unwrap_or(0);
|
||||
let max_boards = rows.iter().map(|r| r.board_status.len()).max().unwrap_or(0);
|
||||
let max_pools = rows.iter().map(|r| r.pools.len()).max().unwrap_or(0);
|
||||
|
||||
// Header.
|
||||
let mut headers: Vec<String> = cols.iter().map(|(h, _)| (*h).to_string()).collect();
|
||||
for i in 1..=max_board_temps {
|
||||
headers.push(format!("board_temp_{i}_c"));
|
||||
}
|
||||
for i in 1..=max_fans {
|
||||
headers.push(format!("fan_{i}_rpm"));
|
||||
}
|
||||
for i in 1..=max_boards {
|
||||
headers.push(format!("board_{i}_status"));
|
||||
}
|
||||
for i in 1..=max_pools {
|
||||
headers.push(format!("pool_{i}_url"));
|
||||
headers.push(format!("pool_{i}_worker"));
|
||||
}
|
||||
|
||||
let mut out = String::new();
|
||||
out.push_str(&headers.iter().map(|h| esc(h)).collect::<Vec<_>>().join(","));
|
||||
out.push('\n');
|
||||
|
||||
for r in rows {
|
||||
let mut vals: Vec<String> = cols.iter().map(|(_, f)| f(r)).collect();
|
||||
for i in 0..max_board_temps {
|
||||
vals.push(r.board_temps.get(i).map(|&t| num(t)).unwrap_or_default());
|
||||
}
|
||||
for i in 0..max_fans {
|
||||
vals.push(r.fan_rpms.get(i).map(|&t| num(t)).unwrap_or_default());
|
||||
}
|
||||
for i in 0..max_boards {
|
||||
vals.push(r.board_status.get(i).map(board_health_str).unwrap_or("").to_string());
|
||||
}
|
||||
for i in 0..max_pools {
|
||||
let (u, w) = r.pools.get(i).cloned().unwrap_or_default();
|
||||
vals.push(u);
|
||||
vals.push(w);
|
||||
}
|
||||
out.push_str(&vals.iter().map(|v| esc(v)).collect::<Vec<_>>().join(","));
|
||||
out.push('\n');
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn csv_has_header_and_one_row_per_miner() {
|
||||
let rows = vec![
|
||||
MinerRow {
|
||||
ip: "10.0.0.1".into(),
|
||||
model: "S19".into(),
|
||||
hashrate_ths: 95.0,
|
||||
expected_ths: 96.0,
|
||||
board_temps: vec![77.0, 64.0, 74.0],
|
||||
fan_rpms: vec![6000.0, 6100.0],
|
||||
..Default::default()
|
||||
},
|
||||
MinerRow { ip: "10.0.0.2".into(), model: "M30S".into(), ..Default::default() },
|
||||
];
|
||||
let csv = rows_to_csv(&rows);
|
||||
let lines: Vec<&str> = csv.lines().collect();
|
||||
assert_eq!(lines.len(), 3, "header + 2 rows");
|
||||
assert!(lines[0].starts_with("ip,model,brand,"));
|
||||
// Expanded columns out to the widest miner (3 board temps, 2 fans).
|
||||
assert!(lines[0].contains("board_temp_3_c"));
|
||||
assert!(lines[0].contains("fan_2_rpm"));
|
||||
assert!(lines[1].starts_with("10.0.0.1,S19,"));
|
||||
// One value per cell: hashrate and expected are separate columns.
|
||||
assert!(lines[1].contains(",95,96,") || lines[1].contains("95,96"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn csv_escapes_commas_and_quotes() {
|
||||
assert_eq!(esc("a,b"), "\"a,b\"");
|
||||
assert_eq!(esc("he said \"hi\""), "\"he said \"\"hi\"\"\"");
|
||||
assert_eq!(esc("plain"), "plain");
|
||||
}
|
||||
}
|
||||
@@ -3,10 +3,12 @@
|
||||
|
||||
mod access_probe;
|
||||
mod credentials;
|
||||
mod export;
|
||||
mod fixtures;
|
||||
mod log_scan;
|
||||
mod model;
|
||||
mod naming;
|
||||
mod pool_prefs;
|
||||
mod presets;
|
||||
mod restore;
|
||||
mod scan;
|
||||
|
||||
@@ -527,6 +527,97 @@ impl MinerRow {
|
||||
val as f64
|
||||
}
|
||||
|
||||
/// Errors mentioning hashboard/chain number `n` (1-indexed), for attributing
|
||||
/// an issue to a specific board in its tooltip (round 15 #15). Matches "board
|
||||
/// N", "chain N", "hashboard N" or "slot N" case-insensitively, trying both
|
||||
/// 1-indexed and 0-indexed chain numbering.
|
||||
pub fn errors_for_board(&self, n: usize) -> Vec<String> {
|
||||
let needles = [
|
||||
format!("board {n}"),
|
||||
format!("chain {n}"),
|
||||
format!("hashboard {n}"),
|
||||
format!("slot {n}"),
|
||||
format!("board {}", n - 1),
|
||||
format!("chain {}", n - 1),
|
||||
];
|
||||
self.errors
|
||||
.iter()
|
||||
.filter(|e| {
|
||||
let lo = e.to_lowercase();
|
||||
needles.iter().any(|nd| lo.contains(nd.as_str()))
|
||||
})
|
||||
.cloned()
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Errors that don't name a specific board (attributed to the miner / control
|
||||
/// board), for the control-board icon tooltip (round 15 #15).
|
||||
pub fn general_errors(&self, boards: usize) -> Vec<String> {
|
||||
let attributed: std::collections::HashSet<String> =
|
||||
(1..=boards).flat_map(|n| self.errors_for_board(n)).collect();
|
||||
self.errors.iter().filter(|e| !attributed.contains(*e)).cloned().collect()
|
||||
}
|
||||
|
||||
/// Per-icon hover tooltips for the Health column, in the same draw order (and
|
||||
/// length) as `encode_component_health`'s segments: power, control, each fan
|
||||
/// padded to `max_fans`, each hashboard padded to `max_boards` (round 15 #15).
|
||||
pub fn health_tooltips(&self, max_fans: usize, max_boards: usize) -> Vec<String> {
|
||||
let mut tips: Vec<String> = Vec::with_capacity(2 + max_fans + max_boards);
|
||||
// Power.
|
||||
tips.push(format!(
|
||||
"Power supply: {}",
|
||||
match self.power_health() {
|
||||
CompHealth::Ok => "OK (drawing power)",
|
||||
CompHealth::Down => "detected but not delivering",
|
||||
CompHealth::Degraded => "sub-optimal",
|
||||
CompHealth::Unreachable => "unknown (no wattage/PSU-fan reported)",
|
||||
}
|
||||
));
|
||||
// Control board -- also carries the miner's un-attributed errors.
|
||||
let mut ctl = "Control board: OK (miner reachable)".to_string();
|
||||
for e in self.general_errors(max_boards) {
|
||||
ctl.push('\n');
|
||||
ctl.push_str(&e);
|
||||
}
|
||||
tips.push(ctl);
|
||||
// Fans.
|
||||
let fans = self.fan_healths();
|
||||
for i in 0..max_fans {
|
||||
let s = match fans.get(i) {
|
||||
Some(CompHealth::Ok) => {
|
||||
let rpm = self.fan_rpms.get(i).map(|r| format!(" ({:.0} rpm)", r)).unwrap_or_default();
|
||||
format!("spinning{rpm}")
|
||||
}
|
||||
Some(CompHealth::Degraded) => {
|
||||
let rpm = self.fan_rpms.get(i).map(|r| format!(" ({:.0} rpm)", r)).unwrap_or_default();
|
||||
format!("slow{rpm}")
|
||||
}
|
||||
Some(CompHealth::Down) => "stopped (0 rpm)".to_string(),
|
||||
Some(CompHealth::Unreachable) => "expected but not detected".to_string(),
|
||||
None => "not present".to_string(),
|
||||
};
|
||||
tips.push(format!("Fan {}: {s}", i + 1));
|
||||
}
|
||||
// Hashboards.
|
||||
let boards = self.board_healths();
|
||||
for i in 0..max_boards {
|
||||
let s = match boards.get(i) {
|
||||
Some(CompHealth::Ok) => "hashing".to_string(),
|
||||
Some(CompHealth::Degraded) => "hashing sub-optimally".to_string(),
|
||||
Some(CompHealth::Down) => "faulted".to_string(),
|
||||
Some(CompHealth::Unreachable) => "expected but not detected".to_string(),
|
||||
None => "not present".to_string(),
|
||||
};
|
||||
let mut t = format!("Hashboard {}: {s}", i + 1);
|
||||
for e in self.errors_for_board(i + 1) {
|
||||
t.push('\n');
|
||||
t.push_str(&e);
|
||||
}
|
||||
tips.push(t);
|
||||
}
|
||||
tips
|
||||
}
|
||||
|
||||
/// 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".
|
||||
@@ -738,7 +829,7 @@ pub const ALL_COLUMNS: [Column; 43] = [
|
||||
/// 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] = [
|
||||
pub const DEFAULT_VISIBLE: [Column; 9] = [
|
||||
Column::Model,
|
||||
Column::Health,
|
||||
Column::Hashrate,
|
||||
@@ -747,6 +838,8 @@ pub const DEFAULT_VISIBLE: [Column; 8] = [
|
||||
Column::Firmware,
|
||||
Column::Cpu,
|
||||
Column::Locked,
|
||||
// Locate-light beacon, last (round 15 #6).
|
||||
Column::Light,
|
||||
];
|
||||
|
||||
impl Column {
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
//! Dropdown presets + user-saved values for the Configure-pools dialog (round 15
|
||||
//! #1). Each pool field (address / account / worker / password) has a "+" menu
|
||||
//! offering built-in presets (pool stratums, worker placeholders) plus values the
|
||||
//! user has saved, and the user can add the current box value to the saved list.
|
||||
//! Saved lists persist one-per-line under the config dir.
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
const CONFIG_DIR: &str = ".config/alkane-toolkit";
|
||||
|
||||
/// Which pool field a "+" menu belongs to.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum PoolField {
|
||||
Address,
|
||||
Account,
|
||||
Worker,
|
||||
Password,
|
||||
}
|
||||
|
||||
impl PoolField {
|
||||
fn saved_file(self) -> &'static str {
|
||||
match self {
|
||||
PoolField::Address => "pool-addresses.txt",
|
||||
PoolField::Account => "pool-accounts.txt",
|
||||
PoolField::Worker => "pool-workers.txt",
|
||||
PoolField::Password => "pool-passwords.txt",
|
||||
}
|
||||
}
|
||||
|
||||
/// Built-in presets offered before the user's saved values.
|
||||
pub fn presets(self) -> Vec<&'static str> {
|
||||
match self {
|
||||
// Top Bitcoin pools by hashrate with their primary stratum endpoints
|
||||
// (researched round 15; verify in-app before relying on any one).
|
||||
PoolField::Address => POOL_STRATUMS.iter().map(|(_, u)| *u).collect(),
|
||||
PoolField::Account => Vec::new(),
|
||||
// Per-miner worker-name placeholders (see MinerRow::expand_worker_template).
|
||||
PoolField::Worker => vec![
|
||||
"{ip1}", "{ip2}", "{ip3}", "{ip4}", "{serial}", "{mac}", "{nameplate-hr}",
|
||||
"{brand}", "{model}", "{submodel}", "{cpu}", "{cb}", "{firmware}", "{hostname}",
|
||||
],
|
||||
PoolField::Password => vec!["x"],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// (pool name, primary stratum URL). Used for the address dropdown labels.
|
||||
pub const POOL_STRATUMS: &[(&str, &str)] = &[
|
||||
("Foundry USA", "stratum+tcp://btc.foundryusapool.com:3333"),
|
||||
("AntPool", "stratum+tcp://ss.antpool.com:3333"),
|
||||
("F2Pool", "stratum+tcp://btc.f2pool.com:1314"),
|
||||
("ViaBTC", "stratum+tcp://btc.viabtc.io:3333"),
|
||||
("SpiderPool", "stratum+tcp://btc-us.spiderpool.com:2309"),
|
||||
("Binance Pool", "stratum+tcp://bs.poolbinance.com:3333"),
|
||||
("Luxor", "stratum+tcp://btc.global.luxor.tech:700"),
|
||||
("SBI Crypto", "stratum+tcp://us1.sbicrypto.com:3333"),
|
||||
("Braiins Pool", "stratum+tcp://stratum.braiins.com:3333"),
|
||||
("ULTIMUSPOOL", "stratum+tcp://bs.ultimuspool.com:8888"),
|
||||
("SECPOOL", "stratum+tcp://btc.secpool.com:3333"),
|
||||
];
|
||||
|
||||
fn config_path(file: &str) -> PathBuf {
|
||||
let home = std::env::var("HOME").unwrap_or_else(|_| ".".into());
|
||||
PathBuf::from(home).join(CONFIG_DIR).join(file)
|
||||
}
|
||||
|
||||
/// The user's saved values for `field`, in save order (most recent last).
|
||||
pub fn load_saved(field: PoolField) -> Vec<String> {
|
||||
std::fs::read_to_string(config_path(field.saved_file()))
|
||||
.ok()
|
||||
.map(|s| s.lines().map(str::trim).filter(|l| !l.is_empty()).map(String::from).collect())
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
/// Add `value` to `field`'s saved list (deduplicated, no-op if empty/already
|
||||
/// present or already a preset). Returns true if it was newly added.
|
||||
pub fn add_saved(field: PoolField, value: &str) -> bool {
|
||||
let value = value.trim();
|
||||
if value.is_empty() {
|
||||
return false;
|
||||
}
|
||||
if field.presets().iter().any(|p| *p == value) {
|
||||
return false;
|
||||
}
|
||||
let mut saved = load_saved(field);
|
||||
if saved.iter().any(|s| s == value) {
|
||||
return false;
|
||||
}
|
||||
saved.push(value.to_string());
|
||||
let p = config_path(field.saved_file());
|
||||
if let Some(dir) = p.parent() {
|
||||
let _ = std::fs::create_dir_all(dir);
|
||||
}
|
||||
let _ = std::fs::write(p, saved.join("\n"));
|
||||
true
|
||||
}
|
||||
|
||||
/// The full dropdown list for a field: presets first, then the user's saved
|
||||
/// values. For the address field each entry is labelled with the pool name.
|
||||
pub fn dropdown_entries(field: PoolField) -> Vec<(String, String)> {
|
||||
// (label, value)
|
||||
let mut out: Vec<(String, String)> = Vec::new();
|
||||
if field == PoolField::Address {
|
||||
for (name, url) in POOL_STRATUMS {
|
||||
out.push((format!("{name} -- {url}"), url.to_string()));
|
||||
}
|
||||
} else {
|
||||
for p in field.presets() {
|
||||
out.push((p.to_string(), p.to_string()));
|
||||
}
|
||||
}
|
||||
for s in load_saved(field) {
|
||||
out.push((s.clone(), s));
|
||||
}
|
||||
out
|
||||
}
|
||||
@@ -15,7 +15,7 @@ pub const PRESETS_FILE: &str = "presets.json";
|
||||
/// 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] = [
|
||||
const DEFAULT_PROFILE: [Column; 10] = [
|
||||
Column::Ip,
|
||||
Column::Model,
|
||||
Column::Health,
|
||||
@@ -25,6 +25,7 @@ const DEFAULT_PROFILE: [Column; 9] = [
|
||||
Column::Firmware,
|
||||
Column::Cpu,
|
||||
Column::Locked,
|
||||
Column::Light,
|
||||
];
|
||||
|
||||
/// A serializable snapshot of a `ViewState` (Vec-based so JSON has no map keys
|
||||
|
||||
@@ -455,6 +455,33 @@ fn summarize_messages(messages: &[asic_rs::core::data::message::MinerMessage]) -
|
||||
ranked.into_iter().map(|(_, s)| s).collect()
|
||||
}
|
||||
|
||||
/// Infer whether an Antminer's hashboards carry a per-board PIC MCU from the
|
||||
/// model string (round 14 #2). No firmware (stock cgminer, Vnish, LuxOS, Braiins)
|
||||
/// exposes a PIC flag over the network; PIC-vs-noPIC is fixed by the hashboard
|
||||
/// type, so a model map is the only network-only method:
|
||||
/// - noPIC: an explicit "noPIC" model, the S19k Pro board, and the BM1368+
|
||||
/// generation (S21 family, T21), where Bitmain dropped the per-board PIC.
|
||||
/// - PIC: the rest of the S19 line (BM1362/BM1366, PIC16F1704/1542).
|
||||
/// - unknown: everything else (older Antminers, non-Antminer makes).
|
||||
/// The one genuinely ambiguous model is the plain "S19j Pro" (both PIC and noPIC
|
||||
/// revisions exist); it is assumed PIC unless the model string says noPIC.
|
||||
fn infer_pic(model: &str) -> Option<bool> {
|
||||
let m = model.to_lowercase();
|
||||
if m.contains("nopic") {
|
||||
return Some(false);
|
||||
}
|
||||
if m.contains("s21") || m.contains("t21") {
|
||||
return Some(false);
|
||||
}
|
||||
if m.contains("s19k") {
|
||||
return Some(false);
|
||||
}
|
||||
if m.contains("s19") {
|
||||
return Some(true);
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
async fn to_row(miner: &dyn Miner) -> MinerRow {
|
||||
let data = miner.get_data().await;
|
||||
let hashrate_ths = data
|
||||
@@ -588,10 +615,10 @@ async fn to_row(miner: &dyn Miner) -> MinerRow {
|
||||
firmware_flash: miner.supports_upgrade_firmware(),
|
||||
pools: miner.supports_pools_config(),
|
||||
};
|
||||
// PIC vs noPIC is not reported over the network by asic-rs; best-effort
|
||||
// heuristic from the model string, else unknown (true detection needs an
|
||||
// on-board SSH/I2C probe -- a separate feature).
|
||||
let pic_present = if model.to_lowercase().contains("nopic") { Some(false) } else { None };
|
||||
// PIC vs noPIC (round 14 #2 rework). No firmware exposes a PIC flag over the
|
||||
// network -- it's a fixed hardware property of the hashboard type -- so infer
|
||||
// it from the model, which every API reports. See `infer_pic`.
|
||||
let pic_present = infer_pic(&model);
|
||||
// Access: locked/view-only when the miner exposes no writable control at
|
||||
// all, otherwise unlocked. Inferred from asic-rs capabilities (there is no
|
||||
// direct lock-state field). This now covers WhatsMiner too: since round 12
|
||||
@@ -842,16 +869,20 @@ pub fn start_config_action(ips: Vec<String>, action: ConfigAction) -> ActionHand
|
||||
ActionHandle { rx, cancel }
|
||||
}
|
||||
|
||||
/// One miner's pool config to write (round 14 #7). The worker `username` has
|
||||
/// already been expanded from the per-firmware worker template in the UI (which
|
||||
/// holds the scanned MinerRow), so this carries a fully-resolved endpoint.
|
||||
pub struct PoolTarget {
|
||||
pub ip: String,
|
||||
/// One resolved pool endpoint (worker already expanded from the template).
|
||||
pub struct PoolEntry {
|
||||
pub url: String,
|
||||
pub username: String,
|
||||
pub password: String,
|
||||
}
|
||||
|
||||
/// One miner's pool config to write (round 14 #7, round 15 #1): up to three
|
||||
/// pools (primary + backups), each already worker-expanded in the UI.
|
||||
pub struct PoolTarget {
|
||||
pub ip: String,
|
||||
pub pools: Vec<PoolEntry>,
|
||||
}
|
||||
|
||||
/// Apply a single "default" pool group to each target miner on a background
|
||||
/// thread (round 14 #7). Reuses the ActionMsg/ActionHandle plumbing so the
|
||||
/// existing drain_action + status handling covers it. Miners whose backend does
|
||||
@@ -869,10 +900,11 @@ pub fn start_pools_action(targets: Vec<PoolTarget>) -> ActionHandle {
|
||||
let err_tx = tx.clone();
|
||||
let res = std::thread::Builder::new().name("fake-pools".into()).spawn(move || {
|
||||
for t in targets {
|
||||
let first = t.pools.first().map(|p| p.username.clone()).unwrap_or_default();
|
||||
let _ = tx.send(ActionMsg::Result {
|
||||
ip: t.ip,
|
||||
ok: true,
|
||||
detail: format!("simulated ({})", t.username),
|
||||
detail: format!("simulated ({} pool(s), {first})", t.pools.len()),
|
||||
});
|
||||
}
|
||||
let _ = tx.send(ActionMsg::Done { ok: total, total });
|
||||
@@ -910,11 +942,15 @@ pub fn start_pools_action(targets: Vec<PoolTarget>) -> ActionHandle {
|
||||
let group = PoolGroupConfig {
|
||||
name: "default".to_string(),
|
||||
quota: 1,
|
||||
pools: vec![PoolConfig {
|
||||
url: PoolURL::from(t.url.clone()),
|
||||
username: t.username.clone(),
|
||||
password: t.password.clone(),
|
||||
}],
|
||||
pools: t
|
||||
.pools
|
||||
.iter()
|
||||
.map(|p| PoolConfig {
|
||||
url: PoolURL::from(p.url.clone()),
|
||||
username: p.username.clone(),
|
||||
password: p.password.clone(),
|
||||
})
|
||||
.collect(),
|
||||
};
|
||||
match miner.set_pools_config(vec![group]).await {
|
||||
Ok(true) => (true, "ok".to_string()),
|
||||
|
||||
+279
-183
@@ -18,6 +18,8 @@ pub const ID_PAUSE: i32 = 105;
|
||||
pub const ID_STOP: i32 = 106;
|
||||
pub const ID_SCAN_CREDS: i32 = 107;
|
||||
pub const ID_PRESETS: i32 = 108;
|
||||
// Export all scan data to CSV (round 15 #14).
|
||||
pub const ID_EXPORT: i32 = 109;
|
||||
// Presets dialog.
|
||||
const ID_PRESET_LOAD: i32 = 770;
|
||||
const ID_PRESET_SAVE: i32 = 771;
|
||||
@@ -70,6 +72,11 @@ const ID_RESTORE_CANCEL: i32 = 787;
|
||||
const ID_CTX_POOLS: i32 = 736;
|
||||
const ID_POOLS_OK: i32 = 788;
|
||||
const ID_POOLS_CANCEL: i32 = 789;
|
||||
// Pool-field "+" dropdown buttons (round 15 #1): 12 buttons (3 rows x 4 fields),
|
||||
// id = base + row*4 + field. The dropdown menu items use their own id range.
|
||||
const ID_POOL_PLUS_BASE: i32 = 800;
|
||||
const ID_POOL_MENU_ADD: i32 = 819; // "add current box value to the dropdown"
|
||||
const ID_POOL_MENU_BASE: i32 = 820; // one id per dropdown entry (820 + index)
|
||||
// Value-prompt dialog for power-limit / tuning-percent actions.
|
||||
const ID_ACTION_OK: i32 = 740;
|
||||
const ID_ACTION_CANCEL: i32 = 741;
|
||||
@@ -96,7 +103,6 @@ const ID_HDR_SORT_REL_ASC: i32 = 765;
|
||||
const ID_HDR_SORT_REL_DESC: i32 = 766;
|
||||
// Ticks (~seconds) to keep an action's result on the status bar before the
|
||||
// idle/countdown status takes over again.
|
||||
const ACTION_RESULT_TICKS: u8 = 8;
|
||||
// Filter dialog: the column-selector dropdown + the comparator dropdown.
|
||||
const ID_FILTER_COL: i32 = 730;
|
||||
const ID_FILTER_OP: i32 = 731;
|
||||
@@ -284,6 +290,12 @@ 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
|
||||
/// Locate-light beacon (round 15 #6): a green dot above a red dot, both flashing
|
||||
/// quickly. Replaces the single fading amber dot for the Light column.
|
||||
const SHAPE_LIGHT_BEACON: &str = "\u{0011}";
|
||||
/// Health-column alignment gap (round 15 #5): one health-icon-width slot that
|
||||
/// draws nothing, so component icons line up across rows.
|
||||
const SHAPE_GAP: &str = "\u{0012}";
|
||||
|
||||
/// 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;
|
||||
@@ -357,12 +369,12 @@ fn encode_access_icon(pal: &Palette, write_locked: Option<bool>) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
/// Light column: a yellow dot while the miner's locate light is flashing, else
|
||||
/// blank (round 11 #10). The dot fades in and out (round 12 #6) via the pulsing
|
||||
/// sentinel, so a flashing light reads as a live pulse rather than a static dot.
|
||||
fn encode_light_dot(pal: &Palette, flashing: Option<bool>) -> String {
|
||||
/// Light column: a green-over-red beacon flashing quickly while the miner's
|
||||
/// locate light is on, else blank (round 15 #6; was a single fading amber dot).
|
||||
/// The beacon draws its own colours, so the segment colour is unused.
|
||||
fn encode_light_dot(_pal: &Palette, flashing: Option<bool>) -> String {
|
||||
match flashing {
|
||||
Some(true) => encode_segments(&[(Some(pal.amber), SHAPE_PULSE_DOT.to_string())]),
|
||||
Some(true) => encode_segments(&[(None, SHAPE_LIGHT_BEACON.to_string())]),
|
||||
_ => encode_segments(&[(None, String::new())]),
|
||||
}
|
||||
}
|
||||
@@ -396,15 +408,34 @@ fn health_color(pal: &Palette, h: crate::model::CompHealth) -> (u8, u8, u8) {
|
||||
/// 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 {
|
||||
///
|
||||
/// Icons line up in fixed slots across rows (round 15 #5): the fan and hashboard
|
||||
/// groups are padded with blank gaps out to `max_fans` / `max_boards` (the widest
|
||||
/// counts in the current fleet), so a miner with fewer fans/boards leaves a gap
|
||||
/// where the missing ones would be and its hashboards still align. This is
|
||||
/// parametric -- the maxima are recomputed from the fleet each refresh.
|
||||
fn encode_component_health(
|
||||
pal: &Palette,
|
||||
r: &crate::model::MinerRow,
|
||||
max_fans: usize,
|
||||
max_boards: usize,
|
||||
) -> 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()));
|
||||
let fans = r.fan_healths();
|
||||
for h in &fans {
|
||||
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()));
|
||||
for _ in fans.len()..max_fans {
|
||||
segs.push((None, SHAPE_GAP.to_string()));
|
||||
}
|
||||
let boards = r.board_healths();
|
||||
for h in &boards {
|
||||
segs.push((Some(health_color(pal, *h)), SHAPE_CHIP.to_string()));
|
||||
}
|
||||
for _ in boards.len()..max_boards {
|
||||
segs.push((None, SHAPE_GAP.to_string()));
|
||||
}
|
||||
encode_segments(&segs)
|
||||
}
|
||||
@@ -660,21 +691,21 @@ pub struct App {
|
||||
// Restore-to-stock (round 12 #8a): background job + its typed-confirm dialog.
|
||||
restore: Option<restore::RestoreHandle>,
|
||||
restore_dialog: Widget,
|
||||
restore_input: Widget,
|
||||
pending_restore: Vec<restore::RestoreTarget>,
|
||||
// Configure-pools dialog (round 14 #7).
|
||||
// Configure-pools dialog (round 14 #7, expanded round 15 #1): 3 pool rows x 4
|
||||
// fields (address, account, worker, password) = 12 text controls, indexed
|
||||
// row*4 + field. Plus the "+" dropdown menu state.
|
||||
pools_dialog: Widget,
|
||||
pools_url_input: Widget,
|
||||
pools_account_input: Widget,
|
||||
pools_worker_input: Widget,
|
||||
pool_fields: Vec<Widget>,
|
||||
pool_menu_target: usize, // which field the open "+" menu edits
|
||||
pool_menu_field: crate::pool_prefs::PoolField,
|
||||
pool_menu_values: Vec<String>, // values behind the open menu, by item index
|
||||
// Saved view presets + the Presets dialog widgets.
|
||||
presets: Vec<crate::presets::Preset>,
|
||||
presets_dialog: Widget,
|
||||
presets_choice: Widget,
|
||||
presets_name_input: Widget,
|
||||
// The last action's result, kept on the status bar for a few ticks.
|
||||
action_result: Option<String>,
|
||||
action_result_ticks: u8,
|
||||
ranges_dialog: Widget,
|
||||
ranges_edit: Widget,
|
||||
ranges_auto: Widget,
|
||||
@@ -847,6 +878,8 @@ 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 export_btn = Widget::button(panel, "Export", ID_EXPORT);
|
||||
ctl.add(export_btn, 0, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_ALL, 4);
|
||||
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);
|
||||
@@ -940,18 +973,16 @@ pub fn build(frame: Widget) -> App {
|
||||
logview_dialog: frame,
|
||||
restore: None,
|
||||
restore_dialog: frame,
|
||||
restore_input: frame,
|
||||
pending_restore: Vec::new(),
|
||||
pools_dialog: frame,
|
||||
pools_url_input: frame,
|
||||
pools_account_input: frame,
|
||||
pools_worker_input: frame,
|
||||
pool_fields: Vec::new(),
|
||||
pool_menu_target: 0,
|
||||
pool_menu_field: crate::pool_prefs::PoolField::Address,
|
||||
pool_menu_values: Vec::new(),
|
||||
presets: crate::presets::load_presets(),
|
||||
presets_dialog: frame,
|
||||
presets_choice: frame,
|
||||
presets_name_input: frame,
|
||||
action_result: None,
|
||||
action_result_ticks: 0,
|
||||
ranges_dialog: frame,
|
||||
ranges_edit: frame,
|
||||
ranges_auto: frame,
|
||||
@@ -1105,6 +1136,13 @@ impl App {
|
||||
// (set at table build) separate rows instead.
|
||||
// Overwrite the conditionally-coloured cells with segment-encoded text
|
||||
// (the custom renderer these columns use parses it back out).
|
||||
// Widest fan / hashboard counts across the visible fleet, so the Health
|
||||
// column can pad shorter miners with gaps and keep every component icon
|
||||
// in a fixed slot (round 15 #5).
|
||||
let (max_fans, max_boards) = self.view_idx.iter().fold((0usize, 0usize), |(f, b), &ri| {
|
||||
let r = &self.rows[ri];
|
||||
(f.max(r.fan_healths().len()), b.max(r.board_healths().len()))
|
||||
});
|
||||
for (disp, &ri) in self.view_idx.iter().enumerate() {
|
||||
let r = &self.rows[ri];
|
||||
for (ci, c) in cols.iter().enumerate() {
|
||||
@@ -1125,7 +1163,7 @@ impl App {
|
||||
// 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),
|
||||
None => encode_component_health(&self.pal, r, max_fans, max_boards),
|
||||
},
|
||||
// Boards column: per-hashboard health dots (round 11 #10).
|
||||
Column::Hashboards => encode_board_dots(&self.pal, &r.board_status),
|
||||
@@ -1164,16 +1202,19 @@ 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).
|
||||
// The Health icons carry a per-ICON hover tooltip (round 15 #15):
|
||||
// hovering a specific fan/board shows just that component's state
|
||||
// (and any error attributed to it). While an operation runs, the
|
||||
// cell is text, so use a plain cell tooltip instead.
|
||||
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"));
|
||||
if self.op_status.contains_key(&r.ip) {
|
||||
t.dvlc_set_icon_tooltips(disp, ci, &[]);
|
||||
t.dvlc_set_cell_tooltip(disp, ci, &r.health_summary());
|
||||
} else {
|
||||
t.dvlc_set_cell_tooltip(disp, ci, "");
|
||||
let tips = r.health_tooltips(max_fans, max_boards);
|
||||
t.dvlc_set_icon_tooltips(disp, ci, &tips);
|
||||
}
|
||||
t.dvlc_set_cell_tooltip(disp, ci, &tip);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1443,10 +1484,11 @@ impl App {
|
||||
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.
|
||||
/// Build (but do not show) the Configure-pools dialog (round 15 #1): three
|
||||
/// pool rows, each with address + account + worker + password boxes and a "+"
|
||||
/// dropdown next to each. Address/account are required per used row; the
|
||||
/// worker expands per miner from placeholders. 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");
|
||||
@@ -1462,88 +1504,161 @@ impl App {
|
||||
root.add(
|
||||
Widget::static_text(
|
||||
dlg,
|
||||
&format!("Set the primary pool on {n} selected miner(s). Address and account are required."),
|
||||
&format!("Set up to 3 pools on {n} selected miner(s). Leave a row blank to skip it; address + account are required for a used row. Use \"+\" for presets; worker placeholders (e.g. {{ip4}}, {{serial}}) expand per miner and insert at the cursor."),
|
||||
),
|
||||
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
|
||||
// Column headers.
|
||||
let head = Widget::box_sizer(false);
|
||||
let hl = |t: &str, w: i32| {
|
||||
let l = Widget::static_text(dlg, t);
|
||||
l.set_min_size(w, -1);
|
||||
l
|
||||
};
|
||||
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,
|
||||
);
|
||||
head.add(hl("", 46), 0, sf::BORDER_LEFT, 6);
|
||||
head.add(hl("Address", 210), 0, sf::BORDER_LEFT, 6);
|
||||
head.add(hl("Account", 150), 0, sf::BORDER_LEFT, 6);
|
||||
head.add(hl("Worker", 150), 0, sf::BORDER_LEFT, 6);
|
||||
head.add(hl("Password", 110), 0, sf::BORDER_LEFT, 6);
|
||||
root.add_sizer(head, 0, sf::BORDER_LEFT | sf::BORDER_RIGHT | sf::BORDER_TOP, 6);
|
||||
|
||||
let mut fields: Vec<Widget> = Vec::with_capacity(12);
|
||||
// widths per field type (address, account, worker, password).
|
||||
let widths = [180, 120, 120, 80];
|
||||
for row in 0..3usize {
|
||||
let rsizer = Widget::box_sizer(false);
|
||||
let lbl = Widget::static_text(dlg, &format!("Pool {}", row + 1));
|
||||
lbl.set_min_size(46, -1);
|
||||
rsizer.add(lbl, 0, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_LEFT, 6);
|
||||
for field in 0..4usize {
|
||||
let input = Widget::text_ctrl(dlg, false);
|
||||
input.set_min_size(widths[field], -1);
|
||||
rsizer.add(input, 0, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_LEFT, 6);
|
||||
let plus = Widget::button(dlg, "+", ID_POOL_PLUS_BASE + (row * 4 + field) as i32);
|
||||
plus.set_min_size(26, -1);
|
||||
rsizer.add(plus, 0, sf::ALIGN_CENTRE_VERTICAL, 0);
|
||||
fields.push(input);
|
||||
}
|
||||
root.add_sizer(rsizer, 0, sf::BORDER_LEFT | sf::BORDER_RIGHT | sf::BORDER_TOP, 4);
|
||||
}
|
||||
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.set_min_size(760, 260);
|
||||
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;
|
||||
self.pool_fields = fields;
|
||||
Some(dlg)
|
||||
}
|
||||
|
||||
/// Validate the pool inputs, expand the worker template per selected miner,
|
||||
/// and start the background pool-config action (round 14 #7).
|
||||
/// The `PoolField` kind of a 0..4 field index within a pool row.
|
||||
fn pool_field_kind(field: usize) -> crate::pool_prefs::PoolField {
|
||||
use crate::pool_prefs::PoolField;
|
||||
match field {
|
||||
0 => PoolField::Address,
|
||||
1 => PoolField::Account,
|
||||
2 => PoolField::Worker,
|
||||
_ => PoolField::Password,
|
||||
}
|
||||
}
|
||||
|
||||
/// A pool "+" button was clicked: build its dropdown (presets + saved + "add
|
||||
/// current") and queue it to pop up (round 15 #1).
|
||||
fn open_pool_dropdown(&mut self, target: usize) {
|
||||
if target >= self.pool_fields.len() {
|
||||
return;
|
||||
}
|
||||
let field = Self::pool_field_kind(target % 4);
|
||||
let entries = crate::pool_prefs::dropdown_entries(field);
|
||||
let menu = Widget::menu_new();
|
||||
self.pool_menu_values.clear();
|
||||
for (i, (label, value)) in entries.into_iter().enumerate() {
|
||||
menu.menu_append(ID_POOL_MENU_BASE + i as i32, &label);
|
||||
self.pool_menu_values.push(value);
|
||||
}
|
||||
menu.menu_append_separator();
|
||||
menu.menu_append(ID_POOL_MENU_ADD, "Add this box's value to the list");
|
||||
self.pool_menu_target = target;
|
||||
self.pool_menu_field = field;
|
||||
self.pending_popup = Some((self.pools_dialog, menu));
|
||||
}
|
||||
|
||||
/// A pool dropdown item was chosen (round 15 #1). Worker values insert at the
|
||||
/// cursor (so several placeholders can be combined); other fields replace.
|
||||
fn choose_pool_dropdown(&mut self, id: i32) {
|
||||
use crate::pool_prefs::PoolField;
|
||||
let Some(input) = self.pool_fields.get(self.pool_menu_target).copied() else {
|
||||
return;
|
||||
};
|
||||
if id == ID_POOL_MENU_ADD {
|
||||
let val = input.get_value();
|
||||
if crate::pool_prefs::add_saved(self.pool_menu_field, &val) {
|
||||
wx_rs::set_status_text("added to the dropdown list");
|
||||
}
|
||||
return;
|
||||
}
|
||||
let idx = (id - ID_POOL_MENU_BASE) as usize;
|
||||
let Some(value) = self.pool_menu_values.get(idx).cloned() else {
|
||||
return;
|
||||
};
|
||||
if self.pool_menu_field == PoolField::Worker {
|
||||
input.write_text(&value); // insert at cursor
|
||||
} else {
|
||||
input.set_value(&value);
|
||||
}
|
||||
}
|
||||
|
||||
/// Read the 3 pool rows, expand each row's worker per selected miner, and
|
||||
/// start the background pool-config action (round 15 #1). Rows missing an
|
||||
/// address or account are skipped; a miner with no usable rows is skipped.
|
||||
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;
|
||||
}
|
||||
// Collect the raw rows: (address, account, worker_template, password).
|
||||
let mut rows: Vec<(String, String, String, String)> = Vec::new();
|
||||
for row in 0..3usize {
|
||||
let get = |f: usize| self.pool_fields.get(row * 4 + f).map(|w| w.get_value()).unwrap_or_default();
|
||||
let addr = get(0).trim().to_string();
|
||||
let account = get(1).trim().to_string();
|
||||
let worker_tpl = get(2);
|
||||
let password = {
|
||||
let p = get(3).trim().to_string();
|
||||
if p.is_empty() { "x".to_string() } else { p }
|
||||
};
|
||||
// A row is used only when it has both an address and an account.
|
||||
if !addr.is_empty() && addr != "stratum+tcp://" && !account.is_empty() {
|
||||
rows.push((addr, account, worker_tpl, password));
|
||||
}
|
||||
}
|
||||
if rows.is_empty() {
|
||||
wx_rs::set_status_text("enter at least one pool (address + account)");
|
||||
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(),
|
||||
}
|
||||
let pools = rows
|
||||
.iter()
|
||||
.map(|(addr, account, worker_tpl, password)| {
|
||||
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::PoolEntry { url: addr.clone(), username, password: password.clone() }
|
||||
})
|
||||
.collect();
|
||||
scan::PoolTarget { ip: r.ip.clone(), pools }
|
||||
})
|
||||
.collect();
|
||||
if targets.is_empty() {
|
||||
@@ -1551,7 +1666,6 @@ impl App {
|
||||
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();
|
||||
}
|
||||
@@ -1559,7 +1673,6 @@ impl App {
|
||||
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
|
||||
@@ -1575,14 +1688,14 @@ impl App {
|
||||
if let Some(old) = self.action.take() {
|
||||
old.stop();
|
||||
}
|
||||
let msg = format!("applying {} to {} miner(s)...", action.label(), ips.len());
|
||||
// Progress shows in each miner's Health cell (round 15 #8), not the scan
|
||||
// line; the bottom-right indicator still surfaces failures at the end.
|
||||
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.
|
||||
self.clear_indicator();
|
||||
wx_rs::set_status_text(&msg);
|
||||
}
|
||||
|
||||
/// Start a background per-IP refresh (right-click "Refresh"): re-probes
|
||||
@@ -1599,11 +1712,10 @@ impl App {
|
||||
if let Some(old) = self.refresh.take() {
|
||||
old.stop();
|
||||
}
|
||||
let msg = format!("refreshing {} miner(s)...", ips.len());
|
||||
// Show "refreshing…" in each miner's Health cell while it re-probes (#4).
|
||||
// Show "refreshing…" in each miner's Health cell while it re-probes (#4);
|
||||
// the bottom-left scan line is left untouched (round 15 #8).
|
||||
self.set_op_status(&ips, "refreshing…");
|
||||
self.refresh = Some(scan::start_refresh(ips));
|
||||
wx_rs::set_status_text(&msg);
|
||||
}
|
||||
|
||||
/// Fetch the selected miner's log over its firmware API and show it in a
|
||||
@@ -1659,9 +1771,9 @@ impl App {
|
||||
Some(dlg)
|
||||
}
|
||||
|
||||
/// Strong typed confirmation before restoring aftermarket firmware to stock
|
||||
/// (round 12 #8a): the operator must type RESTORE, on top of seeing exactly
|
||||
/// which miners (IP + firmware) will be reverted. DESTRUCTIVE + reboots.
|
||||
/// Confirmation before restoring aftermarket firmware to stock (round 12 #8a,
|
||||
/// simplified in round 15 #11 to a plain confirm): shows exactly which miners
|
||||
/// (IP + firmware) will be reverted. DESTRUCTIVE + reboots.
|
||||
fn build_restore_confirm_dialog(&mut self) -> Option<Widget> {
|
||||
let targets: Vec<restore::RestoreTarget> = self
|
||||
.selected_rows()
|
||||
@@ -1683,34 +1795,26 @@ impl App {
|
||||
let frame = Widget::main_frame();
|
||||
let dlg = Widget::dialog(frame, "Restore to stock firmware");
|
||||
let root = Widget::box_sizer(true);
|
||||
let msg = format!(
|
||||
"Restore these {n} miner(s) to STOCK firmware? This removes the aftermarket firmware and reboots the miner; it interrupts mining and cannot be undone remotely for all firmwares.\n\n{list}\n\nType RESTORE to confirm:"
|
||||
);
|
||||
// Simple confirmation (round 15 #11): the list of miners + a one-line
|
||||
// question, no typed keyword and no long warning tidbit.
|
||||
let msg = format!("Restore these {n} miner(s) to stock firmware?\n\n{list}");
|
||||
root.add(Widget::static_text(dlg, &msg), 0, sf::BORDER_ALL, 12);
|
||||
let input = Widget::text_ctrl(dlg, false);
|
||||
input.set_min_size(200, -1);
|
||||
root.add(input, 0, sf::EXPAND | sf::BORDER_LEFT | sf::BORDER_RIGHT, 12);
|
||||
let btns = Widget::box_sizer(false);
|
||||
btns.add_stretch(1);
|
||||
btns.add(Widget::button(dlg, "Restore to stock", ID_RESTORE_OK), 0, sf::BORDER_ALL, 6);
|
||||
btns.add(Widget::button(dlg, "Cancel", ID_RESTORE_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, 200);
|
||||
dlg.set_min_size(420, 180);
|
||||
dlg.fit(dlg);
|
||||
self.restore_dialog = dlg;
|
||||
self.restore_input = input;
|
||||
Some(dlg)
|
||||
}
|
||||
|
||||
/// Apply the restore confirmation: only start if the operator typed RESTORE
|
||||
/// exactly. Resolves the per-firmware credentials (VNish password from the
|
||||
/// Apply the restore confirmation (round 15 #11: a plain confirm, no typed
|
||||
/// keyword). Resolves the per-firmware credentials (VNish password from the
|
||||
/// round 12 #13 defaults; Braiins SSH login from the saved SSH creds).
|
||||
fn apply_restore_confirm(&mut self) {
|
||||
if self.restore_input.get_value().trim() != "RESTORE" {
|
||||
wx_rs::set_status_text("type RESTORE exactly to confirm");
|
||||
return;
|
||||
}
|
||||
let targets = std::mem::take(&mut self.pending_restore);
|
||||
if targets.is_empty() {
|
||||
self.restore_dialog.close(0);
|
||||
@@ -1723,12 +1827,10 @@ impl App {
|
||||
.unwrap_or_else(|| credentials::firmware_default_for("VNish").1);
|
||||
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..."));
|
||||
}
|
||||
|
||||
/// Drain restore-to-stock results into the status bar.
|
||||
@@ -1740,9 +1842,7 @@ impl App {
|
||||
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::Started { .. } => {}
|
||||
restore::RestoreMsg::Result { ip, ok, detail } => {
|
||||
op_clear.push(ip.clone());
|
||||
if ok {
|
||||
@@ -1764,18 +1864,12 @@ impl App {
|
||||
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 {
|
||||
self.set_error_indicator(&format!("restore: {} failed", fails.len()));
|
||||
wx_rs::set_status_text(&format!(
|
||||
"restore-to-stock: {oks} ok, {} failed ({})",
|
||||
fails.len(),
|
||||
fails.join("; ")
|
||||
));
|
||||
}
|
||||
// Only failures surface (bottom-right indicator); the bottom-left is
|
||||
// scan-only and per-miner restore progress is in the Health column (#8).
|
||||
if done && !fails.is_empty() {
|
||||
self.set_error_indicator(&format!("restore: {} failed", fails.len()));
|
||||
}
|
||||
let _ = oks;
|
||||
}
|
||||
|
||||
/// Start the access (lock-state) probe on the selected miners, using the
|
||||
@@ -1801,11 +1895,9 @@ impl App {
|
||||
return;
|
||||
}
|
||||
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)..."));
|
||||
}
|
||||
|
||||
/// Drain the running access probe: update each miner's write_locked as its
|
||||
@@ -1859,17 +1951,21 @@ impl App {
|
||||
}
|
||||
if done {
|
||||
self.access_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);
|
||||
}
|
||||
// Operation progress stays out of the bottom-left scan line (round 15 #8);
|
||||
// per-miner status shows in the Health column.
|
||||
let _ = status;
|
||||
}
|
||||
|
||||
/// 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> {
|
||||
// Pool "+" dropdown selections (round 15 #1): the "add current" item and
|
||||
// one id per dropdown entry from ID_POOL_MENU_BASE up.
|
||||
if id == ID_POOL_MENU_ADD || id >= ID_POOL_MENU_BASE {
|
||||
self.choose_pool_dropdown(id);
|
||||
return None;
|
||||
}
|
||||
match id {
|
||||
ID_HDR_SORT_ASC | ID_HDR_SORT_DESC | ID_HDR_SORT_REL_ASC | ID_HDR_SORT_REL_DESC
|
||||
| ID_HDR_HIDE | ID_HDR_AUTOSIZE | ID_HDR_COLUMNS => return self.on_header_menu(id),
|
||||
@@ -2118,15 +2214,6 @@ impl App {
|
||||
let frame = Widget::main_frame();
|
||||
let dlg = Widget::dialog(frame, "Credentials");
|
||||
let root = Widget::box_sizer(true);
|
||||
root.add(
|
||||
Widget::static_text(
|
||||
dlg,
|
||||
"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).
|
||||
@@ -2322,10 +2409,6 @@ impl App {
|
||||
// Release the firmware-flash exclusive lock (harmless no-op for a
|
||||
// plain config action, which never set it).
|
||||
self.flashing = false;
|
||||
// Keep the summary on the status bar for a few ticks so a fleet
|
||||
// action's outcome (incl. failures) isn't clobbered by the next tick.
|
||||
self.action_result = status.clone();
|
||||
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). The follow-up refresh
|
||||
@@ -2341,7 +2424,9 @@ impl App {
|
||||
self.fill_rows();
|
||||
}
|
||||
}
|
||||
// Apply the captured indicator now the `h` borrow is gone.
|
||||
// Apply the captured indicator now the `h` borrow is gone. Failures still
|
||||
// surface in the bottom-right indicator; the bottom-left stays scan-only
|
||||
// and per-miner progress is in the Health column (round 15 #8).
|
||||
if let Some(ind) = indicator {
|
||||
match ind {
|
||||
None => self.clear_indicator(),
|
||||
@@ -2349,12 +2434,10 @@ impl App {
|
||||
Some((false, msg)) => self.set_warning_indicator(&msg),
|
||||
}
|
||||
}
|
||||
if let Some(s) = status {
|
||||
wx_rs::set_status_text(&s);
|
||||
}
|
||||
let _ = status;
|
||||
}
|
||||
|
||||
/// Drain a running per-IP refresh's results into the status bar and the
|
||||
/// Drain a running per-IP refresh's results into the rows it touches and the
|
||||
/// rows it touches (mirrors `drain_action`'s shape, but a Row message
|
||||
/// upserts a fresh row instead of reporting per-miner ok/fail).
|
||||
fn drain_refresh(&mut self) {
|
||||
@@ -2404,9 +2487,8 @@ impl App {
|
||||
// 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);
|
||||
}
|
||||
// Refresh progress stays in the Health column, not the scan line (#8).
|
||||
let _ = status;
|
||||
if changed || !op_clear.is_empty() || finished {
|
||||
self.fill_rows();
|
||||
}
|
||||
@@ -2499,26 +2581,12 @@ impl App {
|
||||
self.drain_refresh();
|
||||
self.drain_access_probe();
|
||||
self.drain_restore();
|
||||
// The bottom-left status is for the scan only (round 15 #8): per-miner
|
||||
// operation progress lives in the Health column, so operations no longer
|
||||
// hold or overwrite this line -- only an active scan does.
|
||||
if self.scanning {
|
||||
return; // status already shows scan progress
|
||||
}
|
||||
if self.access_probe.is_some() {
|
||||
return; // a probe is in flight; keep its status
|
||||
}
|
||||
if self.action.is_some() {
|
||||
return; // a config action is in flight; keep its status
|
||||
}
|
||||
if self.refresh.is_some() {
|
||||
return; // a per-IP refresh is in flight; keep its status
|
||||
}
|
||||
if self.action_result_ticks > 0 {
|
||||
// Hold the last action's result on the status bar briefly.
|
||||
self.action_result_ticks -= 1;
|
||||
if let Some(m) = &self.action_result {
|
||||
wx_rs::set_status_text(m);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if self.playing && self.auto_secs > 0 {
|
||||
if self.countdown > 1 {
|
||||
self.countdown -= 1;
|
||||
@@ -2769,13 +2837,13 @@ impl App {
|
||||
let frame = Widget::main_frame();
|
||||
let dlg = Widget::dialog(frame, "Edit IP scanning ranges");
|
||||
let root = Widget::box_sizer(true);
|
||||
let hint = Widget::static_text(
|
||||
dlg,
|
||||
"One range per line:\n CIDR 10.255.1.0/24\n range 10.253.1.3-10.253.1.234\n single 10.253.1.5",
|
||||
);
|
||||
root.add(hint, 0, sf::BORDER_ALL, 6);
|
||||
// The range-format help moved from an inline block to a tooltip on the
|
||||
// text box (round 15 #10).
|
||||
let edit = Widget::text_ctrl(dlg, true);
|
||||
edit.set_value(&scan::load_ranges().join("\n"));
|
||||
edit.set_tool_tip(
|
||||
"One range per line:\n CIDR 10.255.1.0/24\n range 10.253.1.3-10.253.1.234\n single 10.253.1.5",
|
||||
);
|
||||
root.add(edit, 1, sf::EXPAND | sf::BORDER_ALL, 6);
|
||||
// Auto-rescan interval (seconds; 0 = off) and per-miner scan timeout.
|
||||
let auto_row = Widget::box_sizer(false);
|
||||
@@ -2960,6 +3028,29 @@ impl App {
|
||||
/// Build (but do not show) the columns chooser: a rearrangeable checklist of
|
||||
/// every scannable metric. Check to show; drag or use the up/down arrows to
|
||||
/// reorder. IP is always the first column and is not listed here.
|
||||
/// Export the full scan data to a CSV the user picks (round 15 #14). Every
|
||||
/// scanned data point is exported, one value per cell -- more complete and
|
||||
/// machine-readable than the on-screen table.
|
||||
fn apply_export(&mut self) {
|
||||
if self.rows.is_empty() {
|
||||
wx_rs::set_status_text("nothing to export yet -- run a scan first");
|
||||
return;
|
||||
}
|
||||
let Some(path) = Widget::save_file_dialog(
|
||||
Widget::main_frame(),
|
||||
"Export scan data",
|
||||
"alkane-export.csv",
|
||||
"CSV files (*.csv)|*.csv|All files (*.*)|*.*",
|
||||
) else {
|
||||
return; // cancelled
|
||||
};
|
||||
let csv = crate::export::rows_to_csv(&self.rows);
|
||||
match std::fs::write(&path, csv) {
|
||||
Ok(()) => wx_rs::set_status_text(&format!("exported {} miner(s) to {path}", self.rows.len())),
|
||||
Err(e) => self.set_error_indicator(&format!("export failed: {e}")),
|
||||
}
|
||||
}
|
||||
|
||||
fn build_columns_dialog(&mut self) -> Widget {
|
||||
let frame = Widget::main_frame();
|
||||
let dlg = Widget::dialog(frame, "Choose columns");
|
||||
@@ -3406,6 +3497,7 @@ impl App {
|
||||
ID_RANGES => return Some(self.build_ranges_dialog()),
|
||||
ID_RANGES_APPLY => self.apply_ranges(),
|
||||
ID_RANGES_CANCEL => self.ranges_dialog.close(0),
|
||||
ID_EXPORT => self.apply_export(),
|
||||
ID_COLUMNS => return Some(self.build_columns_dialog()),
|
||||
ID_COLUMNS_OK => self.apply_columns(),
|
||||
ID_COLUMNS_CANCEL => self.columns_dialog.close(0),
|
||||
@@ -3449,6 +3541,10 @@ impl App {
|
||||
}
|
||||
ID_POOLS_OK => self.apply_pools(),
|
||||
ID_POOLS_CANCEL => self.pools_dialog.close(0),
|
||||
// Pool-field "+" dropdown buttons (round 15 #1).
|
||||
id if (ID_POOL_PLUS_BASE..ID_POOL_PLUS_BASE + 12).contains(&id) => {
|
||||
self.open_pool_dropdown((id - ID_POOL_PLUS_BASE) as usize);
|
||||
}
|
||||
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