fix: loading of data from the database seems to do something

This commit is contained in:
2026-04-04 21:46:56 +02:00
parent a7cc12ffb8
commit 989efeaf25
12 changed files with 303 additions and 55 deletions

View File

@@ -106,13 +106,19 @@ pub fn view(
let items: Vec<Element<'static, Message>> = task_snapshots
.iter()
.map(|snap| {
let progress_str = snap.progress
.map(|p| format!(" ({:.0}%)", p * 100.0))
.unwrap_or_default();
let phase_str = snap.message
.as_deref()
.map(|m| format!(" \u{2014} {m}"))
.unwrap_or_default();
let status_text = format!(
"{} \u{2014} {}{}",
"{} \u{2014} {}{}{}",
snap.label,
snap.status,
snap.progress
.map(|p| format!(" ({:.0}%)", p * 100.0))
.unwrap_or_default(),
progress_str,
phase_str,
);
text(status_text).size(11).color(Color::from_rgb(0.70, 0.70, 0.75)).into()
})

View File

@@ -1,11 +1,13 @@
use iced::widget::{column, container, scrollable, text, Space};
use iced::widget::{button, column, container, scrollable, text, Space};
use iced::{Background, Border, Color, Element, Length, Theme};
use bds_core::i18n::UiLocale;
use bds_core::model::Post;
use crate::app::Message;
use crate::i18n::t;
use crate::state::navigation::SidebarView;
use crate::state::tabs::{Tab, TabType};
/// Sidebar container style — dark background with right border separator.
fn sidebar_style(_theme: &Theme) -> container::Style {
@@ -20,6 +22,20 @@ fn sidebar_style(_theme: &Theme) -> container::Style {
}
}
/// Sidebar item button style.
fn item_style(_theme: &Theme, status: button::Status) -> button::Style {
let bg = match status {
button::Status::Hovered => Color::from_rgb(0.22, 0.22, 0.27),
_ => Color::TRANSPARENT,
};
button::Style {
background: Some(Background::Color(bg)),
text_color: Color::from_rgb(0.80, 0.80, 0.85),
border: Border::default(),
..button::Style::default()
}
}
/// Get the appropriate empty-state message key for each sidebar view.
fn placeholder_key(view: SidebarView) -> &'static str {
match view {
@@ -38,19 +54,63 @@ fn placeholder_key(view: SidebarView) -> &'static str {
pub fn view(
sidebar_view: SidebarView,
posts: &[Post],
locale: UiLocale,
) -> Element<'static, Message> {
let header_text = t(locale, sidebar_view.i18n_key());
let placeholder = t(locale, placeholder_key(sidebar_view));
let muted = Color::from_rgb(0.50, 0.50, 0.55);
let header = text(header_text)
.size(13)
.color(Color::from_rgb(0.85, 0.85, 0.90));
let body: Element<'static, Message> = match sidebar_view {
SidebarView::Posts => {
if posts.is_empty() {
text(t(locale, placeholder_key(sidebar_view)))
.size(12)
.color(muted)
.into()
} else {
let items: Vec<Element<'static, Message>> = posts
.iter()
.map(|p| {
let status_indicator = match p.status {
bds_core::model::PostStatus::Draft => "\u{25CB} ", // ○
bds_core::model::PostStatus::Published => "\u{25CF} ", // ●
bds_core::model::PostStatus::Archived => "\u{25A1} ", // □
};
let label = format!("{status_indicator}{}", p.title);
button(text(label).size(12))
.on_press(Message::OpenTab(Tab {
id: p.id.clone(),
tab_type: TabType::Post,
title: p.title.clone(),
is_transient: true,
}))
.padding([3, 6])
.width(Length::Fill)
.style(item_style)
.into()
})
.collect();
iced::widget::Column::with_children(items)
.spacing(1)
.into()
}
}
_ => {
text(t(locale, placeholder_key(sidebar_view)))
.size(12)
.color(muted)
.into()
}
};
let content = column![
text(header_text)
.size(13)
.color(Color::from_rgb(0.85, 0.85, 0.90)),
header,
Space::with_height(8.0),
text(placeholder)
.size(12)
.color(Color::from_rgb(0.50, 0.50, 0.55)),
body,
]
.spacing(4)
.padding(12);

View File

@@ -129,12 +129,24 @@ pub fn view(
.filter(|t| t.status == "running")
.collect();
let task_indicator: Element<'static, Message> = if !running.is_empty() {
let first = running[0].label.clone();
if running.len() > 1 {
text(format!("{first} (+{})", running.len() - 1)).size(11).color(label_color).into()
let first = &running[0];
let progress_str = first.progress
.map(|p| format!(" {:.0}%", p * 100.0))
.unwrap_or_default();
let phase_str = first.message
.as_deref()
.unwrap_or("");
let extra = if running.len() > 1 {
format!(" (+{})", running.len() - 1)
} else {
text(first).size(11).color(label_color).into()
}
String::new()
};
let display = if phase_str.is_empty() {
format!("{}{progress_str}{extra}", first.label)
} else {
format!("{phase_str}{progress_str}{extra}")
};
text(display).size(11).color(label_color).into()
} else {
Space::with_width(0).into()
};

View File

@@ -3,7 +3,7 @@ use iced::widget::text::Shaping;
use iced::{Alignment, Background, Color, Element, Length, Padding, Theme};
use bds_core::i18n::UiLocale;
use bds_core::model::Project;
use bds_core::model::{Post, Project};
use crate::app::Message;
use crate::state::navigation::{OutputEntry, PanelTab, SidebarView, TaskSnapshot};
@@ -53,6 +53,8 @@ pub fn view(
panel_tab: PanelTab,
task_snapshots: &[TaskSnapshot],
output_entries: &[OutputEntry],
// Sidebar data
sidebar_posts: &[Post],
// Status bar
active_project_name: Option<&str>,
projects: &[Project],
@@ -89,7 +91,7 @@ pub fn view(
let mut main_row = row![activity];
if sidebar_visible {
main_row = main_row.push(sidebar::view(sidebar_view, locale));
main_row = main_row.push(sidebar::view(sidebar_view, sidebar_posts, locale));
main_row = main_row.push(separator_v());
}