Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b7a77cbed8 | ||
|
|
606ae85781 | ||
|
|
ad9b0dc868 | ||
|
|
aaf049bbfc | ||
|
|
8b7b0c70b4 | ||
|
|
3ae80efdde | ||
|
|
7901d82c4b | ||
|
|
8f7aab3f80 | ||
|
|
e593548746 | ||
|
|
2fd433c3b0 | ||
|
|
5399f9fc49 | ||
|
|
6b4961d7bc | ||
|
|
fc7c665166 | ||
|
|
ae437c0d24 | ||
|
|
b343746718 |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><path fill="currentColor" d="M240 8L48 296h112L128 504 336 216H224L272 8z"/></svg>
|
||||
|
After Width: | Height: | Size: 145 B |
@@ -0,0 +1 @@
|
||||
<svg version="1.0" xmlns="http://www.w3.org/2000/svg" width="511.104248pt" height="512.144915pt" viewBox="0 0 511.104248 512.144915" preserveAspectRatio="xMidYMid meet"><g transform="translate(-0.500000,511.997478) scale(0.100000,-0.100000)" fill="currentColor" stroke="none"><path d="M82 5103 c-52 -25 -77 -69 -77 -133 0 -41 6 -63 22 -86 49 -68 -31 -64 1237 -64 l1146 0 0 -150 0 -150 -323 0 c-292 0 -332 -2 -403 -20 -201 -52 -370 -228 -414 -432 -8 -34 -11 -94 -8 -155 5 -90 12 -119 52 -214 6 -14 -9 -17 -121 -22 -142 -7 -205 -22 -304 -73 -123 -65 -229 -192 -272 -329 -33 -106 -30 -264 7 -360 15 -38 30 -77 32 -85 4 -12 -9 -20 -49 -33 -76 -24 -163 -83 -228 -156 -160 -176 -193 -424 -86 -638 61 -123 195 -242 315 -280 40 -13 52 -21 48 -33 -2 -8 -17 -46 -32 -85 -38 -95 -41 -253 -7 -360 56 -178 206 -323 393 -380 32 -9 108 -19 182 -22 l126 -6 -25 -66 c-31 -81 -42 -233 -23 -319 45 -210 221 -387 433 -437 94 -22 1622 -22 1716 0 108 26 188 71 272 155 126 125 176 255 167 437 -5 90 -12 119 -52 214 -6 14 9 17 122 22 147 6 246 33 337 92 110 70 199 186 238 310 33 106 30 264 -7 360 -15 39 -30 77 -32 85 -4 12 9 20 49 33 211 67 377 303 377 537 0 233 -167 470 -378 537 -40 13 -52 21 -48 33 2 8 17 47 32 85 37 96 40 254 7 360 -39 122 -130 241 -240 311 -89 58 -188 85 -335 91 -113 5 -128 8 -122 22 40 95 47 124 52 214 6 119 -7 184 -55 287 -46 97 -157 210 -254 257 -117 58 -159 63 -516 63 l-323 0 0 150 0 150 618 0 617 0 210 -211 c116 -116 227 -219 247 -230 122 -63 256 59 207 187 -5 16 -60 79 -121 141 l-112 113 313 0 c346 0 360 2 404 64 31 43 31 129 0 172 -50 70 173 64 -2535 64 -2230 0 -2446 -2 -2476 -17z m3337 -918 c94 -52 141 -134 141 -244 -1 -102 -60 -192 -155 -237 l-50 -24 -795 0 -795 0 -50 24 c-61 28 -116 87 -140 149 -26 70 -17 172 21 235 31 49 104 105 158 121 18 6 363 9 821 8 l790 -2 54 -30z m649 -834 c95 -43 162 -147 162 -251 0 -66 -30 -131 -85 -187 -84 -83 -84 -83 -593 -83 l-434 0 -55 50 c-281 257 -719 257 -1005 0 l-57 -51 -453 3 c-452 3 -453 3 -500 26 -92 45 -158 151 -158 252 0 119 99 235 221 259 24 5 688 8 1474 8 l1430 -2 53 -24z m-1317 -623 c130 -64 224 -184 249 -317 5 -29 10 -98 10 -151 0 -53 -5 -122 -10 -151 -25 -133 -119 -253 -249 -317 -73 -36 -77 -37 -191 -37 -114 0 -118 1 -191 37 -125 62 -210 164 -244 293 -20 79 -20 271 0 350 39 149 147 263 300 318 38 13 74 17 151 15 93 -3 107 -6 175 -40z m-924 -235 c-16 -51 -16 -415 0 -465 l11 -38 -547 0 -548 0 -62 31 c-87 43 -138 117 -148 213 -11 110 44 211 145 263 l64 33 548 0 548 0 -11 -37z m2580 24 c60 -22 117 -72 148 -128 26 -46 30 -64 30 -129 0 -65 -4 -83 -30 -129 -31 -56 -88 -106 -148 -128 -23 -8 -187 -12 -578 -12 l-546 -1 13 68 c17 86 17 318 0 405 l-13 67 546 -1 c391 0 555 -4 578 -12z m-2349 -878 c286 -256 725 -255 1006 1 l55 51 453 -3 c452 -3 453 -3 500 -26 90 -44 158 -151 158 -247 0 -99 -69 -204 -162 -246 l-53 -24 -1455 0 -1455 0 -53 24 c-95 43 -162 147 -162 251 0 66 30 131 85 187 83 82 79 81 588 82 l439 1 56 -51z m1342 -820 c97 -43 160 -138 160 -240 0 -111 -47 -192 -141 -244 l-54 -30 -783 -3 c-518 -2 -796 1 -822 8 -59 16 -131 70 -164 122 -38 63 -47 165 -21 235 24 62 79 121 140 149 l50 24 795 0 c778 0 796 -1 840 -21z"/></g></svg>
|
||||
|
After Width: | Height: | Size: 3.0 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><!--!Font Awesome Free 7.3.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2026 Fonticons, Inc.--><path d="M181.5 261.1L194.4 267.5C200.3 270.5 206.8 272 213.5 272C237 272 256.1 252.9 256.1 229.4L256.1 208C256.1 172.7 227.4 144 192.1 144L128.1 144C92.8 144 64.1 172.7 64.1 208L64.1 229.4C64.1 252.9 83.2 272 106.7 272C113.3 272 119.8 270.5 125.8 267.5C135.1 262.8 142.2 259.3 147 256.9L135.1 249C130.6 246 128 241 128 235.7L128 232C128 218.7 138.7 208 152 208L168 208C181.3 208 192 218.7 192 232L192 235.7C192 241 189.3 246 184.9 249L173.1 256.9L181.5 261.1zM172.9 310.5L160 304.1L147.1 310.5C134.5 316.8 120.6 320.1 106.6 320.1C103 320.1 99.5 319.9 96 319.5L96 320.1C96 355.4 124.7 384.1 160 384.1L224 384.1C241.7 384.1 256 398.4 256 416.1C256 433.8 241.7 448.1 224 448.1L384 448.1L384 384.1C384 360.4 396.9 339.7 416 328.7C425.4 323.3 436.3 320.1 448 320.1L448 304.1C448 277.6 469.5 256.1 496 256.1C504.8 256.1 512 263.3 512 272.1L512 368.1C512 376.9 519.2 384.1 528 384.1C536.8 384.1 544 376.9 544 368.1L544 268.4C544 220.2 513.2 177.4 467.4 162.1L458.9 159.3C450.9 156.6 446.3 148.2 448.5 140C450.7 131.8 458.8 126.8 467.1 128.4L487 132.4C576 150.1 640 228.2 640 318.9L640 320L640 320C640 443.7 539.7 544 416 544L255.4 544C132 544 32 444 32 320.6L32 280.8C21.9 266.2 16 248.5 16 229.4L16 208L16 206.6C6.7 203.3 0 194.5 0 184C0 170.7 10.7 160 24 160L26.8 160C44.8 122.2 83.3 96 128 96L192 96C236.7 96 275.2 122.2 293.2 160L296 160C309.3 160 320 170.7 320 184C320 194.5 313.3 203.3 304 206.6L304 208L304 229.4C304 230.8 304 232.2 303.9 233.7C315.9 227.5 329.6 224.1 344 224.1L352 224.1C369.7 224.1 384 238.4 384 256.1C384 273.8 369.7 288.1 352 288.1L344 288.1C330.7 288.1 320 298.8 320 312.1L320 320.1L376.4 320.1C361.2 337.1 352 359.5 352 384.1L320 384.1C277.7 384.1 241.8 356.7 229 318.8C223.9 319.7 218.7 320.1 213.4 320.1C199.3 320.1 185.5 316.8 172.9 310.5zM96 192C104.8 192 112 199.2 112 208C112 216.8 104.8 224 96 224C87.2 224 80 216.8 80 208C80 199.2 87.2 192 96 192zM208 208C208 199.2 215.2 192 224 192C232.8 192 240 199.2 240 208C240 216.8 232.8 224 224 224C215.2 224 208 216.8 208 208z"/></svg>
|
||||
|
After Width: | Height: | Size: 2.2 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><!--! Font Awesome Pro 7.3.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2026 Fonticons, Inc. --><path fill="currentColor" d="M460.7 39.3l-2.2-2.1c-4.7-4.6-11.5-6.4-17.9-4.7s-11.4 6.6-13.1 13l-.8 2.9c-3.3 11.8-5.1 23.7-5.5 35.6 24.3 20.6 42.9 47.8 53.3 78.8-8.2-1.9-16.5-2.9-25-2.9-.6 0-1.1 0-1.7 0-18.4-44-56.5-77.4-103.6-89.3l-3.4-.9c-6.2-1.6-12.9-.6-18.5 2.6-10.8 6.2-15.6 19.5-11.2 31.1 14.9 39.5 44.3 71.4 81.4 89.7-3.7 6.6-6.4 14-7.6 21.8L279.7 154.9c-30.9-17.7-65.9-26.9-101.5-26.9-32.3 0-62.2 16.8-78.9 44.4-10.3-12.5-25.8-20.4-43.2-20.4-30.9 0-56 25.1-56 56s25.1 56 56 56c11.3 0 21.8-3.3 30.6-9.1 4.9 17.2 14.5 33.1 28.4 45.9L257.2 431.2C269 442 284.4 448 300.4 448L416 448c17.7 0 32-14.3 32-32s-14.3-32-32-32l-96 0 0-43.5c0-42.9-28.4-80.5-69.6-92.3l-30.8-8.8c-8.5-2.4-13.4-11.3-11-19.8s11.3-13.4 19.8-11l30.8 8.8c55 15.7 92.8 65.9 92.8 123.1l0 15.7 56-32.4 6.4-3.7 101.3 0c33.3 0 60.3-27 60.3-60.3 0-18.1-8.2-35.3-22.2-46.7l-34.6-28.2c-4.6-3.7-9.4-7.1-14.5-10 8.4-49.3-7.8-100-43.9-135.5zm-318.5 382c-14.7 9.8-18.7 29.7-8.9 44.4s29.7 18.7 44.4 8.9l46-30.7-48.6-44.5-32.9 22zM480 240a16 16 0 1 1 32 0 16 16 0 1 1 -32 0z"/></svg>
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><!--! Font Awesome Pro 7.3.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2026 Fonticons, Inc. --><path fill="currentColor" d="M384 249.2c0 21.4-17.4 38.8-38.8 38.8L70.8 288C49.4 288 32 270.6 32 249.2L32 208c0-97.2 78.8-176 176-176s176 78.8 176 176l0 41.2zM480 288c-2 0-4-.1-5.9-.3-16.3 53.3-64.3 92.7-122.1 96l0 56.2c0 22.1-17.9 40-40 40l-48 0c-22.1 0-40-17.9-40-40l0-56-32 0 0 56c0 22.1-17.9 40-40 40l-48 0c-22.1 0-40-17.9-40-40l0-56-32 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l312 0c39.8 0 72-32.2 72-72l0-72c0-35.3 28.7-64 64-64 53 0 96 43 96 96l0 16c0 35.3-28.7 64-64 64l-32 0zm16-64a16 16 0 1 0 0-32 16 16 0 1 0 0 32z"/></svg>
|
||||
|
After Width: | Height: | Size: 761 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><!--! Font Awesome Pro 7.3.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2026 Fonticons, Inc. --><path fill="currentColor" d="M205 64L434.9 64L439.3 82.4L475.6 234.9C478.5 247 480 259.5 480 272C480 352.2 421 418.7 344 430.2L344 560L432 560L432 608L208 608L208 560L296 560L296 430.2C219 418.6 160 352.2 160 272C160 259.5 161.5 247 164.4 234.9L200.7 82.4L205 64zM243 112L211 246C209 254.5 208 263.2 208 272C208 333.9 258.2 384 320 384C381.8 384 432 333.8 432 272C432 263.3 431 254.5 429 246L397.1 112L371.3 112L384.1 176L320.1 216L352.1 320L256.1 216L328.1 144L306.8 112L243.1 112z"/></svg>
|
||||
|
After Width: | Height: | Size: 721 B |
@@ -60,6 +60,28 @@ impl Board {
|
||||
} else {
|
||||
vec![]
|
||||
};
|
||||
// Air-cooled WhatsMiners report an ambient reading (asic-rs surfaces it in
|
||||
// its fluid_temperature field); the scan routes it to env_temp for
|
||||
// air-cooled models, so the demo mirrors that (round 11 #17).
|
||||
let env_temp_c = if self.mining && self.make.eq_ignore_ascii_case("whatsminer") {
|
||||
27.0
|
||||
} else {
|
||||
0.0
|
||||
};
|
||||
// Per-hashboard health dots for the Boards column (round 11 #10): mining
|
||||
// units show three green dots, except two demo cases -- the slow S21 Pro
|
||||
// has one faulted (red) board, and one VNish S19 has a board that wasn't
|
||||
// detected (grey) -- so the offline demo exercises all three states.
|
||||
use crate::model::BoardHealth::{Fault, Missing, Ok};
|
||||
let board_status = if self.mining {
|
||||
match self.ip {
|
||||
"10.255.1.149" => vec![Ok, Fault, Ok],
|
||||
"10.255.1.166" => vec![Ok, Ok, Missing],
|
||||
_ => vec![Ok, Ok, Ok],
|
||||
}
|
||||
} else {
|
||||
vec![]
|
||||
};
|
||||
// Firmware-flash capability is modeled on the real Bitmain/Antminer
|
||||
// upgrade path (S17/S19/S21 family); WhatsMiner boards in this fleet
|
||||
// don't advertise it, so both true and false show up and the
|
||||
@@ -91,6 +113,7 @@ impl Board {
|
||||
power_w: self.power,
|
||||
chip_temp_c: self.temp,
|
||||
board_temps,
|
||||
env_temp_c,
|
||||
fan_rpms,
|
||||
worker: self.worker.to_string(),
|
||||
is_mining: self.mining,
|
||||
@@ -101,10 +124,13 @@ impl Board {
|
||||
hostname: format!("miner-{last_octet}"),
|
||||
hashboards: boards,
|
||||
expected_hashboards: Some(3),
|
||||
board_status,
|
||||
total_chips: chips,
|
||||
psu_fan_rpm: if self.mining { self.fan * 0.9 } else { 0.0 },
|
||||
uptime_secs: if self.mining { 3600 * 24 * 2 + 3600 * 5 } else { 0 },
|
||||
light_flashing: Some(false),
|
||||
// One unit is "being located" so the Light column's yellow dot is
|
||||
// demonstrable offline (round 11 #10).
|
||||
light_flashing: Some(self.ip == "10.255.1.167"),
|
||||
pool_url: if self.worker.is_empty() { String::new() } else { "stratum+tcp://pool.blueflare:3333".to_string() },
|
||||
pools: if self.worker.is_empty() {
|
||||
Vec::new()
|
||||
|
||||
@@ -236,6 +236,16 @@ impl MinerCaps {
|
||||
}
|
||||
}
|
||||
|
||||
/// Per-hashboard health for the Boards column's status dots (round 11 #10):
|
||||
/// green = present and hashing, red = present but idle/faulty, grey = expected
|
||||
/// but not detected at all.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum BoardHealth {
|
||||
Ok,
|
||||
Fault,
|
||||
Missing,
|
||||
}
|
||||
|
||||
/// 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.
|
||||
@@ -295,7 +305,14 @@ pub struct MinerRow {
|
||||
/// Per-hashboard chip temperature (hottest chip per board), shown in the
|
||||
/// Chip-temp column as "77 / 64 / 74". Empty falls back to the average.
|
||||
pub board_temps: Vec<f64>,
|
||||
/// Coolant/immersion-fluid temperature (liquid-cooled miners only).
|
||||
pub fluid_temp_c: f64,
|
||||
/// Environment/ambient air temperature. asic-rs reports air-cooled miners'
|
||||
/// ambient reading in its `fluid_temperature` field (see the WhatsMiner
|
||||
/// backends' "Env Temp"/"environment-temperature" key); the scan routes it
|
||||
/// here for air-cooled models so it isn't mislabelled as a fluid temp
|
||||
/// (round 11 #17).
|
||||
pub env_temp_c: f64,
|
||||
pub outlet_temp_c: f64,
|
||||
/// Individual cooling-fan RPMs (empty if unknown). PSU fan is tracked
|
||||
/// separately below since it is not part of the cooling-fan set.
|
||||
@@ -308,6 +325,10 @@ pub struct MinerRow {
|
||||
pub expected_chips: Option<u32>,
|
||||
pub hashboards: Option<u32>,
|
||||
pub expected_hashboards: Option<u32>,
|
||||
/// Per-hashboard health for the Boards status dots (round 11 #10), one entry
|
||||
/// per expected board, ordered by position (index 0 = board 1). Empty = no
|
||||
/// per-board data (the cell renders blank).
|
||||
pub board_status: Vec<BoardHealth>,
|
||||
// pool: active-pool convenience fields, plus the (url, worker) of each
|
||||
// configured pool (miners usually allow up to 3 redundant pools).
|
||||
pub worker: String,
|
||||
@@ -379,6 +400,11 @@ pub fn flash_confirmed(input: &str) -> bool {
|
||||
pub enum Column {
|
||||
Ip,
|
||||
Hashrate,
|
||||
/// Sort-only pseudo-column (round 11 #16): the actual/expected hashrate
|
||||
/// ratio. Deliberately NOT in `ALL_COLUMNS`, so it never appears in the
|
||||
/// column picker or the display order; it exists only as a `sort` target the
|
||||
/// Hashrate header cycles into.
|
||||
HashrateRel,
|
||||
Power,
|
||||
ChipTemp,
|
||||
Cooling,
|
||||
@@ -392,6 +418,7 @@ pub enum Column {
|
||||
Status,
|
||||
Efficiency,
|
||||
FluidTemp,
|
||||
EnvTemp,
|
||||
OutletTemp,
|
||||
PsuFan,
|
||||
FanCount,
|
||||
@@ -402,7 +429,6 @@ pub enum Column {
|
||||
Hostname,
|
||||
Serial,
|
||||
ApiVersion,
|
||||
ControlBoard,
|
||||
Cpu,
|
||||
BoardCode,
|
||||
Algorithm,
|
||||
@@ -442,6 +468,7 @@ pub const ALL_COLUMNS: [Column; 45] = [
|
||||
Column::Status,
|
||||
Column::Efficiency,
|
||||
Column::FluidTemp,
|
||||
Column::EnvTemp,
|
||||
Column::OutletTemp,
|
||||
Column::PsuFan,
|
||||
Column::FanCount,
|
||||
@@ -452,7 +479,6 @@ pub const ALL_COLUMNS: [Column; 45] = [
|
||||
Column::Hostname,
|
||||
Column::Serial,
|
||||
Column::ApiVersion,
|
||||
Column::ControlBoard,
|
||||
Column::Cpu,
|
||||
Column::BoardCode,
|
||||
Column::Algorithm,
|
||||
@@ -474,16 +500,19 @@ pub const ALL_COLUMNS: [Column; 45] = [
|
||||
Column::Pool3Worker,
|
||||
];
|
||||
|
||||
/// The columns shown by default (UI-SPEC), after the fixed IP column.
|
||||
pub const DEFAULT_VISIBLE: [Column; 8] = [
|
||||
/// 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] = [
|
||||
Column::Model,
|
||||
Column::Error,
|
||||
Column::Hashrate,
|
||||
Column::Power,
|
||||
Column::ChipTemp,
|
||||
Column::Cooling,
|
||||
Column::Firmware,
|
||||
Column::Worker,
|
||||
Column::Model,
|
||||
Column::Status,
|
||||
Column::Cpu,
|
||||
Column::Hashboards,
|
||||
Column::Locked,
|
||||
];
|
||||
|
||||
impl Column {
|
||||
@@ -491,6 +520,7 @@ impl Column {
|
||||
match self {
|
||||
Column::Ip => "IP",
|
||||
Column::Hashrate => "Hashrate",
|
||||
Column::HashrateRel => "Rel. hashrate",
|
||||
Column::Power => "Power",
|
||||
Column::ChipTemp => "Chip temp",
|
||||
Column::Cooling => "Fan (RPM)",
|
||||
@@ -504,6 +534,7 @@ impl Column {
|
||||
Column::Status => "Status",
|
||||
Column::Efficiency => "Efficiency (J/TH)",
|
||||
Column::FluidTemp => "Fluid temp",
|
||||
Column::EnvTemp => "Env temp",
|
||||
Column::OutletTemp => "Outlet temp",
|
||||
Column::PsuFan => "PSU fan (RPM)",
|
||||
Column::FanCount => "Fans",
|
||||
@@ -514,9 +545,8 @@ impl Column {
|
||||
Column::Hostname => "Hostname",
|
||||
Column::Serial => "Serial",
|
||||
Column::ApiVersion => "API ver",
|
||||
Column::ControlBoard => "Control board",
|
||||
Column::Cpu => "CPU",
|
||||
Column::BoardCode => "Board",
|
||||
Column::BoardCode => "Control Board",
|
||||
Column::Algorithm => "Algorithm",
|
||||
Column::Pic => "PIC",
|
||||
Column::Locked => "Access",
|
||||
@@ -541,8 +571,9 @@ impl Column {
|
||||
match self {
|
||||
Column::Ip => 130,
|
||||
Column::Hashrate => 110,
|
||||
Column::HashrateRel => 110,
|
||||
Column::Power => 90,
|
||||
Column::ChipTemp | Column::FluidTemp | Column::OutletTemp => 95,
|
||||
Column::ChipTemp | Column::FluidTemp | Column::EnvTemp | Column::OutletTemp => 95,
|
||||
Column::Cooling | Column::PsuFan => 100,
|
||||
Column::Firmware => 110,
|
||||
Column::FwVersion => 130,
|
||||
@@ -557,7 +588,6 @@ impl Column {
|
||||
Column::ExpectedFans | Column::TuningPercent => 90,
|
||||
Column::Mac | Column::Hostname | Column::Serial => 150,
|
||||
Column::ApiVersion | Column::Light => 90,
|
||||
Column::ControlBoard => 130,
|
||||
Column::Cpu => 70,
|
||||
Column::BoardCode => 70,
|
||||
Column::Algorithm => 100,
|
||||
@@ -579,10 +609,12 @@ impl Column {
|
||||
matches!(
|
||||
self,
|
||||
Column::Hashrate
|
||||
| Column::HashrateRel
|
||||
| Column::Power
|
||||
| Column::Efficiency
|
||||
| Column::ChipTemp
|
||||
| Column::FluidTemp
|
||||
| Column::EnvTemp
|
||||
| Column::OutletTemp
|
||||
| Column::Cooling
|
||||
| Column::PsuFan
|
||||
@@ -630,10 +662,16 @@ impl Column {
|
||||
let none = f64::NEG_INFINITY;
|
||||
match self {
|
||||
Column::Hashrate => SortKey::Num(r.hashrate_ths),
|
||||
// Relative hashrate = actual/expected; unknown expectation sorts to
|
||||
// the bottom (round 11 #16).
|
||||
Column::HashrateRel => {
|
||||
SortKey::Num(actual_expected_ratio(r.hashrate_ths, r.expected_ths).unwrap_or(none))
|
||||
}
|
||||
Column::Power => SortKey::Num(r.power_w),
|
||||
Column::Efficiency => SortKey::Num(if r.efficiency > 0.0 { r.efficiency } else { none }),
|
||||
Column::ChipTemp => SortKey::Num(r.chip_temp_c),
|
||||
Column::FluidTemp => SortKey::Num(r.fluid_temp_c),
|
||||
Column::EnvTemp => SortKey::Num(r.env_temp_c),
|
||||
Column::OutletTemp => SortKey::Num(r.outlet_temp_c),
|
||||
Column::Cooling => SortKey::Num(if r.fan_rpms.is_empty() {
|
||||
none
|
||||
@@ -644,7 +682,21 @@ impl Column {
|
||||
Column::FanCount => SortKey::Num(r.fan_count.map(|v| v as f64).unwrap_or(none)),
|
||||
Column::ExpectedFans => SortKey::Num(r.expected_fans.map(|v| v as f64).unwrap_or(none)),
|
||||
Column::TotalChips => SortKey::Num(r.total_chips.map(|v| v as f64).unwrap_or(none)),
|
||||
Column::Hashboards => SortKey::Num(r.hashboards.map(|v| v as f64).unwrap_or(none)),
|
||||
// The Boards column shows per-hashboard health dots, so sort by the
|
||||
// number of ONLINE (green) boards -- surfacing units with dead/missing
|
||||
// boards -- with the total board count as a tiebreaker (so full-health
|
||||
// units still order by how many boards they have). Falls back to the
|
||||
// reported board count when no per-board health is available (round 11).
|
||||
Column::Hashboards => {
|
||||
if r.board_status.is_empty() {
|
||||
SortKey::Num(r.hashboards.map(|v| v as f64).unwrap_or(none))
|
||||
} else {
|
||||
let online =
|
||||
r.board_status.iter().filter(|h| matches!(h, BoardHealth::Ok)).count();
|
||||
let total = r.board_status.len();
|
||||
SortKey::Num((online * 100 + total) as f64)
|
||||
}
|
||||
}
|
||||
Column::Uptime => SortKey::Num(if r.uptime_secs > 0 { r.uptime_secs as f64 } else { none }),
|
||||
Column::BestShare => SortKey::Num(r.best_share.unwrap_or(none)),
|
||||
Column::SessionBestShare => SortKey::Num(r.session_best_share.unwrap_or(none)),
|
||||
@@ -674,6 +726,11 @@ impl Column {
|
||||
match self {
|
||||
Column::Ip => r.ip.clone(),
|
||||
Column::Hashrate => combined_si(r.hashrate_ths, r.expected_ths),
|
||||
// Never displayed as its own column; rendered as a percentage only for
|
||||
// completeness (e.g. a debug/self-test read of the cell).
|
||||
Column::HashrateRel => actual_expected_ratio(r.hashrate_ths, r.expected_ths)
|
||||
.map(|ratio| format!("{:.0}%", ratio * 100.0))
|
||||
.unwrap_or_default(),
|
||||
Column::Power => {
|
||||
if r.power_w > 0.0 {
|
||||
format_si(r.power_w, "W")
|
||||
@@ -692,6 +749,7 @@ impl Column {
|
||||
}
|
||||
}
|
||||
Column::FluidTemp => num(r.fluid_temp_c, 1, " C"),
|
||||
Column::EnvTemp => num(r.env_temp_c, 1, " C"),
|
||||
Column::OutletTemp => num(r.outlet_temp_c, 1, " C"),
|
||||
Column::Cooling => {
|
||||
r.fan_rpms.iter().map(|&v| format_fan_rpm(v)).collect::<Vec<_>>().join("/")
|
||||
@@ -713,7 +771,6 @@ impl Column {
|
||||
Column::Hostname => r.hostname.clone(),
|
||||
Column::Serial => r.serial.clone(),
|
||||
Column::ApiVersion => r.api_version.clone(),
|
||||
Column::ControlBoard => r.control_board.clone(),
|
||||
Column::Cpu => r.cpu.clone(),
|
||||
Column::BoardCode => r.board_code.clone(),
|
||||
Column::Algorithm => r.algorithm.clone(),
|
||||
@@ -838,9 +895,17 @@ pub struct ViewState {
|
||||
|
||||
impl Default for ViewState {
|
||||
fn default() -> Self {
|
||||
// Registry order for `order`; Ip + DEFAULT_VISIBLE are shown. Default
|
||||
// sort is by IP ascending.
|
||||
let order: Vec<Column> = ALL_COLUMNS.to_vec();
|
||||
// Display order = Ip, then DEFAULT_VISIBLE in its own order, then every
|
||||
// remaining metric (so the initial columns match the UI-SPEC order rather
|
||||
// than the ALL_COLUMNS registry order). Default sort is by IP ascending.
|
||||
let mut order: Vec<Column> = Vec::with_capacity(ALL_COLUMNS.len());
|
||||
order.push(Column::Ip);
|
||||
order.extend(DEFAULT_VISIBLE);
|
||||
for c in ALL_COLUMNS {
|
||||
if !order.contains(&c) {
|
||||
order.push(c);
|
||||
}
|
||||
}
|
||||
let mut visible: HashSet<Column> = DEFAULT_VISIBLE.iter().copied().collect();
|
||||
visible.insert(Column::Ip);
|
||||
ViewState { order, visible, sort: Some((Column::Ip, true)), filters: HashMap::new() }
|
||||
@@ -1145,9 +1210,12 @@ mod tests {
|
||||
fn reorder_with_hidden_column_keeps_all_columns() {
|
||||
let mut view = ViewState::default();
|
||||
view.visible.remove(&Column::Power);
|
||||
// display now: Ip(0), Hashrate(1), ChipTemp(2), ... - swap Hashrate/ChipTemp
|
||||
// Swap Hashrate and ChipTemp in the visible display order (order-agnostic:
|
||||
// find them by identity rather than by a fixed index).
|
||||
let mut vis = view.display_columns();
|
||||
vis.swap(1, 2);
|
||||
let hr0 = vis.iter().position(|c| *c == Column::Hashrate).unwrap();
|
||||
let ct0 = vis.iter().position(|c| *c == Column::ChipTemp).unwrap();
|
||||
vis.swap(hr0, ct0);
|
||||
view.apply_visible_reorder(&vis);
|
||||
assert!(view.order.contains(&Column::Power), "hidden column dropped!");
|
||||
assert_eq!(view.order.len(), ALL_COLUMNS.len());
|
||||
|
||||
@@ -46,6 +46,38 @@ fn is_antminer(make: &str) -> bool {
|
||||
make.trim().eq_ignore_ascii_case("antminer")
|
||||
}
|
||||
|
||||
/// Split asic-rs's firmware family string into the family shown in the Firmware
|
||||
/// column and an optional vendor prefix that moves into the FW Version column
|
||||
/// (round 11 #6). asic-rs reports stock firmware as "AntMiner Stock" /
|
||||
/// "WhatsMiner Stock"; the Firmware column should read just "Stock" (so it
|
||||
/// colours as the neutral/default family), and the vendor word belongs with the
|
||||
/// version. Aftermarket families ("VNish", "Braiins", ...) carry no vendor
|
||||
/// prefix and pass through unchanged.
|
||||
pub fn firmware_family(raw: &str) -> (String, Option<String>) {
|
||||
let trimmed = raw.trim();
|
||||
// Vendor prefixes asic-rs prepends on stock-firmware family strings, matched
|
||||
// case-insensitively.
|
||||
for vendor in ["AntMiner", "WhatsMiner"] {
|
||||
if trimmed.len() > vendor.len() && trimmed[..vendor.len()].eq_ignore_ascii_case(vendor) {
|
||||
let rest = trimmed[vendor.len()..].trim();
|
||||
if !rest.is_empty() {
|
||||
return (rest.to_string(), Some(vendor.to_string()));
|
||||
}
|
||||
}
|
||||
}
|
||||
(trimmed.to_string(), None)
|
||||
}
|
||||
|
||||
/// Whether a miner is liquid-cooled (hydro / water / immersion) rather than
|
||||
/// air-cooled, inferred from the model name (round 11 #17). asic-rs exposes no
|
||||
/// cooling-type field, so this is a best-effort model-string heuristic: it
|
||||
/// decides whether a reported "fluid" temperature is a real coolant reading or
|
||||
/// (for air-cooled units) the ambient/environment temperature.
|
||||
pub fn is_liquid_cooled(model: &str) -> bool {
|
||||
let m = model.to_ascii_lowercase();
|
||||
m.contains("hydro") || m.contains("immers") || m.contains("water")
|
||||
}
|
||||
|
||||
/// The human model name for the Model column: brand dropped (it has its own
|
||||
/// column), family-letter suffix lowercased, word suffixes spaced, "+"/"++" for
|
||||
/// Plus/PlusPlus, and (WhatsMiner) the trailing version block moved to Submodel.
|
||||
@@ -354,4 +386,28 @@ mod tests {
|
||||
assert_eq!(control_board_cpu("Antminer", "Unknown: FOO", "S19"), "Unknown: FOO");
|
||||
assert_eq!(control_board_board("Antminer", "Unknown: FOO", "S19"), "");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn firmware_family_splits_vendor_prefix() {
|
||||
// Stock firmware: vendor word moves out of the family word (round 11 #6).
|
||||
assert_eq!(firmware_family("AntMiner Stock"), ("Stock".to_string(), Some("AntMiner".to_string())));
|
||||
assert_eq!(
|
||||
firmware_family("WhatsMiner Stock"),
|
||||
("Stock".to_string(), Some("WhatsMiner".to_string()))
|
||||
);
|
||||
// Aftermarket families pass through with no vendor prefix.
|
||||
assert_eq!(firmware_family("VNish"), ("VNish".to_string(), None));
|
||||
assert_eq!(firmware_family("Braiins"), ("Braiins".to_string(), None));
|
||||
// A bare vendor word with nothing after it is left as-is (not emptied).
|
||||
assert_eq!(firmware_family("AntMiner"), ("AntMiner".to_string(), None));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn liquid_cooling_detection() {
|
||||
assert!(is_liquid_cooled("S21 XP Hydro"));
|
||||
assert!(is_liquid_cooled("Antminer S19 Hydro"));
|
||||
assert!(is_liquid_cooled("M53 immersion"));
|
||||
assert!(!is_liquid_cooled("S21 Pro"));
|
||||
assert!(!is_liquid_cooled("M30S++"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,17 +25,28 @@ pub struct SshCreds {
|
||||
pub pass: String,
|
||||
}
|
||||
|
||||
/// Which I2C bus to probe, chosen from the control-board family. AMLogic uses
|
||||
/// i2c-1, BeagleBone uses i2c-0; for anything else (Xilinx/CVITek/unknown) we
|
||||
/// try both. The wiki confirms the AML/BB buses; Zynx/CVITek are unconfirmed.
|
||||
/// I2C buses to probe for the hashboard MCU/LM75 at 0x48, most-likely first,
|
||||
/// chosen from the control-board family. `probe_pic` tries them in order and
|
||||
/// stops at the first bus that classifies definitively, so extra fallbacks only
|
||||
/// cost an SSH round-trip when earlier buses are absent/indeterminate.
|
||||
///
|
||||
/// Confirmed live (2026-09-19): a VNish CVITek S19k Pro exposes the hashboard
|
||||
/// MCU on i2c-3 (i2c-4 is the second, usually empty); its buses are i2c-3/i2c-4,
|
||||
/// NOT i2c-0/i2c-1 -- the earlier CVITek -> [1,0] guess never found the MCU,
|
||||
/// which is why PIC detection appeared not to work. AMLogic=i2c-1 and
|
||||
/// BeagleBone=i2c-0 are from the wiki; buses vary across firmware, so each family
|
||||
/// also lists the others as fallbacks.
|
||||
pub fn bus_candidates(control_board: &str) -> Vec<u8> {
|
||||
let cb = control_board.to_lowercase();
|
||||
if cb.contains("amlogic") || cb.contains("aml") {
|
||||
vec![1]
|
||||
if cb.contains("cvi") {
|
||||
vec![3, 4, 1, 0]
|
||||
} else if cb.contains("amlogic") || cb.contains("aml") {
|
||||
vec![1, 3, 4, 0]
|
||||
} else if cb.contains("beaglebone") || cb.contains("bb") {
|
||||
vec![0]
|
||||
vec![0, 1, 3, 4]
|
||||
} else {
|
||||
vec![1, 0]
|
||||
// Xilinx / unknown: try the common buses.
|
||||
vec![1, 0, 3, 4]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,9 +226,13 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn bus_from_control_board() {
|
||||
assert_eq!(bus_candidates("AMLogic"), vec![1]);
|
||||
assert_eq!(bus_candidates("BeagleBone Black"), vec![0]);
|
||||
assert_eq!(bus_candidates("Xilinx"), vec![1, 0]);
|
||||
assert_eq!(bus_candidates(""), vec![1, 0]);
|
||||
// Most-likely bus first, then fallbacks. CVITek's i2c-3 first is the live
|
||||
// fix; AMLogic i2c-1 and BeagleBone i2c-0 keep their wiki-confirmed lead.
|
||||
assert_eq!(bus_candidates("CVI (C88)"), vec![3, 4, 1, 0]);
|
||||
assert_eq!(bus_candidates("CVITek"), vec![3, 4, 1, 0]);
|
||||
assert_eq!(bus_candidates("AMLogic")[0], 1);
|
||||
assert_eq!(bus_candidates("BeagleBone Black")[0], 0);
|
||||
assert_eq!(bus_candidates("Xilinx")[0], 1);
|
||||
assert_eq!(bus_candidates("")[0], 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,20 +11,20 @@ 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).
|
||||
const DEFAULT_PROFILE: [Column; 12] = [
|
||||
/// 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] = [
|
||||
Column::Ip,
|
||||
Column::Model,
|
||||
Column::Error,
|
||||
Column::Hashrate,
|
||||
Column::Power,
|
||||
Column::ChipTemp,
|
||||
Column::Firmware,
|
||||
Column::FwVersion,
|
||||
Column::Cpu,
|
||||
Column::BoardCode,
|
||||
Column::Pic,
|
||||
Column::Error,
|
||||
Column::Status,
|
||||
Column::Hashboards,
|
||||
Column::Locked,
|
||||
];
|
||||
|
||||
/// A serializable snapshot of a `ViewState` (Vec-based so JSON has no map keys
|
||||
@@ -126,10 +126,13 @@ mod tests {
|
||||
let view = p.view.to_view();
|
||||
// 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::Cpu));
|
||||
assert!(view.visible.contains(&Column::BoardCode));
|
||||
assert!(view.visible.contains(&Column::Pic));
|
||||
assert!(view.visible.contains(&Column::Status));
|
||||
assert!(view.visible.contains(&Column::Hashboards));
|
||||
assert!(view.visible.contains(&Column::Locked));
|
||||
// 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");
|
||||
// to_view covers every column in `order`.
|
||||
assert_eq!(view.order.len(), ALL_COLUMNS.len());
|
||||
|
||||
@@ -449,15 +449,19 @@ async fn to_row(miner: &dyn Miner) -> MinerRow {
|
||||
.as_ref()
|
||||
.map(|t| t.as_celsius())
|
||||
.unwrap_or(0.0);
|
||||
// Per-hashboard chip temperature (hottest chip per board, falling back to
|
||||
// the board/PCB temp), for the "77 / 64 / 74" Chip-temp cell.
|
||||
// Per-hashboard temperature for the "77 / 64 / 74" Chip-temp cell. Prefer the
|
||||
// board/PCB temperature over the hottest-chip (outlet) reading: WhatsMiner's
|
||||
// outlet_chip is the max chip temp (~100C on the hottest board), which read
|
||||
// alarmingly high and didn't match the temperature the miner itself reports;
|
||||
// the board temperature (~60-79C) is the figure the miner's own UI shows
|
||||
// (round 12 #3). Falls back to the chip temp when no board temp is reported.
|
||||
let board_temps: Vec<f64> = data
|
||||
.hashboards
|
||||
.iter()
|
||||
.filter_map(|b| {
|
||||
b.outlet_chip_temperature
|
||||
b.board_temperature
|
||||
.as_ref()
|
||||
.or(b.board_temperature.as_ref())
|
||||
.or(b.outlet_chip_temperature.as_ref())
|
||||
.map(|t| t.as_celsius())
|
||||
})
|
||||
.filter(|&t| t > 0.0)
|
||||
@@ -496,9 +500,16 @@ async fn to_row(miner: &dyn Miner) -> MinerRow {
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
// Firmware family (coloured column) and version go in separate columns now.
|
||||
let firmware = data.device_info.firmware.clone();
|
||||
let fw_version = data.firmware_version.clone().unwrap_or_default();
|
||||
// Firmware family (coloured column) and version go in separate columns. Strip
|
||||
// the vendor word asic-rs prepends on stock firmware ("AntMiner Stock" ->
|
||||
// "Stock") and carry it into the version instead (round 11 #6).
|
||||
let (firmware, fw_vendor) = crate::naming::firmware_family(&data.device_info.firmware);
|
||||
let raw_fw_version = data.firmware_version.clone().unwrap_or_default();
|
||||
let fw_version = match (fw_vendor, raw_fw_version.is_empty()) {
|
||||
(Some(vendor), false) => format!("{vendor} {raw_fw_version}"),
|
||||
(Some(vendor), true) => vendor,
|
||||
(None, _) => raw_fw_version,
|
||||
};
|
||||
// Split asic-rs's compact make/model identifiers into the human-facing
|
||||
// Brand / Model / Submodel the table shows (see crate::naming). asic-rs hands
|
||||
// us "Antminer"/"S19KPro"; we render brand "Antminer", model "S19k Pro".
|
||||
@@ -511,7 +522,16 @@ async fn to_row(miner: &dyn Miner) -> MinerRow {
|
||||
let control_board = crate::naming::control_board_code(&make, &raw_board, &model);
|
||||
let cpu = crate::naming::control_board_cpu(&make, &raw_board, &model);
|
||||
let board_code = crate::naming::control_board_board(&make, &raw_board, &model);
|
||||
let fluid_temp_c = data.fluid_temperature.as_ref().map(|t| t.as_celsius()).unwrap_or(0.0);
|
||||
// asic-rs has no cooling-type field and reports air-cooled miners' ambient
|
||||
// reading in `fluid_temperature` (the WhatsMiner backends read the "Env
|
||||
// Temp"/"environment-temperature" key). Route it to the Env-temp column for
|
||||
// air-cooled models so it isn't mislabelled as a coolant temp (round 11 #17).
|
||||
let reported_fluid = data.fluid_temperature.as_ref().map(|t| t.as_celsius()).unwrap_or(0.0);
|
||||
let (fluid_temp_c, env_temp_c) = if crate::naming::is_liquid_cooled(&model) {
|
||||
(reported_fluid, 0.0)
|
||||
} else {
|
||||
(0.0, reported_fluid)
|
||||
};
|
||||
let outlet_temp_c = data
|
||||
.outlet_fluid_temperature
|
||||
.as_ref()
|
||||
@@ -551,6 +571,31 @@ async fn to_row(miner: &dyn Miner) -> MinerRow {
|
||||
// all, otherwise unlocked. Inferred from capabilities (asic-rs has no direct
|
||||
// lock-state field).
|
||||
let write_locked = Some(!caps.any_control());
|
||||
// Per-hashboard health for the Boards status dots (round 11 #10): green =
|
||||
// present & hashing, red = present but idle/faulty, grey = expected but not
|
||||
// detected. Boards keep asic-rs's reported order (board 1 first); any boards
|
||||
// expected beyond those reported are padded as Missing.
|
||||
let mut board_status: Vec<crate::model::BoardHealth> = data
|
||||
.hashboards
|
||||
.iter()
|
||||
.map(|b| {
|
||||
let ok = match (b.active, b.working_chips) {
|
||||
(Some(a), _) => a,
|
||||
(None, Some(c)) => c > 0,
|
||||
(None, None) => true,
|
||||
};
|
||||
if ok {
|
||||
crate::model::BoardHealth::Ok
|
||||
} else {
|
||||
crate::model::BoardHealth::Fault
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
if let Some(exp) = data.expected_hashboards {
|
||||
while board_status.len() < exp as usize {
|
||||
board_status.push(crate::model::BoardHealth::Missing);
|
||||
}
|
||||
}
|
||||
let errors = summarize_messages(&data.messages);
|
||||
MinerRow {
|
||||
ip: data.ip.to_string(),
|
||||
@@ -565,7 +610,22 @@ async fn to_row(miner: &dyn Miner) -> MinerRow {
|
||||
submodel,
|
||||
mac: data.mac.map(|m| m.to_string()).unwrap_or_default(),
|
||||
hostname: data.hostname.clone().unwrap_or_default(),
|
||||
serial: data.serial_number.clone().unwrap_or_default(),
|
||||
serial: {
|
||||
// Some miners report a placeholder serial ("N/A", "none", ...); show
|
||||
// those as an empty cell rather than the literal placeholder (round 12).
|
||||
let s = data.serial_number.clone().unwrap_or_default();
|
||||
let t = s.trim();
|
||||
if t.is_empty()
|
||||
|| t.eq_ignore_ascii_case("n/a")
|
||||
|| t.eq_ignore_ascii_case("na")
|
||||
|| t.eq_ignore_ascii_case("none")
|
||||
|| t.eq_ignore_ascii_case("null")
|
||||
{
|
||||
String::new()
|
||||
} else {
|
||||
s
|
||||
}
|
||||
},
|
||||
firmware,
|
||||
fw_version,
|
||||
api_version: data.api_version.clone().unwrap_or_default(),
|
||||
@@ -580,6 +640,7 @@ async fn to_row(miner: &dyn Miner) -> MinerRow {
|
||||
chip_temp_c,
|
||||
board_temps,
|
||||
fluid_temp_c,
|
||||
env_temp_c,
|
||||
outlet_temp_c,
|
||||
fan_rpms,
|
||||
psu_fan_rpm,
|
||||
@@ -589,6 +650,7 @@ async fn to_row(miner: &dyn Miner) -> MinerRow {
|
||||
expected_chips: data.expected_chips.map(|v| v as u32),
|
||||
hashboards: (!data.hashboards.is_empty()).then_some(data.hashboards.len() as u32),
|
||||
expected_hashboards: data.expected_hashboards.map(|v| v as u32),
|
||||
board_status,
|
||||
worker,
|
||||
pool_url,
|
||||
pools,
|
||||
|
||||
+317
-60
@@ -78,6 +78,10 @@ const ID_HDR_SORT_DESC: i32 = 761;
|
||||
const ID_HDR_HIDE: i32 = 762;
|
||||
const ID_HDR_AUTOSIZE: i32 = 763;
|
||||
const ID_HDR_COLUMNS: i32 = 764;
|
||||
// Relative-hashrate (actual/expected) sort, offered on the Hashrate header only
|
||||
// (round 11 #16).
|
||||
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;
|
||||
@@ -232,6 +236,98 @@ fn encode_flag_cell(plain: &str, color: Option<(u8, u8, u8)>) -> String {
|
||||
encode_segments(&[(color, plain.to_string())])
|
||||
}
|
||||
|
||||
/// Shape-sentinel strings the SegmentRenderer draws as small vector icons rather
|
||||
/// than text (round 11 #10/#13). These byte values MUST match the SHAPE_* set in
|
||||
/// widgets_bridge.cpp. They are control characters, never emoji/pictographs.
|
||||
const SHAPE_DOT: &str = "\u{0007}";
|
||||
const SHAPE_LOCK: &str = "\u{0002}";
|
||||
const SHAPE_UNLOCK: &str = "\u{0003}";
|
||||
|
||||
/// Boards column: one status dot per hashboard (round 11 #10). Board 1 is the
|
||||
/// rightmost dot, so boards render high-position-first (left to right). green =
|
||||
/// present and hashing, red = present but idle/faulty, grey = not detected.
|
||||
fn encode_board_dots(pal: &Palette, status: &[crate::model::BoardHealth]) -> String {
|
||||
use crate::model::BoardHealth;
|
||||
if status.is_empty() {
|
||||
return encode_segments(&[(None, String::new())]);
|
||||
}
|
||||
let segs: Vec<(Option<(u8, u8, u8)>, String)> = status
|
||||
.iter()
|
||||
.rev()
|
||||
.map(|h| {
|
||||
let color = match h {
|
||||
BoardHealth::Ok => pal.green,
|
||||
BoardHealth::Fault => pal.red,
|
||||
BoardHealth::Missing => pal.label,
|
||||
};
|
||||
(Some(color), SHAPE_DOT.to_string())
|
||||
})
|
||||
.collect();
|
||||
encode_segments(&segs)
|
||||
}
|
||||
|
||||
/// Access column: a green open padlock (writable) or red closed padlock
|
||||
/// (view-only); blank when the lock state is unknown (round 11 #13).
|
||||
fn encode_access_icon(pal: &Palette, write_locked: Option<bool>) -> String {
|
||||
match write_locked {
|
||||
Some(true) => encode_segments(&[(Some(pal.red), SHAPE_LOCK.to_string())]),
|
||||
Some(false) => encode_segments(&[(Some(pal.green), SHAPE_UNLOCK.to_string())]),
|
||||
None => encode_segments(&[(None, String::new())]),
|
||||
}
|
||||
}
|
||||
|
||||
/// Light column: a yellow dot while the miner's locate light is flashing, else
|
||||
/// blank (round 11 #10).
|
||||
fn encode_light_dot(pal: &Palette, flashing: Option<bool>) -> String {
|
||||
match flashing {
|
||||
Some(true) => encode_segments(&[(Some(pal.amber), SHAPE_DOT.to_string())]),
|
||||
_ => encode_segments(&[(None, String::new())]),
|
||||
}
|
||||
}
|
||||
|
||||
// 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.
|
||||
const SVG_RABBIT: &str = include_str!("../assets/icons/rabbit.svg");
|
||||
const SVG_TURTLE: &str = include_str!("../assets/icons/turtle.svg");
|
||||
const SVG_WINE_CRACK: &str = include_str!("../assets/icons/wine-glass-crack.svg");
|
||||
const SVG_OTTER: &str = include_str!("../assets/icons/otter.svg");
|
||||
const SVG_HIVE: &str = include_str!("../assets/icons/hive.svg");
|
||||
const SVG_BOLT: &str = include_str!("../assets/icons/bolt.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
|
||||
/// icon + units-bearing value never clips (round 12 #2). The wide floor fits the
|
||||
/// widest realistic value the card can show -- a ~20px icon + 5px gap + a value
|
||||
/// text up to "118.0 PH" (~127px at 19pt bold) + the card's 16px side inset --
|
||||
/// so the units ("kW"/"PH"/...) stay visible instead of being squeezed off; the
|
||||
/// row collapses the wide cards entirely (see `on_resize`) rather than shrink
|
||||
/// them below this and clip.
|
||||
const KPI_MIN: i32 = 116;
|
||||
const KPI_WIDE_MIN: i32 = 176;
|
||||
|
||||
/// Recolour an SVG to the KPI card's colour (round 11 #15). Some Font Awesome
|
||||
/// exports use fill="currentColor" (replaced here); others omit fill entirely and
|
||||
/// default to black, so a root `fill` is also injected for shapes to inherit.
|
||||
fn svg_recolored(svg: &str, color: (u8, u8, u8)) -> String {
|
||||
let hex = format!("#{:02X}{:02X}{:02X}", color.0, color.1, color.2);
|
||||
let s = svg.replace("currentColor", &hex);
|
||||
s.replacen("<svg ", &format!("<svg fill=\"{hex}\" "), 1)
|
||||
}
|
||||
|
||||
/// Width to render an SVG at, preserving its viewBox aspect ratio at height `h`.
|
||||
fn svg_width_for_height(svg: &str, h: i32) -> i32 {
|
||||
svg.split("viewBox=\"")
|
||||
.nth(1)
|
||||
.and_then(|s| s.split('"').next())
|
||||
.and_then(|vb| {
|
||||
let n: Vec<f64> = vb.split_whitespace().filter_map(|x| x.parse().ok()).collect();
|
||||
(n.len() == 4 && n[3] > 0.0).then(|| ((h as f64) * n[2] / n[3]).round() as i32)
|
||||
})
|
||||
.unwrap_or(h)
|
||||
.max(1)
|
||||
}
|
||||
|
||||
/// Build the segment-encoded cell text for the Cooling column: each fan's RPM
|
||||
/// gets its own grey-to-blue colour by speed, and the "/" separators between
|
||||
/// them stay in the default text colour.
|
||||
@@ -363,6 +459,12 @@ pub struct App {
|
||||
// so both can be repainted when the system light/dark theme changes.
|
||||
pal: Palette,
|
||||
kpi_cards: Vec<(Widget, Widget, Widget, ColorKind)>,
|
||||
/// The main content panel and the KPI card row sizer, plus whether the two
|
||||
/// wide KPI cards (Hashrate, Est. power) are currently collapsed because the
|
||||
/// window is too narrow to fit all seven cards (round 11 #2).
|
||||
panel: Widget,
|
||||
kpi_row: Widget,
|
||||
kpi_collapsed: bool,
|
||||
// The 4 status KPI cards that double as quick-filters: (status text, its
|
||||
// ButtonClicked id, card panel, value text, label text). The three widgets
|
||||
// are all painted for the active-filter highlight (so the whole box tints,
|
||||
@@ -428,6 +530,11 @@ pub struct App {
|
||||
ranges_auto: Widget,
|
||||
columns_dialog: Widget,
|
||||
columns_list: Widget,
|
||||
/// The columns-dialog "hide empty columns" checkbox, read at Apply.
|
||||
columns_hide_empty_cb: Widget,
|
||||
/// When set, columns with no scanned value in any row are hidden from the
|
||||
/// table (non-destructively -- clearing it restores them) (round 11 #9).
|
||||
auto_hide_empty: bool,
|
||||
// Filter dialog (Excel-style, one column at a time via a dropdown).
|
||||
filter_dialog: Widget,
|
||||
filter_col_choice: Widget, // which column to filter
|
||||
@@ -458,18 +565,23 @@ pub fn build(frame: Widget) -> App {
|
||||
// min size floors them at their largest content's width.
|
||||
let kpi_row = Widget::box_sizer(false);
|
||||
let mut kpi_cards: Vec<(Widget, Widget, Widget, ColorKind)> = Vec::new();
|
||||
let mut mk_card = |label: &str, kind: ColorKind| -> (Widget, Widget) {
|
||||
let mut mk_card = |label: &str, kind: ColorKind, icon: Option<&'static str>| -> (Widget, Widget) {
|
||||
let vc = kind_color(&pal, kind);
|
||||
let card = Widget::panel(panel);
|
||||
card.set_bg(pal.card_bg.0, pal.card_bg.1, pal.card_bg.2);
|
||||
// Min-content floor (the widest label/value); cards grow equally past
|
||||
// this to fill the window (proportion 1 + EXPAND on add).
|
||||
card.set_min_size(116, 62);
|
||||
card.set_min_size(KPI_MIN, 62);
|
||||
let cs = Widget::box_sizer(true);
|
||||
let value = Widget::static_text(card, "0");
|
||||
value.set_font_size(19);
|
||||
value.set_bold();
|
||||
value.set_fg(vc.0, vc.1, vc.2);
|
||||
// Neutral cards (Total, Est. power) keep the default text colour so they
|
||||
// dim with the rest of the dashboard when the window loses focus; only
|
||||
// the semantically-coloured cards force a foreground (round-10 #2).
|
||||
if !matches!(kind, ColorKind::Neutral) {
|
||||
value.set_fg(vc.0, vc.1, vc.2);
|
||||
}
|
||||
value.set_bg(pal.card_bg.0, pal.card_bg.1, pal.card_bg.2);
|
||||
let lbl = Widget::static_text(card, label);
|
||||
lbl.set_font_size(9);
|
||||
@@ -484,8 +596,26 @@ pub fn build(frame: Widget) -> App {
|
||||
row.add_stretch(1);
|
||||
row
|
||||
};
|
||||
// The value row optionally leads with a small drawn KPI icon (round 11
|
||||
// #15). Neutral cards (Est. power) colour the icon amber for pop since
|
||||
// their value text stays the default (dimming) colour.
|
||||
let value_row = {
|
||||
let row = Widget::box_sizer(false);
|
||||
row.add_stretch(1);
|
||||
if let Some(svg) = icon {
|
||||
// Icon takes the card's value colour, so each icon matches its KPI
|
||||
// text (otter = paused colour, bolt = est-power colour, etc.).
|
||||
let icol = vc;
|
||||
let h = 20;
|
||||
let ic = Widget::svg_icon(card, &svg_recolored(svg, icol), svg_width_for_height(svg, h), h);
|
||||
row.add(ic, 0, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_RIGHT, 5);
|
||||
}
|
||||
row.add(value, 0, sf::ALIGN_CENTRE_VERTICAL, 0);
|
||||
row.add_stretch(1);
|
||||
row
|
||||
};
|
||||
cs.add_stretch(1);
|
||||
cs.add_sizer(centre(value), 0, sf::EXPAND | sf::BORDER_LEFT | sf::BORDER_TOP | sf::BORDER_RIGHT, 8);
|
||||
cs.add_sizer(value_row, 0, sf::EXPAND | sf::BORDER_LEFT | sf::BORDER_TOP | sf::BORDER_RIGHT, 8);
|
||||
cs.add_sizer(centre(lbl), 0, sf::EXPAND | sf::BORDER_LEFT | sf::BORDER_BOTTOM | sf::BORDER_RIGHT, 8);
|
||||
cs.add_stretch(1);
|
||||
cs.set_sizer_on(card);
|
||||
@@ -493,14 +623,23 @@ pub fn build(frame: Widget) -> App {
|
||||
kpi_cards.push((card, value, lbl, kind));
|
||||
(card, value)
|
||||
};
|
||||
let (_card_total, kpi_total) = mk_card("Total", ColorKind::Neutral);
|
||||
let (card_hashing, kpi_hashing) = mk_card("Hashing", ColorKind::Green);
|
||||
let (card_slow, kpi_slow) = mk_card("Slow", ColorKind::Amber);
|
||||
let (card_not, kpi_not) = mk_card("Not hashing", ColorKind::Red);
|
||||
let (card_paused, kpi_paused) = mk_card("Paused", ColorKind::Blue);
|
||||
let (card_hashrate, kpi_hashrate) = mk_card("SHA-256 Hashrate", ColorKind::Accent);
|
||||
let (_card_power, kpi_power) = mk_card("Est. power", ColorKind::Neutral);
|
||||
// Icons (round 11 #15): rabbit=hashing, turtle=slow, cracked wine glass=not
|
||||
// hashing, otter=paused, hive=hashrate, lightning=power; Total has none.
|
||||
let (_card_total, kpi_total) = mk_card("Total", ColorKind::Neutral, None);
|
||||
let (card_hashing, kpi_hashing) = mk_card("Hashing", ColorKind::Green, Some(SVG_RABBIT));
|
||||
let (card_slow, kpi_slow) = mk_card("Slow", ColorKind::Amber, Some(SVG_TURTLE));
|
||||
let (card_not, kpi_not) = mk_card("Not hashing", ColorKind::Red, Some(SVG_WINE_CRACK));
|
||||
let (card_paused, kpi_paused) = mk_card("Paused", ColorKind::Blue, Some(SVG_OTTER));
|
||||
// Total-hashrate value renders in the default (black) text colour, not accent
|
||||
// (round 12 #1); it still dims with focus like the other neutral cards.
|
||||
let (card_hashrate, kpi_hashrate) = mk_card("SHA-256 Hashrate", ColorKind::Neutral, Some(SVG_HIVE));
|
||||
let (card_power, kpi_power) = mk_card("Est. power", ColorKind::Neutral, Some(SVG_BOLT));
|
||||
drop(mk_card);
|
||||
// The two wide cards carry a units-bearing value (icon + e.g. "685 TH" /
|
||||
// "21.3 kW"); give them a larger min width so the value never clips, and
|
||||
// collapse them before the row would squeeze them below it (round 12 #2).
|
||||
card_hashrate.set_min_size(KPI_WIDE_MIN, 62);
|
||||
card_power.set_min_size(KPI_WIDE_MIN, 62);
|
||||
let _ = (card_hashing, card_slow, card_not, card_paused);
|
||||
// The hashrate card is kpi_cards[5] in build order (Total, Hashing, Slow,
|
||||
// Not, Paused, Hashrate, Power); its caption is retitled per algorithm.
|
||||
@@ -567,6 +706,9 @@ pub fn build(frame: Widget) -> App {
|
||||
let table_parent = panel;
|
||||
|
||||
root.set_sizer_on(panel);
|
||||
// Collapse the two wide KPI cards when the window is too narrow to fit all
|
||||
// seven (round 11 #2): listen for panel resizes.
|
||||
panel.bind_size();
|
||||
let frame_sizer = Widget::box_sizer(true);
|
||||
frame_sizer.add(panel, 1, sf::EXPAND, 0);
|
||||
frame_sizer.set_sizer_on(frame);
|
||||
@@ -611,6 +753,9 @@ pub fn build(frame: Widget) -> App {
|
||||
selected_ips: HashSet::new(),
|
||||
pal,
|
||||
kpi_cards,
|
||||
panel,
|
||||
kpi_row,
|
||||
kpi_collapsed: false,
|
||||
kpi_filter_cards,
|
||||
active_kpi_filter: None,
|
||||
pending_popup: None,
|
||||
@@ -649,6 +794,8 @@ pub fn build(frame: Widget) -> App {
|
||||
ranges_auto: frame,
|
||||
columns_dialog: frame,
|
||||
columns_list: frame,
|
||||
columns_hide_empty_cb: frame,
|
||||
auto_hide_empty: false,
|
||||
filter_dialog: frame,
|
||||
filter_col_choice: frame,
|
||||
filter_controls: frame,
|
||||
@@ -674,6 +821,61 @@ pub fn build(frame: Widget) -> App {
|
||||
}
|
||||
|
||||
impl App {
|
||||
/// Whether `c` has no scanned value in any current row (round 11 #9). IP is
|
||||
/// never empty. With no rows loaded, nothing is considered empty (so the
|
||||
/// table isn't blanked before the first scan).
|
||||
fn column_is_empty(&self, c: Column) -> bool {
|
||||
c != Column::Ip
|
||||
&& !self.rows.is_empty()
|
||||
&& self.rows.iter().all(|r| c.cell(r).trim().is_empty())
|
||||
}
|
||||
|
||||
/// The columns the table actually shows: the view's display columns, minus
|
||||
/// any that are empty across all rows when the "hide empty columns" option is
|
||||
/// on (round 11 #9). Every table-path caller uses this (not
|
||||
/// `view.display_columns()` directly) so header/sort/reorder indices agree
|
||||
/// with what is rendered.
|
||||
fn table_columns(&self) -> Vec<Column> {
|
||||
let mut cols = self.view.display_columns();
|
||||
if self.auto_hide_empty {
|
||||
cols.retain(|c| !self.column_is_empty(*c));
|
||||
}
|
||||
cols
|
||||
}
|
||||
|
||||
/// Collapse or restore the two wide KPI cards (Hashrate, Est. power) as the
|
||||
/// window is resized (round 11 #2). When the panel is too narrow to fit all
|
||||
/// seven cards at their minimum width, the two wide cards are hidden so the
|
||||
/// five miner-count cards fill the row; they return when there is room again.
|
||||
fn on_resize(&mut self, width: i32) {
|
||||
// Each card occupies its min width + BORDER_ALL*2 (8px); the row itself is
|
||||
// inset by the root border (~12px). Collapse the two wide cards below the
|
||||
// width where all seven fit at their mins, so the wide cards' units-bearing
|
||||
// value never gets squeezed/clipped (round 12 #2) -- they drop out cleanly
|
||||
// instead.
|
||||
let need_all = 5 * (KPI_MIN + 8) + 2 * (KPI_WIDE_MIN + 8) + 12;
|
||||
let want_collapsed = width < need_all;
|
||||
if want_collapsed != self.kpi_collapsed {
|
||||
self.kpi_collapsed = want_collapsed;
|
||||
let show = !want_collapsed;
|
||||
// kpi_cards[5] = Hashrate card, [6] = Est. power card (build order).
|
||||
let hashrate_card = self.kpi_cards[5].0;
|
||||
let power_card = self.kpi_cards[6].0;
|
||||
self.kpi_row.sizer_show(hashrate_card, show);
|
||||
self.kpi_row.sizer_show(power_card, show);
|
||||
self.panel.layout();
|
||||
}
|
||||
// A nested wxPanel does not re-run its own sizer when the parent resizes
|
||||
// it, so the value/label centring spacers keep the slot sizes they were
|
||||
// given at the previous width. Re-layout each card here so the value
|
||||
// (which may carry a units suffix like "kW"/"PH") stays centred and its
|
||||
// full text is allocated -- otherwise the suffix reads as clipped when
|
||||
// the row is squeezed (round 12 #2).
|
||||
for (card, _, _, _) in &self.kpi_cards {
|
||||
card.layout();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn rebuild_table(&mut self) {
|
||||
// Detach the old table from the sizer before destroying it, so the
|
||||
// sizer never holds a dangling item, then drop it.
|
||||
@@ -690,7 +892,7 @@ impl App {
|
||||
// an ASCII direction marker in its header ("^" asc, "v" desc) -- wx's
|
||||
// native SetSortOrder re-sorts the store lexically and would fight our
|
||||
// numeric sort, so we mark the header text instead.
|
||||
for c in self.view.display_columns() {
|
||||
for c in self.table_columns() {
|
||||
let fixed = self.view.is_fixed(c);
|
||||
let mut title = c.title().to_string();
|
||||
match self.view.sort {
|
||||
@@ -698,7 +900,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::Error | Column::Status | Column::Firmware) {
|
||||
if matches!(c, Column::Hashrate | 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.
|
||||
@@ -723,7 +925,7 @@ impl App {
|
||||
let top = t.dvlc_get_top_row();
|
||||
t.dvlc_clear();
|
||||
self.view_idx = self.view.view(&self.rows);
|
||||
let cols = self.view.display_columns();
|
||||
let cols = self.table_columns();
|
||||
for &ri in &self.view_idx {
|
||||
let r = &self.rows[ri];
|
||||
let cells: Vec<String> = cols.iter().map(|c| c.cell(r)).collect();
|
||||
@@ -751,17 +953,8 @@ impl App {
|
||||
.flatten();
|
||||
encode_combined_cell(&self.pal, actual, expected, "/", ratio)
|
||||
}
|
||||
Column::Hashboards => {
|
||||
let actual = r.hashboards.map(|v| v.to_string());
|
||||
let expected = r.expected_hashboards.map(|v| v.to_string());
|
||||
let ratio = r.hashboards.and_then(|a| {
|
||||
actual_expected_ratio(
|
||||
a as f64,
|
||||
r.expected_hashboards.map(|v| v as f64).unwrap_or(0.0),
|
||||
)
|
||||
});
|
||||
encode_combined_cell(&self.pal, actual, expected, " / ", ratio)
|
||||
}
|
||||
// Boards column: per-hashboard health dots (round 11 #10).
|
||||
Column::Hashboards => encode_board_dots(&self.pal, &r.board_status),
|
||||
Column::TotalChips => {
|
||||
let actual = r.total_chips.map(|v| v.to_string());
|
||||
let expected = r.expected_chips.map(|v| v.to_string());
|
||||
@@ -775,15 +968,11 @@ impl App {
|
||||
}
|
||||
Column::ChipTemp => encode_board_temps_cell(&self.pal, &r.board_temps, r.chip_temp_c),
|
||||
Column::Cooling => encode_cooling_cell(&self.pal, &r.fan_rpms),
|
||||
Column::Locked => {
|
||||
// green = unlocked/writable, red = locked/view-only.
|
||||
let color = match r.write_locked {
|
||||
Some(true) => Some(self.pal.red),
|
||||
Some(false) => Some(self.pal.green),
|
||||
None => None,
|
||||
};
|
||||
encode_flag_cell(&c.cell(r), color)
|
||||
}
|
||||
// Access column: a padlock icon, green open (writable) / red
|
||||
// closed (view-only) (round 11 #13).
|
||||
Column::Locked => encode_access_icon(&self.pal, r.write_locked),
|
||||
// Light column: a yellow locate dot while flashing (round 11 #10).
|
||||
Column::Light => encode_light_dot(&self.pal, r.light_flashing),
|
||||
Column::Error => {
|
||||
let color = (!r.errors.is_empty()).then_some(self.pal.red);
|
||||
encode_flag_cell(&c.cell(r), color)
|
||||
@@ -875,7 +1064,10 @@ impl App {
|
||||
let vc = kind_color(&self.pal, *kind);
|
||||
card.set_bg(self.pal.card_bg.0, self.pal.card_bg.1, self.pal.card_bg.2);
|
||||
value.set_bg(self.pal.card_bg.0, self.pal.card_bg.1, self.pal.card_bg.2);
|
||||
value.set_fg(vc.0, vc.1, vc.2);
|
||||
// Neutral cards keep the default (dimming) text colour -- see mk_card.
|
||||
if !matches!(kind, ColorKind::Neutral) {
|
||||
value.set_fg(vc.0, vc.1, vc.2);
|
||||
}
|
||||
caption.set_bg(self.pal.card_bg.0, self.pal.card_bg.1, self.pal.card_bg.2);
|
||||
caption.set_fg(self.pal.label.0, self.pal.label.1, self.pal.label.2);
|
||||
}
|
||||
@@ -1296,9 +1488,8 @@ impl App {
|
||||
/// actions (power limit / tuning %) return a prompt dialog to show modally.
|
||||
fn on_menu_item(&mut self, id: i32) -> Option<Widget> {
|
||||
match id {
|
||||
ID_HDR_SORT_ASC | ID_HDR_SORT_DESC | ID_HDR_HIDE | ID_HDR_AUTOSIZE | ID_HDR_COLUMNS => {
|
||||
return self.on_header_menu(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),
|
||||
ID_CTX_OPEN => {
|
||||
for ip in self.selected_ip_list() {
|
||||
wx_rs::launch_browser(&format!("http://{ip}"));
|
||||
@@ -1917,15 +2108,28 @@ impl App {
|
||||
// Columns are appended in display order; map the clicked creation index
|
||||
// back to a model column through display_columns() (hidden columns don't
|
||||
// shift the mapping). Every column, including IP at index 0, is sortable.
|
||||
let cols = self.view.display_columns();
|
||||
let cols = self.table_columns();
|
||||
if creation_idx >= cols.len() {
|
||||
return;
|
||||
}
|
||||
let col = cols[creation_idx];
|
||||
self.view.sort = match self.view.sort {
|
||||
Some((c, true)) if c == col => Some((col, false)),
|
||||
Some((c, false)) if c == col => None,
|
||||
_ => Some((col, true)),
|
||||
self.view.sort = if col == Column::Hashrate {
|
||||
// The Hashrate header cycles through four modes: absolute asc, absolute
|
||||
// desc, relative (actual/expected) asc, relative desc, then unsorted
|
||||
// (round 11 #16).
|
||||
match self.view.sort {
|
||||
Some((Column::Hashrate, true)) => Some((Column::Hashrate, false)),
|
||||
Some((Column::Hashrate, false)) => Some((Column::HashrateRel, true)),
|
||||
Some((Column::HashrateRel, true)) => Some((Column::HashrateRel, false)),
|
||||
Some((Column::HashrateRel, false)) => None,
|
||||
_ => Some((Column::Hashrate, true)),
|
||||
}
|
||||
} else {
|
||||
match self.view.sort {
|
||||
Some((c, true)) if c == col => Some((col, false)),
|
||||
Some((c, false)) if c == col => None,
|
||||
_ => Some((col, true)),
|
||||
}
|
||||
};
|
||||
// Update the header marker in place + re-sort rows. Avoids destroying and
|
||||
// recreating the whole control on every sort click (janky on big fleets).
|
||||
@@ -1937,12 +2141,18 @@ impl App {
|
||||
/// auto-size, and open the full column picker).
|
||||
fn header_context_menu(&mut self, creation_idx: usize) {
|
||||
let Some(t) = self.table else { return };
|
||||
let cols = self.view.display_columns();
|
||||
let cols = self.table_columns();
|
||||
let Some(&col) = cols.get(creation_idx) else { return };
|
||||
self.header_menu_col = Some(col);
|
||||
let menu = Widget::menu_new();
|
||||
menu.menu_append(ID_HDR_SORT_ASC, &format!("Sort {} ascending", col.title()));
|
||||
menu.menu_append(ID_HDR_SORT_DESC, &format!("Sort {} descending", col.title()));
|
||||
// The Hashrate column also offers a relative (actual/expected) sort
|
||||
// (round 11 #16).
|
||||
if col == Column::Hashrate {
|
||||
menu.menu_append(ID_HDR_SORT_REL_ASC, "Sort relative hashrate ascending");
|
||||
menu.menu_append(ID_HDR_SORT_REL_DESC, "Sort relative hashrate descending");
|
||||
}
|
||||
menu.menu_append_separator();
|
||||
menu.menu_append(ID_HDR_AUTOSIZE, "Auto-size this column");
|
||||
// The fixed IP column can't be hidden.
|
||||
@@ -1968,13 +2178,23 @@ impl App {
|
||||
self.update_headers();
|
||||
self.fill_rows();
|
||||
}
|
||||
ID_HDR_SORT_REL_ASC => {
|
||||
self.view.sort = Some((Column::HashrateRel, true));
|
||||
self.update_headers();
|
||||
self.fill_rows();
|
||||
}
|
||||
ID_HDR_SORT_REL_DESC => {
|
||||
self.view.sort = Some((Column::HashrateRel, false));
|
||||
self.update_headers();
|
||||
self.fill_rows();
|
||||
}
|
||||
ID_HDR_HIDE if !self.view.is_fixed(col) => {
|
||||
self.view.visible.remove(&col);
|
||||
self.rebuild_table();
|
||||
}
|
||||
ID_HDR_AUTOSIZE => {
|
||||
if let (Some(t), Some(pos)) =
|
||||
(self.table, self.view.display_columns().iter().position(|c| *c == col))
|
||||
(self.table, self.table_columns().iter().position(|c| *c == col))
|
||||
{
|
||||
t.dvlc_autosize_col(pos);
|
||||
}
|
||||
@@ -1989,11 +2209,16 @@ impl App {
|
||||
/// place, without recreating the table.
|
||||
fn update_headers(&self) {
|
||||
let Some(t) = self.table else { return };
|
||||
for (i, c) in self.view.display_columns().iter().enumerate() {
|
||||
for (i, c) in self.table_columns().iter().enumerate() {
|
||||
let mut title = c.title().to_string();
|
||||
match self.view.sort {
|
||||
Some((sc, true)) if sc == *c => title.push_str(" ^"),
|
||||
Some((sc, false)) if sc == *c => title.push_str(" v"),
|
||||
// The relative-hashrate sort is a pseudo-column; mark it on the
|
||||
// Hashrate header with a "%" so the mode is visible (round 11 #16).
|
||||
Some((Column::HashrateRel, asc)) if *c == Column::Hashrate => {
|
||||
title.push_str(if asc { " %^" } else { " %v" })
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
t.dvlc_set_col_title(i, &title);
|
||||
@@ -2006,7 +2231,7 @@ impl App {
|
||||
// model column via display_columns(). Read the new visible order from
|
||||
// the drag result and hand it to the model, which splices it back into
|
||||
// the full column order while leaving hidden columns in place.
|
||||
let disp = self.view.display_columns();
|
||||
let disp = self.table_columns();
|
||||
let n = t.dvlc_col_count();
|
||||
let mut new_visible = Vec::with_capacity(n);
|
||||
for pos in 0..n {
|
||||
@@ -2211,7 +2436,7 @@ impl App {
|
||||
let root = Widget::box_sizer(true);
|
||||
let hint = Widget::static_text(
|
||||
dlg,
|
||||
"Check to show a metric; drag or use the arrows to reorder (IP is always first).",
|
||||
"Check to show a metric; drag rows to reorder (IP is always first). Shift/Ctrl-click or drag to select several.",
|
||||
);
|
||||
root.add(hint, 0, sf::BORDER_ALL, 6);
|
||||
// Base list is registry order; the wx order array lists items in the
|
||||
@@ -2226,8 +2451,13 @@ impl App {
|
||||
order.push(if self.view.visible.contains(c) { idx } else { !idx });
|
||||
}
|
||||
}
|
||||
let list = Widget::rearrange_list(dlg, &order, &titles);
|
||||
let list = Widget::reorder_list(dlg, &order, &titles);
|
||||
root.add(list, 1, sf::EXPAND | sf::BORDER_ALL, 6);
|
||||
// Option: hide columns with no scanned value in any row (round 11 #9).
|
||||
let hide_empty = Widget::check_box(dlg, "Hide columns with no scanned values");
|
||||
hide_empty.set_checked(self.auto_hide_empty);
|
||||
root.add(hide_empty, 0, sf::BORDER_LEFT | sf::BORDER_RIGHT | sf::BORDER_BOTTOM, 6);
|
||||
self.columns_hide_empty_cb = hide_empty;
|
||||
let btns = Widget::box_sizer(false);
|
||||
btns.add(Widget::button(dlg, "OK", ID_COLUMNS_OK), 0, sf::BORDER_ALL, 6);
|
||||
btns.add(Widget::button(dlg, "Cancel", ID_COLUMNS_CANCEL), 0, sf::BORDER_ALL, 6);
|
||||
@@ -2240,8 +2470,11 @@ impl App {
|
||||
}
|
||||
|
||||
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.
|
||||
self.auto_hide_empty = self.columns_hide_empty_cb.is_checked();
|
||||
let base = Self::selectable_columns();
|
||||
let order = self.columns_list.rearrange_get_order();
|
||||
let order = self.columns_list.reorder_get_order();
|
||||
let mut new_order: Vec<Column> = vec![Column::Ip];
|
||||
let mut visible: HashSet<Column> = HashSet::from([Column::Ip]);
|
||||
for entry in order {
|
||||
@@ -2664,6 +2897,7 @@ impl App {
|
||||
WxEventKind::MenuItem => return self.on_menu_item(ev.p1 as i32),
|
||||
WxEventKind::ChoiceChanged => self.on_choice_changed(ev.p1 as i32, ev.p2 as i32),
|
||||
WxEventKind::SysColour => self.repaint_theme(),
|
||||
WxEventKind::Sized => self.on_resize(ev.p1 as i32),
|
||||
WxEventKind::Deferred => self.on_deferred(ev.p1 as i32),
|
||||
WxEventKind::TimerTick if ev.p1 as i32 == TIMER_SCAN => self.tick(),
|
||||
_ => {}
|
||||
@@ -2707,7 +2941,7 @@ impl App {
|
||||
check("table exists", false, "no table widget".into());
|
||||
return false;
|
||||
};
|
||||
let cols = self.view.display_columns();
|
||||
let cols = self.table_columns();
|
||||
|
||||
// 2. Row count in the store matches the (unfiltered) fixture count.
|
||||
let want_rows = self.view_idx.len();
|
||||
@@ -2723,9 +2957,15 @@ impl App {
|
||||
for (disp_row, &ri) in self.view_idx.iter().enumerate() {
|
||||
let r = &self.rows[ri];
|
||||
for (j, c) in cols.iter().enumerate() {
|
||||
// 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) {
|
||||
continue;
|
||||
}
|
||||
let want = c.cell(r);
|
||||
let raw = t.dvlc_get_cell(disp_row, j).unwrap_or_default();
|
||||
let got = if matches!(c, Column::Hashrate | Column::Hashboards | Column::TotalChips | Column::ChipTemp | Column::Cooling | Column::Locked | Column::Error | Column::Status | Column::Firmware) {
|
||||
let got = if matches!(c, Column::Hashrate | Column::TotalChips | Column::ChipTemp | Column::Cooling | Column::Error | Column::Status | Column::Firmware) {
|
||||
decode_segments_plain(&raw)
|
||||
} else {
|
||||
raw
|
||||
@@ -2743,7 +2983,6 @@ impl App {
|
||||
|
||||
// 4. Independent spot-checks by IP against the known hardware output.
|
||||
let ip_col = cols.iter().position(|c| *c == Column::Ip);
|
||||
let status_col = cols.iter().position(|c| *c == Column::Status);
|
||||
let hr_col = cols.iter().position(|c| *c == Column::Hashrate);
|
||||
let find = |ip: &str| -> Option<usize> {
|
||||
self.view_idx.iter().position(|&ri| self.rows[ri].ip == ip)
|
||||
@@ -2756,9 +2995,27 @@ impl App {
|
||||
None => String::new(),
|
||||
}
|
||||
};
|
||||
if let (Some(row), Some(_)) = (find("10.255.1.149"), status_col) {
|
||||
check("S21 Pro (.149) is slow", cell(row, status_col) == "slow",
|
||||
format!("status=\"{}\"", cell(row, status_col)));
|
||||
// Status is a model property; the Status column is not in the default
|
||||
// view (round 11 #12), so verify it straight from the row rather than a
|
||||
// displayed cell.
|
||||
let status_of = |row: usize| -> &'static str { self.rows[self.view_idx[row]].status() };
|
||||
// Icon columns (round 11 #10/#13): the store carries shape sentinels
|
||||
// (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);
|
||||
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:?}"));
|
||||
}
|
||||
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",
|
||||
raw.contains('\u{0002}'), format!("cell={raw:?}"));
|
||||
}
|
||||
if let Some(row) = find("10.255.1.149") {
|
||||
check("S21 Pro (.149) is slow", status_of(row) == "slow",
|
||||
format!("status=\"{}\"", status_of(row)));
|
||||
check("S21 Pro (.149) hashrate == 60.0T/200T",
|
||||
cell(row, hr_col) == "60.0T/200T",
|
||||
format!("hashrate=\"{}\"", cell(row, hr_col)));
|
||||
@@ -2766,16 +3023,16 @@ impl App {
|
||||
check("S21 Pro (.149) present", false, "row not found".into());
|
||||
}
|
||||
if let Some(row) = find("10.255.1.112") {
|
||||
check("S17 (.112) is not hashing", cell(row, status_col) == "not hashing",
|
||||
format!("status=\"{}\"", cell(row, status_col)));
|
||||
check("S17 (.112) is not hashing", status_of(row) == "not hashing",
|
||||
format!("status=\"{}\"", status_of(row)));
|
||||
check("S17 (.112) blank hashrate", cell(row, hr_col).is_empty(),
|
||||
format!("hashrate=\"{}\"", cell(row, hr_col)));
|
||||
} else {
|
||||
check("S17 (.112) present", false, "row not found".into());
|
||||
}
|
||||
if let Some(row) = find("10.255.1.115") {
|
||||
check("WardenOS-dev (.115) is paused", cell(row, status_col) == "paused",
|
||||
format!("status=\"{}\"", cell(row, status_col)));
|
||||
check("WardenOS-dev (.115) is paused", status_of(row) == "paused",
|
||||
format!("status=\"{}\"", status_of(row)));
|
||||
} else {
|
||||
check("WardenOS-dev (.115) present", false, "row not found".into());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
Subject: [PATCH 0003] antminer: recognise VNish short control-board platforms (CV, XIL)
|
||||
|
||||
Round-11 #5 -- VNish reports the control board in short form via /api/v1/info
|
||||
"platform": "cv" (CVITek), "xil" (Xilinx), "aml" (AMLogic). asic-rs's
|
||||
AntMinerControlBoard::parse matched the full names (CVITEK, XILINX) but not the
|
||||
short "CV"/"XIL", so VNish CVITek and Xilinx boards showed a blank control board
|
||||
(the "can't scan XIL or CVITek boards" bug). Add the short forms. Verified live:
|
||||
S19k Pro platform "cv" -> CVITek, S19 platform "xil" -> Xilinx.
|
||||
|
||||
diff --git a/vendor/asic-rs-makes-antminer/src/hardware.rs b/vendor/asic-rs-makes-antminer/src/hardware.rs
|
||||
index 41a73240..aa0923c8 100644
|
||||
--- a/vendor/asic-rs-makes-antminer/src/hardware.rs
|
||||
+++ b/vendor/asic-rs-makes-antminer/src/hardware.rs
|
||||
@@ -268,11 +268,13 @@ impl AntMinerControlBoard {
|
||||
.collect::<String>();
|
||||
|
||||
match compact.as_str() {
|
||||
- "XILINX" => Some(Self::Xilinx),
|
||||
+ // "XIL" is VNish's short platform form for a Xilinx control board.
|
||||
+ "XILINX" | "XIL" => Some(Self::Xilinx),
|
||||
"BBB" | "BBCTRL" | "BB" | "BEAGLEBONE" | "BEAGLEBONEBLACK" => {
|
||||
Some(Self::BeagleBoneBlack)
|
||||
}
|
||||
- "CVITEK" | "CVCTRL" => Some(Self::CVITek),
|
||||
+ // "CV" is VNish's short platform form for a CVITek control board.
|
||||
+ "CVITEK" | "CVCTRL" | "CV" => Some(Self::CVITek),
|
||||
"AMLOGIC" | "AML" => Some(Self::AMLogic),
|
||||
"AMCB07" => Some(Self::Xilinx), // Mara FW
|
||||
"ZYNQ7007" => Some(Self::Xilinx),
|
||||
@@ -0,0 +1,65 @@
|
||||
Subject: [PATCH 0004] whatsminer v1: control-board fallback + optional ALLWINNER_ prefix
|
||||
|
||||
Round-11 #5 -- older M30S firmware (< 2022.7.29, the v1 backend) often omits
|
||||
"CB Platform" from the summary RPC, and its parse mandatorily stripped an
|
||||
"ALLWINNER_" prefix (strip_prefix(..)? -> None when absent), so those units
|
||||
showed a blank control board. Add get_version /Msg/platform (the source v2 uses)
|
||||
as a fallback location, and make the ALLWINNER_ strip optional. Verified live:
|
||||
M30S+ VE40 (fw 20220422, v1) blank -> H6OS.
|
||||
|
||||
diff --git a/vendor/asic-rs-firmwares-whatsminer/src/backends/v1/mod.rs b/vendor/asic-rs-firmwares-whatsminer/src/backends/v1/mod.rs
|
||||
index b4a27db8..f95a22ae 100644
|
||||
--- a/vendor/asic-rs-firmwares-whatsminer/src/backends/v1/mod.rs
|
||||
+++ b/vendor/asic-rs-firmwares-whatsminer/src/backends/v1/mod.rs
|
||||
@@ -131,14 +131,28 @@ impl GetDataLocations for WhatsMinerV1 {
|
||||
tag: None,
|
||||
},
|
||||
)],
|
||||
- DataField::ControlBoardVersion => vec![(
|
||||
- RPC_SUMMARY,
|
||||
- DataExtractor {
|
||||
- func: get_by_pointer,
|
||||
- key: Some("/SUMMARY/0/CB Platform"),
|
||||
- tag: None,
|
||||
- },
|
||||
- )],
|
||||
+ DataField::ControlBoardVersion => vec![
|
||||
+ (
|
||||
+ RPC_SUMMARY,
|
||||
+ DataExtractor {
|
||||
+ func: get_by_pointer,
|
||||
+ key: Some("/SUMMARY/0/CB Platform"),
|
||||
+ tag: None,
|
||||
+ },
|
||||
+ ),
|
||||
+ // Older M30S firmware (< 2022.7.29, so this v1 backend) often omits
|
||||
+ // "CB Platform" from summary but still reports the board under
|
||||
+ // get_version /Msg/platform (the source v2 uses). Fall back to it so
|
||||
+ // those units don't show a blank control board.
|
||||
+ (
|
||||
+ RPC_GET_VERSION,
|
||||
+ DataExtractor {
|
||||
+ func: get_by_pointer,
|
||||
+ key: Some("/Msg/platform"),
|
||||
+ tag: None,
|
||||
+ },
|
||||
+ ),
|
||||
+ ],
|
||||
DataField::TuningTarget => vec![(
|
||||
RPC_SUMMARY,
|
||||
DataExtractor {
|
||||
@@ -285,8 +299,12 @@ impl GetControlBoardVersion for WhatsMinerV1 {
|
||||
) -> Option<MinerControlBoard> {
|
||||
data.extract::<String>(DataField::ControlBoardVersion)
|
||||
.and_then(|s| {
|
||||
- WhatsMinerControlBoard::parse(s.to_uppercase().strip_prefix("ALLWINNER_")?)
|
||||
- .map(|cb| cb.into())
|
||||
+ // The "ALLWINNER_" prefix is optional: summary's CB Platform carries
|
||||
+ // it (e.g. "ALLWINNER_H6"), but the get_version /Msg/platform fallback
|
||||
+ // does not (e.g. "H6OS"). Strip it only when present.
|
||||
+ let up = s.to_uppercase();
|
||||
+ let board = up.strip_prefix("ALLWINNER_").unwrap_or(&up);
|
||||
+ WhatsMinerControlBoard::parse(board).map(|cb| cb.into())
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
Subject: [PATCH 0005] vnish: surface the partner build name in the firmware version
|
||||
|
||||
Round-11 #6b/#11 -- VNish /api/v1/info carries a partner/reseller "build_name"
|
||||
("WildRose", "vnishreturn", ...) alongside "fw_version"; it is shown in the
|
||||
Hashcore toolkit but asic-rs did not expose it. Point the FirmwareVersion
|
||||
extractor at /build_name and combine it with the /fw_version number (still on
|
||||
ApiVersion) in parse_firmware_version, so firmware_version reads "<build>
|
||||
<version>", e.g. "WildRose 1.2.7". Applies to both the v1_2_0 and v1_3_0
|
||||
backends. Verified live: S19j Pro -> "WildRose 1.2.7", S19k Pro -> "vnishreturn 1.3.5".
|
||||
|
||||
diff --git a/vendor/asic-rs-firmwares-vnish/src/backends/v1_2_0/mod.rs b/vendor/asic-rs-firmwares-vnish/src/backends/v1_2_0/mod.rs
|
||||
index 4cc1434a..e734a03e 100644
|
||||
--- a/vendor/asic-rs-firmwares-vnish/src/backends/v1_2_0/mod.rs
|
||||
+++ b/vendor/asic-rs-firmwares-vnish/src/backends/v1_2_0/mod.rs
|
||||
@@ -179,11 +179,15 @@ impl GetDataLocations for VnishV120 {
|
||||
tag: None,
|
||||
},
|
||||
)],
|
||||
+ // The partner/reseller build name ("WildRose", "vnishreturn", ...) --
|
||||
+ // combined with the version number in parse_firmware_version so the FW
|
||||
+ // Version column shows e.g. "WildRose 1.3.5". ApiVersion still carries
|
||||
+ // the bare /fw_version.
|
||||
DataField::FirmwareVersion => vec![(
|
||||
WEB_INFO,
|
||||
DataExtractor {
|
||||
func: get_by_pointer,
|
||||
- key: Some("/fw_version"),
|
||||
+ key: Some("/build_name"),
|
||||
tag: None,
|
||||
},
|
||||
)],
|
||||
@@ -415,7 +419,20 @@ impl GetApiVersion for VnishV120 {
|
||||
|
||||
impl GetFirmwareVersion for VnishV120 {
|
||||
fn parse_firmware_version(&self, data: &HashMap<DataField, Value>) -> Option<String> {
|
||||
- data.extract::<String>(DataField::FirmwareVersion)
|
||||
+ // FirmwareVersion carries /build_name (the partner build), ApiVersion the
|
||||
+ // /fw_version number; show "<build> <version>" when both are present, else
|
||||
+ // whichever is available.
|
||||
+ let build = data
|
||||
+ .extract::<String>(DataField::FirmwareVersion)
|
||||
+ .filter(|b| !b.is_empty());
|
||||
+ let version = data
|
||||
+ .extract::<String>(DataField::ApiVersion)
|
||||
+ .filter(|v| !v.is_empty());
|
||||
+ match (build, version) {
|
||||
+ (Some(b), Some(v)) => Some(format!("{b} {v}")),
|
||||
+ (Some(b), None) => Some(b),
|
||||
+ (None, v) => v,
|
||||
+ }
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/vendor/asic-rs-firmwares-vnish/src/backends/v1_3_0/mod.rs b/vendor/asic-rs-firmwares-vnish/src/backends/v1_3_0/mod.rs
|
||||
index 6975d9e5..0a5d694e 100644
|
||||
--- a/vendor/asic-rs-firmwares-vnish/src/backends/v1_3_0/mod.rs
|
||||
+++ b/vendor/asic-rs-firmwares-vnish/src/backends/v1_3_0/mod.rs
|
||||
@@ -179,11 +179,13 @@ impl GetDataLocations for VnishV130 {
|
||||
tag: None,
|
||||
},
|
||||
)],
|
||||
+ // Partner/reseller build name; combined with the version number in
|
||||
+ // parse_firmware_version (FW Version shows e.g. "WildRose 1.3.5").
|
||||
DataField::FirmwareVersion => vec![(
|
||||
WEB_INFO,
|
||||
DataExtractor {
|
||||
func: get_by_pointer,
|
||||
- key: Some("/fw_version"),
|
||||
+ key: Some("/build_name"),
|
||||
tag: None,
|
||||
},
|
||||
)],
|
||||
@@ -423,7 +425,19 @@ impl GetApiVersion for VnishV130 {
|
||||
|
||||
impl GetFirmwareVersion for VnishV130 {
|
||||
fn parse_firmware_version(&self, data: &HashMap<DataField, Value>) -> Option<String> {
|
||||
- data.extract::<String>(DataField::FirmwareVersion)
|
||||
+ // FirmwareVersion carries /build_name (partner build), ApiVersion the
|
||||
+ // /fw_version number; show "<build> <version>" when both are present.
|
||||
+ let build = data
|
||||
+ .extract::<String>(DataField::FirmwareVersion)
|
||||
+ .filter(|b| !b.is_empty());
|
||||
+ let version = data
|
||||
+ .extract::<String>(DataField::ApiVersion)
|
||||
+ .filter(|v| !v.is_empty());
|
||||
+ match (build, version) {
|
||||
+ (Some(b), Some(v)) => Some(format!("{b} {v}")),
|
||||
+ (Some(b), None) => Some(b),
|
||||
+ (None, v) => v,
|
||||
+ }
|
||||
}
|
||||
}
|
||||
|
||||
+50
-1
@@ -10,7 +10,7 @@
|
||||
+pub use widgets::*;
|
||||
--- a/src/widgets.rs
|
||||
+++ b/src/widgets.rs
|
||||
@@ -0,0 +1,745 @@
|
||||
@@ -0,0 +1,794 @@
|
||||
+// widgets.rs — alkane-toolkit extension: Rust bindings for the widget bridge
|
||||
+// in cpp_src/widgets_bridge.cpp. Handles are opaque pointers owned by the
|
||||
+// wxWidgets object tree (parents own children; nothing to free in Rust).
|
||||
@@ -36,6 +36,8 @@
|
||||
+ pub fn wxbr_set_sizer(win: *mut c_void, sizer: *mut c_void);
|
||||
+ pub fn wxbr_layout(win: *mut c_void);
|
||||
+ pub fn wxbr_sizer_detach(sizer: *mut c_void, win: *mut c_void);
|
||||
+ pub fn wxbr_sizer_show(sizer: *mut c_void, win: *mut c_void, show: c_int);
|
||||
+ pub fn wxbr_bind_size(win: *mut c_void);
|
||||
+ pub fn wxbr_fit(win: *mut c_void);
|
||||
+ pub fn wxbr_set_min_size(win: *mut c_void, w: c_int, h: c_int);
|
||||
+ pub fn wxbr_static_text(parent: *mut c_void, label: *const c_char) -> *mut c_void;
|
||||
@@ -90,6 +92,8 @@
|
||||
+ pub fn wxbr_apply_zebra_css(r: c_int, g: c_int, b: c_int);
|
||||
+ pub fn wxbr_rearrange_list(parent: *mut c_void, n: c_int, order: *const c_int, items: *const *const c_char) -> *mut c_void;
|
||||
+ pub fn wxbr_rearrange_get_order(win: *mut c_void, buf: *mut c_int, cap: c_int) -> c_int;
|
||||
+ pub fn wxbr_reorder_list(parent: *mut c_void, n: c_int, order: *const c_int, items: *const *const c_char) -> *mut c_void;
|
||||
+ pub fn wxbr_reorder_get_order(win: *mut c_void, buf: *mut c_int, cap: c_int) -> c_int;
|
||||
+ pub fn wxbr_menu_new() -> *mut c_void;
|
||||
+ pub fn wxbr_menu_append(menu: *mut c_void, id: c_int, label: *const c_char);
|
||||
+ pub fn wxbr_menu_append_separator(menu: *mut c_void);
|
||||
@@ -112,6 +116,7 @@
|
||||
+ pub fn wxbr_choice_get_selection(win: *mut c_void) -> c_int;
|
||||
+ pub fn wxbr_choice_set_selection(win: *mut c_void, i: c_int);
|
||||
+ pub fn wxbr_media_button(parent: *mut c_void, id: c_int, kind: c_int, r: c_int, g: c_int, b: c_int) -> *mut c_void;
|
||||
+ pub fn wxbr_svg_icon(parent: *mut c_void, svg: *const c_char, w: c_int, h: c_int) -> *mut c_void;
|
||||
+ pub fn wxbr_bind_sys_colour(win: *mut c_void);
|
||||
+ pub fn wxbr_destroy(win: *mut c_void);
|
||||
+ pub fn wxbr_destroy_children(win: *mut c_void);
|
||||
@@ -154,6 +159,8 @@
|
||||
+ SysColour,
|
||||
+ Deferred,
|
||||
+ DvlcHeaderRightClick,
|
||||
+ /// Window resized; p1 = new client width, p2 = new client height.
|
||||
+ Sized,
|
||||
+}
|
||||
+
|
||||
+impl WxEventKind {
|
||||
@@ -173,6 +180,7 @@
|
||||
+ 13 => WxEventKind::SysColour,
|
||||
+ 14 => WxEventKind::Deferred,
|
||||
+ 15 => WxEventKind::DvlcHeaderRightClick,
|
||||
+ 16 => WxEventKind::Sized,
|
||||
+ _ => return None,
|
||||
+ })
|
||||
+ }
|
||||
@@ -321,6 +329,18 @@
|
||||
+ unsafe { notsafe::wxbr_sizer_detach(self.0, win.0) }
|
||||
+ }
|
||||
+
|
||||
+ /// Show or hide a child window in this sizer (self = a sizer), reclaiming or
|
||||
+ /// restoring its space on the next `layout()`.
|
||||
+ pub fn sizer_show(&self, win: Widget, show: bool) {
|
||||
+ unsafe { notsafe::wxbr_sizer_show(self.0, win.0, show as c_int) }
|
||||
+ }
|
||||
+
|
||||
+ /// Emit `WxEventKind::Sized` (p1 = width, p2 = height) whenever this window
|
||||
+ /// is resized.
|
||||
+ pub fn bind_size(&self) {
|
||||
+ unsafe { notsafe::wxbr_bind_size(self.0) }
|
||||
+ }
|
||||
+
|
||||
+ pub fn fit(&self, win: Widget) {
|
||||
+ unsafe { notsafe::wxbr_fit(win.0) }
|
||||
+ }
|
||||
@@ -626,6 +646,27 @@
|
||||
+ buf.into_iter().take(n.max(0) as usize).collect()
|
||||
+ }
|
||||
+
|
||||
+ /// A checkable, multi-select, drag-reorderable column list (round 11 #4):
|
||||
+ /// like `rearrange_list` but with no up/down buttons -- rows are reordered by
|
||||
+ /// dragging, and selected with shift/ctrl-click or a rubber-band drag. Same
|
||||
+ /// `[idx | !idx]` order encoding.
|
||||
+ pub fn reorder_list(parent: Widget, order: &[i32], items: &[&str]) -> Widget {
|
||||
+ let cs: Vec<CString> = items.iter().map(|s| CString::new(*s).unwrap_or_default()).collect();
|
||||
+ let ptrs: Vec<*const c_char> = cs.iter().map(|c| c.as_ptr()).collect();
|
||||
+ Widget(unsafe {
|
||||
+ notsafe::wxbr_reorder_list(parent.0, items.len() as c_int, order.as_ptr(), ptrs.as_ptr())
|
||||
+ })
|
||||
+ }
|
||||
+
|
||||
+ /// Read back the current order from a `reorder_list` (same encoding).
|
||||
+ pub fn reorder_get_order(&self) -> Vec<i32> {
|
||||
+ let mut buf = vec![0i32; 4096];
|
||||
+ let n = unsafe {
|
||||
+ notsafe::wxbr_reorder_get_order(self.0, buf.as_mut_ptr(), buf.len() as c_int)
|
||||
+ };
|
||||
+ buf.into_iter().take(n.max(0) as usize).collect()
|
||||
+ }
|
||||
+
|
||||
+ // ---- popup menu ----
|
||||
+
|
||||
+ pub fn menu_new() -> Widget {
|
||||
@@ -740,6 +781,14 @@
|
||||
+ })
|
||||
+ }
|
||||
+
|
||||
+ /// Render an SVG string (recolour it first -- its fill must be an explicit
|
||||
+ /// colour, not "currentColor") into a static-bitmap icon at `w`x`h` px
|
||||
+ /// (round 11 #15).
|
||||
+ pub fn svg_icon(parent: Widget, svg: &str, w: i32, h: i32) -> Widget {
|
||||
+ let c = CString::new(svg).unwrap_or_default();
|
||||
+ Widget(unsafe { notsafe::wxbr_svg_icon(parent.0, c.as_ptr(), w as c_int, h as c_int) })
|
||||
+ }
|
||||
+
|
||||
+ /// Listen for OS light/dark theme changes on this window (emits `SysColour`).
|
||||
+ pub fn bind_sys_colour(&self) {
|
||||
+ unsafe { notsafe::wxbr_bind_sys_colour(self.0) }
|
||||
|
||||
+338
-11
@@ -1,6 +1,6 @@
|
||||
--- a/cpp_src/widgets_bridge.cpp
|
||||
+++ b/cpp_src/widgets_bridge.cpp
|
||||
@@ -0,0 +1,1133 @@
|
||||
@@ -0,0 +1,1460 @@
|
||||
+// widgets_bridge.cpp — alkane-toolkit extension to wx-rs
|
||||
+// Adds the widget/event surface the toolkit UI needs on top of the upstream
|
||||
+// render-callback bridge (which is kept untouched).
|
||||
@@ -22,10 +22,12 @@
|
||||
+#include <wx/utils.h>
|
||||
+#include <wx/app.h>
|
||||
+#include <wx/rearrangectrl.h>
|
||||
+#include <wx/listctrl.h>
|
||||
+#include <wx/menu.h>
|
||||
+#include <wx/choice.h>
|
||||
+#include <wx/bmpbuttn.h>
|
||||
+#include <wx/bitmap.h>
|
||||
+#include <wx/bmpbndl.h>
|
||||
+#include <wx/image.h>
|
||||
+#include <wx/dcmemory.h>
|
||||
+#include <wx/dcgraph.h>
|
||||
@@ -69,6 +71,7 @@
|
||||
+ WxEV_SYS_COLOUR = 13,
|
||||
+ WxEV_DEFERRED = 14,
|
||||
+ WxEV_DVLC_HEADER_RIGHT_CLICK = 15,
|
||||
+ WxEV_SIZE = 16, // p1 = new client width, p2 = new client height
|
||||
+};
|
||||
+
|
||||
+// A list store that carries an optional per-row foreground colour plus an
|
||||
@@ -149,6 +152,57 @@
|
||||
+ return segs;
|
||||
+}
|
||||
+
|
||||
+// Shape sentinels a segment's text may carry instead of glyphs (round 11
|
||||
+// #10/#13): a single control char selects a small vector icon drawn in the
|
||||
+// segment's colour. These are control characters (never emoji/pictographs) so
|
||||
+// they are safe in source and independent of the font's glyph coverage.
|
||||
+const wxUniChar SHAPE_DOT = 0x07; // filled status dot (hashboards, locate light)
|
||||
+const wxUniChar SHAPE_LOCK = 0x02; // closed padlock (locked / view-only)
|
||||
+const wxUniChar SHAPE_UNLOCK = 0x03; // open padlock (unlocked / writable)
|
||||
+const int SHAPE_ADVANCE = 15; // horizontal space one shape occupies
|
||||
+
|
||||
+bool IsShapeSentinel(const wxString& s, wxUniChar& out) {
|
||||
+ if (s.length() != 1) return false;
|
||||
+ wxUniChar c = s[0];
|
||||
+ if (c == SHAPE_DOT || c == SHAPE_LOCK || c == SHAPE_UNLOCK) {
|
||||
+ out = c;
|
||||
+ return true;
|
||||
+ }
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
+// Draw one shape sentinel, centred in the SHAPE_ADVANCE-wide slot at x.
|
||||
+void DrawShape(wxDC* dc, wxUniChar shape, wxCoord x, const wxRect& cell, const wxColour& colour) {
|
||||
+ int cy = cell.y + cell.height / 2;
|
||||
+ int cx = x + SHAPE_ADVANCE / 2;
|
||||
+ if (shape == SHAPE_DOT) {
|
||||
+ dc->SetPen(*wxTRANSPARENT_PEN);
|
||||
+ dc->SetBrush(wxBrush(colour));
|
||||
+ dc->DrawCircle(cx, cy, 4);
|
||||
+ return;
|
||||
+ }
|
||||
+ // Padlock: a filled body with a staple shackle above. The colour carries the
|
||||
+ // state (green = unlocked, red = locked); the shackle is drawn ajar when open.
|
||||
+ bool open = (shape == SHAPE_UNLOCK);
|
||||
+ int bw = 9, bh = 7;
|
||||
+ int bx = cx - bw / 2;
|
||||
+ int by = cy - bh / 2 + 1;
|
||||
+ dc->SetPen(*wxTRANSPARENT_PEN);
|
||||
+ dc->SetBrush(wxBrush(colour));
|
||||
+ dc->DrawRoundedRectangle(bx, by, bw, bh, 1.5);
|
||||
+ dc->SetBrush(*wxTRANSPARENT_BRUSH);
|
||||
+ dc->SetPen(wxPen(colour, 2));
|
||||
+ int sr = 3;
|
||||
+ int legTop = by - sr - 1;
|
||||
+ int lx = cx - sr, rx = cx + sr;
|
||||
+ dc->DrawLine(lx, by, lx, legTop); // left leg
|
||||
+ dc->DrawLine(lx, legTop, rx, legTop); // top bar
|
||||
+ if (open)
|
||||
+ dc->DrawLine(rx, legTop, rx, legTop + sr); // ajar: right leg lifted
|
||||
+ else
|
||||
+ dc->DrawLine(rx, legTop, rx, by); // closed: right leg to body
|
||||
+}
|
||||
+
|
||||
+} // namespace
|
||||
+
|
||||
+class SegmentRenderer : public wxDataViewCustomRenderer {
|
||||
@@ -168,12 +222,63 @@
|
||||
+
|
||||
+ bool Render(wxRect cell, wxDC* dc, int state) override {
|
||||
+ bool selected = (state & wxDATAVIEW_CELL_SELECTED) != 0;
|
||||
+ // wxGTK does NOT paint a custom renderer's cell background, so the per-row
|
||||
+ // (zebra) background set via GetAttrByRow shows on the native columns but
|
||||
+ // not here -- the zebra looked inconsistent across columns. Paint it here so
|
||||
+ // every column stripes the same (skip when the row is selected: the control
|
||||
+ // already drew the selection highlight).
|
||||
+ if (!selected && GetAttr().HasBackgroundColour()) {
|
||||
+ dc->SetBrush(wxBrush(GetAttr().GetBackgroundColour()));
|
||||
+ dc->SetPen(*wxTRANSPARENT_PEN);
|
||||
+ // The `cell` rect wx hands a custom renderer is shrunk to the content
|
||||
+ // (text/shape) size in BOTH dimensions by the alignment logic, so filling
|
||||
+ // it alone left the zebra covering only a content-sized band -- and since
|
||||
+ // shape cells (dots) and text cells have different content heights, the
|
||||
+ // stripes ended up unequal across columns. Fill an over-sized rect (full
|
||||
+ // column width, and well beyond the row vertically); wxGTK clips the cell
|
||||
+ // DC to the real cell background area, so this lands exactly on the full
|
||||
+ // row height of this cell without bleeding into neighbours (round 11 #1/#3).
|
||||
+ wxRect bg = cell;
|
||||
+ if (wxDataViewColumn* owner = const_cast<SegmentRenderer*>(this)->GetOwner()) {
|
||||
+ int cw = owner->GetWidth();
|
||||
+ if (cw > bg.width) bg.width = cw;
|
||||
+ }
|
||||
+ bg.y -= 40;
|
||||
+ bg.height += 80;
|
||||
+ dc->DrawRectangle(bg);
|
||||
+ }
|
||||
+ wxColour highlight = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT);
|
||||
+ wxColour plain = GetAttr().HasColour()
|
||||
+ ? GetAttr().GetColour()
|
||||
+ : wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
|
||||
+ // An uncoloured (default) segment -- the "/" in a combined cell, a "Stock"
|
||||
+ // firmware family, etc. -- must dim exactly like the native columns when the
|
||||
+ // top-level window is backdropped. wxGTK dims a native cell's text via the
|
||||
+ // widget's themed state colour, but a custom renderer's DC keeps the normal
|
||||
+ // WINDOWTEXT, so ask the tree widget for its themed text colour AT ITS
|
||||
+ // CURRENT STATE (which carries GTK_STATE_FLAG_BACKDROP while unfocused) and
|
||||
+ // use that; off-GTK (or if the widget isn't reachable) fall back to the DC
|
||||
+ // then the system colour (round 11 #1/#7).
|
||||
+ wxColour plain;
|
||||
+ if (GetAttr().HasColour()) {
|
||||
+ plain = GetAttr().GetColour();
|
||||
+ } else {
|
||||
+ plain = ThemedTextColour();
|
||||
+ }
|
||||
+ if (!plain.IsOk()) {
|
||||
+ plain = dc->GetTextForeground();
|
||||
+ }
|
||||
+ if (!plain.IsOk()) {
|
||||
+ plain = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
|
||||
+ }
|
||||
+ wxCoord x = cell.x;
|
||||
+ for (const ColorSegment& seg : ParseColorSegments(m_value)) {
|
||||
+ // Shape segments (status dots, access padlock) keep their own semantic
|
||||
+ // colour even on a selected row, so the green/red reading survives the
|
||||
+ // selection highlight (round 11 #10/#13).
|
||||
+ wxUniChar shape;
|
||||
+ if (IsShapeSentinel(seg.text, shape)) {
|
||||
+ DrawShape(dc, shape, x, cell, seg.has_colour ? seg.colour : plain);
|
||||
+ x += SHAPE_ADVANCE;
|
||||
+ continue;
|
||||
+ }
|
||||
+ if (seg.text.IsEmpty()) continue;
|
||||
+ dc->SetTextForeground(selected ? highlight : (seg.has_colour ? seg.colour : plain));
|
||||
+ wxSize extent = dc->GetTextExtent(seg.text);
|
||||
@@ -185,14 +290,60 @@
|
||||
+ }
|
||||
+
|
||||
+ wxSize GetSize() const override {
|
||||
+ wxString plain;
|
||||
+ for (const ColorSegment& seg : ParseColorSegments(m_value)) plain += seg.text;
|
||||
+ wxSize sz = GetTextExtent(plain);
|
||||
+ if (sz.GetWidth() < 1) sz.SetWidth(1);
|
||||
+ return sz;
|
||||
+ int w = 0, h = 0;
|
||||
+ for (const ColorSegment& seg : ParseColorSegments(m_value)) {
|
||||
+ wxUniChar shape;
|
||||
+ if (IsShapeSentinel(seg.text, shape)) {
|
||||
+ w += SHAPE_ADVANCE;
|
||||
+ if (h < 12) h = 12;
|
||||
+ continue;
|
||||
+ }
|
||||
+ wxSize e = GetTextExtent(seg.text);
|
||||
+ w += e.GetWidth();
|
||||
+ if (e.GetHeight() > h) h = e.GetHeight();
|
||||
+ }
|
||||
+ if (w < 1) w = 1;
|
||||
+ if (h < 1) h = 1;
|
||||
+ return wxSize(w, h);
|
||||
+ }
|
||||
+
|
||||
+ private:
|
||||
+ // The owning tree widget's themed text colour at its current GTK state, so
|
||||
+ // uncoloured segments dim on window-backdrop like the native columns
|
||||
+ // (round 11 #1/#7). Returns an invalid colour off wxGTK or when the widget is
|
||||
+ // unreachable, so the caller falls back to the DC / system colour.
|
||||
+ wxColour ThemedTextColour() const {
|
||||
+#ifdef __WXGTK__
|
||||
+ wxDataViewColumn* col = const_cast<SegmentRenderer*>(this)->GetOwner();
|
||||
+ if (col && col->GetOwner()) {
|
||||
+ GtkWidget* tv = col->GetOwner()->GtkGetTreeView();
|
||||
+ if (tv && GTK_IS_WIDGET(tv)) {
|
||||
+ // The treeview's own state flags do NOT reliably carry
|
||||
+ // GTK_STATE_FLAG_BACKDROP (that lives on the toplevel), so query the
|
||||
+ // toplevel window's active state directly and force BACKDROP onto the
|
||||
+ // style-context state when it is inactive. Then the themed cell text
|
||||
+ // colour matches what GTK paints on the native columns when the window
|
||||
+ // loses focus (round 11 #1/#7).
|
||||
+ GtkWidget* top = gtk_widget_get_toplevel(tv);
|
||||
+ bool active = GTK_IS_WINDOW(top) && gtk_window_is_active(GTK_WINDOW(top));
|
||||
+ GtkStyleContext* ctx = gtk_widget_get_style_context(tv);
|
||||
+ GtkStateFlags st = gtk_widget_get_state_flags(tv);
|
||||
+ st = active ? (GtkStateFlags)(st & ~GTK_STATE_FLAG_BACKDROP)
|
||||
+ : (GtkStateFlags)(st | GTK_STATE_FLAG_BACKDROP);
|
||||
+ GdkRGBA c;
|
||||
+ gtk_style_context_save(ctx);
|
||||
+ gtk_style_context_set_state(ctx, st);
|
||||
+ gtk_style_context_get_color(ctx, gtk_style_context_get_state(ctx), &c);
|
||||
+ gtk_style_context_restore(ctx);
|
||||
+ return wxColour((unsigned char)(c.red * 255.0 + 0.5),
|
||||
+ (unsigned char)(c.green * 255.0 + 0.5),
|
||||
+ (unsigned char)(c.blue * 255.0 + 0.5));
|
||||
+ }
|
||||
+ }
|
||||
+#endif
|
||||
+ return wxColour();
|
||||
+ }
|
||||
+
|
||||
+ wxString m_value;
|
||||
+};
|
||||
+
|
||||
@@ -274,6 +425,23 @@
|
||||
+ ((wxSizer*)sizer)->Detach((wxWindow*)win);
|
||||
+}
|
||||
+
|
||||
+// Show or hide a sizer-managed child window AND reclaim (or restore) its space
|
||||
+// on the next Layout(). Used to collapse the wide KPI cards when the window is
|
||||
+// too narrow (round 11 #2).
|
||||
+void wxbr_sizer_show(void* sizer, void* win, int show) {
|
||||
+ ((wxSizer*)sizer)->Show((wxWindow*)win, show != 0);
|
||||
+}
|
||||
+
|
||||
+// Emit WxEV_SIZE (p1 = new client width, p2 = height) whenever this window is
|
||||
+// resized. e.Skip() keeps the normal sizer layout running (round 11 #2).
|
||||
+void wxbr_bind_size(void* win) {
|
||||
+ ((wxWindow*)win)->Bind(wxEVT_SIZE, [](wxSizeEvent& e) {
|
||||
+ if (g_widget_event) g_widget_event(WxEV_SIZE, (long)e.GetSize().GetWidth(),
|
||||
+ (long)e.GetSize().GetHeight());
|
||||
+ e.Skip();
|
||||
+ });
|
||||
+}
|
||||
+
|
||||
+void wxbr_fit(void* win) { ((wxWindow*)win)->Fit(); }
|
||||
+
|
||||
+void wxbr_set_min_size(void* win, int w, int h) {
|
||||
@@ -384,12 +552,31 @@
|
||||
+// ---- check list box ---------------------------------------------------------
|
||||
+
|
||||
+void* wxbr_check_list_box(void* parent) {
|
||||
+ // wxLB_EXTENDED so several rows can be selected at once (ctrl/shift-click and
|
||||
+ // rubber-band drag, native to wxListBox); a checkbox toggle on any selected
|
||||
+ // row then applies to every selected row (see the handler below). This is the
|
||||
+ // Excel-style batch-check the filter menu needs (round 12 #7).
|
||||
+ wxCheckListBox* clb = new wxCheckListBox((wxWindow*)parent, wxID_ANY,
|
||||
+ wxDefaultPosition, wxSize(-1, -1),
|
||||
+ 0, NULL, wxLB_SINGLE | wxLB_NEEDED_SB);
|
||||
+ 0, NULL, wxLB_EXTENDED | wxLB_NEEDED_SB);
|
||||
+ clb->Bind(wxEVT_CHECKLISTBOX, [clb](wxCommandEvent& e) {
|
||||
+ int idx = e.GetInt();
|
||||
+ // Batch toggle: if the clicked row is part of a multi-row selection, give
|
||||
+ // every selected row the clicked row's new state. Check() does not itself
|
||||
+ // fire wxEVT_CHECKLISTBOX, so there is no recursion.
|
||||
+ wxArrayInt sel;
|
||||
+ clb->GetSelections(sel);
|
||||
+ if (sel.GetCount() > 1) {
|
||||
+ bool inSel = false;
|
||||
+ for (size_t i = 0; i < sel.GetCount(); i++)
|
||||
+ if (sel[i] == idx) { inSel = true; break; }
|
||||
+ if (inSel) {
|
||||
+ bool state = clb->IsChecked(idx);
|
||||
+ for (size_t i = 0; i < sel.GetCount(); i++) clb->Check(sel[i], state);
|
||||
+ }
|
||||
+ }
|
||||
+ if (g_widget_event)
|
||||
+ g_widget_event(WxEV_CLB_TOGGLED, (long)(intptr_t)clb, e.GetInt());
|
||||
+ g_widget_event(WxEV_CLB_TOGGLED, (long)(intptr_t)clb, idx);
|
||||
+ });
|
||||
+ return (void*)clb;
|
||||
+}
|
||||
@@ -962,6 +1149,137 @@
|
||||
+ return n < cap ? n : cap;
|
||||
+}
|
||||
+
|
||||
+// ---- reorder list: a checkable, multi-select, drag-reorderable column list
|
||||
+// for the Columns dialog (round 11 #4). Replaces wxRearrangeCtrl (which had
|
||||
+// up/down buttons and no drag / multi-select). It is a single-column headerless
|
||||
+// wxListCtrl with native checkboxes; rows carry their base model index as item
|
||||
+// data, and the check state + row order encode the same [idx | ~idx] contract
|
||||
+// as wxbr_rearrange_get_order. Selection (shift/ctrl-click, rubber-band drag) is
|
||||
+// native to wxListCtrl. Drag-reorder: on begin-drag we record the selected rows'
|
||||
+// base indices, and on the following mouse-up we move that group to the row
|
||||
+// under the cursor (we never start a real DnD loop, so the mouse-up still
|
||||
+// arrives).
|
||||
+static wxVector<long> g_reorder_drag;
|
||||
+static wxListCtrl* g_reorder_list = nullptr;
|
||||
+
|
||||
+void* wxbr_reorder_list(void* parent, int n, const int* order, const char** items) {
|
||||
+ wxListCtrl* lc = new wxListCtrl((wxWindow*)parent, wxID_ANY, wxDefaultPosition,
|
||||
+ wxSize(-1, 240), wxLC_REPORT | wxLC_NO_HEADER);
|
||||
+ lc->EnableCheckBoxes(true);
|
||||
+ lc->InsertColumn(0, wxT("Column"), wxLIST_FORMAT_LEFT, 260);
|
||||
+ for (int i = 0; i < n; i++) {
|
||||
+ int enc = order[i];
|
||||
+ int idx = enc < 0 ? ~enc : enc;
|
||||
+ long row = lc->InsertItem(i, wxString::FromUTF8(items[idx]));
|
||||
+ lc->SetItemData(row, (long)idx);
|
||||
+ lc->CheckItem(row, enc >= 0);
|
||||
+ }
|
||||
+ // Batch checkbox toggle: checking/unchecking a row that is part of a
|
||||
+ // multi-row selection applies the same state to every selected row, so the
|
||||
+ // user can ctrl/shift-click several columns and show/hide them together
|
||||
+ // (round 12 #7). CheckItem() re-enters this handler, so guard against it.
|
||||
+ auto batchCheck = [lc](long item, bool state) {
|
||||
+ static bool busy = false;
|
||||
+ if (busy) return;
|
||||
+ if (!(lc->GetItemState(item, wxLIST_STATE_SELECTED) & wxLIST_STATE_SELECTED))
|
||||
+ return;
|
||||
+ wxVector<long> sel;
|
||||
+ long it = -1;
|
||||
+ for (;;) {
|
||||
+ it = lc->GetNextItem(it, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
|
||||
+ if (it == -1) break;
|
||||
+ sel.push_back(it);
|
||||
+ }
|
||||
+ if (sel.size() <= 1) return;
|
||||
+ busy = true;
|
||||
+ for (size_t i = 0; i < sel.size(); i++)
|
||||
+ if (sel[i] != item) lc->CheckItem(sel[i], state);
|
||||
+ busy = false;
|
||||
+ };
|
||||
+ lc->Bind(wxEVT_LIST_ITEM_CHECKED, [batchCheck](wxListEvent& e) {
|
||||
+ batchCheck(e.GetIndex(), true);
|
||||
+ });
|
||||
+ lc->Bind(wxEVT_LIST_ITEM_UNCHECKED, [batchCheck](wxListEvent& e) {
|
||||
+ batchCheck(e.GetIndex(), false);
|
||||
+ });
|
||||
+ lc->Bind(wxEVT_LIST_BEGIN_DRAG, [lc](wxListEvent&) {
|
||||
+ g_reorder_drag.clear();
|
||||
+ g_reorder_list = lc;
|
||||
+ long it = -1;
|
||||
+ for (;;) {
|
||||
+ it = lc->GetNextItem(it, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
|
||||
+ if (it == -1) break;
|
||||
+ g_reorder_drag.push_back(lc->GetItemData(it));
|
||||
+ }
|
||||
+ });
|
||||
+ lc->Bind(wxEVT_LEFT_UP, [lc](wxMouseEvent& e) {
|
||||
+ e.Skip();
|
||||
+ if (g_reorder_list != lc || g_reorder_drag.empty()) return;
|
||||
+ struct Row {
|
||||
+ long data;
|
||||
+ bool checked;
|
||||
+ wxString text;
|
||||
+ };
|
||||
+ int count = lc->GetItemCount();
|
||||
+ wxVector<Row> rows;
|
||||
+ for (int i = 0; i < count; i++) {
|
||||
+ Row r;
|
||||
+ r.data = lc->GetItemData(i);
|
||||
+ r.checked = lc->IsItemChecked(i);
|
||||
+ r.text = lc->GetItemText(i);
|
||||
+ rows.push_back(r);
|
||||
+ }
|
||||
+ auto isDragged = [](long d) {
|
||||
+ for (size_t i = 0; i < g_reorder_drag.size(); i++)
|
||||
+ if (g_reorder_drag[i] == d) return true;
|
||||
+ return false;
|
||||
+ };
|
||||
+ int flags = 0;
|
||||
+ long targetRow = lc->HitTest(e.GetPosition(), flags);
|
||||
+ long anchor = (targetRow >= 0 && targetRow < count) ? rows[targetRow].data : -1;
|
||||
+ if (anchor >= 0 && isDragged(anchor)) anchor = -1;
|
||||
+ wxVector<Row> remaining, moved;
|
||||
+ for (size_t i = 0; i < rows.size(); i++) {
|
||||
+ if (isDragged(rows[i].data))
|
||||
+ moved.push_back(rows[i]);
|
||||
+ else
|
||||
+ remaining.push_back(rows[i]);
|
||||
+ }
|
||||
+ int insertAt = (int)remaining.size();
|
||||
+ if (anchor >= 0) {
|
||||
+ for (size_t i = 0; i < remaining.size(); i++)
|
||||
+ if (remaining[i].data == anchor) {
|
||||
+ insertAt = (int)i;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ wxVector<Row> result;
|
||||
+ for (int i = 0; i < insertAt; i++) result.push_back(remaining[i]);
|
||||
+ for (size_t i = 0; i < moved.size(); i++) result.push_back(moved[i]);
|
||||
+ for (int i = insertAt; i < (int)remaining.size(); i++) result.push_back(remaining[i]);
|
||||
+ lc->DeleteAllItems();
|
||||
+ for (size_t i = 0; i < result.size(); i++) {
|
||||
+ long row = lc->InsertItem((long)i, result[i].text);
|
||||
+ lc->SetItemData(row, result[i].data);
|
||||
+ lc->CheckItem(row, result[i].checked);
|
||||
+ }
|
||||
+ g_reorder_drag.clear();
|
||||
+ g_reorder_list = nullptr;
|
||||
+ });
|
||||
+ return (void*)lc;
|
||||
+}
|
||||
+
|
||||
+int wxbr_reorder_get_order(void* win, int* buf, int cap) {
|
||||
+ wxListCtrl* lc = (wxListCtrl*)win;
|
||||
+ int count = lc->GetItemCount();
|
||||
+ int n = 0;
|
||||
+ for (int i = 0; i < count && n < cap; i++) {
|
||||
+ int idx = (int)lc->GetItemData(i);
|
||||
+ buf[n++] = lc->IsItemChecked(i) ? idx : ~idx;
|
||||
+ }
|
||||
+ return n;
|
||||
+}
|
||||
+
|
||||
+// ---- popup menu (right-click context menu) ----------------------------------
|
||||
+
|
||||
+void* wxbr_menu_new() { return (void*)new wxMenu(); }
|
||||
@@ -1054,6 +1372,15 @@
|
||||
+ return (void*)btn;
|
||||
+}
|
||||
+
|
||||
+// Render an SVG (already recoloured on the Rust side -- its fill is an explicit
|
||||
+// #RRGGBB) into a wxStaticBitmap for the KPI cards (round 11 #15). The caller
|
||||
+// passes the target pixel size (w chosen from the SVG aspect ratio, h fixed).
|
||||
+void* wxbr_svg_icon(void* parent, const char* svg, int w, int h) {
|
||||
+ wxBitmapBundle bundle = wxBitmapBundle::FromSVG(svg, wxSize(w, h));
|
||||
+ wxBitmap bmp = bundle.GetBitmap(wxSize(w, h));
|
||||
+ return (void*)new wxStaticBitmap((wxWindow*)parent, wxID_ANY, bmp);
|
||||
+}
|
||||
+
|
||||
+// ---- live theme changes -----------------------------------------------------
|
||||
+
|
||||
+// Emit WxEV_SYS_COLOUR when the OS light/dark theme changes so the app can
|
||||
|
||||
+337
-10
@@ -19,10 +19,12 @@
|
||||
#include <wx/utils.h>
|
||||
#include <wx/app.h>
|
||||
#include <wx/rearrangectrl.h>
|
||||
#include <wx/listctrl.h>
|
||||
#include <wx/menu.h>
|
||||
#include <wx/choice.h>
|
||||
#include <wx/bmpbuttn.h>
|
||||
#include <wx/bitmap.h>
|
||||
#include <wx/bmpbndl.h>
|
||||
#include <wx/image.h>
|
||||
#include <wx/dcmemory.h>
|
||||
#include <wx/dcgraph.h>
|
||||
@@ -66,6 +68,7 @@ enum WxWidgetEventKind {
|
||||
WxEV_SYS_COLOUR = 13,
|
||||
WxEV_DEFERRED = 14,
|
||||
WxEV_DVLC_HEADER_RIGHT_CLICK = 15,
|
||||
WxEV_SIZE = 16, // p1 = new client width, p2 = new client height
|
||||
};
|
||||
|
||||
// A list store that carries an optional per-row foreground colour plus an
|
||||
@@ -146,6 +149,57 @@ std::vector<ColorSegment> ParseColorSegments(const wxString& value) {
|
||||
return segs;
|
||||
}
|
||||
|
||||
// Shape sentinels a segment's text may carry instead of glyphs (round 11
|
||||
// #10/#13): a single control char selects a small vector icon drawn in the
|
||||
// segment's colour. These are control characters (never emoji/pictographs) so
|
||||
// they are safe in source and independent of the font's glyph coverage.
|
||||
const wxUniChar SHAPE_DOT = 0x07; // filled status dot (hashboards, locate light)
|
||||
const wxUniChar SHAPE_LOCK = 0x02; // closed padlock (locked / view-only)
|
||||
const wxUniChar SHAPE_UNLOCK = 0x03; // open padlock (unlocked / writable)
|
||||
const int SHAPE_ADVANCE = 15; // horizontal space one shape occupies
|
||||
|
||||
bool IsShapeSentinel(const wxString& s, wxUniChar& out) {
|
||||
if (s.length() != 1) return false;
|
||||
wxUniChar c = s[0];
|
||||
if (c == SHAPE_DOT || c == SHAPE_LOCK || c == SHAPE_UNLOCK) {
|
||||
out = c;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Draw one shape sentinel, centred in the SHAPE_ADVANCE-wide slot at x.
|
||||
void DrawShape(wxDC* dc, wxUniChar shape, wxCoord x, const wxRect& cell, const wxColour& colour) {
|
||||
int cy = cell.y + cell.height / 2;
|
||||
int cx = x + SHAPE_ADVANCE / 2;
|
||||
if (shape == SHAPE_DOT) {
|
||||
dc->SetPen(*wxTRANSPARENT_PEN);
|
||||
dc->SetBrush(wxBrush(colour));
|
||||
dc->DrawCircle(cx, cy, 4);
|
||||
return;
|
||||
}
|
||||
// Padlock: a filled body with a staple shackle above. The colour carries the
|
||||
// state (green = unlocked, red = locked); the shackle is drawn ajar when open.
|
||||
bool open = (shape == SHAPE_UNLOCK);
|
||||
int bw = 9, bh = 7;
|
||||
int bx = cx - bw / 2;
|
||||
int by = cy - bh / 2 + 1;
|
||||
dc->SetPen(*wxTRANSPARENT_PEN);
|
||||
dc->SetBrush(wxBrush(colour));
|
||||
dc->DrawRoundedRectangle(bx, by, bw, bh, 1.5);
|
||||
dc->SetBrush(*wxTRANSPARENT_BRUSH);
|
||||
dc->SetPen(wxPen(colour, 2));
|
||||
int sr = 3;
|
||||
int legTop = by - sr - 1;
|
||||
int lx = cx - sr, rx = cx + sr;
|
||||
dc->DrawLine(lx, by, lx, legTop); // left leg
|
||||
dc->DrawLine(lx, legTop, rx, legTop); // top bar
|
||||
if (open)
|
||||
dc->DrawLine(rx, legTop, rx, legTop + sr); // ajar: right leg lifted
|
||||
else
|
||||
dc->DrawLine(rx, legTop, rx, by); // closed: right leg to body
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
class SegmentRenderer : public wxDataViewCustomRenderer {
|
||||
@@ -165,12 +219,63 @@ class SegmentRenderer : public wxDataViewCustomRenderer {
|
||||
|
||||
bool Render(wxRect cell, wxDC* dc, int state) override {
|
||||
bool selected = (state & wxDATAVIEW_CELL_SELECTED) != 0;
|
||||
// wxGTK does NOT paint a custom renderer's cell background, so the per-row
|
||||
// (zebra) background set via GetAttrByRow shows on the native columns but
|
||||
// not here -- the zebra looked inconsistent across columns. Paint it here so
|
||||
// every column stripes the same (skip when the row is selected: the control
|
||||
// already drew the selection highlight).
|
||||
if (!selected && GetAttr().HasBackgroundColour()) {
|
||||
dc->SetBrush(wxBrush(GetAttr().GetBackgroundColour()));
|
||||
dc->SetPen(*wxTRANSPARENT_PEN);
|
||||
// The `cell` rect wx hands a custom renderer is shrunk to the content
|
||||
// (text/shape) size in BOTH dimensions by the alignment logic, so filling
|
||||
// it alone left the zebra covering only a content-sized band -- and since
|
||||
// shape cells (dots) and text cells have different content heights, the
|
||||
// stripes ended up unequal across columns. Fill an over-sized rect (full
|
||||
// column width, and well beyond the row vertically); wxGTK clips the cell
|
||||
// DC to the real cell background area, so this lands exactly on the full
|
||||
// row height of this cell without bleeding into neighbours (round 11 #1/#3).
|
||||
wxRect bg = cell;
|
||||
if (wxDataViewColumn* owner = const_cast<SegmentRenderer*>(this)->GetOwner()) {
|
||||
int cw = owner->GetWidth();
|
||||
if (cw > bg.width) bg.width = cw;
|
||||
}
|
||||
bg.y -= 40;
|
||||
bg.height += 80;
|
||||
dc->DrawRectangle(bg);
|
||||
}
|
||||
wxColour highlight = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT);
|
||||
wxColour plain = GetAttr().HasColour()
|
||||
? GetAttr().GetColour()
|
||||
: wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
|
||||
// An uncoloured (default) segment -- the "/" in a combined cell, a "Stock"
|
||||
// firmware family, etc. -- must dim exactly like the native columns when the
|
||||
// top-level window is backdropped. wxGTK dims a native cell's text via the
|
||||
// widget's themed state colour, but a custom renderer's DC keeps the normal
|
||||
// WINDOWTEXT, so ask the tree widget for its themed text colour AT ITS
|
||||
// CURRENT STATE (which carries GTK_STATE_FLAG_BACKDROP while unfocused) and
|
||||
// use that; off-GTK (or if the widget isn't reachable) fall back to the DC
|
||||
// then the system colour (round 11 #1/#7).
|
||||
wxColour plain;
|
||||
if (GetAttr().HasColour()) {
|
||||
plain = GetAttr().GetColour();
|
||||
} else {
|
||||
plain = ThemedTextColour();
|
||||
}
|
||||
if (!plain.IsOk()) {
|
||||
plain = dc->GetTextForeground();
|
||||
}
|
||||
if (!plain.IsOk()) {
|
||||
plain = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
|
||||
}
|
||||
wxCoord x = cell.x;
|
||||
for (const ColorSegment& seg : ParseColorSegments(m_value)) {
|
||||
// Shape segments (status dots, access padlock) keep their own semantic
|
||||
// colour even on a selected row, so the green/red reading survives the
|
||||
// selection highlight (round 11 #10/#13).
|
||||
wxUniChar shape;
|
||||
if (IsShapeSentinel(seg.text, shape)) {
|
||||
DrawShape(dc, shape, x, cell, seg.has_colour ? seg.colour : plain);
|
||||
x += SHAPE_ADVANCE;
|
||||
continue;
|
||||
}
|
||||
if (seg.text.IsEmpty()) continue;
|
||||
dc->SetTextForeground(selected ? highlight : (seg.has_colour ? seg.colour : plain));
|
||||
wxSize extent = dc->GetTextExtent(seg.text);
|
||||
@@ -182,14 +287,60 @@ class SegmentRenderer : public wxDataViewCustomRenderer {
|
||||
}
|
||||
|
||||
wxSize GetSize() const override {
|
||||
wxString plain;
|
||||
for (const ColorSegment& seg : ParseColorSegments(m_value)) plain += seg.text;
|
||||
wxSize sz = GetTextExtent(plain);
|
||||
if (sz.GetWidth() < 1) sz.SetWidth(1);
|
||||
return sz;
|
||||
int w = 0, h = 0;
|
||||
for (const ColorSegment& seg : ParseColorSegments(m_value)) {
|
||||
wxUniChar shape;
|
||||
if (IsShapeSentinel(seg.text, shape)) {
|
||||
w += SHAPE_ADVANCE;
|
||||
if (h < 12) h = 12;
|
||||
continue;
|
||||
}
|
||||
wxSize e = GetTextExtent(seg.text);
|
||||
w += e.GetWidth();
|
||||
if (e.GetHeight() > h) h = e.GetHeight();
|
||||
}
|
||||
if (w < 1) w = 1;
|
||||
if (h < 1) h = 1;
|
||||
return wxSize(w, h);
|
||||
}
|
||||
|
||||
private:
|
||||
// The owning tree widget's themed text colour at its current GTK state, so
|
||||
// uncoloured segments dim on window-backdrop like the native columns
|
||||
// (round 11 #1/#7). Returns an invalid colour off wxGTK or when the widget is
|
||||
// unreachable, so the caller falls back to the DC / system colour.
|
||||
wxColour ThemedTextColour() const {
|
||||
#ifdef __WXGTK__
|
||||
wxDataViewColumn* col = const_cast<SegmentRenderer*>(this)->GetOwner();
|
||||
if (col && col->GetOwner()) {
|
||||
GtkWidget* tv = col->GetOwner()->GtkGetTreeView();
|
||||
if (tv && GTK_IS_WIDGET(tv)) {
|
||||
// The treeview's own state flags do NOT reliably carry
|
||||
// GTK_STATE_FLAG_BACKDROP (that lives on the toplevel), so query the
|
||||
// toplevel window's active state directly and force BACKDROP onto the
|
||||
// style-context state when it is inactive. Then the themed cell text
|
||||
// colour matches what GTK paints on the native columns when the window
|
||||
// loses focus (round 11 #1/#7).
|
||||
GtkWidget* top = gtk_widget_get_toplevel(tv);
|
||||
bool active = GTK_IS_WINDOW(top) && gtk_window_is_active(GTK_WINDOW(top));
|
||||
GtkStyleContext* ctx = gtk_widget_get_style_context(tv);
|
||||
GtkStateFlags st = gtk_widget_get_state_flags(tv);
|
||||
st = active ? (GtkStateFlags)(st & ~GTK_STATE_FLAG_BACKDROP)
|
||||
: (GtkStateFlags)(st | GTK_STATE_FLAG_BACKDROP);
|
||||
GdkRGBA c;
|
||||
gtk_style_context_save(ctx);
|
||||
gtk_style_context_set_state(ctx, st);
|
||||
gtk_style_context_get_color(ctx, gtk_style_context_get_state(ctx), &c);
|
||||
gtk_style_context_restore(ctx);
|
||||
return wxColour((unsigned char)(c.red * 255.0 + 0.5),
|
||||
(unsigned char)(c.green * 255.0 + 0.5),
|
||||
(unsigned char)(c.blue * 255.0 + 0.5));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return wxColour();
|
||||
}
|
||||
|
||||
wxString m_value;
|
||||
};
|
||||
|
||||
@@ -271,6 +422,23 @@ void wxbr_sizer_detach(void* sizer, void* win) {
|
||||
((wxSizer*)sizer)->Detach((wxWindow*)win);
|
||||
}
|
||||
|
||||
// Show or hide a sizer-managed child window AND reclaim (or restore) its space
|
||||
// on the next Layout(). Used to collapse the wide KPI cards when the window is
|
||||
// too narrow (round 11 #2).
|
||||
void wxbr_sizer_show(void* sizer, void* win, int show) {
|
||||
((wxSizer*)sizer)->Show((wxWindow*)win, show != 0);
|
||||
}
|
||||
|
||||
// Emit WxEV_SIZE (p1 = new client width, p2 = height) whenever this window is
|
||||
// resized. e.Skip() keeps the normal sizer layout running (round 11 #2).
|
||||
void wxbr_bind_size(void* win) {
|
||||
((wxWindow*)win)->Bind(wxEVT_SIZE, [](wxSizeEvent& e) {
|
||||
if (g_widget_event) g_widget_event(WxEV_SIZE, (long)e.GetSize().GetWidth(),
|
||||
(long)e.GetSize().GetHeight());
|
||||
e.Skip();
|
||||
});
|
||||
}
|
||||
|
||||
void wxbr_fit(void* win) { ((wxWindow*)win)->Fit(); }
|
||||
|
||||
void wxbr_set_min_size(void* win, int w, int h) {
|
||||
@@ -381,12 +549,31 @@ void wxbr_check_box_set(void* win, int v) {
|
||||
// ---- check list box ---------------------------------------------------------
|
||||
|
||||
void* wxbr_check_list_box(void* parent) {
|
||||
// wxLB_EXTENDED so several rows can be selected at once (ctrl/shift-click and
|
||||
// rubber-band drag, native to wxListBox); a checkbox toggle on any selected
|
||||
// row then applies to every selected row (see the handler below). This is the
|
||||
// Excel-style batch-check the filter menu needs (round 12 #7).
|
||||
wxCheckListBox* clb = new wxCheckListBox((wxWindow*)parent, wxID_ANY,
|
||||
wxDefaultPosition, wxSize(-1, -1),
|
||||
0, NULL, wxLB_SINGLE | wxLB_NEEDED_SB);
|
||||
0, NULL, wxLB_EXTENDED | wxLB_NEEDED_SB);
|
||||
clb->Bind(wxEVT_CHECKLISTBOX, [clb](wxCommandEvent& e) {
|
||||
int idx = e.GetInt();
|
||||
// Batch toggle: if the clicked row is part of a multi-row selection, give
|
||||
// every selected row the clicked row's new state. Check() does not itself
|
||||
// fire wxEVT_CHECKLISTBOX, so there is no recursion.
|
||||
wxArrayInt sel;
|
||||
clb->GetSelections(sel);
|
||||
if (sel.GetCount() > 1) {
|
||||
bool inSel = false;
|
||||
for (size_t i = 0; i < sel.GetCount(); i++)
|
||||
if (sel[i] == idx) { inSel = true; break; }
|
||||
if (inSel) {
|
||||
bool state = clb->IsChecked(idx);
|
||||
for (size_t i = 0; i < sel.GetCount(); i++) clb->Check(sel[i], state);
|
||||
}
|
||||
}
|
||||
if (g_widget_event)
|
||||
g_widget_event(WxEV_CLB_TOGGLED, (long)(intptr_t)clb, e.GetInt());
|
||||
g_widget_event(WxEV_CLB_TOGGLED, (long)(intptr_t)clb, idx);
|
||||
});
|
||||
return (void*)clb;
|
||||
}
|
||||
@@ -959,6 +1146,137 @@ int wxbr_rearrange_get_order(void* win, int* buf, int cap) {
|
||||
return n < cap ? n : cap;
|
||||
}
|
||||
|
||||
// ---- reorder list: a checkable, multi-select, drag-reorderable column list
|
||||
// for the Columns dialog (round 11 #4). Replaces wxRearrangeCtrl (which had
|
||||
// up/down buttons and no drag / multi-select). It is a single-column headerless
|
||||
// wxListCtrl with native checkboxes; rows carry their base model index as item
|
||||
// data, and the check state + row order encode the same [idx | ~idx] contract
|
||||
// as wxbr_rearrange_get_order. Selection (shift/ctrl-click, rubber-band drag) is
|
||||
// native to wxListCtrl. Drag-reorder: on begin-drag we record the selected rows'
|
||||
// base indices, and on the following mouse-up we move that group to the row
|
||||
// under the cursor (we never start a real DnD loop, so the mouse-up still
|
||||
// arrives).
|
||||
static wxVector<long> g_reorder_drag;
|
||||
static wxListCtrl* g_reorder_list = nullptr;
|
||||
|
||||
void* wxbr_reorder_list(void* parent, int n, const int* order, const char** items) {
|
||||
wxListCtrl* lc = new wxListCtrl((wxWindow*)parent, wxID_ANY, wxDefaultPosition,
|
||||
wxSize(-1, 240), wxLC_REPORT | wxLC_NO_HEADER);
|
||||
lc->EnableCheckBoxes(true);
|
||||
lc->InsertColumn(0, wxT("Column"), wxLIST_FORMAT_LEFT, 260);
|
||||
for (int i = 0; i < n; i++) {
|
||||
int enc = order[i];
|
||||
int idx = enc < 0 ? ~enc : enc;
|
||||
long row = lc->InsertItem(i, wxString::FromUTF8(items[idx]));
|
||||
lc->SetItemData(row, (long)idx);
|
||||
lc->CheckItem(row, enc >= 0);
|
||||
}
|
||||
// Batch checkbox toggle: checking/unchecking a row that is part of a
|
||||
// multi-row selection applies the same state to every selected row, so the
|
||||
// user can ctrl/shift-click several columns and show/hide them together
|
||||
// (round 12 #7). CheckItem() re-enters this handler, so guard against it.
|
||||
auto batchCheck = [lc](long item, bool state) {
|
||||
static bool busy = false;
|
||||
if (busy) return;
|
||||
if (!(lc->GetItemState(item, wxLIST_STATE_SELECTED) & wxLIST_STATE_SELECTED))
|
||||
return;
|
||||
wxVector<long> sel;
|
||||
long it = -1;
|
||||
for (;;) {
|
||||
it = lc->GetNextItem(it, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
|
||||
if (it == -1) break;
|
||||
sel.push_back(it);
|
||||
}
|
||||
if (sel.size() <= 1) return;
|
||||
busy = true;
|
||||
for (size_t i = 0; i < sel.size(); i++)
|
||||
if (sel[i] != item) lc->CheckItem(sel[i], state);
|
||||
busy = false;
|
||||
};
|
||||
lc->Bind(wxEVT_LIST_ITEM_CHECKED, [batchCheck](wxListEvent& e) {
|
||||
batchCheck(e.GetIndex(), true);
|
||||
});
|
||||
lc->Bind(wxEVT_LIST_ITEM_UNCHECKED, [batchCheck](wxListEvent& e) {
|
||||
batchCheck(e.GetIndex(), false);
|
||||
});
|
||||
lc->Bind(wxEVT_LIST_BEGIN_DRAG, [lc](wxListEvent&) {
|
||||
g_reorder_drag.clear();
|
||||
g_reorder_list = lc;
|
||||
long it = -1;
|
||||
for (;;) {
|
||||
it = lc->GetNextItem(it, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
|
||||
if (it == -1) break;
|
||||
g_reorder_drag.push_back(lc->GetItemData(it));
|
||||
}
|
||||
});
|
||||
lc->Bind(wxEVT_LEFT_UP, [lc](wxMouseEvent& e) {
|
||||
e.Skip();
|
||||
if (g_reorder_list != lc || g_reorder_drag.empty()) return;
|
||||
struct Row {
|
||||
long data;
|
||||
bool checked;
|
||||
wxString text;
|
||||
};
|
||||
int count = lc->GetItemCount();
|
||||
wxVector<Row> rows;
|
||||
for (int i = 0; i < count; i++) {
|
||||
Row r;
|
||||
r.data = lc->GetItemData(i);
|
||||
r.checked = lc->IsItemChecked(i);
|
||||
r.text = lc->GetItemText(i);
|
||||
rows.push_back(r);
|
||||
}
|
||||
auto isDragged = [](long d) {
|
||||
for (size_t i = 0; i < g_reorder_drag.size(); i++)
|
||||
if (g_reorder_drag[i] == d) return true;
|
||||
return false;
|
||||
};
|
||||
int flags = 0;
|
||||
long targetRow = lc->HitTest(e.GetPosition(), flags);
|
||||
long anchor = (targetRow >= 0 && targetRow < count) ? rows[targetRow].data : -1;
|
||||
if (anchor >= 0 && isDragged(anchor)) anchor = -1;
|
||||
wxVector<Row> remaining, moved;
|
||||
for (size_t i = 0; i < rows.size(); i++) {
|
||||
if (isDragged(rows[i].data))
|
||||
moved.push_back(rows[i]);
|
||||
else
|
||||
remaining.push_back(rows[i]);
|
||||
}
|
||||
int insertAt = (int)remaining.size();
|
||||
if (anchor >= 0) {
|
||||
for (size_t i = 0; i < remaining.size(); i++)
|
||||
if (remaining[i].data == anchor) {
|
||||
insertAt = (int)i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
wxVector<Row> result;
|
||||
for (int i = 0; i < insertAt; i++) result.push_back(remaining[i]);
|
||||
for (size_t i = 0; i < moved.size(); i++) result.push_back(moved[i]);
|
||||
for (int i = insertAt; i < (int)remaining.size(); i++) result.push_back(remaining[i]);
|
||||
lc->DeleteAllItems();
|
||||
for (size_t i = 0; i < result.size(); i++) {
|
||||
long row = lc->InsertItem((long)i, result[i].text);
|
||||
lc->SetItemData(row, result[i].data);
|
||||
lc->CheckItem(row, result[i].checked);
|
||||
}
|
||||
g_reorder_drag.clear();
|
||||
g_reorder_list = nullptr;
|
||||
});
|
||||
return (void*)lc;
|
||||
}
|
||||
|
||||
int wxbr_reorder_get_order(void* win, int* buf, int cap) {
|
||||
wxListCtrl* lc = (wxListCtrl*)win;
|
||||
int count = lc->GetItemCount();
|
||||
int n = 0;
|
||||
for (int i = 0; i < count && n < cap; i++) {
|
||||
int idx = (int)lc->GetItemData(i);
|
||||
buf[n++] = lc->IsItemChecked(i) ? idx : ~idx;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
// ---- popup menu (right-click context menu) ----------------------------------
|
||||
|
||||
void* wxbr_menu_new() { return (void*)new wxMenu(); }
|
||||
@@ -1051,6 +1369,15 @@ void* wxbr_media_button(void* parent, int id, int kind, int r, int g, int b) {
|
||||
return (void*)btn;
|
||||
}
|
||||
|
||||
// Render an SVG (already recoloured on the Rust side -- its fill is an explicit
|
||||
// #RRGGBB) into a wxStaticBitmap for the KPI cards (round 11 #15). The caller
|
||||
// passes the target pixel size (w chosen from the SVG aspect ratio, h fixed).
|
||||
void* wxbr_svg_icon(void* parent, const char* svg, int w, int h) {
|
||||
wxBitmapBundle bundle = wxBitmapBundle::FromSVG(svg, wxSize(w, h));
|
||||
wxBitmap bmp = bundle.GetBitmap(wxSize(w, h));
|
||||
return (void*)new wxStaticBitmap((wxWindow*)parent, wxID_ANY, bmp);
|
||||
}
|
||||
|
||||
// ---- live theme changes -----------------------------------------------------
|
||||
|
||||
// Emit WxEV_SYS_COLOUR when the OS light/dark theme changes so the app can
|
||||
|
||||
@@ -23,6 +23,8 @@ mod notsafe {
|
||||
pub fn wxbr_set_sizer(win: *mut c_void, sizer: *mut c_void);
|
||||
pub fn wxbr_layout(win: *mut c_void);
|
||||
pub fn wxbr_sizer_detach(sizer: *mut c_void, win: *mut c_void);
|
||||
pub fn wxbr_sizer_show(sizer: *mut c_void, win: *mut c_void, show: c_int);
|
||||
pub fn wxbr_bind_size(win: *mut c_void);
|
||||
pub fn wxbr_fit(win: *mut c_void);
|
||||
pub fn wxbr_set_min_size(win: *mut c_void, w: c_int, h: c_int);
|
||||
pub fn wxbr_static_text(parent: *mut c_void, label: *const c_char) -> *mut c_void;
|
||||
@@ -77,6 +79,8 @@ mod notsafe {
|
||||
pub fn wxbr_apply_zebra_css(r: c_int, g: c_int, b: c_int);
|
||||
pub fn wxbr_rearrange_list(parent: *mut c_void, n: c_int, order: *const c_int, items: *const *const c_char) -> *mut c_void;
|
||||
pub fn wxbr_rearrange_get_order(win: *mut c_void, buf: *mut c_int, cap: c_int) -> c_int;
|
||||
pub fn wxbr_reorder_list(parent: *mut c_void, n: c_int, order: *const c_int, items: *const *const c_char) -> *mut c_void;
|
||||
pub fn wxbr_reorder_get_order(win: *mut c_void, buf: *mut c_int, cap: c_int) -> c_int;
|
||||
pub fn wxbr_menu_new() -> *mut c_void;
|
||||
pub fn wxbr_menu_append(menu: *mut c_void, id: c_int, label: *const c_char);
|
||||
pub fn wxbr_menu_append_separator(menu: *mut c_void);
|
||||
@@ -99,6 +103,7 @@ mod notsafe {
|
||||
pub fn wxbr_choice_get_selection(win: *mut c_void) -> c_int;
|
||||
pub fn wxbr_choice_set_selection(win: *mut c_void, i: c_int);
|
||||
pub fn wxbr_media_button(parent: *mut c_void, id: c_int, kind: c_int, r: c_int, g: c_int, b: c_int) -> *mut c_void;
|
||||
pub fn wxbr_svg_icon(parent: *mut c_void, svg: *const c_char, w: c_int, h: c_int) -> *mut c_void;
|
||||
pub fn wxbr_bind_sys_colour(win: *mut c_void);
|
||||
pub fn wxbr_destroy(win: *mut c_void);
|
||||
pub fn wxbr_destroy_children(win: *mut c_void);
|
||||
@@ -141,6 +146,8 @@ pub enum WxEventKind {
|
||||
SysColour,
|
||||
Deferred,
|
||||
DvlcHeaderRightClick,
|
||||
/// Window resized; p1 = new client width, p2 = new client height.
|
||||
Sized,
|
||||
}
|
||||
|
||||
impl WxEventKind {
|
||||
@@ -160,6 +167,7 @@ impl WxEventKind {
|
||||
13 => WxEventKind::SysColour,
|
||||
14 => WxEventKind::Deferred,
|
||||
15 => WxEventKind::DvlcHeaderRightClick,
|
||||
16 => WxEventKind::Sized,
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
@@ -308,6 +316,18 @@ impl Widget {
|
||||
unsafe { notsafe::wxbr_sizer_detach(self.0, win.0) }
|
||||
}
|
||||
|
||||
/// Show or hide a child window in this sizer (self = a sizer), reclaiming or
|
||||
/// restoring its space on the next `layout()`.
|
||||
pub fn sizer_show(&self, win: Widget, show: bool) {
|
||||
unsafe { notsafe::wxbr_sizer_show(self.0, win.0, show as c_int) }
|
||||
}
|
||||
|
||||
/// Emit `WxEventKind::Sized` (p1 = width, p2 = height) whenever this window
|
||||
/// is resized.
|
||||
pub fn bind_size(&self) {
|
||||
unsafe { notsafe::wxbr_bind_size(self.0) }
|
||||
}
|
||||
|
||||
pub fn fit(&self, win: Widget) {
|
||||
unsafe { notsafe::wxbr_fit(win.0) }
|
||||
}
|
||||
@@ -613,6 +633,27 @@ impl Widget {
|
||||
buf.into_iter().take(n.max(0) as usize).collect()
|
||||
}
|
||||
|
||||
/// A checkable, multi-select, drag-reorderable column list (round 11 #4):
|
||||
/// like `rearrange_list` but with no up/down buttons -- rows are reordered by
|
||||
/// dragging, and selected with shift/ctrl-click or a rubber-band drag. Same
|
||||
/// `[idx | !idx]` order encoding.
|
||||
pub fn reorder_list(parent: Widget, order: &[i32], items: &[&str]) -> Widget {
|
||||
let cs: Vec<CString> = items.iter().map(|s| CString::new(*s).unwrap_or_default()).collect();
|
||||
let ptrs: Vec<*const c_char> = cs.iter().map(|c| c.as_ptr()).collect();
|
||||
Widget(unsafe {
|
||||
notsafe::wxbr_reorder_list(parent.0, items.len() as c_int, order.as_ptr(), ptrs.as_ptr())
|
||||
})
|
||||
}
|
||||
|
||||
/// Read back the current order from a `reorder_list` (same encoding).
|
||||
pub fn reorder_get_order(&self) -> Vec<i32> {
|
||||
let mut buf = vec![0i32; 4096];
|
||||
let n = unsafe {
|
||||
notsafe::wxbr_reorder_get_order(self.0, buf.as_mut_ptr(), buf.len() as c_int)
|
||||
};
|
||||
buf.into_iter().take(n.max(0) as usize).collect()
|
||||
}
|
||||
|
||||
// ---- popup menu ----
|
||||
|
||||
pub fn menu_new() -> Widget {
|
||||
@@ -727,6 +768,14 @@ impl Widget {
|
||||
})
|
||||
}
|
||||
|
||||
/// Render an SVG string (recolour it first -- its fill must be an explicit
|
||||
/// colour, not "currentColor") into a static-bitmap icon at `w`x`h` px
|
||||
/// (round 11 #15).
|
||||
pub fn svg_icon(parent: Widget, svg: &str, w: i32, h: i32) -> Widget {
|
||||
let c = CString::new(svg).unwrap_or_default();
|
||||
Widget(unsafe { notsafe::wxbr_svg_icon(parent.0, c.as_ptr(), w as c_int, h as c_int) })
|
||||
}
|
||||
|
||||
/// Listen for OS light/dark theme changes on this window (emits `SysColour`).
|
||||
pub fn bind_sys_colour(&self) {
|
||||
unsafe { notsafe::wxbr_bind_sys_colour(self.0) }
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"$comment":"This file only protects against accidental modifications. It is not a security mechanism and does not protect against malicious changes.","files":{".cargo_vcs_info.json":"de321c89f62a60690ba07d6bb145ac688c6141c458638e68b3ed36b50b8de1f1","Cargo.lock":"5942ec7c9cf5c201bd32442d65020dc3ae72e33cb5aaf374b2a26501571a1487","Cargo.toml":"cb9ee00cbb415fa66a71a7d4822839bb3552336ec9ab975ae7b1137c711449cb","Cargo.toml.orig":"08409c395e4d502015da62e97efdc9c5bc6e3076031144f3f5aa35c900c7c735","src/backends/mod.rs":"26591e67688f8d015242295dde5050c4b34986e9980018a855346291a0472206","src/backends/v1_2_0/mod.rs":"c87949458cf3c73ef957b319abc1a39c4755d709d7e3cf5ea9b9b326eb054605","src/backends/v1_2_0/web.rs":"ac89f16bf623f7d85590d34b45c99b0e522d9d434b4c22af7fa8a8a653e09d2e","src/backends/v1_3_0/mod.rs":"722301b45abe8177269cc008a528ae5c5b122f4d0ced28aaa5bee6b5b9f0c062","src/backends/v1_3_0/web.rs":"1ec4cbe6bdc26f165d9e54e9bf2aac4c3706357ce4677dc21113710d4a26c3c1","src/firmware.rs":"168eeffaef90cb1525bb2e126e73905b5205d49215437263813e30323f6b7a05","src/lib.rs":"16ea1c0007fa6d6c86c1f83d3ac9cdf065cd9936cd52f35ef89c227397bbc54a","src/timezone.rs":"309bf23de1bdc9126bde5db8dabff0d2c0fea797dbf2630a772a18539838a05e"},"package":"1cb662e56f104c0fe45c8ccdac13f60cbcaad45ac228f939c6ac46ff40335052"}
|
||||
{"$comment":"This file only protects against accidental modifications. It is not a security mechanism and does not protect against malicious changes.","files":{".cargo_vcs_info.json":"de321c89f62a60690ba07d6bb145ac688c6141c458638e68b3ed36b50b8de1f1","Cargo.lock":"5942ec7c9cf5c201bd32442d65020dc3ae72e33cb5aaf374b2a26501571a1487","Cargo.toml":"cb9ee00cbb415fa66a71a7d4822839bb3552336ec9ab975ae7b1137c711449cb","Cargo.toml.orig":"08409c395e4d502015da62e97efdc9c5bc6e3076031144f3f5aa35c900c7c735","src/backends/mod.rs":"26591e67688f8d015242295dde5050c4b34986e9980018a855346291a0472206","src/backends/v1_2_0/mod.rs":"fc68a12769890e18231255c6a53cb2c68e4706a887d91f49113c6192684340d2","src/backends/v1_2_0/web.rs":"ac89f16bf623f7d85590d34b45c99b0e522d9d434b4c22af7fa8a8a653e09d2e","src/backends/v1_3_0/mod.rs":"0bba1bf94e7a86d763dbedda3bb5d68cf760e17f744204b0bbc0de4e3754f795","src/backends/v1_3_0/web.rs":"1ec4cbe6bdc26f165d9e54e9bf2aac4c3706357ce4677dc21113710d4a26c3c1","src/firmware.rs":"168eeffaef90cb1525bb2e126e73905b5205d49215437263813e30323f6b7a05","src/lib.rs":"16ea1c0007fa6d6c86c1f83d3ac9cdf065cd9936cd52f35ef89c227397bbc54a","src/timezone.rs":"309bf23de1bdc9126bde5db8dabff0d2c0fea797dbf2630a772a18539838a05e"},"package":"1cb662e56f104c0fe45c8ccdac13f60cbcaad45ac228f939c6ac46ff40335052"}
|
||||
+19
-2
@@ -179,11 +179,15 @@ impl GetDataLocations for VnishV120 {
|
||||
tag: None,
|
||||
},
|
||||
)],
|
||||
// The partner/reseller build name ("WildRose", "vnishreturn", ...) --
|
||||
// combined with the version number in parse_firmware_version so the FW
|
||||
// Version column shows e.g. "WildRose 1.3.5". ApiVersion still carries
|
||||
// the bare /fw_version.
|
||||
DataField::FirmwareVersion => vec![(
|
||||
WEB_INFO,
|
||||
DataExtractor {
|
||||
func: get_by_pointer,
|
||||
key: Some("/fw_version"),
|
||||
key: Some("/build_name"),
|
||||
tag: None,
|
||||
},
|
||||
)],
|
||||
@@ -415,7 +419,20 @@ impl GetApiVersion for VnishV120 {
|
||||
|
||||
impl GetFirmwareVersion for VnishV120 {
|
||||
fn parse_firmware_version(&self, data: &HashMap<DataField, Value>) -> Option<String> {
|
||||
data.extract::<String>(DataField::FirmwareVersion)
|
||||
// FirmwareVersion carries /build_name (the partner build), ApiVersion the
|
||||
// /fw_version number; show "<build> <version>" when both are present, else
|
||||
// whichever is available.
|
||||
let build = data
|
||||
.extract::<String>(DataField::FirmwareVersion)
|
||||
.filter(|b| !b.is_empty());
|
||||
let version = data
|
||||
.extract::<String>(DataField::ApiVersion)
|
||||
.filter(|v| !v.is_empty());
|
||||
match (build, version) {
|
||||
(Some(b), Some(v)) => Some(format!("{b} {v}")),
|
||||
(Some(b), None) => Some(b),
|
||||
(None, v) => v,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+16
-2
@@ -179,11 +179,13 @@ impl GetDataLocations for VnishV130 {
|
||||
tag: None,
|
||||
},
|
||||
)],
|
||||
// Partner/reseller build name; combined with the version number in
|
||||
// parse_firmware_version (FW Version shows e.g. "WildRose 1.3.5").
|
||||
DataField::FirmwareVersion => vec![(
|
||||
WEB_INFO,
|
||||
DataExtractor {
|
||||
func: get_by_pointer,
|
||||
key: Some("/fw_version"),
|
||||
key: Some("/build_name"),
|
||||
tag: None,
|
||||
},
|
||||
)],
|
||||
@@ -423,7 +425,19 @@ impl GetApiVersion for VnishV130 {
|
||||
|
||||
impl GetFirmwareVersion for VnishV130 {
|
||||
fn parse_firmware_version(&self, data: &HashMap<DataField, Value>) -> Option<String> {
|
||||
data.extract::<String>(DataField::FirmwareVersion)
|
||||
// FirmwareVersion carries /build_name (partner build), ApiVersion the
|
||||
// /fw_version number; show "<build> <version>" when both are present.
|
||||
let build = data
|
||||
.extract::<String>(DataField::FirmwareVersion)
|
||||
.filter(|b| !b.is_empty());
|
||||
let version = data
|
||||
.extract::<String>(DataField::ApiVersion)
|
||||
.filter(|v| !v.is_empty());
|
||||
match (build, version) {
|
||||
(Some(b), Some(v)) => Some(format!("{b} {v}")),
|
||||
(Some(b), None) => Some(b),
|
||||
(None, v) => v,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"$comment":"This file only protects against accidental modifications. It is not a security mechanism and does not protect against malicious changes.","files":{".cargo_vcs_info.json":"30f09ad063df45fdf223aff235fe2da15cb1a7e79e86d7012074153b91662fc4","Cargo.lock":"9d0886791db53421d3218ab72d964145b86cfbe9738eaf09aac5d3c89a1c0190","Cargo.toml":"8c2e9938436850f2e250e8268ed7b385fce903e2077923b207a0560ca3e3242c","Cargo.toml.orig":"891fcfa45e79d6bc4d838c4f3075618f791bd013c99231da48e752b987f409d5","src/backends/mod.rs":"0f5a0ae31d5443d0d0f41a2540def806196238c92d22761b3ad9843cb2e77f45","src/backends/v1/mod.rs":"80f3915f1e87c6f7483e9bd0e5b1fb5552f8d017634c82eea6150fe5134b171f","src/backends/v1/rpc.rs":"4cee9caeb9bc291c4efec04f4b7fc2b8eaead904a1f2d0f30e13236476d9aac5","src/backends/v2/mod.rs":"68fd8c1762b424a7785174fdb3ae4fede1d599632657808d4b7c76bcfbfb202c","src/backends/v2/rpc.rs":"b7afc5357d24de42350d4ec15a6b5a37698e4fd77b2c2cc8071f303ee62e957c","src/backends/v3/mod.rs":"f19e673c47c2cc366e2ff7782bca93daf750563d62221a12a043b3ee79a15251","src/backends/v3/rpc.rs":"7a5f80aec4af1bcaa0d36e67345aa9acbbd8ead73c0be474f06305358b38e81b","src/error_codes.rs":"de85845f52b1d4e1a0bff73462cef00962b60fad8a3ed71c7bb083c02df3a413","src/firmware.rs":"6d002e481ce0a897c0485b9393b0382fcb25811164e893eb8eb67b2ff392ca0d","src/lib.rs":"710b46c9d934f26f900e1366ca1df5f872896e7d8da03569c0f159859e899cc9","src/test/json/mod.rs":"99760925ccfefc40d2455d3567fb1ecfc99e9e55e70478190ef372a954825909","src/test/json/v1/devs.json":"b4fd010f0bae3584efde93387cf2dab5933b499cc30a2dd7635fdc994b56c3b8","src/test/json/v1/get_psu.json":"8c11b6495e0bd5da496dd5c10ca53ec53b2d8fe9a3737f470ec9ce2c1aaf9d99","src/test/json/v1/get_version.json":"c43e947e654792ab191210d50c6f793ee0dd7af41e8cb59f0722b70f32a203bc","src/test/json/v1/mod.rs":"e79509eee78a1fef63735afe385299813726822c8259a02d1dcf5e8b4db9d04e","src/test/json/v1/pools.json":"b570808a3428a0773d7d2ee322150d8fd0794a33804af970300a7fef128a8a01","src/test/json/v1/status.json":"00ec38dd9f980b7ac0ffd6f815374afdbbed98d601bd8ef18bcf0f76ae0aa853","src/test/json/v1/summary.json":"d6e3e75654eb4019e1f479b3d9cf3097130f1afb85dd3338682c094fd4ab498a","src/test/json/v1/summary_with_errors.json":"1ba682f6ad5c43e41ae22a4069d0f52f04da3f07a18031bf4c07e07b3c59cc97","src/test/json/v2/devs.json":"2d203e41ef6ef337c0c81456b73d08730882c3167403c557c3c9776022a972d1","src/test/json/v2/get_error_code.json":"e90b702fd97bceb4f62dcb8228f75ff5ce930290355dca94eefd7192f7f57009","src/test/json/v2/get_error_code_with_errors.json":"6cb6038366eb3835684421c41be0b2b30ae8ce79a7ed51a85f4f52f70da9df16","src/test/json/v2/get_miner_info.json":"55d2af984833a692f502188ae4df4e41bdc10386b47f921c896a452ef1de9062","src/test/json/v2/get_psu.json":"b43086b65897061521d1f6611e200ef372a1724f9ea1876e347c03d5fb19b8f2","src/test/json/v2/get_version.json":"b17e3a81603b43186b2e15745e6822b6c82b3c6f5928b22f84e683d7728dbfcd","src/test/json/v2/mod.rs":"c847205d076323bbd9698e393d241b08f3cf75d32aae86f7058cf8748266b935","src/test/json/v2/pools.json":"926d34e8dae774473ebfec83d4a38e77ca73231708f07683763e212be7af0580","src/test/json/v2/status.json":"fc268cd23864ef99e84813dbf8eb916b2e6f339351a0ee5dab217cbe02569fc3","src/test/json/v2/summary.json":"4e4c01b986e2960893f58d0f1ea4dce23b8ef88db4985348f7f0183eb4818478","src/test/json/v3/get_device_info.json":"83ac22ea9a11adbceb4c963db80aa62d9a2aa50d019a372394dece817d924cda","src/test/json/v3/get_device_info_with_errors.json":"24cee4b7840e87e12147cbfddf6c361f3b378a15bb85330b339d3be9e17cdbd5","src/test/json/v3/get_miner_status_edevs.json":"2d831c06113f555e0988df994c2e602a053a4aea603dded0db8f0f80e191ca5a","src/test/json/v3/get_miner_status_pools.json":"cd65c2efd3a5ce80b57aae46c420298a34ca06df7ac7f8c36fd556217703d242","src/test/json/v3/get_miner_status_summary.json":"799a94ba13ef54aed0f81a3d041d6c1fa263d4183754b384c69ca12d85a8d3ba","src/test/json/v3/mod.rs":"7ea3a8ff1b81c7a5b0f44f7c12dda880a9aeac5b0e6b56ac4fff4f4a7cbfe451","src/test/mod.rs":"ed52c3d613eabc4a0346bb38bcfdf7a94933d61e368d3c9094821edeab92f81b"},"package":"c85da6325b62f061327dc5f7605dd3721c823a9e8a2cfd6a356363dfbc84d66e"}
|
||||
{"$comment":"This file only protects against accidental modifications. It is not a security mechanism and does not protect against malicious changes.","files":{".cargo_vcs_info.json":"30f09ad063df45fdf223aff235fe2da15cb1a7e79e86d7012074153b91662fc4","Cargo.lock":"9d0886791db53421d3218ab72d964145b86cfbe9738eaf09aac5d3c89a1c0190","Cargo.toml":"8c2e9938436850f2e250e8268ed7b385fce903e2077923b207a0560ca3e3242c","Cargo.toml.orig":"891fcfa45e79d6bc4d838c4f3075618f791bd013c99231da48e752b987f409d5","src/backends/mod.rs":"0f5a0ae31d5443d0d0f41a2540def806196238c92d22761b3ad9843cb2e77f45","src/backends/v1/mod.rs":"b96cd7679b575335d716b114a3986167b2696b9e94a1a06a4696757aef08c7d1","src/backends/v1/rpc.rs":"4cee9caeb9bc291c4efec04f4b7fc2b8eaead904a1f2d0f30e13236476d9aac5","src/backends/v2/mod.rs":"68fd8c1762b424a7785174fdb3ae4fede1d599632657808d4b7c76bcfbfb202c","src/backends/v2/rpc.rs":"b7afc5357d24de42350d4ec15a6b5a37698e4fd77b2c2cc8071f303ee62e957c","src/backends/v3/mod.rs":"f19e673c47c2cc366e2ff7782bca93daf750563d62221a12a043b3ee79a15251","src/backends/v3/rpc.rs":"7a5f80aec4af1bcaa0d36e67345aa9acbbd8ead73c0be474f06305358b38e81b","src/error_codes.rs":"de85845f52b1d4e1a0bff73462cef00962b60fad8a3ed71c7bb083c02df3a413","src/firmware.rs":"6d002e481ce0a897c0485b9393b0382fcb25811164e893eb8eb67b2ff392ca0d","src/lib.rs":"710b46c9d934f26f900e1366ca1df5f872896e7d8da03569c0f159859e899cc9","src/test/json/mod.rs":"99760925ccfefc40d2455d3567fb1ecfc99e9e55e70478190ef372a954825909","src/test/json/v1/devs.json":"b4fd010f0bae3584efde93387cf2dab5933b499cc30a2dd7635fdc994b56c3b8","src/test/json/v1/get_psu.json":"8c11b6495e0bd5da496dd5c10ca53ec53b2d8fe9a3737f470ec9ce2c1aaf9d99","src/test/json/v1/get_version.json":"c43e947e654792ab191210d50c6f793ee0dd7af41e8cb59f0722b70f32a203bc","src/test/json/v1/mod.rs":"e79509eee78a1fef63735afe385299813726822c8259a02d1dcf5e8b4db9d04e","src/test/json/v1/pools.json":"b570808a3428a0773d7d2ee322150d8fd0794a33804af970300a7fef128a8a01","src/test/json/v1/status.json":"00ec38dd9f980b7ac0ffd6f815374afdbbed98d601bd8ef18bcf0f76ae0aa853","src/test/json/v1/summary.json":"d6e3e75654eb4019e1f479b3d9cf3097130f1afb85dd3338682c094fd4ab498a","src/test/json/v1/summary_with_errors.json":"1ba682f6ad5c43e41ae22a4069d0f52f04da3f07a18031bf4c07e07b3c59cc97","src/test/json/v2/devs.json":"2d203e41ef6ef337c0c81456b73d08730882c3167403c557c3c9776022a972d1","src/test/json/v2/get_error_code.json":"e90b702fd97bceb4f62dcb8228f75ff5ce930290355dca94eefd7192f7f57009","src/test/json/v2/get_error_code_with_errors.json":"6cb6038366eb3835684421c41be0b2b30ae8ce79a7ed51a85f4f52f70da9df16","src/test/json/v2/get_miner_info.json":"55d2af984833a692f502188ae4df4e41bdc10386b47f921c896a452ef1de9062","src/test/json/v2/get_psu.json":"b43086b65897061521d1f6611e200ef372a1724f9ea1876e347c03d5fb19b8f2","src/test/json/v2/get_version.json":"b17e3a81603b43186b2e15745e6822b6c82b3c6f5928b22f84e683d7728dbfcd","src/test/json/v2/mod.rs":"c847205d076323bbd9698e393d241b08f3cf75d32aae86f7058cf8748266b935","src/test/json/v2/pools.json":"926d34e8dae774473ebfec83d4a38e77ca73231708f07683763e212be7af0580","src/test/json/v2/status.json":"fc268cd23864ef99e84813dbf8eb916b2e6f339351a0ee5dab217cbe02569fc3","src/test/json/v2/summary.json":"4e4c01b986e2960893f58d0f1ea4dce23b8ef88db4985348f7f0183eb4818478","src/test/json/v3/get_device_info.json":"83ac22ea9a11adbceb4c963db80aa62d9a2aa50d019a372394dece817d924cda","src/test/json/v3/get_device_info_with_errors.json":"24cee4b7840e87e12147cbfddf6c361f3b378a15bb85330b339d3be9e17cdbd5","src/test/json/v3/get_miner_status_edevs.json":"2d831c06113f555e0988df994c2e602a053a4aea603dded0db8f0f80e191ca5a","src/test/json/v3/get_miner_status_pools.json":"cd65c2efd3a5ce80b57aae46c420298a34ca06df7ac7f8c36fd556217703d242","src/test/json/v3/get_miner_status_summary.json":"799a94ba13ef54aed0f81a3d041d6c1fa263d4183754b384c69ca12d85a8d3ba","src/test/json/v3/mod.rs":"7ea3a8ff1b81c7a5b0f44f7c12dda880a9aeac5b0e6b56ac4fff4f4a7cbfe451","src/test/mod.rs":"ed52c3d613eabc4a0346bb38bcfdf7a94933d61e368d3c9094821edeab92f81b"},"package":"c85da6325b62f061327dc5f7605dd3721c823a9e8a2cfd6a356363dfbc84d66e"}
|
||||
+28
-10
@@ -131,14 +131,28 @@ impl GetDataLocations for WhatsMinerV1 {
|
||||
tag: None,
|
||||
},
|
||||
)],
|
||||
DataField::ControlBoardVersion => vec![(
|
||||
RPC_SUMMARY,
|
||||
DataExtractor {
|
||||
func: get_by_pointer,
|
||||
key: Some("/SUMMARY/0/CB Platform"),
|
||||
tag: None,
|
||||
},
|
||||
)],
|
||||
DataField::ControlBoardVersion => vec![
|
||||
(
|
||||
RPC_SUMMARY,
|
||||
DataExtractor {
|
||||
func: get_by_pointer,
|
||||
key: Some("/SUMMARY/0/CB Platform"),
|
||||
tag: None,
|
||||
},
|
||||
),
|
||||
// Older M30S firmware (< 2022.7.29, so this v1 backend) often omits
|
||||
// "CB Platform" from summary but still reports the board under
|
||||
// get_version /Msg/platform (the source v2 uses). Fall back to it so
|
||||
// those units don't show a blank control board.
|
||||
(
|
||||
RPC_GET_VERSION,
|
||||
DataExtractor {
|
||||
func: get_by_pointer,
|
||||
key: Some("/Msg/platform"),
|
||||
tag: None,
|
||||
},
|
||||
),
|
||||
],
|
||||
DataField::TuningTarget => vec![(
|
||||
RPC_SUMMARY,
|
||||
DataExtractor {
|
||||
@@ -285,8 +299,12 @@ impl GetControlBoardVersion for WhatsMinerV1 {
|
||||
) -> Option<MinerControlBoard> {
|
||||
data.extract::<String>(DataField::ControlBoardVersion)
|
||||
.and_then(|s| {
|
||||
WhatsMinerControlBoard::parse(s.to_uppercase().strip_prefix("ALLWINNER_")?)
|
||||
.map(|cb| cb.into())
|
||||
// The "ALLWINNER_" prefix is optional: summary's CB Platform carries
|
||||
// it (e.g. "ALLWINNER_H6"), but the get_version /Msg/platform fallback
|
||||
// does not (e.g. "H6OS"). Strip it only when present.
|
||||
let up = s.to_uppercase();
|
||||
let board = up.strip_prefix("ALLWINNER_").unwrap_or(&up);
|
||||
WhatsMinerControlBoard::parse(board).map(|cb| cb.into())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"$comment":"This file only protects against accidental modifications. It is not a security mechanism and does not protect against malicious changes.","files":{".cargo_vcs_info.json":"aaaa0f14e3aff2543d3d09a4515efa5ab439f0651a36b582e87b9843d0475752","Cargo.lock":"58da2f3399ff680bf7d619204897b4edf5c03d336a8c3cceb54c9aba280bfed1","Cargo.toml":"57f92bf3808fa6f468dbabf43763a808d9ead128eef83b748f940ef3b219a80e","Cargo.toml.orig":"cbfb99fc843dd61ad2025dcfc16bd435afd2b6d43c2c983867af08af415916f1","src/hardware.rs":"77612b4f39e9c15355172b0582693d86b2fe44a305f5b01eef592e5a34b37188","src/lib.rs":"b2f55767a7f3fdacb1e898c5cb961c2dec8481823f94386ee67628960e91bf7d","src/make.rs":"e968e4dbd745d485fc9ad4c5a4c081d679eddce11f66e572f81f2dbe37ede3f0","src/models.rs":"da72a570d8cbb2c843c04047c3d879ca9709455f9bd6a02c3f2ab739e1b5be60"},"package":"67cca6e6bf4ac14562084ce7534521ffa7cd313fa39e2392f98ff98a047a4353"}
|
||||
{"$comment":"This file only protects against accidental modifications. It is not a security mechanism and does not protect against malicious changes.","files":{".cargo_vcs_info.json":"aaaa0f14e3aff2543d3d09a4515efa5ab439f0651a36b582e87b9843d0475752","Cargo.lock":"58da2f3399ff680bf7d619204897b4edf5c03d336a8c3cceb54c9aba280bfed1","Cargo.toml":"57f92bf3808fa6f468dbabf43763a808d9ead128eef83b748f940ef3b219a80e","Cargo.toml.orig":"cbfb99fc843dd61ad2025dcfc16bd435afd2b6d43c2c983867af08af415916f1","src/hardware.rs":"c3edc06f2404efd473bcc4ab16d66bb647369f2d43c0a10cb77bbc12cb98bf43","src/lib.rs":"b2f55767a7f3fdacb1e898c5cb961c2dec8481823f94386ee67628960e91bf7d","src/make.rs":"e968e4dbd745d485fc9ad4c5a4c081d679eddce11f66e572f81f2dbe37ede3f0","src/models.rs":"da72a570d8cbb2c843c04047c3d879ca9709455f9bd6a02c3f2ab739e1b5be60"},"package":"67cca6e6bf4ac14562084ce7534521ffa7cd313fa39e2392f98ff98a047a4353"}
|
||||
+4
-2
@@ -268,11 +268,13 @@ impl AntMinerControlBoard {
|
||||
.collect::<String>();
|
||||
|
||||
match compact.as_str() {
|
||||
"XILINX" => Some(Self::Xilinx),
|
||||
// "XIL" is VNish's short platform form for a Xilinx control board.
|
||||
"XILINX" | "XIL" => Some(Self::Xilinx),
|
||||
"BBB" | "BBCTRL" | "BB" | "BEAGLEBONE" | "BEAGLEBONEBLACK" => {
|
||||
Some(Self::BeagleBoneBlack)
|
||||
}
|
||||
"CVITEK" | "CVCTRL" => Some(Self::CVITek),
|
||||
// "CV" is VNish's short platform form for a CVITek control board.
|
||||
"CVITEK" | "CVCTRL" | "CV" => Some(Self::CVITek),
|
||||
"AMLOGIC" | "AML" => Some(Self::AMLogic),
|
||||
"AMCB07" => Some(Self::Xilinx), // Mara FW
|
||||
"ZYNQ7007" => Some(Self::Xilinx),
|
||||
|
||||
Reference in New Issue
Block a user