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,5 +1,5 @@
use serde::{Serialize, Deserialize};
use super::wire::{WireLayoutNode, WireWidgetState, WireDisplayHint};
use super::wire::{WireDisplayHint, WireLayoutNode, WireWidgetState};
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct WidgetDescriptor {

View File

@@ -1,13 +1,11 @@
mod wire;
mod frame;
mod wire;
pub use wire::{
WireValue, WireWidgetState, WireWidgetError, WireDisplayHint,
WireLayoutNode, WireContainerNode, WireLayoutChild, WireDirection, WireSizing,
WireKeyValue,
};
pub use frame::{
ServerMessage, ClientMessage, WidgetDescriptor,
encode, decode_server_message, encode_client, decode_client_message,
MAX_FRAME_SIZE,
ClientMessage, MAX_FRAME_SIZE, ServerMessage, WidgetDescriptor, decode_client_message,
decode_server_message, encode, encode_client,
};
pub use wire::{
WireContainerNode, WireDirection, WireDisplayHint, WireKeyValue, WireLayoutChild,
WireLayoutNode, WireSizing, WireValue, WireWidgetError, WireWidgetState,
};

View File

@@ -1,9 +1,9 @@
use std::collections::BTreeMap;
use serde::{Serialize, Deserialize};
use domain::value_objects::{
ContainerNode, Direction, DisplayHint, LayoutChild, LayoutNode, Sizing, Value,
WidgetError, WidgetState,
ContainerNode, Direction, DisplayHint, LayoutChild, LayoutNode, Sizing, Value, WidgetError,
WidgetState,
};
use serde::{Deserialize, Serialize};
use std::collections::BTreeMap;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum WireValue {
@@ -84,10 +84,14 @@ pub struct WireWidgetState {
impl From<&WidgetState> for WireWidgetState {
fn from(s: &WidgetState) -> Self {
WireWidgetState {
data: s.data.iter().map(|(k, v)| WireKeyValue {
key: k.clone(),
value: v.into(),
}).collect(),
data: s
.data
.iter()
.map(|(k, v)| WireKeyValue {
key: k.clone(),
value: v.into(),
})
.collect(),
error: s.error.as_ref().map(Into::into),
}
}
@@ -96,7 +100,11 @@ impl From<&WidgetState> for WireWidgetState {
impl From<WireWidgetState> for WidgetState {
fn from(w: WireWidgetState) -> Self {
WidgetState {
data: w.data.into_iter().map(|kv| (kv.key, kv.value.into())).collect(),
data: w
.data
.into_iter()
.map(|kv| (kv.key, kv.value.into()))
.collect(),
error: w.error.map(Into::into),
}
}
@@ -205,10 +213,14 @@ impl From<&LayoutNode> for WireLayoutNode {
direction: (&c.direction).into(),
gap: c.gap,
padding: c.padding,
children: c.children.iter().map(|ch| WireLayoutChild {
sizing: (&ch.sizing).into(),
node: (&ch.node).into(),
}).collect(),
children: c
.children
.iter()
.map(|ch| WireLayoutChild {
sizing: (&ch.sizing).into(),
node: (&ch.node).into(),
})
.collect(),
}),
}
}
@@ -222,10 +234,14 @@ impl From<WireLayoutNode> for LayoutNode {
direction: c.direction.into(),
gap: c.gap,
padding: c.padding,
children: c.children.into_iter().map(|ch| LayoutChild {
sizing: ch.sizing.into(),
node: ch.node.into(),
}).collect(),
children: c
.children
.into_iter()
.map(|ch| LayoutChild {
sizing: ch.sizing.into(),
node: ch.node.into(),
})
.collect(),
}),
}
}

View File

