2022-06-03 02:03:37 +02:00
|
|
|
mod app;
|
|
|
|
|
2022-06-07 00:05:45 +02:00
|
|
|
use std::sync::Arc;
|
2022-06-12 23:52:06 +02:00
|
|
|
use tracing_subscriber::prelude::*;
|
|
|
|
use crate::app::{App, util::InternalLogger, data::ApplicationState, worker::{BackgroundWorker, NativeBackgroundWorker}};
|
2022-06-05 20:05:39 +02:00
|
|
|
|
2022-06-03 02:03:37 +02:00
|
|
|
// When compiling natively:
|
|
|
|
#[cfg(not(target_arch = "wasm32"))]
|
2022-06-06 04:42:06 +02:00
|
|
|
fn main() -> ! {
|
2022-06-12 23:52:06 +02:00
|
|
|
use tracing::metadata::LevelFilter;
|
|
|
|
|
|
|
|
|
2022-06-03 02:03:37 +02:00
|
|
|
let native_options = eframe::NativeOptions::default();
|
2022-06-06 04:42:06 +02:00
|
|
|
|
|
|
|
let mut store_path = dirs::data_dir().unwrap_or(std::path::PathBuf::from(".")); // TODO get cwd more consistently?
|
|
|
|
store_path.push("dashboard.db");
|
|
|
|
|
2022-06-12 23:52:06 +02:00
|
|
|
let store = Arc::new(
|
|
|
|
ApplicationState::new(store_path).expect("Failed creating application state")
|
|
|
|
);
|
|
|
|
|
|
|
|
tracing_subscriber::registry()
|
|
|
|
.with(LevelFilter::INFO)
|
|
|
|
.with(tracing_subscriber::fmt::Layer::new())
|
|
|
|
.with(InternalLogger::new(store.clone()))
|
|
|
|
.init();
|
2022-06-05 20:05:39 +02:00
|
|
|
|
|
|
|
eframe::run_native( // TODO replace this with a loop that ends so we can cleanly exit the background worker
|
2022-06-06 04:42:06 +02:00
|
|
|
"dashboard",
|
2022-06-03 02:03:37 +02:00
|
|
|
native_options,
|
2022-06-06 04:42:06 +02:00
|
|
|
Box::new(move |cc| {
|
2022-06-07 00:05:45 +02:00
|
|
|
let _worker = NativeBackgroundWorker::start(store.clone(), cc.egui_ctx.clone());
|
2022-06-06 04:42:06 +02:00
|
|
|
Box::new(App::new(cc, store))
|
|
|
|
}),
|
2022-06-03 02:03:37 +02:00
|
|
|
);
|
2022-06-05 20:05:39 +02:00
|
|
|
|
|
|
|
// worker.stop();
|
2022-06-03 02:03:37 +02:00
|
|
|
}
|