1#![allow(clippy::too_many_arguments)]
7#![allow(dead_code)]
8
9use serde::{Deserialize, Serialize};
10use std::collections::HashMap;
11use std::time::Duration;
12
13#[derive(Debug, Clone, Serialize, Deserialize)]
15pub struct DashboardConfig {
16 pub title: String,
18 pub width: u32,
20 pub height: u32,
22 pub theme: ThemeConfig,
24 pub layout: LayoutConfig,
26 pub realtime_config: RealtimeConfig,
28 pub interaction_config: InteractionConfig,
30 pub export_config: ExportConfig,
32 pub collaboration_config: Option<CollaborationConfig>,
34}
35
36#[derive(Debug, Clone, Serialize, Deserialize)]
38pub struct ThemeConfig {
39 pub primary_color: String,
41 pub secondary_color: String,
43 pub background_color: String,
45 pub text_color: String,
47 pub font_family: String,
49 pub font_size: u32,
51 pub border_radius: u32,
53 pub shadow_enabled: bool,
55 pub custom_variables: HashMap<String, String>,
57}
58
59#[derive(Debug, Clone, Serialize, Deserialize)]
61pub struct LayoutConfig {
62 pub layout_type: LayoutType,
64 pub grid_config: Option<GridConfig>,
66 pub spacing: SpacingConfig,
68 pub animation: AnimationConfig,
70 pub breakpoints: HashMap<String, u32>,
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize)]
76pub enum LayoutType {
77 Fixed,
79 Grid,
81 Flexbox,
83 Masonry,
85 Custom(String),
87}
88
89#[derive(Debug, Clone, Serialize, Deserialize)]
91pub struct GridConfig {
92 pub columns: u32,
94 pub rows: u32,
96 pub column_gap: u32,
98 pub row_gap: u32,
100 pub auto_fit: bool,
102}
103
104#[derive(Debug, Clone, Serialize, Deserialize)]
106pub struct SpacingConfig {
107 pub margin: u32,
109 pub padding: u32,
111 pub widget_spacing: u32,
113 pub container_spacing: u32,
115}
116
117#[derive(Debug, Clone, Serialize, Deserialize)]
119pub struct AnimationConfig {
120 pub enabled: bool,
122 pub duration: Duration,
124 pub easing: String,
126 pub performance_mode: bool,
128}
129
130#[derive(Debug, Clone, Serialize, Deserialize)]
132pub struct RealtimeConfig {
133 pub enabled: bool,
135 pub update_interval: Duration,
137 pub buffer_size: usize,
139 pub max_connections: u32,
141 pub protocol: StreamingProtocol,
143 pub connection_timeout: Duration,
145 pub retry_attempts: u32,
147}
148
149#[derive(Debug, Clone, Serialize, Deserialize)]
151pub enum StreamingProtocol {
152 WebSocket,
154 SSE,
156 LongPolling,
158 WebRTC,
160}
161
162#[derive(Debug, Clone, Serialize, Deserialize)]
164pub struct InteractionConfig {
165 pub touch_enabled: bool,
167 pub keyboard_shortcuts: bool,
169 pub zoom_pan_enabled: bool,
171 pub selection_enabled: bool,
173 pub drag_drop_enabled: bool,
175 pub double_click_threshold: Duration,
177 pub hover_delay: Duration,
179 pub custom_handlers: HashMap<String, String>,
181}
182
183#[derive(Debug, Clone, Serialize, Deserialize)]
185pub struct ExportConfig {
186 pub formats: Vec<ExportFormat>,
188 pub default_format: ExportFormat,
190 pub quality: u32,
192 pub include_metadata: bool,
194 pub compression: bool,
196}
197
198#[derive(Debug, Clone, Serialize, Deserialize)]
200pub enum ExportFormat {
201 PNG,
203 JPEG,
205 SVG,
207 PDF,
209 HTML,
211 JSON,
213}
214
215#[derive(Debug, Clone, Serialize, Deserialize)]
217pub struct CollaborationConfig {
218 pub enabled: bool,
220 pub auth: AuthConfig,
222 pub sharing: ShareConfig,
224 pub sync: SyncConfig,
226 pub max_collaborators: u32,
228}
229
230#[derive(Debug, Clone, Serialize, Deserialize)]
232pub struct AuthConfig {
233 pub method: AuthMethod,
235 pub session_timeout: Duration,
237 pub guest_access: bool,
239 pub required_permissions: Vec<String>,
241}
242
243#[derive(Debug, Clone, Serialize, Deserialize)]
245pub enum AuthMethod {
246 None,
248 Token,
250 OAuth,
252 ApiKey,
254 Custom(String),
256}
257
258#[derive(Debug, Clone, Serialize, Deserialize)]
260pub struct ShareConfig {
261 pub public_sharing: bool,
263 pub default_permission: PermissionLevel,
265 pub link_expiration: Option<Duration>,
267 pub password_protection: bool,
269}
270
271#[derive(Debug, Clone, Serialize, Deserialize)]
273pub enum PermissionLevel {
274 ReadOnly,
276 Comment,
278 Edit,
280 Admin,
282}
283
284#[derive(Debug, Clone, Serialize, Deserialize)]
286pub struct SyncConfig {
287 pub sync_interval: Duration,
289 pub conflict_resolution: ConflictResolution,
291 pub operational_transforms: bool,
293 pub history_retention: Duration,
295}
296
297#[derive(Debug, Clone, Serialize, Deserialize)]
299pub enum ConflictResolution {
300 LastWriterWins,
302 FirstWriterWins,
304 Manual,
306 Merge,
308}
309
310#[derive(Debug, Clone, Serialize, Deserialize)]
312pub struct Position {
313 pub x: f64,
315 pub y: f64,
317}
318
319#[derive(Debug, Clone, Serialize, Deserialize)]
321pub struct Size {
322 pub width: f64,
324 pub height: f64,
326}
327
328impl Default for DashboardConfig {
329 fn default() -> Self {
330 Self {
331 title: "Interactive Dashboard".to_string(),
332 width: 1200,
333 height: 800,
334 theme: ThemeConfig::default(),
335 layout: LayoutConfig::default(),
336 realtime_config: RealtimeConfig::default(),
337 interaction_config: InteractionConfig::default(),
338 export_config: ExportConfig::default(),
339 collaboration_config: None,
340 }
341 }
342}
343
344impl Default for ThemeConfig {
345 fn default() -> Self {
346 Self {
347 primary_color: "#007bff".to_string(),
348 secondary_color: "#6c757d".to_string(),
349 background_color: "#ffffff".to_string(),
350 text_color: "#212529".to_string(),
351 font_family: "Arial, sans-serif".to_string(),
352 font_size: 14,
353 border_radius: 4,
354 shadow_enabled: true,
355 custom_variables: HashMap::new(),
356 }
357 }
358}
359
360impl Default for LayoutConfig {
361 fn default() -> Self {
362 Self {
363 layout_type: LayoutType::Grid,
364 grid_config: Some(GridConfig::default()),
365 spacing: SpacingConfig::default(),
366 animation: AnimationConfig::default(),
367 breakpoints: HashMap::new(),
368 }
369 }
370}
371
372impl Default for GridConfig {
373 fn default() -> Self {
374 Self {
375 columns: 12,
376 rows: 8,
377 column_gap: 16,
378 row_gap: 16,
379 auto_fit: true,
380 }
381 }
382}
383
384impl Default for SpacingConfig {
385 fn default() -> Self {
386 Self {
387 margin: 16,
388 padding: 16,
389 widget_spacing: 8,
390 container_spacing: 24,
391 }
392 }
393}
394
395impl Default for AnimationConfig {
396 fn default() -> Self {
397 Self {
398 enabled: true,
399 duration: Duration::from_millis(300),
400 easing: "ease-in-out".to_string(),
401 performance_mode: false,
402 }
403 }
404}
405
406impl Default for RealtimeConfig {
407 fn default() -> Self {
408 Self {
409 enabled: true,
410 update_interval: Duration::from_millis(1000),
411 buffer_size: 1000,
412 max_connections: 100,
413 protocol: StreamingProtocol::WebSocket,
414 connection_timeout: Duration::from_secs(30),
415 retry_attempts: 3,
416 }
417 }
418}
419
420impl Default for InteractionConfig {
421 fn default() -> Self {
422 Self {
423 touch_enabled: true,
424 keyboard_shortcuts: true,
425 zoom_pan_enabled: true,
426 selection_enabled: true,
427 drag_drop_enabled: true,
428 double_click_threshold: Duration::from_millis(500),
429 hover_delay: Duration::from_millis(300),
430 custom_handlers: HashMap::new(),
431 }
432 }
433}
434
435impl Default for ExportConfig {
436 fn default() -> Self {
437 Self {
438 formats: vec![ExportFormat::PNG, ExportFormat::SVG, ExportFormat::JSON],
439 default_format: ExportFormat::PNG,
440 quality: 90,
441 include_metadata: true,
442 compression: true,
443 }
444 }
445}
446
447impl Default for Position {
448 fn default() -> Self {
449 Self { x: 0.0, y: 0.0 }
450 }
451}
452
453impl Default for Size {
454 fn default() -> Self {
455 Self {
456 width: 100.0,
457 height: 100.0,
458 }
459 }
460}