add SPA config UI, wire media/rss adapters, event-driven layout push

- React SPA: dashboard, data sources CRUD, widgets CRUD, layout builder,
  presets. TanStack Router + Query, shadcn/ui, Vite proxy to :3000
- wire media + rss adapters into polling loop, remove xtb source type
- media adapter: read username/password from headers, proper subsonic auth
- event handler: subscribe to LayoutChanged, push screen update to clients
- fix clippy warnings across workspace (Default impls, collapsible ifs,
  redundant closures, is_none_or, unused imports)
This commit is contained in:
2026-06-19 00:12:42 +02:00
parent 21c08911df
commit 26ebfad3a2
175 changed files with 12338 additions and 801 deletions

View File

@@ -1,9 +1,7 @@
use std::collections::HashMap;
use domain::LayoutNode;
use client_domain::{BoundingBox, LayoutEngine, RenderTree};
use protocol::{
ServerMessage, WidgetDescriptor, WireDisplayHint, WireWidgetState, WireLayoutNode,
};
use domain::LayoutNode;
use protocol::{ServerMessage, WidgetDescriptor, WireDisplayHint, WireLayoutNode, WireWidgetState};
use std::collections::HashMap;
pub struct ClientApp {
screen: BoundingBox,
@@ -33,9 +31,7 @@ impl ClientApp {
ServerMessage::ScreenUpdate { layout, widgets } => {
self.handle_screen_update(layout, widgets)
}
ServerMessage::DataUpdate { widgets } => {
self.handle_data_update(widgets)
}
ServerMessage::DataUpdate { widgets } => self.handle_data_update(widgets),
ServerMessage::Heartbeat => Vec::new(),
}
}
@@ -50,7 +46,8 @@ impl ClientApp {
self.widget_states.clear();
for w in &widgets {
self.widget_states.insert(w.id, (w.display_hint.clone(), w.state.clone()));
self.widget_states
.insert(w.id, (w.display_hint.clone(), w.state.clone()));
}
let repaints = self.build_repaints_for_all(&new_tree);
@@ -58,10 +55,7 @@ impl ClientApp {
repaints
}
fn handle_data_update(
&mut self,
widgets: Vec<WidgetDescriptor>,
) -> Vec<RepaintCommand> {
fn handle_data_update(&mut self, widgets: Vec<WidgetDescriptor>) -> Vec<RepaintCommand> {
let tree = match &self.render_tree {
Some(t) => t,
None => return Vec::new(),
@@ -70,9 +64,10 @@ impl ClientApp {
let mut repaints = Vec::new();
for w in widgets {
let changed = self.widget_states
let changed = self
.widget_states
.get(&w.id)
.map_or(true, |(_, prev_state)| *prev_state != w.state);
.is_none_or(|(_, prev_state)| *prev_state != w.state);
if changed {
if let Some(bounds) = tree.get_widget_bounds(w.id) {

View File

@@ -1,9 +1,8 @@
use client_application::{ClientApp, RepaintCommand};
use client_domain::BoundingBox;
use protocol::{
ServerMessage, WidgetDescriptor,
WireDisplayHint, WireLayoutNode, WireContainerNode, WireLayoutChild,
WireDirection, WireSizing, WireWidgetState, WireKeyValue, WireValue,
ServerMessage, WidgetDescriptor, WireContainerNode, WireDirection, WireDisplayHint,
WireKeyValue, WireLayoutChild, WireLayoutNode, WireSizing, WireValue, WireWidgetState,
};
fn screen() -> BoundingBox {
@@ -15,9 +14,10 @@ fn weather_descriptor(id: u16, temp: &str) -> WidgetDescriptor {
id,
display_hint: WireDisplayHint::IconValue,
state: WireWidgetState {
data: vec![
WireKeyValue { key: "temperature".into(), value: WireValue::String(temp.into()) },
],
data: vec![WireKeyValue {
key: "temperature".into(),
value: WireValue::String(temp.into()),
}],
error: None,
},
}
@@ -29,8 +29,14 @@ fn two_widget_layout() -> WireLayoutNode {
gap: 0,
padding: 0,
children: vec![
WireLayoutChild { sizing: WireSizing::Flex(1), node: WireLayoutNode::Leaf(1) },
WireLayoutChild { sizing: WireSizing::Flex(1), node: WireLayoutNode::Leaf(2) },
WireLayoutChild {
sizing: WireSizing::Flex(1),
node: WireLayoutNode::Leaf(1),
},
WireLayoutChild {
sizing: WireSizing::Flex(1),
node: WireLayoutNode::Leaf(2),
},
],
})
}
@@ -116,8 +122,14 @@ fn second_screen_update_repaints_all_widgets_with_new_layout() {
gap: 0,
padding: 0,
children: vec![
WireLayoutChild { sizing: WireSizing::Flex(1), node: WireLayoutNode::Leaf(1) },
WireLayoutChild { sizing: WireSizing::Flex(1), node: WireLayoutNode::Leaf(2) },
WireLayoutChild {
sizing: WireSizing::Flex(1),
node: WireLayoutNode::Leaf(1),
},
WireLayoutChild {
sizing: WireSizing::Flex(1),
node: WireLayoutNode::Leaf(2),
},
],
});