mirror of
https://git.alemi.dev/dashboard.git
synced 2024-11-22 15:34:54 +01:00
feat: allow passing initial db url
also chore: removed wasm32 stuff. it probably can't work so i'll think again about it some other time
This commit is contained in:
parent
2e38a00583
commit
d6c2e49843
3 changed files with 15 additions and 24 deletions
13
Cargo.toml
13
Cargo.toml
|
@ -16,21 +16,14 @@ serde = { version = "1", features = ["derive"] }
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
csv = "1.1"
|
csv = "1.1"
|
||||||
jql = { version = "4", default-features = false }
|
jql = { version = "4", default-features = false }
|
||||||
rfd = "0.9"
|
|
||||||
eframe = { version = "0.19", features = ["persistence"] }
|
eframe = { version = "0.19", features = ["persistence"] }
|
||||||
tokio = { version = "1", features = ["full"] }
|
|
||||||
clap = { version = "4", features = ["derive"] }
|
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
sea-orm = { version = "0.10", features = [ "runtime-tokio-rustls", "sqlx-sqlite", "sqlx-postgres", "macros" ] }
|
|
||||||
reqwest = { version = "0.11", features = ["json"] }
|
reqwest = { version = "0.11", features = ["json"] }
|
||||||
|
sea-orm = { version = "0.10", features = [ "runtime-tokio-rustls", "sqlx-sqlite", "sqlx-postgres", "macros" ] }
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
clap = { version = "4", features = ["derive"] }
|
||||||
|
tokio = { version = "1", features = ["full"] }
|
||||||
tracing-subscriber = "0.3"
|
tracing-subscriber = "0.3"
|
||||||
ctrlc = "3.2.3"
|
ctrlc = "3.2.3"
|
||||||
|
|
||||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
|
||||||
console_error_panic_hook = "0.1.6"
|
|
||||||
tracing-wasm = "0.2"
|
|
||||||
|
|
||||||
[profile.dev.package."*"]
|
[profile.dev.package."*"]
|
||||||
opt-level = 3
|
opt-level = 3
|
||||||
|
|
|
@ -44,6 +44,7 @@ pub struct App {
|
||||||
impl App {
|
impl App {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
_cc: &eframe::CreationContext,
|
_cc: &eframe::CreationContext,
|
||||||
|
initial_uri: Option<String>,
|
||||||
db_uri_tx: mpsc::Sender<String>,
|
db_uri_tx: mpsc::Sender<String>,
|
||||||
interval: i64,
|
interval: i64,
|
||||||
view: AppStateView,
|
view: AppStateView,
|
||||||
|
@ -51,9 +52,14 @@ impl App {
|
||||||
logger_view: watch::Receiver<Vec<String>>,
|
logger_view: watch::Receiver<Vec<String>>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let panels = view.panels.borrow().clone();
|
let panels = view.panels.borrow().clone();
|
||||||
|
if let Some(initial_uri) = &initial_uri {
|
||||||
|
if let Err(e) = db_uri_tx.blocking_send(initial_uri.clone()) {
|
||||||
|
error!(target: "app", "Could not send initial uri: {:?}", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
Self {
|
Self {
|
||||||
db_uri_tx, interval, panels, width_tx, view, logger_view,
|
db_uri_tx, interval, panels, width_tx, view, logger_view,
|
||||||
db_uri: "".into(),
|
db_uri: initial_uri.unwrap_or("".into()),
|
||||||
buffer_source: entities::sources::Model::default(),
|
buffer_source: entities::sources::Model::default(),
|
||||||
buffer_metric: entities::metrics::Model::default(),
|
buffer_metric: entities::metrics::Model::default(),
|
||||||
last_redraw: 0,
|
last_redraw: 0,
|
||||||
|
|
18
src/main.rs
18
src/main.rs
|
@ -52,21 +52,12 @@ enum Mode {
|
||||||
},
|
},
|
||||||
/// Run as foreground user interface displaying collected data
|
/// Run as foreground user interface displaying collected data
|
||||||
GUI {
|
GUI {
|
||||||
|
/// Immediately connect to this database on startup
|
||||||
|
#[arg(short, long)]
|
||||||
|
db_uri: Option<String>,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// When compiling for web:
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
|
||||||
fn setup_tracing(_layer: Option<InternalLoggerLayer>) {
|
|
||||||
// Make sure panics are logged using `console.error`.
|
|
||||||
console_error_panic_hook::set_once();
|
|
||||||
// Redirect tracing to console.log and friends:
|
|
||||||
tracing_wasm::set_as_global_default();
|
|
||||||
}
|
|
||||||
|
|
||||||
// When compiling natively:
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
|
||||||
fn setup_tracing(layer: Option<InternalLoggerLayer>) {
|
fn setup_tracing(layer: Option<InternalLoggerLayer>) {
|
||||||
let sub = tracing_subscriber::registry()
|
let sub = tracing_subscriber::registry()
|
||||||
.with(LevelFilter::INFO)
|
.with(LevelFilter::INFO)
|
||||||
|
@ -146,7 +137,7 @@ fn main() {
|
||||||
worker.join().expect("Failed joining worker thread");
|
worker.join().expect("Failed joining worker thread");
|
||||||
},
|
},
|
||||||
|
|
||||||
Mode::GUI { } => {
|
Mode::GUI { db_uri } => {
|
||||||
let (uri_tx, uri_rx) = mpsc::channel(10);
|
let (uri_tx, uri_rx) = mpsc::channel(10);
|
||||||
let (width_tx, width_rx) = watch::channel(0);
|
let (width_tx, width_rx) = watch::channel(0);
|
||||||
|
|
||||||
|
@ -226,6 +217,7 @@ fn main() {
|
||||||
Box::new(
|
Box::new(
|
||||||
App::new(
|
App::new(
|
||||||
cc,
|
cc,
|
||||||
|
db_uri,
|
||||||
uri_tx,
|
uri_tx,
|
||||||
args.interval as i64,
|
args.interval as i64,
|
||||||
view,
|
view,
|
||||||
|
|
Loading…
Reference in a new issue