поппо
parent
ead266377f
commit
b0aca0e5d4
|
|
@ -1,6 +1,9 @@
|
||||||
use egui_dock::{DockArea, Style};
|
use std::sync::Arc;
|
||||||
|
|
||||||
use crate::database::DBOperator;
|
use egui::mutex::RwLock;
|
||||||
|
use egui_dock::{DockArea, Style};
|
||||||
|
use sqlx::{Connection, MySqlConnection, MySqlPool};
|
||||||
|
use crate::{database::DBOperator, models::{self, Position}};
|
||||||
|
|
||||||
static TABS_CAN_BE_WINDOWS: bool = false;
|
static TABS_CAN_BE_WINDOWS: bool = false;
|
||||||
|
|
||||||
|
|
@ -20,7 +23,7 @@ struct Tab{
|
||||||
title: String,
|
title: String,
|
||||||
}
|
}
|
||||||
pub struct App{
|
pub struct App{
|
||||||
tree: egui_dock::DockState<Tab>,
|
pub tree: egui_dock::DockState<Tab>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for App{
|
impl Default for App{
|
||||||
|
|
@ -54,19 +57,26 @@ impl eframe::App for App{
|
||||||
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame){
|
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame){
|
||||||
DockArea::new(&mut self.tree)
|
DockArea::new(&mut self.tree)
|
||||||
.style(Style::from_egui(ui.style().as_ref()))
|
.style(Style::from_egui(ui.style().as_ref()))
|
||||||
.show_inside(ui, &mut MainTabViewer {
|
.show_inside(ui, &mut MainTabViewer::default());
|
||||||
equipment: vec![
|
|
||||||
crate::models::Equipment::default(),
|
|
||||||
crate::models::Equipment::default(),
|
|
||||||
crate::models::Equipment::default(),
|
|
||||||
crate::models::Equipment::default(),
|
|
||||||
]
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct MainTabViewer {
|
struct MainTabViewer {
|
||||||
|
positions: Arc<RwLock<Option<Vec<Position>>>>,
|
||||||
equipment: std::vec::Vec<crate::models::Equipment>,
|
equipment: std::vec::Vec<crate::models::Equipment>,
|
||||||
|
db_oper: DBOperator,
|
||||||
|
}
|
||||||
|
impl Default for MainTabViewer{
|
||||||
|
|
||||||
|
fn default() -> Self {
|
||||||
|
let db_oper = DBOperator::new();
|
||||||
|
let rt = tokio::runtime::Runtime::new().unwrap();
|
||||||
|
Self{
|
||||||
|
positions: Arc::new(RwLock::new(Option::Some(rt.block_on(async{db_oper.get_position().await.unwrap()})))),
|
||||||
|
equipment: vec![models::Equipment::default()],
|
||||||
|
db_oper
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
impl MainTabViewer{
|
impl MainTabViewer{
|
||||||
fn show_equipment(&mut self, ui: &mut egui::Ui){
|
fn show_equipment(&mut self, ui: &mut egui::Ui){
|
||||||
|
|
@ -108,10 +118,7 @@ impl MainTabViewer{
|
||||||
fn show_worker(&mut self, ui: &mut egui::Ui){
|
fn show_worker(&mut self, ui: &mut egui::Ui){
|
||||||
let rt = tokio::runtime::Runtime::new().unwrap();
|
let rt = tokio::runtime::Runtime::new().unwrap();
|
||||||
rt.block_on(async{
|
rt.block_on(async{
|
||||||
let dbd = DBOperator::new();
|
for eq in self.positions.read().clone().unwrap().iter(){
|
||||||
let positions = dbd.get_position().await.unwrap();
|
|
||||||
for eq in positions{
|
|
||||||
println!("{}",&eq.name);
|
|
||||||
ui.push_id(&eq.name, |ui|{
|
ui.push_id(&eq.name, |ui|{
|
||||||
egui::CollapsingHeader::new(&eq.name)
|
egui::CollapsingHeader::new(&eq.name)
|
||||||
.default_open(false)
|
.default_open(false)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
use sqlx::MySqlConnection;
|
|
||||||
use sqlx::mysql::MySqlPoolOptions;
|
use sqlx::mysql::MySqlPoolOptions;
|
||||||
use sqlx::mysql::MySqlPool;
|
use sqlx::mysql::MySqlPool;
|
||||||
use sqlx::Connection;
|
|
||||||
|
|
||||||
use dotenv::dotenv;
|
use dotenv::dotenv;
|
||||||
// use crate::schema::equipment::dsl::*;
|
// use crate::schema::equipment::dsl::*;
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,15 @@
|
||||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||||
|
|
||||||
|
use egui::mutex::RwLock;
|
||||||
|
use sqlx::MySqlPool;
|
||||||
|
|
||||||
use crate::database::DBOperator;
|
use crate::database::DBOperator;
|
||||||
mod app;
|
mod app;
|
||||||
mod models;
|
mod models;
|
||||||
mod database;
|
mod database;
|
||||||
// mod schema;
|
// mod schema;
|
||||||
fn main() -> eframe::Result{
|
fn main()
|
||||||
|
{
|
||||||
database::estabilish_connection();
|
database::estabilish_connection();
|
||||||
let native_opts = eframe::NativeOptions {
|
let native_opts = eframe::NativeOptions {
|
||||||
viewport: egui::ViewportBuilder::default()
|
viewport: egui::ViewportBuilder::default()
|
||||||
|
|
@ -14,6 +18,6 @@ fn main() -> eframe::Result{
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
eframe::run_native("BCS", native_opts, Box::new(|cc| Ok(Box::new(app::App::new(cc)))),)
|
eframe::run_native("BCS", native_opts, Box::new(|cc| Ok(Box::new(app::App::new(cc)))),);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue