mirror of
https://git.alemi.dev/dashboard.git
synced 2024-11-22 23:44:55 +01:00
feat: allow to rename panels
This commit is contained in:
parent
573c6991b4
commit
625b8020b2
3 changed files with 25 additions and 20 deletions
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "dashboard"
|
name = "dashboard"
|
||||||
version = "0.3.0"
|
version = "0.3.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
|
|
|
@ -38,7 +38,7 @@ pub fn metric_display_ui(ui: &mut Ui, metric: &Metric, _width: f32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn metric_edit_ui(ui: &mut Ui, metric: &mut Metric, panels: Option<&Vec<Panel>>, width: f32) {
|
pub fn metric_edit_ui(ui: &mut Ui, metric: &mut Metric, panels: Option<&Vec<Panel>>, width: f32) {
|
||||||
let text_width = width - 190.0;
|
let text_width = width - 195.0;
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
ui.color_edit_button_srgba(&mut metric.color);
|
ui.color_edit_button_srgba(&mut metric.color);
|
||||||
TextEdit::singleline(&mut metric.name)
|
TextEdit::singleline(&mut metric.name)
|
||||||
|
@ -57,7 +57,7 @@ pub fn metric_edit_ui(ui: &mut Ui, metric: &mut Metric, panels: Option<&Vec<Pane
|
||||||
if let Some(panels) = panels {
|
if let Some(panels) = panels {
|
||||||
ComboBox::from_id_source(format!("panel-selector-{}", metric.id))
|
ComboBox::from_id_source(format!("panel-selector-{}", metric.id))
|
||||||
.width(60.0)
|
.width(60.0)
|
||||||
.selected_text(format!("panel: {}", metric.panel_id))
|
.selected_text(format!("panel: {:02}", metric.panel_id))
|
||||||
.show_ui(ui, |ui| {
|
.show_ui(ui, |ui| {
|
||||||
ui.selectable_value(&mut metric.panel_id, -1, "None");
|
ui.selectable_value(&mut metric.panel_id, -1, "None");
|
||||||
for p in panels {
|
for p in panels {
|
||||||
|
|
|
@ -16,9 +16,20 @@ pub fn panel_edit_inline_ui(ui: &mut Ui, panel: &mut Panel) {
|
||||||
.show(ui);
|
.show(ui);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn panel_title_ui(ui: &mut Ui, panel: &mut Panel, extra: bool) {
|
pub fn panel_title_ui(ui: &mut Ui, panel: &mut Panel, edit: bool) { // TODO make edit UI in separate func
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
|
if edit {
|
||||||
|
TextEdit::singleline(&mut panel.name)
|
||||||
|
.hint_text("name")
|
||||||
|
.desired_width(150.0)
|
||||||
|
.show(ui);
|
||||||
|
ui.separator();
|
||||||
|
ui.add(Slider::new(&mut panel.height, 0..=500).text("height"));
|
||||||
|
ui.separator();
|
||||||
|
ui.checkbox(&mut panel.timeserie, "timeserie");
|
||||||
|
} else {
|
||||||
ui.heading(panel.name.as_str());
|
ui.heading(panel.name.as_str());
|
||||||
|
}
|
||||||
ui.with_layout(Layout::right_to_left(), |ui| {
|
ui.with_layout(Layout::right_to_left(), |ui| {
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
ui.toggle_value(&mut panel.view_scroll, "🔒");
|
ui.toggle_value(&mut panel.view_scroll, "🔒");
|
||||||
|
@ -52,12 +63,6 @@ pub fn panel_title_ui(ui: &mut Ui, panel: &mut Panel, extra: bool) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
ui.toggle_value(&mut panel.reduce, "reduce");
|
ui.toggle_value(&mut panel.reduce, "reduce");
|
||||||
if extra {
|
|
||||||
ui.separator();
|
|
||||||
ui.checkbox(&mut panel.timeserie, "timeserie");
|
|
||||||
ui.separator();
|
|
||||||
ui.add(Slider::new(&mut panel.height, 0..=500).text("height"));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -138,13 +143,13 @@ pub fn panel_body_ui(ui: &mut Ui, panel: &mut Panel, metrics: &Vec<Metric>) {
|
||||||
for metric in metrics {
|
for metric in metrics {
|
||||||
if metric.panel_id == panel.id {
|
if metric.panel_id == panel.id {
|
||||||
let values = metric.values(min_x, max_x, chunk_size);
|
let values = metric.values(min_x, max_x, chunk_size);
|
||||||
if !panel.timeserie && panel.view_scroll && values.len() > 0 {
|
// if !panel.timeserie && panel.view_scroll && values.len() > 0 {
|
||||||
let l = values.len() - 1;
|
// let l = values.len() - 1;
|
||||||
p = p.include_x(values[0].x)
|
// p = p.include_x(values[0].x)
|
||||||
.include_x(values[l].x)
|
// .include_x(values[l].x)
|
||||||
.include_y(values[0].y)
|
// .include_y(values[0].y)
|
||||||
.include_y(values[l].y);
|
// .include_y(values[l].y);
|
||||||
}
|
// }
|
||||||
lines.push(
|
lines.push(
|
||||||
Line::new(Values::from_values(values))
|
Line::new(Values::from_values(values))
|
||||||
.name(metric.name.as_str())
|
.name(metric.name.as_str())
|
||||||
|
|
Loading…
Reference in a new issue