@@ -1,24 +1,24 @@
use std::collections::BTreeMap;
use domain::{
Value, WidgetState, WidgetError, DisplayHint,
LayoutNode, ContainerNode, LayoutChild, Direction, Sizing,
ContainerNode, Direction, DisplayHint, LayoutChild, LayoutNode, Sizing, Value, WidgetError,
WidgetState,
};
use protocol::{
WireValue, WireWidgetState, WireWidgetError, WireDisplayHint,
WireLayoutNode, WireContainerNode, WireLayoutChild, WireDirection, WireSizing,
WireKeyValue,
WireContainerNode, WireDirection, WireDisplayHint, WireKeyValue, WireLayoutChild,
WireLayoutNode, WireSizing, WireValue, WireWidgetError, WireWidgetState,
};
use std::collections::BTreeMap;
#[test]
fn value_converts_to_wire_and_back() {
let original = Value::Object(BTreeMap::from([
("items".into(), Value::Array(vec![
let original = Value::Object(BTreeMap::from([(
"items".into(),
Value::Array(vec![
Value::String("hello".into()),
Value::Number(42.0),
Value::Bool(true),
Value::Null,
])),
]));
]),
)]));
let wire: WireValue = (&original).into();
let roundtripped: Value = wire.into();
@@ -28,9 +28,7 @@ fn value_converts_to_wire_and_back() {
#[test]
fn widget_state_with_error_converts_to_wire_and_back() {
let original = WidgetState {
data: BTreeMap::from([
("temp".into(), Value::Number(5.4)),
]),
data: BTreeMap::from([("temp".into(), Value::Number(5.4))]),
error: Some(WidgetError::SourceUnavailable),
};
@@ -56,12 +54,10 @@ fn layout_tree_converts_to_wire_and_back() {
direction: Direction::Column,
gap: 2,
padding: 0,
children: vec![
LayoutChild {
sizing: Sizing::Flex(1),
node: LayoutNode::Leaf(2),
},
],
children: vec![LayoutChild {
sizing: Sizing::Flex(1),
node: LayoutNode::Leaf(2),
}],
}),
},
],
@@ -74,7 +70,11 @@ fn layout_tree_converts_to_wire_and_back() {
#[test]
fn display_hint_converts_to_wire_and_back() {
for hint in [DisplayHint::IconValue, DisplayHint::TextBlock, DisplayHint::KeyValue] {
for hint in [
DisplayHint::IconValue,
DisplayHint::TextBlock,
DisplayHint::KeyValue,
] {
let wire: WireDisplayHint = (&hint).into();
let roundtripped: DisplayHint = wire.into();
assert_eq!(hint, roundtripped);

View File

@@ -1,8 +1,7 @@
use protocol::{
ServerMessage, ClientMessage, WidgetDescriptor,
WireDisplayHint, WireLayoutNode, WireContainerNode, WireLayoutChild,
WireDirection, WireSizing, WireWidgetState, WireKeyValue, WireValue,
encode, decode_server_message, encode_client, decode_client_message,
ClientMessage, ServerMessage, WidgetDescriptor, WireContainerNode, WireDirection,
WireDisplayHint, WireKeyValue, WireLayoutChild, WireLayoutNode, WireSizing, WireValue,
WireWidgetState, decode_client_message, decode_server_message, encode, encode_client,
};
#[test]
@@ -23,19 +22,23 @@ fn screen_update_round_trips() {
},
],
}),
widgets: vec![
WidgetDescriptor {
id: 1,
display_hint: WireDisplayHint::IconValue,
state: WireWidgetState {
data: vec![
WireKeyValue { key: "temperature".into(), value: WireValue::String("5.4°C".into()) },
WireKeyValue { key: "icon".into(), value: WireValue::String("cloud_rain".into()) },
],
error: None,
},
widgets: vec![WidgetDescriptor {
id: 1,
display_hint: WireDisplayHint::IconValue,
state: WireWidgetState {
data: vec![
WireKeyValue {
key: "temperature".into(),
value: WireValue::String("5.4°C".into()),
},
WireKeyValue {
key: "icon".into(),
value: WireValue::String("cloud_rain".into()),
},
],
error: None,
},
],
}],
};
let frame = encode(&msg).unwrap();
@@ -47,18 +50,17 @@ fn screen_update_round_trips() {
#[test]
fn data_update_round_trips() {
let msg = ServerMessage::DataUpdate {
widgets: vec![
WidgetDescriptor {
id: 3,
display_hint: WireDisplayHint::TextBlock,
state: WireWidgetState {
data: vec![
WireKeyValue { key: "body".into(), value: WireValue::String("Breaking news...".into()) },
],
error: None,
},
widgets: vec![WidgetDescriptor {
id: 3,
display_hint: WireDisplayHint::TextBlock,
state: WireWidgetState {
data: vec![WireKeyValue {
key: "body".into(),
value: WireValue::String("Breaking news...".into()),
}],
error: None,
},
],
}],
};
let frame = encode(&msg).unwrap();