Find dashboard files in the user's config path
This commit is contained in:
parent
4f45d2b96d
commit
a0f85a4fdf
|
@ -78,6 +78,17 @@ version = "1.0.48"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "62e1f47f7dc0422027a4e370dd4548d4d66b26782e513e98dca1e689e058a80e"
|
||||
|
||||
[[package]]
|
||||
name = "appdirs"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d512b3e61196d27562dcc71446a58ba8a93d3bed2a03a87f96101b9a17f1d378"
|
||||
dependencies = [
|
||||
"ole32-sys",
|
||||
"shell32-sys",
|
||||
"winapi 0.2.8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "atk-sys"
|
||||
version = "0.14.0"
|
||||
|
@ -104,7 +115,7 @@ checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
|
|||
dependencies = [
|
||||
"hermit-abi",
|
||||
"libc",
|
||||
"winapi",
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -142,6 +153,7 @@ name = "bare-metrics-gui"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"appdirs",
|
||||
"bare-metrics-core",
|
||||
"bare-metrics-reader",
|
||||
"eframe",
|
||||
|
@ -151,6 +163,8 @@ dependencies = [
|
|||
"hdrhistogram",
|
||||
"log",
|
||||
"rfd",
|
||||
"ron",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -274,7 +288,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "9fdf5e01086b6be750428ba4a40619f847eb2e95756eee84b18e06e5f0b50342"
|
||||
dependencies = [
|
||||
"lazy-bytes-cast",
|
||||
"winapi",
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -560,7 +574,7 @@ checksum = "03d86534ed367a67548dc68113a0f5db55432fdfbb6e6f9d77704397d95d5780"
|
|||
dependencies = [
|
||||
"libc",
|
||||
"redox_users",
|
||||
"winapi",
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -802,7 +816,7 @@ dependencies = [
|
|||
"gobject-sys",
|
||||
"libc",
|
||||
"system-deps",
|
||||
"winapi",
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -865,7 +879,7 @@ dependencies = [
|
|||
"parking_lot",
|
||||
"wayland-client 0.28.6",
|
||||
"wayland-egl",
|
||||
"winapi",
|
||||
"winapi 0.3.9",
|
||||
"winit",
|
||||
]
|
||||
|
||||
|
@ -876,7 +890,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "2abb6aa55523480c4adc5a56bbaa249992e2dddb2fc63dc96e04a3355364c211"
|
||||
dependencies = [
|
||||
"gl_generator",
|
||||
"winapi",
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1051,7 +1065,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "351a32417a12d5f7e82c368a66781e307834dae04c6ce0cd4456d52989229883"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"winapi",
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1061,7 +1075,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "afe203d669ec979b7128619bae5a63b7b42e9203c1b29146079ee05e2f604b52"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"winapi",
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1175,7 +1189,7 @@ dependencies = [
|
|||
"log",
|
||||
"miow",
|
||||
"ntapi",
|
||||
"winapi",
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1196,7 +1210,7 @@ version = "0.3.7"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1304,7 +1318,7 @@ version = "0.3.6"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1386,6 +1400,16 @@ dependencies = [
|
|||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ole32-sys"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5d2c49021782e5233cd243168edfa8037574afed4eba4bbaf538b3d8d1789d8c"
|
||||
dependencies = [
|
||||
"winapi 0.2.8",
|
||||
"winapi-build",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.8.0"
|
||||
|
@ -1453,7 +1477,7 @@ dependencies = [
|
|||
"libc",
|
||||
"redox_syscall",
|
||||
"smallvec",
|
||||
"winapi",
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1597,6 +1621,17 @@ dependencies = [
|
|||
"windows",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ron"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b861ecaade43ac97886a512b360d01d66be9f41f3c61088b42cedf92e03d678"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"bitflags",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-demangle"
|
||||
version = "0.1.21"
|
||||
|
@ -1673,6 +1708,16 @@ dependencies = [
|
|||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shell32-sys"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ee04b46101f57121c9da2b151988283b6beb79b34f5bb29a58ee48cb695122c"
|
||||
dependencies = [
|
||||
"winapi 0.2.8",
|
||||
"winapi-build",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.7.0"
|
||||
|
@ -1866,7 +1911,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56"
|
||||
dependencies = [
|
||||
"same-file",
|
||||
"winapi",
|
||||
"winapi 0.3.9",
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
|
@ -2116,7 +2161,7 @@ checksum = "ecad156490d6b620308ed411cfee90d280b3cbd13e189ea0d3fada8acc89158a"
|
|||
dependencies = [
|
||||
"web-sys",
|
||||
"widestring",
|
||||
"winapi",
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2125,6 +2170,12 @@ version = "0.4.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c168940144dd21fd8046987c16a46a33d5fc84eec29ef9dcddc2ac9e31526b7c"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.2.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
|
@ -2135,6 +2186,12 @@ dependencies = [
|
|||
"winapi-x86_64-pc-windows-gnu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-build"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
|
@ -2147,7 +2204,7 @@ version = "0.1.5"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2236,7 +2293,7 @@ dependencies = [
|
|||
"scopeguard",
|
||||
"smithay-client-toolkit 0.12.3",
|
||||
"wayland-client 0.28.6",
|
||||
"winapi",
|
||||
"winapi 0.3.9",
|
||||
"x11-dl",
|
||||
]
|
||||
|
||||
|
|
|
@ -17,4 +17,7 @@ env_logger = "0.9.0"
|
|||
anyhow = "1.0.48"
|
||||
hdrhistogram = "7.4.0"
|
||||
# Rusty File Dialogue
|
||||
rfd = "0.6.1"
|
||||
rfd = "0.6.1"
|
||||
ron = "0.7.0"
|
||||
serde = { version = "1.0.130", features = ["derive"] }
|
||||
appdirs = "0.2.0"
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
use bare_metrics_core::structures::MetricKind;
|
||||
use serde::Deserialize;
|
||||
|
||||
#[derive(Deserialize, Default, Clone)]
|
||||
pub struct DashboardConfig {
|
||||
graphs: Vec<GraphConfig>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Clone)]
|
||||
pub struct GraphConfig {
|
||||
name: String,
|
||||
kind: MetricKind,
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
use crate::config::DashboardConfig;
|
||||
use crate::graph::{Graph, MetricsLogReaderMessage, MetricsLogReadingRequester};
|
||||
use bare_metrics_core::structures::MetricId;
|
||||
use bare_metrics_reader::MetricsLogReader;
|
||||
|
@ -6,13 +7,14 @@ use eframe::epi::{App, Frame, Storage};
|
|||
use eframe::NativeOptions;
|
||||
use env_logger::Env;
|
||||
use std::fs::File;
|
||||
use std::path::PathBuf;
|
||||
use std::str::FromStr;
|
||||
|
||||
pub mod config;
|
||||
pub mod graph;
|
||||
|
||||
pub struct MetricsGui {
|
||||
requester: MetricsLogReadingRequester,
|
||||
|
||||
dashboard: Option<DashboardConfig>,
|
||||
}
|
||||
|
||||
impl App for MetricsGui {
|
||||
|
@ -40,7 +42,7 @@ impl App for MetricsGui {
|
|||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
fn main() -> anyhow::Result<()> {
|
||||
env_logger::Builder::from_env(Env::default().default_filter_or("info")).init();
|
||||
|
||||
let path = rfd::FileDialog::new()
|
||||
|
@ -53,9 +55,29 @@ fn main() {
|
|||
|
||||
let file = File::open(path).unwrap();
|
||||
|
||||
let requester = MetricsLogReadingRequester::new_manager(MetricsLogReader::new(file).unwrap());
|
||||
let reader = MetricsLogReader::new(file).unwrap();
|
||||
let log_app_name = reader.header.application_name.clone();
|
||||
let requester = MetricsLogReadingRequester::new_manager(reader);
|
||||
|
||||
let app = MetricsGui { requester };
|
||||
let dashboard_dir = appdirs::user_data_dir(Some("baremetrics"), Some("rei"), true)
|
||||
.unwrap()
|
||||
.join("gui/dashboards");
|
||||
|
||||
let filtered_log_app_name = log_app_name.to_lowercase().replace(' ', "_");
|
||||
let dashboard_file = dashboard_dir.join(filtered_log_app_name + ".ron");
|
||||
eprintln!("Looking for dashboard file at {:?}", dashboard_file);
|
||||
|
||||
let dashboard = if dashboard_file.exists() {
|
||||
let rules_data: DashboardConfig = ron::de::from_reader(File::open(dashboard_file)?)?;
|
||||
Some(rules_data)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let app = MetricsGui {
|
||||
requester,
|
||||
dashboard,
|
||||
};
|
||||
|
||||
let native_options = NativeOptions::default();
|
||||
|
||||
|
|
Loading…
Reference in New Issue