feat: allow to rename panels

This commit is contained in:
əlemi 2022-06-21 12:24:28 +02:00
parent 573c6991b4
commit 625b8020b2
No known key found for this signature in database
GPG key ID: BBCBFE5D7244634E
3 changed files with 25 additions and 20 deletions

View file

@ -1,6 +1,6 @@
[package]
name = "dashboard"
version = "0.3.0"
version = "0.3.1"
edition = "2021"
[[bin]]

View file

@ -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) {
let text_width = width - 190.0;
let text_width = width - 195.0;
ui.horizontal(|ui| {
ui.color_edit_button_srgba(&mut metric.color);
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 {
ComboBox::from_id_source(format!("panel-selector-{}", metric.id))
.width(60.0)
.selected_text(format!("panel: {}", metric.panel_id))
.selected_text(format!("panel: {:02}", metric.panel_id))
.show_ui(ui, |ui| {
ui.selectable_value(&mut metric.panel_id, -1, "None");
for p in panels {

View file

@ -16,9 +16,20 @@ pub fn panel_edit_inline_ui(ui: &mut Ui, panel: &mut Panel) {
.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.heading(panel.name.as_str());
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.with_layout(Layout::right_to_left(), |ui| {
ui.horizontal(|ui| {
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");
if extra {
ui.separator();
ui.checkbox(&mut panel.timeserie, "timeserie");
ui.separator();
ui.add(Slider::new(&mut panel.height, 0..=500).text("height"));
}
});
});
});
@ -138,17 +143,17 @@ pub fn panel_body_ui(ui: &mut Ui, panel: &mut Panel, metrics: &Vec<Metric>) {
for metric in metrics {
if metric.panel_id == panel.id {
let values = metric.values(min_x, max_x, chunk_size);
if !panel.timeserie && panel.view_scroll && values.len() > 0 {
let l = values.len() - 1;
p = p.include_x(values[0].x)
.include_x(values[l].x)
.include_y(values[0].y)
.include_y(values[l].y);
}
// if !panel.timeserie && panel.view_scroll && values.len() > 0 {
// let l = values.len() - 1;
// p = p.include_x(values[0].x)
// .include_x(values[l].x)
// .include_y(values[0].y)
// .include_y(values[l].y);
// }
lines.push(
Line::new(Values::from_values(values))
.name(metric.name.as_str())
.color(metric.color)
.name(metric.name.as_str())
.color(metric.color)
);
}
}