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,5 +1,5 @@
|
||||
use std::collections::BTreeMap;
|
||||
use domain::{DisplayHint, KeyMapping, Value, WidgetConfig};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
#[test]
|
||||
fn extract_applies_all_mappings_to_produce_widget_state() {
|
||||
@@ -9,27 +9,39 @@ fn extract_applies_all_mappings_to_produce_widget_state() {
|
||||
display_hint: DisplayHint::IconValue,
|
||||
data_source_id: 1,
|
||||
mappings: vec![
|
||||
KeyMapping { source_path: "$.main.temp".into(), target_key: "temperature".into() },
|
||||
KeyMapping { source_path: "$.weather[0].icon".into(), target_key: "icon".into() },
|
||||
KeyMapping {
|
||||
source_path: "$.main.temp".into(),
|
||||
target_key: "temperature".into(),
|
||||
},
|
||||
KeyMapping {
|
||||
source_path: "$.weather[0].icon".into(),
|
||||
target_key: "icon".into(),
|
||||
},
|
||||
],
|
||||
max_data_size: 2048,
|
||||
};
|
||||
|
||||
let raw = Value::Object(BTreeMap::from([
|
||||
("main".into(), Value::Object(BTreeMap::from([
|
||||
("temp".into(), Value::Number(5.4)),
|
||||
]))),
|
||||
("weather".into(), Value::Array(vec![
|
||||
Value::Object(BTreeMap::from([
|
||||
("icon".into(), Value::String("cloud_rain".into())),
|
||||
])),
|
||||
])),
|
||||
(
|
||||
"main".into(),
|
||||
Value::Object(BTreeMap::from([("temp".into(), Value::Number(5.4))])),
|
||||
),
|
||||
(
|
||||
"weather".into(),
|
||||
Value::Array(vec![Value::Object(BTreeMap::from([(
|
||||
"icon".into(),
|
||||
Value::String("cloud_rain".into()),
|
||||
)]))]),
|
||||
),
|
||||
]));
|
||||
|
||||
let state = config.extract(&raw);
|
||||
|
||||
assert_eq!(state.data.get("temperature"), Some(&Value::Number(5.4)));
|
||||
assert_eq!(state.data.get("icon"), Some(&Value::String("cloud_rain".into())));
|
||||
assert_eq!(
|
||||
state.data.get("icon"),
|
||||
Some(&Value::String("cloud_rain".into()))
|
||||
);
|
||||
assert_eq!(state.error, None);
|
||||
}
|
||||
|
||||
@@ -41,15 +53,14 @@ fn extract_truncates_string_values_exceeding_max_data_size() {
|
||||
name: "news".into(),
|
||||
display_hint: DisplayHint::TextBlock,
|
||||
data_source_id: 1,
|
||||
mappings: vec![
|
||||
KeyMapping { source_path: "$.text".into(), target_key: "body".into() },
|
||||
],
|
||||
mappings: vec![KeyMapping {
|
||||
source_path: "$.text".into(),
|
||||
target_key: "body".into(),
|
||||
}],
|
||||
max_data_size: 100,
|
||||
};
|
||||
|
||||
let raw = Value::Object(BTreeMap::from([
|
||||
("text".into(), Value::String(long_text)),
|
||||
]));
|
||||
let raw = Value::Object(BTreeMap::from([("text".into(), Value::String(long_text))]));
|
||||
|
||||
let state = config.extract(&raw);
|
||||
match state.data.get("body") {
|
||||
@@ -66,9 +77,18 @@ fn extract_respects_max_data_size_across_total_state() {
|
||||
display_hint: DisplayHint::TextBlock,
|
||||
data_source_id: 1,
|
||||
mappings: vec![
|
||||
KeyMapping { source_path: "$.a".into(), target_key: "a".into() },
|
||||
KeyMapping { source_path: "$.b".into(), target_key: "b".into() },
|
||||
KeyMapping { source_path: "$.c".into(), target_key: "c".into() },
|
||||
KeyMapping {
|
||||
source_path: "$.a".into(),
|
||||
target_key: "a".into(),
|
||||
},
|
||||
KeyMapping {
|
||||
source_path: "$.b".into(),
|
||||
target_key: "b".into(),
|
||||
},
|
||||
KeyMapping {
|
||||
source_path: "$.c".into(),
|
||||
target_key: "c".into(),
|
||||
},
|
||||
],
|
||||
max_data_size: 50,
|
||||
};
|
||||
@@ -92,15 +112,19 @@ fn extract_skips_mappings_that_dont_match() {
|
||||
display_hint: DisplayHint::IconValue,
|
||||
data_source_id: 1,
|
||||
mappings: vec![
|
||||
KeyMapping { source_path: "$.temp".into(), target_key: "temperature".into() },
|
||||
KeyMapping { source_path: "$.missing".into(), target_key: "gone".into() },
|
||||
KeyMapping {
|
||||
source_path: "$.temp".into(),
|
||||
target_key: "temperature".into(),
|
||||
},
|
||||
KeyMapping {
|
||||
source_path: "$.missing".into(),
|
||||
target_key: "gone".into(),
|
||||
},
|
||||
],
|
||||
max_data_size: 2048,
|
||||
};
|
||||
|
||||
let raw = Value::Object(BTreeMap::from([
|
||||
("temp".into(), Value::Number(5.4)),
|
||||
]));
|
||||
let raw = Value::Object(BTreeMap::from([("temp".into(), Value::Number(5.4))]));
|
||||
|
||||
let state = config.extract(&raw);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user