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:
@@ -1,11 +1,9 @@
|
||||
use std::time::Duration;
|
||||
use domain::{
|
||||
ConfigRepository, DisplayHint, KeyMapping, WidgetConfig,
|
||||
DataSource, DataSourceConfig, DataSourceType,
|
||||
Layout, LayoutNode, ContainerNode, LayoutChild, Direction, Sizing,
|
||||
LayoutPreset,
|
||||
};
|
||||
use config_sqlite::SqliteConfigStore;
|
||||
use domain::{
|
||||
ConfigRepository, ContainerNode, DataSource, DataSourceConfig, DataSourceType, Direction,
|
||||
DisplayHint, KeyMapping, Layout, LayoutChild, LayoutNode, LayoutPreset, Sizing, WidgetConfig,
|
||||
};
|
||||
use std::time::Duration;
|
||||
|
||||
async fn test_store() -> SqliteConfigStore {
|
||||
SqliteConfigStore::new("sqlite::memory:").await.unwrap()
|
||||
@@ -18,8 +16,14 @@ fn weather_widget() -> WidgetConfig {
|
||||
display_hint: DisplayHint::IconValue,
|
||||
data_source_id: 10,
|
||||
mappings: vec![
|
||||
KeyMapping { source_path: "$.temp".into(), target_key: "temperature".into() },
|
||||
KeyMapping { source_path: "$.icon".into(), target_key: "icon".into() },
|
||||
KeyMapping {
|
||||
source_path: "$.temp".into(),
|
||||
target_key: "temperature".into(),
|
||||
},
|
||||
KeyMapping {
|
||||
source_path: "$.icon".into(),
|
||||
target_key: "icon".into(),
|
||||
},
|
||||
],
|
||||
max_data_size: 2048,
|
||||
}
|
||||
@@ -46,8 +50,14 @@ fn test_layout() -> Layout {
|
||||
gap: 4,
|
||||
padding: 2,
|
||||
children: vec![
|
||||
LayoutChild { sizing: Sizing::Flex(1), node: LayoutNode::Leaf(1) },
|
||||
LayoutChild { sizing: Sizing::Fixed(80), node: LayoutNode::Leaf(2) },
|
||||
LayoutChild {
|
||||
sizing: Sizing::Flex(1),
|
||||
node: LayoutNode::Leaf(1),
|
||||
},
|
||||
LayoutChild {
|
||||
sizing: Sizing::Fixed(80),
|
||||
node: LayoutNode::Leaf(2),
|
||||
},
|
||||
],
|
||||
}),
|
||||
}
|
||||
@@ -78,14 +88,17 @@ async fn get_nonexistent_widget_returns_none() {
|
||||
async fn list_widgets_returns_all() {
|
||||
let store = test_store().await;
|
||||
store.save_widget(&weather_widget()).await.unwrap();
|
||||
store.save_widget(&WidgetConfig {
|
||||
id: 2,
|
||||
name: "portfolio".into(),
|
||||
display_hint: DisplayHint::KeyValue,
|
||||
data_source_id: 20,
|
||||
mappings: vec![],
|
||||
max_data_size: 1024,
|
||||
}).await.unwrap();
|
||||
store
|
||||
.save_widget(&WidgetConfig {
|
||||
id: 2,
|
||||
name: "portfolio".into(),
|
||||
display_hint: DisplayHint::KeyValue,
|
||||
data_source_id: 20,
|
||||
mappings: vec![],
|
||||
max_data_size: 1024,
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let widgets = store.list_widgets().await.unwrap();
|
||||
assert_eq!(widgets.len(), 2);
|
||||
@@ -172,12 +185,22 @@ async fn save_and_retrieve_preset() {
|
||||
#[tokio::test]
|
||||
async fn list_and_delete_presets() {
|
||||
let store = test_store().await;
|
||||
store.save_preset(&LayoutPreset {
|
||||
id: 1, name: "a".into(), layout: test_layout(),
|
||||
}).await.unwrap();
|
||||
store.save_preset(&LayoutPreset {
|
||||
id: 2, name: "b".into(), layout: test_layout(),
|
||||
}).await.unwrap();
|
||||
store
|
||||
.save_preset(&LayoutPreset {
|
||||
id: 1,
|
||||
name: "a".into(),
|
||||
layout: test_layout(),
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
store
|
||||
.save_preset(&LayoutPreset {
|
||||
id: 2,
|
||||
name: "b".into(),
|
||||
layout: test_layout(),
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(store.list_presets().await.unwrap().len(), 2);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user