Эта гавно я перепишу
parent
666cd516c2
commit
7ccb55cb43
|
|
@ -743,7 +743,7 @@ version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"chrono",
|
"chrono",
|
||||||
"dotenv",
|
"dotenvy",
|
||||||
"eframe",
|
"eframe",
|
||||||
"egui",
|
"egui",
|
||||||
"egui_dock",
|
"egui_dock",
|
||||||
|
|
@ -986,12 +986,6 @@ dependencies = [
|
||||||
"litrs",
|
"litrs",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "dotenv"
|
|
||||||
version = "0.15.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dotenvy"
|
name = "dotenvy"
|
||||||
version = "0.15.7"
|
version = "0.15.7"
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ edition = "2024"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0.102"
|
anyhow = "1.0.102"
|
||||||
chrono = { version = "0.4.44", features = ["serde"] }
|
chrono = { version = "0.4.44", features = ["serde"] }
|
||||||
dotenv = "0.15.0"
|
dotenvy = "0.15.7"
|
||||||
eframe = "0.34.2"
|
eframe = "0.34.2"
|
||||||
egui = "0.34.2"
|
egui = "0.34.2"
|
||||||
egui_dock = "0.19.1"
|
egui_dock = "0.19.1"
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,9 @@ enum TabTypes{
|
||||||
Recipe,
|
Recipe,
|
||||||
Product,
|
Product,
|
||||||
Order,
|
Order,
|
||||||
Settings
|
Settings,
|
||||||
|
WorkerList,
|
||||||
|
WorkerPosition,
|
||||||
}
|
}
|
||||||
struct Tab{
|
struct Tab{
|
||||||
tab_type: TabTypes,
|
tab_type: TabTypes,
|
||||||
|
|
@ -84,6 +86,7 @@ struct MainTabViewer {
|
||||||
equipment: std::vec::Vec<crate::models::Equipment>,
|
equipment: std::vec::Vec<crate::models::Equipment>,
|
||||||
db_oper: DBOperator,
|
db_oper: DBOperator,
|
||||||
worker_tabs: WorkerTabViewer,
|
worker_tabs: WorkerTabViewer,
|
||||||
|
worker_tree: egui_dock::DockState<Tab>,
|
||||||
}
|
}
|
||||||
impl Default for MainTabViewer{
|
impl Default for MainTabViewer{
|
||||||
|
|
||||||
|
|
@ -95,7 +98,17 @@ impl Default for MainTabViewer{
|
||||||
workers: Arc::new(RwLock::new(Option::Some(rt.block_on(async{db_oper.get_workers().await.unwrap()})))),
|
workers: Arc::new(RwLock::new(Option::Some(rt.block_on(async{db_oper.get_workers().await.unwrap()})))),
|
||||||
equipment: vec![models::Equipment::default()],
|
equipment: vec![models::Equipment::default()],
|
||||||
db_oper,
|
db_oper,
|
||||||
worker_tabs: WorkerTabViewer{}
|
worker_tabs: WorkerTabViewer{},
|
||||||
|
worker_tree: egui_dock::DockState::new(vec![
|
||||||
|
Tab{
|
||||||
|
title:"ГойдаЗов".to_owned(),
|
||||||
|
tab_type:TabTypes::WorkerList,
|
||||||
|
},
|
||||||
|
Tab{
|
||||||
|
title:"Еееееее".to_owned(),
|
||||||
|
tab_type:TabTypes::WorkerPosition,
|
||||||
|
}
|
||||||
|
]),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -190,7 +203,9 @@ impl MainTabViewer{
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
fn show_salary(&mut self, ui: &mut egui::Ui){
|
fn show_salary(&mut self, ui: &mut egui::Ui){
|
||||||
self.worker_tabs.
|
DockArea::new(&mut self.worker_tree)
|
||||||
|
.style(Style::from_egui(ui.style().as_ref()))
|
||||||
|
.show_inside(ui, &mut WorkerTabViewer::default());
|
||||||
}
|
}
|
||||||
fn show_material(&mut self, ui: &mut egui::Ui){
|
fn show_material(&mut self, ui: &mut egui::Ui){
|
||||||
ui.label("Сырьё короче да");
|
ui.label("Сырьё короче да");
|
||||||
|
|
@ -234,9 +249,11 @@ impl egui_dock::TabViewer for MainTabViewer{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
struct WorkerTabViewer{
|
struct WorkerTabViewer{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl egui_dock::TabViewer for WorkerTabViewer{
|
impl egui_dock::TabViewer for WorkerTabViewer{
|
||||||
type Tab = Tab;
|
type Tab = Tab;
|
||||||
fn title(&mut self, tab: &mut Self::Tab) -> egui::WidgetText {
|
fn title(&mut self, tab: &mut Self::Tab) -> egui::WidgetText {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,8 @@ use sqlx::mysql::MySqlPoolOptions;
|
||||||
use sqlx::mysql::MySqlPool;
|
use sqlx::mysql::MySqlPool;
|
||||||
|
|
||||||
|
|
||||||
use dotenv::dotenv;
|
use dotenvy::dotenv_override;
|
||||||
|
use std::env;
|
||||||
// use crate::schema::equipment::dsl::*;
|
// use crate::schema::equipment::dsl::*;
|
||||||
// use crate::schema::worker::dsl::*;
|
// use crate::schema::worker::dsl::*;
|
||||||
use crate::models::*;
|
use crate::models::*;
|
||||||
|
|
@ -12,8 +13,8 @@ pub struct DBOperator{
|
||||||
}
|
}
|
||||||
impl DBOperator{
|
impl DBOperator{
|
||||||
pub fn new() -> Self{
|
pub fn new() -> Self{
|
||||||
dotenv().ok();
|
dotenv_override().ok();
|
||||||
let db_url = dotenv::var("DATABASE_URL").expect("DATABASE_URL установи!");
|
let db_url = env::var("DATABASE_URL").expect("DATABASE_URL установи!");
|
||||||
Self{connection_string:db_url}
|
Self{connection_string:db_url}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -46,8 +47,8 @@ impl DBOperator{
|
||||||
|
|
||||||
|
|
||||||
pub async fn estabilish_connection() -> Result<(), sqlx::Error>{
|
pub async fn estabilish_connection() -> Result<(), sqlx::Error>{
|
||||||
dotenv().ok();
|
dotenv_override().ok();
|
||||||
let db_url = dotenv::var("DATABASE_URL").expect("DATABASE_URL установи!");
|
let db_url = env::var("DATABASE_URL").expect("DATABASE_URL установи!");
|
||||||
let pool = MySqlPoolOptions::new()
|
let pool = MySqlPoolOptions::new()
|
||||||
.max_connections(5)
|
.max_connections(5)
|
||||||
.connect(&db_url).await?;
|
.connect(&db_url).await?;
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ mod database;
|
||||||
// mod schema;
|
// mod schema;
|
||||||
fn main()
|
fn main()
|
||||||
{
|
{
|
||||||
database::estabilish_connection();
|
dotenvy::dotenv().ok(); database::estabilish_connection();
|
||||||
let native_opts = eframe::NativeOptions {
|
let native_opts = eframe::NativeOptions {
|
||||||
viewport: egui::ViewportBuilder::default()
|
viewport: egui::ViewportBuilder::default()
|
||||||
.with_inner_size([400.0,300.0])
|
.with_inner_size([400.0,300.0])
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue