поппо
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;
|
||||
|
||||
|
|
@ -20,7 +23,7 @@ struct Tab{
|
|||
title: String,
|
||||
}
|
||||
pub struct App{
|
||||
tree: egui_dock::DockState<Tab>,
|
||||
pub tree: egui_dock::DockState<Tab>,
|
||||
}
|
||||
|
||||
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){
|
||||
DockArea::new(&mut self.tree)
|
||||
.style(Style::from_egui(ui.style().as_ref()))
|
||||
.show_inside(ui, &mut MainTabViewer {
|
||||
equipment: vec![
|
||||
crate::models::Equipment::default(),
|
||||
crate::models::Equipment::default(),
|
||||
crate::models::Equipment::default(),
|
||||
crate::models::Equipment::default(),
|
||||
]
|
||||
});
|
||||
.show_inside(ui, &mut MainTabViewer::default());
|
||||
}
|
||||
}
|
||||
|
||||
struct MainTabViewer {
|
||||
positions: Arc<RwLock<Option<Vec<Position>>>>,
|
||||
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{
|
||||
fn show_equipment(&mut self, ui: &mut egui::Ui){
|
||||
|
|
@ -108,13 +118,10 @@ impl MainTabViewer{
|
|||
fn show_worker(&mut self, ui: &mut egui::Ui){
|
||||
let rt = tokio::runtime::Runtime::new().unwrap();
|
||||
rt.block_on(async{
|
||||
let dbd = DBOperator::new();
|
||||
let positions = dbd.get_position().await.unwrap();
|
||||
for eq in positions{
|
||||
println!("{}",&eq.name);
|
||||
for eq in self.positions.read().clone().unwrap().iter(){
|
||||
ui.push_id(&eq.name, |ui|{
|
||||
egui::CollapsingHeader::new(&eq.name)
|
||||
.default_open(false)
|
||||
.default_open(false)
|
||||
.show(ui, |ui|{
|
||||
ui.label(eq.wage.to_string());
|
||||
})
|
||||
|
|
@ -163,4 +170,4 @@ impl egui_dock::TabViewer for MainTabViewer{
|
|||
fn is_closeable(&self, _tab: &Self::Tab) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
use sqlx::MySqlConnection;
|
||||
use sqlx::mysql::MySqlPoolOptions;
|
||||
use sqlx::mysql::MySqlPool;
|
||||
use sqlx::Connection;
|
||||
|
||||
|
||||
use dotenv::dotenv;
|
||||
// use crate::schema::equipment::dsl::*;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,15 @@
|
|||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
|
||||
use egui::mutex::RwLock;
|
||||
use sqlx::MySqlPool;
|
||||
|
||||
use crate::database::DBOperator;
|
||||
mod app;
|
||||
mod models;
|
||||
mod database;
|
||||
// mod schema;
|
||||
fn main() -> eframe::Result{
|
||||
fn main()
|
||||
{
|
||||
database::estabilish_connection();
|
||||
let native_opts = eframe::NativeOptions {
|
||||
viewport: egui::ViewportBuilder::default()
|
||||
|
|
@ -14,6 +18,6 @@ fn main() -> eframe::Result{
|
|||
..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