Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui): systray format #471

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ log = "0.4.22"
rand = "0.8.5"
device_query = "2.1.0"
nvml-wrapper = "0.10.0"
human_format = "1.1.0"
# tonic = "0.12.0"

[features]
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/src/binary_resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::download_utils::{download_file_with_retries, extract, validate_checks
use crate::{github, ProgressTracker};
use anyhow::{anyhow, Error};
use async_trait::async_trait;
use log::{debug, error, info, warn};
use log::{debug, error, warn};
use regex::Regex;
use semver::{Version, VersionReq};
use std::collections::HashMap;
Expand Down
10 changes: 0 additions & 10 deletions src-tauri/src/format_utils.rs

This file was deleted.

2 changes: 1 addition & 1 deletion src-tauri/src/hardware_monitor.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{ops::Deref, sync::LazyLock};

use log::{debug, info, warn};
use log::{debug, warn};
use nvml_wrapper::{enum_wrappers::device::TemperatureSensor, Nvml};
use serde::Serialize;
use sysinfo::{Component, Components, CpuRefreshKind, RefreshKind, System};
Expand Down
1 change: 0 additions & 1 deletion src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ mod binary_resolver;
mod consts;
mod cpu_miner;
mod download_utils;
mod format_utils;
mod github;
mod gpu_miner;
mod hardware_monitor;
Expand Down
26 changes: 18 additions & 8 deletions src-tauri/src/systemtray_manager.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use human_format::Formatter;
use log::{error, info};
use std::sync::LazyLock;
use tauri::{AppHandle, CustomMenuItem, SystemTray, SystemTrayMenu, SystemTrayMenuItem};

use crate::format_utils::format_balance;
use crate::hardware_monitor::HardwareStatus;

const LOG_TARGET: &str = "tari::universe::systemtray_manager";
Expand Down Expand Up @@ -34,7 +34,13 @@ impl SystrayItemId {
SystrayItemId::CpuUsage => format!("CPU Usage: {:.2}%", value),
SystrayItemId::GpuUsage => format!("GPU Usage: {:.2}%", value),
SystrayItemId::EstimatedEarning => {
format!("Est earning: {} tXTM/day", format_balance(value))
format!(
"Est earning: {:?} tXTM/day",
Formatter::new()
.with_decimals(2)
.with_separator("")
.format(value / 1_000_000.0)
)
}
}
}
Expand Down Expand Up @@ -101,19 +107,23 @@ impl SystemtrayManager {
match current_os {
CurrentOperatingSystem::Windows => {
format!(
"Hashrate | Usage\nCPU: {:.0} H/s | {:.0}%\nGPU: {:.0} H/s | {:.0}%\nEst. earning: {} tXTM/day",
data.cpu_hashrate,
"Hashrate | Usage\nCPU: {} H/s | {:.0}%\nGPU: {} H/s | {:.0}%\nEst. earning: {} tXTM/day",
Formatter::new().with_decimals(2).with_separator("").format(data.cpu_hashrate),
data.cpu_usage,
data.gpu_hashrate,
Formatter::new().with_decimals(2).with_separator("").format(data.gpu_hashrate),
data.gpu_usage,
format_balance(data.estimated_earning)
Formatter::new().with_decimals(2).with_separator("").format(data.estimated_earning / 1_000_000.0)
)
}
CurrentOperatingSystem::Linux => "Not supported".to_string(),
CurrentOperatingSystem::MacOS => {
format!(
"CPU:\n Hashrate: {:.0} H/s\n Usage: {:.0}%\nGPU:\n Hashrate: {:.0} H/s\n Usage: {:.0}%\nEst. earning: {} tXTM/day",
data.cpu_hashrate, data.cpu_usage, data.gpu_hashrate, data.gpu_usage, format_balance(data.estimated_earning)
"CPU:\n Hashrate: {} H/s\n Usage: {:.0}%\nGPU:\n Hashrate: {} H/s\n Usage: {:.0}%\nEst. earning: {} tXTM/day",
Formatter::new().with_decimals(0).with_separator("").format(data.cpu_hashrate),
data.cpu_usage,
Formatter::new().with_decimals(2).with_separator("").format(data.gpu_hashrate),
data.gpu_usage,
Formatter::new().with_decimals(2).with_separator("").format(data.estimated_earning / 1_000_000.0)
)
}
}
Expand Down