Господи Иисусе Христе дай мне сил дописать курсовую до защиты
parent
b44669e3ac
commit
20ed3009b3
|
|
@ -59,6 +59,10 @@ impl Default for App{
|
||||||
Tab{
|
Tab{
|
||||||
tab_type: TabTypes::Product,
|
tab_type: TabTypes::Product,
|
||||||
title: "Продукция".to_owned()
|
title: "Продукция".to_owned()
|
||||||
|
},
|
||||||
|
Tab{
|
||||||
|
tab_type: TabTypes::Settings,
|
||||||
|
title: "Настройки".to_owned(),
|
||||||
}
|
}
|
||||||
|
|
||||||
]);
|
]);
|
||||||
|
|
@ -80,6 +84,13 @@ impl eframe::App for App{
|
||||||
.style(Style::from_egui(ui.style().as_ref()))
|
.style(Style::from_egui(ui.style().as_ref()))
|
||||||
.show_inside(ui, &mut self.main_viewer);
|
.show_inside(ui, &mut self.main_viewer);
|
||||||
}
|
}
|
||||||
|
fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
|
||||||
|
if (self.main_viewer.is_dark_theme){
|
||||||
|
ctx.set_visuals(egui::Visuals::dark());
|
||||||
|
}else{
|
||||||
|
ctx.set_visuals(egui::Visuals::light());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct MainTabViewer {
|
struct MainTabViewer {
|
||||||
|
|
@ -90,6 +101,7 @@ struct MainTabViewer {
|
||||||
worker_tabs: WorkerTabViewer,
|
worker_tabs: WorkerTabViewer,
|
||||||
worker_tree: egui_dock::DockState<Tab>,
|
worker_tree: egui_dock::DockState<Tab>,
|
||||||
rt: tokio::runtime::Runtime,
|
rt: tokio::runtime::Runtime,
|
||||||
|
is_dark_theme: bool,
|
||||||
}
|
}
|
||||||
impl Default for MainTabViewer{
|
impl Default for MainTabViewer{
|
||||||
|
|
||||||
|
|
@ -115,7 +127,8 @@ impl Default for MainTabViewer{
|
||||||
tab_type:TabTypes::WorkerPosition,
|
tab_type:TabTypes::WorkerPosition,
|
||||||
}
|
}
|
||||||
]),
|
]),
|
||||||
rt
|
rt,
|
||||||
|
is_dark_theme: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -149,13 +162,17 @@ impl MainTabViewer{
|
||||||
.default_open(false)
|
.default_open(false)
|
||||||
.show(ui, |ui|{
|
.show(ui, |ui|{
|
||||||
ui.horizontal(|ui|{
|
ui.horizontal(|ui|{
|
||||||
ui.monospace("Инвентарный номер: ");
|
ui.monospace("Инвентарный номер:");
|
||||||
ui.label(&eq.inv_number);
|
ui.label(&eq.inv_number);
|
||||||
});
|
});
|
||||||
ui.horizontal(|ui|{
|
ui.horizontal(|ui|{
|
||||||
ui.monospace("Ответственный: ");
|
ui.monospace("Ответственный:");
|
||||||
ui.label(&eq.worker.full_name);
|
ui.label(&eq.worker.full_name);
|
||||||
});
|
});
|
||||||
|
ui.horizontal(|ui|{
|
||||||
|
ui.monospace("Дата последнего техобслуживания:");
|
||||||
|
ui.label(&eq.maintenance_date.date_naive().to_string());
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -181,6 +198,11 @@ impl MainTabViewer{
|
||||||
fn show_salary(&mut self, ui: &mut egui::Ui){
|
fn show_salary(&mut self, ui: &mut egui::Ui){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
fn show_settings(&mut self, ui: &mut egui::Ui){
|
||||||
|
ui.horizontal(|ui|{
|
||||||
|
ui.checkbox(&mut self.is_dark_theme, "Тёмная тема");
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl egui_dock::TabViewer for MainTabViewer{
|
impl egui_dock::TabViewer for MainTabViewer{
|
||||||
|
|
@ -203,6 +225,9 @@ impl egui_dock::TabViewer for MainTabViewer{
|
||||||
TabTypes::Material => {
|
TabTypes::Material => {
|
||||||
&self.show_material(ui);
|
&self.show_material(ui);
|
||||||
},
|
},
|
||||||
|
TabTypes::Settings =>{
|
||||||
|
&self.show_settings(ui);
|
||||||
|
},
|
||||||
_ =>{
|
_ =>{
|
||||||
ui.label("This is not");
|
ui.label("This is not");
|
||||||
}
|
}
|
||||||
|
|
@ -222,6 +247,7 @@ impl egui_dock::TabViewer for MainTabViewer{
|
||||||
struct WorkerTabViewer{
|
struct WorkerTabViewer{
|
||||||
workers: Arc<RwLock<Option<Vec<Worker>>>>,
|
workers: Arc<RwLock<Option<Vec<Worker>>>>,
|
||||||
positions: Arc<RwLock<Option<Vec<Position>>>>,
|
positions: Arc<RwLock<Option<Vec<Position>>>>,
|
||||||
|
add_modal: egui::Modal,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -229,7 +255,9 @@ impl WorkerTabViewer{
|
||||||
fn show_worker(&mut self, ui: &mut egui::Ui){
|
fn show_worker(&mut self, ui: &mut egui::Ui){
|
||||||
ui.horizontal(|ui|{
|
ui.horizontal(|ui|{
|
||||||
if ui.button("Добавить").clicked() {
|
if ui.button("Добавить").clicked() {
|
||||||
|
&self.add_modal.show(ui.ctx(), |ui|{
|
||||||
|
ui.label("goida");
|
||||||
|
});
|
||||||
};
|
};
|
||||||
if ui.button("Уволить").clicked() {
|
if ui.button("Уволить").clicked() {
|
||||||
|
|
||||||
|
|
@ -261,13 +289,15 @@ impl WorkerTabViewer{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn show_position(&mut self, ui: &mut egui::Ui){
|
fn show_position(&mut self, ui: &mut egui::Ui){
|
||||||
|
|
||||||
for eq in self.positions.read().clone().unwrap().iter(){
|
for eq in self.positions.read().clone().unwrap().iter(){
|
||||||
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)
|
||||||
.show(ui, |ui|{
|
.show(ui, |ui|{
|
||||||
ui.label(eq.wage.to_string());
|
ui.horizontal(|ui|{
|
||||||
|
ui.monospace("Оклад:");
|
||||||
|
ui.label(format!("${}",eq.wage));
|
||||||
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
@ -303,6 +333,7 @@ impl Default for WorkerTabViewer{
|
||||||
let db_oper = rt.block_on(async{DBOperator::new().await});
|
let db_oper = rt.block_on(async{DBOperator::new().await});
|
||||||
Self { workers: Arc::new(RwLock::new(Option::Some(rt.block_on(async{db_oper.get_workers().await.unwrap()})))) ,
|
Self { workers: Arc::new(RwLock::new(Option::Some(rt.block_on(async{db_oper.get_workers().await.unwrap()})))) ,
|
||||||
positions: Arc::new(RwLock::new(Option::Some(rt.block_on(async{db_oper.get_position().await.unwrap()})))),
|
positions: Arc::new(RwLock::new(Option::Some(rt.block_on(async{db_oper.get_position().await.unwrap()})))),
|
||||||
|
add_modal: egui::Modal::new(egui::Id::new("Добавление")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue