mirror of
https://git.alemi.dev/dashboard.git
synced 2024-11-22 15:34:54 +01:00
feat: moved new source in side panel, small tweaks
This commit is contained in:
parent
66253fe900
commit
14e57447f4
3 changed files with 35 additions and 26 deletions
|
@ -12,7 +12,7 @@ use crate::app::{
|
||||||
pub fn panel_edit_inline_ui(ui: &mut Ui, panel: &mut Panel) {
|
pub fn panel_edit_inline_ui(ui: &mut Ui, panel: &mut Panel) {
|
||||||
TextEdit::singleline(&mut panel.name)
|
TextEdit::singleline(&mut panel.name)
|
||||||
.hint_text("name")
|
.hint_text("name")
|
||||||
.desired_width(50.0)
|
.desired_width(100.0)
|
||||||
.show(ui);
|
.show(ui);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ use eframe::egui::{Ui, TextEdit, ComboBox, Slider, DragValue};
|
||||||
|
|
||||||
use crate::app::data::source::{Panel, Source};
|
use crate::app::data::source::{Panel, Source};
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn source_edit_inline_ui(ui: &mut Ui, source: &mut Source, panels: &Vec<Panel>) {
|
pub fn source_edit_inline_ui(ui: &mut Ui, source: &mut Source, panels: &Vec<Panel>) {
|
||||||
TextEdit::singleline(&mut source.name)
|
TextEdit::singleline(&mut source.name)
|
||||||
.hint_text("name")
|
.hint_text("name")
|
||||||
|
@ -49,11 +50,11 @@ pub fn source_edit_ui(ui: &mut Ui, source: &mut Source, panels: &Vec<Panel>, wid
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
let text_width : f32 ;
|
let text_width : f32 ;
|
||||||
if width > 400.0 {
|
if width > 400.0 {
|
||||||
ui.add(Slider::new(&mut source.interval, 1..=60));
|
ui.add(Slider::new(&mut source.interval, 1..=120));
|
||||||
text_width = width - 330.0
|
text_width = width - 330.0
|
||||||
} else {
|
} else {
|
||||||
ui.add(DragValue::new(&mut source.interval).clamp_range(1..=60));
|
ui.add(DragValue::new(&mut source.interval).clamp_range(1..=120));
|
||||||
text_width = width - 220.0
|
text_width = width - 225.0
|
||||||
}
|
}
|
||||||
TextEdit::singleline(&mut source.query_x)
|
TextEdit::singleline(&mut source.query_x)
|
||||||
.desired_width(text_width / 2.0)
|
.desired_width(text_width / 2.0)
|
||||||
|
|
|
@ -4,8 +4,8 @@ pub mod util;
|
||||||
pub mod worker;
|
pub mod worker;
|
||||||
|
|
||||||
use eframe::egui::{
|
use eframe::egui::{
|
||||||
global_dark_light_mode_switch, CentralPanel, Context, Layout, ScrollArea, SidePanel,
|
collapsing_header::CollapsingState, global_dark_light_mode_switch, CentralPanel, Context,
|
||||||
TopBottomPanel, collapsing_header::CollapsingState,
|
Layout, ScrollArea, SidePanel, TopBottomPanel,
|
||||||
};
|
};
|
||||||
use eframe::emath::Align;
|
use eframe::emath::Align;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
@ -14,7 +14,7 @@ use tracing::error;
|
||||||
use self::data::source::{Panel, Source};
|
use self::data::source::{Panel, Source};
|
||||||
use self::data::ApplicationState;
|
use self::data::ApplicationState;
|
||||||
use self::gui::panel::{panel_body_ui, panel_edit_inline_ui, panel_title_ui};
|
use self::gui::panel::{panel_body_ui, panel_edit_inline_ui, panel_title_ui};
|
||||||
use self::gui::source::{source_edit_inline_ui, source_edit_ui};
|
use self::gui::source::source_edit_ui;
|
||||||
use self::util::human_size;
|
use self::util::human_size;
|
||||||
use self::worker::native_save;
|
use self::worker::native_save;
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ pub struct App {
|
||||||
input_source: Source,
|
input_source: Source,
|
||||||
input_panel: Panel,
|
input_panel: Panel,
|
||||||
edit: bool,
|
edit: bool,
|
||||||
|
padding: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl App {
|
impl App {
|
||||||
|
@ -32,6 +33,7 @@ impl App {
|
||||||
input_panel: Panel::default(),
|
input_panel: Panel::default(),
|
||||||
input_source: Source::default(),
|
input_source: Source::default(),
|
||||||
edit: false,
|
edit: false,
|
||||||
|
padding: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,18 +60,6 @@ impl eframe::App for App {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
ui.separator();
|
ui.separator();
|
||||||
ui.label("+ source");
|
|
||||||
source_edit_inline_ui(
|
|
||||||
ui,
|
|
||||||
&mut self.input_source,
|
|
||||||
&self.data.panels.read().expect("Panels RwLock poisoned"),
|
|
||||||
);
|
|
||||||
if ui.button("add").clicked() {
|
|
||||||
if let Err(e) = self.data.add_source(&self.input_source) {
|
|
||||||
error!(target: "ui", "Error adding souce : {:?}", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ui.separator();
|
|
||||||
}
|
}
|
||||||
ui.with_layout(Layout::top_down(Align::RIGHT), |ui| {
|
ui.with_layout(Layout::top_down(Align::RIGHT), |ui| {
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
|
@ -130,18 +120,36 @@ impl eframe::App for App {
|
||||||
.width_range(240.0..=800.0)
|
.width_range(240.0..=800.0)
|
||||||
.default_width(500.0)
|
.default_width(500.0)
|
||||||
.show(ctx, |ui| {
|
.show(ctx, |ui| {
|
||||||
let mut sources = self.data.sources.write().expect("Sources RwLock poisoned");
|
|
||||||
let panels = self.data.panels.read().expect("Panels RwLock poisoned");
|
let panels = self.data.panels.read().expect("Panels RwLock poisoned");
|
||||||
ScrollArea::vertical().show(ui, |ui| {
|
ScrollArea::vertical().show(ui, |ui| {
|
||||||
let width = ui.available_width();
|
let width = ui.available_width();
|
||||||
|
{
|
||||||
|
let mut sources = self.data.sources.write().expect("Sources RwLock poisoned");
|
||||||
for source in &mut *sources {
|
for source in &mut *sources {
|
||||||
source_edit_ui(ui, source, &panels, width);
|
source_edit_ui(ui, source, &panels, width);
|
||||||
}
|
}
|
||||||
// TODO make this not necessary
|
}
|
||||||
ui.collapsing("extra space", |ui| {
|
ui.add_space(20.0);
|
||||||
ui.add_space(300.0);
|
|
||||||
ui.separator();
|
ui.separator();
|
||||||
})
|
ui.horizontal(|ui| {
|
||||||
|
ui.heading("new source");
|
||||||
|
ui.with_layout(Layout::top_down(Align::RIGHT), |ui| {
|
||||||
|
ui.horizontal(|ui| {
|
||||||
|
if ui.button("add").clicked() {
|
||||||
|
if let Err(e) = self.data.add_source(&self.input_source) {
|
||||||
|
error!(target: "ui", "Error adding souce : {:?}", e);
|
||||||
|
} else {
|
||||||
|
self.input_source.id += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ui.toggle_value(&mut self.padding, "#");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
source_edit_ui(ui, &mut self.input_source, &panels, width);
|
||||||
|
if self.padding {
|
||||||
|
ui.add_space(300.0);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue