mirror of
https://git.alemi.dev/dashboard.git
synced 2024-11-14 11:59:18 +01:00
feat: added footer, small fixes
This commit is contained in:
parent
9334ebda1d
commit
c72e8801f9
2 changed files with 34 additions and 23 deletions
20
Cargo.toml
20
Cargo.toml
|
@ -1,35 +1,23 @@
|
||||||
[package]
|
[package]
|
||||||
name = "plotter"
|
name = "dashboard"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "plotter_bin"
|
name = "dashboard_bin"
|
||||||
path = "src/main.rs"
|
path = "src/main.rs"
|
||||||
|
|
||||||
[lib]
|
|
||||||
crate-type = ["cdylib", "rlib"]
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rand = "0.8"
|
rand = "0.8"
|
||||||
|
dirs = "4"
|
||||||
|
git-version = "0.3.5"
|
||||||
chrono = { version = "0.4", features = ["wasmbind"] }
|
chrono = { version = "0.4", features = ["wasmbind"] }
|
||||||
eframe = { version = "0.18", features = ["persistence"] }
|
eframe = { version = "0.18", features = ["persistence"] }
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
|
|
||||||
# native only dependancies:
|
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
|
||||||
dirs = "4"
|
|
||||||
rusqlite = { version = "0.27" }
|
rusqlite = { version = "0.27" }
|
||||||
jq-rs = "0.4"
|
jq-rs = "0.4"
|
||||||
ureq = { version = "2", features = ["json"] }
|
ureq = { version = "2", features = ["json"] }
|
||||||
|
|
||||||
# web only dependancies:
|
|
||||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
|
||||||
console_error_panic_hook = "0.1.6"
|
|
||||||
tracing-wasm = "0.2"
|
|
||||||
|
|
||||||
[env]
|
[env]
|
||||||
JQ_LIB_DIR="/usr/lib"
|
JQ_LIB_DIR="/usr/lib"
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
pub mod data;
|
pub mod data;
|
||||||
pub mod worker;
|
pub mod worker;
|
||||||
|
pub mod util;
|
||||||
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use chrono::{DateTime, NaiveDateTime, Utc};
|
use chrono::{DateTime, NaiveDateTime, Utc};
|
||||||
|
@ -56,7 +57,7 @@ impl App {
|
||||||
|
|
||||||
impl eframe::App for App {
|
impl eframe::App for App {
|
||||||
fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
|
fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
|
||||||
egui::TopBottomPanel::top("??? wtf").show(ctx, |ui| {
|
egui::TopBottomPanel::top("heading").show(ctx, |ui| {
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
egui::widgets::global_dark_light_mode_switch(ui);
|
egui::widgets::global_dark_light_mode_switch(ui);
|
||||||
ui.heading("dashboard");
|
ui.heading("dashboard");
|
||||||
|
@ -109,27 +110,46 @@ impl eframe::App for App {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
egui::TopBottomPanel::bottom("footer").show(ctx, |ui| {
|
||||||
|
ui.horizontal(|ui|{
|
||||||
|
ui.label(self.data.file.to_str().unwrap());
|
||||||
|
ui.with_layout(egui::Layout::top_down(egui::Align::RIGHT), |ui| {
|
||||||
|
ui.horizontal(|ui| {
|
||||||
|
ui.label(format!("v{}-{}", env!("CARGO_PKG_VERSION"), git_version::git_version!()));
|
||||||
|
ui.separator();
|
||||||
|
ui.hyperlink_to("<me@alemi.dev>", "mailto:me@alemi.dev");
|
||||||
|
ui.label("alemi");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
egui::CentralPanel::default().show(ctx, |ui| {
|
egui::CentralPanel::default().show(ctx, |ui| {
|
||||||
egui::ScrollArea::vertical().show(ui, |ui| {
|
egui::ScrollArea::vertical().show(ui, |ui| {
|
||||||
let mut panels = self.data.panels.write().unwrap(); // TODO only lock as write when editing
|
let mut panels = self.data.panels.write().unwrap(); // TODO only lock as write when editing
|
||||||
for panel in &mut *panels {
|
for panel in &mut *panels {
|
||||||
|
let mut sources = panel.sources.write().unwrap(); // TODO only lock as write when editing
|
||||||
ui.group(|ui| {
|
ui.group(|ui| {
|
||||||
ui.vertical(|ui| {
|
ui.vertical(|ui| {
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
ui.heading(panel.name.as_str());
|
ui.heading(panel.name.as_str());
|
||||||
ui.separator();
|
ui.separator();
|
||||||
|
if !self.edit {
|
||||||
|
for source in &*sources {
|
||||||
|
ui.label(source.name.as_str());
|
||||||
|
ui.separator();
|
||||||
|
}
|
||||||
|
}
|
||||||
ui.checkbox(&mut panel.view_scroll, "autoscroll");
|
ui.checkbox(&mut panel.view_scroll, "autoscroll");
|
||||||
ui.checkbox(&mut panel.timeserie, "timeserie");
|
ui.checkbox(&mut panel.timeserie, "timeserie");
|
||||||
ui.separator();
|
ui.separator();
|
||||||
if self.filter {
|
if self.filter {
|
||||||
ui.add(egui::Slider::new(&mut panel.view_size, 1..=86400).text("samples"));
|
ui.add(egui::Slider::new(&mut panel.view_size, 1..=1440).text("samples"));
|
||||||
ui.separator();
|
ui.separator();
|
||||||
}
|
}
|
||||||
ui.add(egui::Slider::new(&mut panel.height, 0..=500).text("height"));
|
ui.add(egui::Slider::new(&mut panel.height, 0..=500).text("height"));
|
||||||
ui.separator();
|
ui.separator();
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut sources = panel.sources.write().unwrap(); // TODO only lock as write when editing
|
|
||||||
|
|
||||||
if self.edit {
|
if self.edit {
|
||||||
for source in &mut *sources {
|
for source in &mut *sources {
|
||||||
|
@ -147,11 +167,14 @@ impl eframe::App for App {
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut p = Plot::new(format!("plot-{}", panel.name))
|
let mut p = Plot::new(format!("plot-{}", panel.name))
|
||||||
.height(panel.height as f32);
|
.height(panel.height as f32)
|
||||||
|
.allow_scroll(false);
|
||||||
|
|
||||||
if panel.view_scroll {
|
if panel.view_scroll {
|
||||||
p = p.include_x(Utc::now().timestamp() as f64)
|
p = p.include_x(Utc::now().timestamp() as f64);
|
||||||
.include_x((Utc::now().timestamp() - panel.view_size as i64) as f64);
|
if self.filter {
|
||||||
|
p = p.include_x((Utc::now().timestamp() - (panel.view_size as i64 * 60)) as f64);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if panel.timeserie {
|
if panel.timeserie {
|
||||||
|
@ -168,7 +191,7 @@ impl eframe::App for App {
|
||||||
p.show(ui, |plot_ui| {
|
p.show(ui, |plot_ui| {
|
||||||
for source in &mut *sources {
|
for source in &mut *sources {
|
||||||
if self.filter {
|
if self.filter {
|
||||||
plot_ui.line(Line::new(source.values_filter((Utc::now().timestamp() - panel.view_size as i64) as f64)).name(source.name.as_str()));
|
plot_ui.line(Line::new(source.values_filter((Utc::now().timestamp() - (panel.view_size as i64 * 60)) as f64)).name(source.name.as_str()));
|
||||||
} else {
|
} else {
|
||||||
plot_ui.line(Line::new(source.values()).name(source.name.as_str()));
|
plot_ui.line(Line::new(source.values()).name(source.name.as_str()));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue