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:
@@ -6,7 +6,6 @@ pub type DataSourceId = u16;
|
||||
pub enum DataSourceType {
|
||||
Weather,
|
||||
Media,
|
||||
Xtb,
|
||||
Rss,
|
||||
HttpJson,
|
||||
Webhook,
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
mod widget_config;
|
||||
mod data_source;
|
||||
mod layout_preset;
|
||||
mod widget_config;
|
||||
|
||||
pub use widget_config::{WidgetConfig, WidgetId};
|
||||
pub use data_source::{DataSource, DataSourceId, DataSourceType, DataSourceConfig, DataSourceValidationError};
|
||||
pub use data_source::{
|
||||
DataSource, DataSourceConfig, DataSourceId, DataSourceType, DataSourceValidationError,
|
||||
};
|
||||
pub use layout_preset::{LayoutPreset, LayoutPresetId};
|
||||
pub use widget_config::{WidgetConfig, WidgetId};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use std::collections::BTreeMap;
|
||||
use crate::value_objects::{DisplayHint, KeyMapping, Value, WidgetState};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
pub type WidgetId = u16;
|
||||
pub type DataSourceId = u16;
|
||||
@@ -58,7 +58,8 @@ impl WidgetConfig {
|
||||
fn truncate_value(value: Value, max_bytes: usize) -> Value {
|
||||
match value {
|
||||
Value::String(s) if s.len() > max_bytes => {
|
||||
let truncated: String = s.char_indices()
|
||||
let truncated: String = s
|
||||
.char_indices()
|
||||
.take_while(|(i, _)| *i < max_bytes)
|
||||
.map(|(_, c)| c)
|
||||
.collect();
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
#![allow(async_fn_in_trait)]
|
||||
|
||||
pub mod entities;
|
||||
pub mod value_objects;
|
||||
pub mod events;
|
||||
pub mod ports;
|
||||
pub mod value_objects;
|
||||
|
||||
pub use entities::{
|
||||
WidgetConfig, WidgetId,
|
||||
DataSource, DataSourceId, DataSourceType, DataSourceConfig, DataSourceValidationError,
|
||||
LayoutPreset, LayoutPresetId,
|
||||
};
|
||||
pub use value_objects::{
|
||||
Value, KeyMapping,
|
||||
WidgetState, WidgetError, DisplayHint,
|
||||
Layout, LayoutNode, LayoutChild, ContainerNode, Direction, Sizing, LayoutValidationError,
|
||||
DataSource, DataSourceConfig, DataSourceId, DataSourceType, DataSourceValidationError,
|
||||
LayoutPreset, LayoutPresetId, WidgetConfig, WidgetId,
|
||||
};
|
||||
pub use events::DomainEvent;
|
||||
pub use ports::{ConfigRepository, DataSourcePort, BroadcastPort, EventPublisher};
|
||||
pub use ports::{BroadcastPort, ConfigRepository, DataSourcePort, EventPublisher};
|
||||
pub use value_objects::{
|
||||
ContainerNode, Direction, DisplayHint, KeyMapping, Layout, LayoutChild, LayoutNode,
|
||||
LayoutValidationError, Sizing, Value, WidgetError, WidgetState,
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::future::Future;
|
||||
use crate::entities::WidgetId;
|
||||
use crate::value_objects::{Layout, WidgetState};
|
||||
use std::future::Future;
|
||||
|
||||
pub trait BroadcastPort {
|
||||
type Error;
|
||||
|
||||
@@ -1,27 +1,53 @@
|
||||
use std::future::Future;
|
||||
use crate::entities::{
|
||||
DataSource, DataSourceId, LayoutPreset, LayoutPresetId, WidgetConfig, WidgetId,
|
||||
};
|
||||
use crate::value_objects::Layout;
|
||||
use std::future::Future;
|
||||
|
||||
pub trait ConfigRepository {
|
||||
type Error;
|
||||
|
||||
fn get_widget(&self, id: WidgetId) -> impl Future<Output = Result<Option<WidgetConfig>, Self::Error>> + Send;
|
||||
fn get_widget(
|
||||
&self,
|
||||
id: WidgetId,
|
||||
) -> impl Future<Output = Result<Option<WidgetConfig>, Self::Error>> + Send;
|
||||
fn list_widgets(&self) -> impl Future<Output = Result<Vec<WidgetConfig>, Self::Error>> + Send;
|
||||
fn save_widget(&self, config: &WidgetConfig) -> impl Future<Output = Result<(), Self::Error>> + Send;
|
||||
fn save_widget(
|
||||
&self,
|
||||
config: &WidgetConfig,
|
||||
) -> impl Future<Output = Result<(), Self::Error>> + Send;
|
||||
fn delete_widget(&self, id: WidgetId) -> impl Future<Output = Result<(), Self::Error>> + Send;
|
||||
|
||||
fn get_data_source(&self, id: DataSourceId) -> impl Future<Output = Result<Option<DataSource>, Self::Error>> + Send;
|
||||
fn list_data_sources(&self) -> impl Future<Output = Result<Vec<DataSource>, Self::Error>> + Send;
|
||||
fn save_data_source(&self, source: &DataSource) -> impl Future<Output = Result<(), Self::Error>> + Send;
|
||||
fn delete_data_source(&self, id: DataSourceId) -> impl Future<Output = Result<(), Self::Error>> + Send;
|
||||
fn get_data_source(
|
||||
&self,
|
||||
id: DataSourceId,
|
||||
) -> impl Future<Output = Result<Option<DataSource>, Self::Error>> + Send;
|
||||
fn list_data_sources(
|
||||
&self,
|
||||
) -> impl Future<Output = Result<Vec<DataSource>, Self::Error>> + Send;
|
||||
fn save_data_source(
|
||||
&self,
|
||||
source: &DataSource,
|
||||
) -> impl Future<Output = Result<(), Self::Error>> + Send;
|
||||
fn delete_data_source(
|
||||
&self,
|
||||
id: DataSourceId,
|
||||
) -> impl Future<Output = Result<(), Self::Error>> + Send;
|
||||
|
||||
fn get_layout(&self) -> impl Future<Output = Result<Option<Layout>, Self::Error>> + Send;
|
||||
fn save_layout(&self, layout: &Layout) -> impl Future<Output = Result<(), Self::Error>> + Send;
|
||||
|
||||
fn get_preset(&self, id: LayoutPresetId) -> impl Future<Output = Result<Option<LayoutPreset>, Self::Error>> + Send;
|
||||
fn get_preset(
|
||||
&self,
|
||||
id: LayoutPresetId,
|
||||
) -> impl Future<Output = Result<Option<LayoutPreset>, Self::Error>> + Send;
|
||||
fn list_presets(&self) -> impl Future<Output = Result<Vec<LayoutPreset>, Self::Error>> + Send;
|
||||
fn save_preset(&self, preset: &LayoutPreset) -> impl Future<Output = Result<(), Self::Error>> + Send;
|
||||
fn delete_preset(&self, id: LayoutPresetId) -> impl Future<Output = Result<(), Self::Error>> + Send;
|
||||
fn save_preset(
|
||||
&self,
|
||||
preset: &LayoutPreset,
|
||||
) -> impl Future<Output = Result<(), Self::Error>> + Send;
|
||||
fn delete_preset(
|
||||
&self,
|
||||
id: LayoutPresetId,
|
||||
) -> impl Future<Output = Result<(), Self::Error>> + Send;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::future::Future;
|
||||
use crate::entities::DataSource;
|
||||
use crate::value_objects::Value;
|
||||
use std::future::Future;
|
||||
|
||||
pub trait DataSourcePort {
|
||||
type Error;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use std::future::Future;
|
||||
use crate::events::DomainEvent;
|
||||
use std::future::Future;
|
||||
|
||||
pub trait EventPublisher {
|
||||
type Error;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
mod broadcast;
|
||||
mod config_repository;
|
||||
mod data_source_port;
|
||||
mod broadcast;
|
||||
mod event;
|
||||
|
||||
pub use broadcast::BroadcastPort;
|
||||
pub use config_repository::ConfigRepository;
|
||||
pub use data_source_port::DataSourcePort;
|
||||
pub use broadcast::BroadcastPort;
|
||||
pub use event::EventPublisher;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use std::collections::BTreeSet;
|
||||
use crate::entities::WidgetId;
|
||||
use std::collections::BTreeSet;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum Sizing {
|
||||
@@ -81,7 +81,9 @@ impl Layout {
|
||||
|
||||
fn collect_ids(node: &LayoutNode, ids: &mut BTreeSet<WidgetId>) {
|
||||
match node {
|
||||
LayoutNode::Leaf(id) => { ids.insert(*id); }
|
||||
LayoutNode::Leaf(id) => {
|
||||
ids.insert(*id);
|
||||
}
|
||||
LayoutNode::Container(c) => {
|
||||
for child in &c.children {
|
||||
Self::collect_ids(&child.node, ids);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
mod value;
|
||||
mod key_mapping;
|
||||
mod widget_state;
|
||||
mod layout;
|
||||
mod value;
|
||||
mod widget_state;
|
||||
|
||||
pub use value::Value;
|
||||
pub use key_mapping::KeyMapping;
|
||||
pub use widget_state::{WidgetState, WidgetError, DisplayHint};
|
||||
pub use layout::{
|
||||
Layout, LayoutNode, LayoutChild, ContainerNode, Direction, Sizing, LayoutValidationError,
|
||||
ContainerNode, Direction, Layout, LayoutChild, LayoutNode, LayoutValidationError, Sizing,
|
||||
};
|
||||
pub use value::Value;
|
||||
pub use widget_state::{DisplayHint, WidgetError, WidgetState};
|
||||
|
||||
@@ -17,10 +17,7 @@ impl Value {
|
||||
Value::Number(_) => 8,
|
||||
Value::String(s) => s.len(),
|
||||
Value::Array(arr) => arr.iter().map(|v| v.estimated_size()).sum(),
|
||||
Value::Object(map) => map
|
||||
.iter()
|
||||
.map(|(k, v)| k.len() + v.estimated_size())
|
||||
.sum(),
|
||||
Value::Object(map) => map.iter().map(|(k, v)| k.len() + v.estimated_size()).sum(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use std::collections::BTreeMap;
|
||||
use super::Value;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct WidgetState {
|
||||
|
||||
Reference in New Issue
Block a user