feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
import { useState, useEffect, useCallback } from 'react';
|
2025-07-23 00:08:00 -06:00
|
|
|
import { Widget, WidgetConfig } from '@/lib/types/widget';
|
2025-07-19 11:34:56 -06:00
|
|
|
import {
|
|
|
|
|
DashboardState,
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
DashboardConfig,
|
|
|
|
|
DASHBOARD_STORAGE_KEYS,
|
2025-07-23 00:08:00 -06:00
|
|
|
} from '@/lib/types/dashboard';
|
|
|
|
|
import { WidgetCache } from '@/lib/types/cache';
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
|
|
|
|
|
// Helper function to request location permission and get user's location
|
|
|
|
|
const requestLocationPermission = async (): Promise<string | undefined> => {
|
|
|
|
|
try {
|
|
|
|
|
if (!navigator.geolocation) {
|
|
|
|
|
console.warn('Geolocation is not supported by this browser');
|
|
|
|
|
return undefined;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
navigator.geolocation.getCurrentPosition(
|
|
|
|
|
(position) => {
|
|
|
|
|
const { latitude, longitude } = position.coords;
|
|
|
|
|
resolve(`${latitude.toFixed(6)}, ${longitude.toFixed(6)}`);
|
|
|
|
|
},
|
|
|
|
|
(error) => {
|
|
|
|
|
console.warn('Location access denied or failed:', error.message);
|
|
|
|
|
// Don't reject, just return undefined to continue without location
|
|
|
|
|
resolve(undefined);
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
enableHighAccuracy: true,
|
|
|
|
|
timeout: 10000, // 10 seconds timeout
|
|
|
|
|
maximumAge: 300000, // 5 minutes cache
|
2025-07-19 11:34:56 -06:00
|
|
|
},
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.warn('Error requesting location:', error);
|
|
|
|
|
return undefined;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Helper function to replace date/time variables in prompts on the client side
|
|
|
|
|
const replaceDateTimeVariables = (prompt: string): string => {
|
|
|
|
|
let processedPrompt = prompt;
|
2025-07-19 11:34:56 -06:00
|
|
|
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
// Replace UTC datetime
|
|
|
|
|
if (processedPrompt.includes('{{current_utc_datetime}}')) {
|
|
|
|
|
const utcDateTime = new Date().toISOString();
|
2025-07-19 11:34:56 -06:00
|
|
|
processedPrompt = processedPrompt.replace(
|
|
|
|
|
/\{\{current_utc_datetime\}\}/g,
|
|
|
|
|
utcDateTime,
|
|
|
|
|
);
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
}
|
2025-07-19 11:34:56 -06:00
|
|
|
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
// Replace local datetime
|
|
|
|
|
if (processedPrompt.includes('{{current_local_datetime}}')) {
|
|
|
|
|
const now = new Date();
|
2025-07-19 11:34:56 -06:00
|
|
|
const localDateTime = new Date(
|
|
|
|
|
now.getTime() - now.getTimezoneOffset() * 60000,
|
|
|
|
|
).toISOString();
|
|
|
|
|
processedPrompt = processedPrompt.replace(
|
|
|
|
|
/\{\{current_local_datetime\}\}/g,
|
|
|
|
|
localDateTime,
|
|
|
|
|
);
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
}
|
2025-07-19 11:34:56 -06:00
|
|
|
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
return processedPrompt;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
interface UseDashboardReturn {
|
|
|
|
|
// State
|
|
|
|
|
widgets: Widget[];
|
|
|
|
|
isLoading: boolean;
|
|
|
|
|
error: string | null;
|
|
|
|
|
settings: DashboardConfig['settings'];
|
2025-07-19 11:34:56 -06:00
|
|
|
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
// Widget management
|
|
|
|
|
addWidget: (config: WidgetConfig) => void;
|
|
|
|
|
updateWidget: (id: string, config: WidgetConfig) => void;
|
|
|
|
|
deleteWidget: (id: string) => void;
|
|
|
|
|
refreshWidget: (id: string, forceRefresh?: boolean) => Promise<void>;
|
2025-07-19 11:34:56 -06:00
|
|
|
refreshAllWidgets: (forceRefresh?: boolean) => Promise<void>;
|
|
|
|
|
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
// Storage management
|
|
|
|
|
exportDashboard: () => Promise<string>;
|
|
|
|
|
importDashboard: (configJson: string) => Promise<void>;
|
|
|
|
|
clearCache: () => void;
|
2025-07-19 11:34:56 -06:00
|
|
|
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
// Settings
|
|
|
|
|
updateSettings: (newSettings: Partial<DashboardConfig['settings']>) => void;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const useDashboard = (): UseDashboardReturn => {
|
|
|
|
|
const [state, setState] = useState<DashboardState>({
|
|
|
|
|
widgets: [],
|
|
|
|
|
isLoading: true, // Start as loading
|
|
|
|
|
error: null,
|
|
|
|
|
settings: {
|
|
|
|
|
parallelLoading: true,
|
|
|
|
|
autoRefresh: false,
|
|
|
|
|
theme: 'auto',
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const loadDashboardData = useCallback(() => {
|
|
|
|
|
try {
|
|
|
|
|
// Load widgets
|
|
|
|
|
const savedWidgets = localStorage.getItem(DASHBOARD_STORAGE_KEYS.WIDGETS);
|
|
|
|
|
const widgets: Widget[] = savedWidgets ? JSON.parse(savedWidgets) : [];
|
2025-07-19 11:34:56 -06:00
|
|
|
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
// Convert date strings back to Date objects
|
2025-07-19 11:34:56 -06:00
|
|
|
widgets.forEach((widget) => {
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
if (widget.lastUpdated) {
|
|
|
|
|
widget.lastUpdated = new Date(widget.lastUpdated);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Load settings
|
2025-07-19 11:34:56 -06:00
|
|
|
const savedSettings = localStorage.getItem(
|
|
|
|
|
DASHBOARD_STORAGE_KEYS.SETTINGS,
|
|
|
|
|
);
|
|
|
|
|
const settings = savedSettings
|
|
|
|
|
? JSON.parse(savedSettings)
|
|
|
|
|
: {
|
|
|
|
|
parallelLoading: true,
|
|
|
|
|
autoRefresh: false,
|
|
|
|
|
theme: 'auto',
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
setState((prev) => ({
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
...prev,
|
|
|
|
|
widgets,
|
|
|
|
|
settings,
|
|
|
|
|
isLoading: false,
|
|
|
|
|
}));
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Error loading dashboard data:', error);
|
2025-07-19 11:34:56 -06:00
|
|
|
setState((prev) => ({
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
...prev,
|
|
|
|
|
error: 'Failed to load dashboard data',
|
|
|
|
|
isLoading: false,
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
}, []);
|
|
|
|
|
|
2025-07-23 00:08:00 -06:00
|
|
|
// Load dashboard data from localStorage on mount
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
loadDashboardData();
|
|
|
|
|
}, [loadDashboardData]);
|
|
|
|
|
|
|
|
|
|
// Save widgets to localStorage whenever they change (but not on initial load)
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (!state.isLoading) {
|
|
|
|
|
localStorage.setItem(
|
|
|
|
|
DASHBOARD_STORAGE_KEYS.WIDGETS,
|
|
|
|
|
JSON.stringify(state.widgets),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}, [state.widgets, state.isLoading]);
|
|
|
|
|
|
|
|
|
|
// Save settings to localStorage whenever they change
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
localStorage.setItem(
|
|
|
|
|
DASHBOARD_STORAGE_KEYS.SETTINGS,
|
|
|
|
|
JSON.stringify(state.settings),
|
|
|
|
|
);
|
|
|
|
|
}, [state.settings]);
|
|
|
|
|
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
const addWidget = useCallback((config: WidgetConfig) => {
|
|
|
|
|
const newWidget: Widget = {
|
|
|
|
|
...config,
|
|
|
|
|
id: Date.now().toString() + Math.random().toString(36).substr(2, 9),
|
|
|
|
|
lastUpdated: null,
|
|
|
|
|
isLoading: false,
|
|
|
|
|
content: null,
|
|
|
|
|
error: null,
|
|
|
|
|
};
|
|
|
|
|
|
2025-07-19 11:34:56 -06:00
|
|
|
setState((prev) => ({
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
...prev,
|
|
|
|
|
widgets: [...prev.widgets, newWidget],
|
|
|
|
|
}));
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
const updateWidget = useCallback((id: string, config: WidgetConfig) => {
|
2025-07-19 11:34:56 -06:00
|
|
|
setState((prev) => ({
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
...prev,
|
2025-07-19 11:34:56 -06:00
|
|
|
widgets: prev.widgets.map((widget) =>
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
widget.id === id
|
|
|
|
|
? { ...widget, ...config, id } // Preserve the ID
|
2025-07-19 11:34:56 -06:00
|
|
|
: widget,
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
),
|
|
|
|
|
}));
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
const deleteWidget = useCallback((id: string) => {
|
2025-07-19 11:34:56 -06:00
|
|
|
setState((prev) => ({
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
...prev,
|
2025-07-19 11:34:56 -06:00
|
|
|
widgets: prev.widgets.filter((widget) => widget.id !== id),
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
// Also remove from cache
|
|
|
|
|
const cache = getWidgetCache();
|
|
|
|
|
delete cache[id];
|
|
|
|
|
localStorage.setItem(DASHBOARD_STORAGE_KEYS.CACHE, JSON.stringify(cache));
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
const getWidgetCache = (): WidgetCache => {
|
|
|
|
|
try {
|
|
|
|
|
const cached = localStorage.getItem(DASHBOARD_STORAGE_KEYS.CACHE);
|
|
|
|
|
return cached ? JSON.parse(cached) : {};
|
|
|
|
|
} catch {
|
|
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2025-07-23 00:08:00 -06:00
|
|
|
const isWidgetCacheValid = useCallback((widget: Widget): boolean => {
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
const cache = getWidgetCache();
|
|
|
|
|
const cachedData = cache[widget.id];
|
2025-07-19 11:34:56 -06:00
|
|
|
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
if (!cachedData) return false;
|
2025-07-19 11:34:56 -06:00
|
|
|
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
const now = new Date();
|
|
|
|
|
const expiresAt = new Date(cachedData.expiresAt);
|
2025-07-19 11:34:56 -06:00
|
|
|
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
return now < expiresAt;
|
2025-07-23 00:08:00 -06:00
|
|
|
}, []);
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
|
2025-07-23 00:08:00 -06:00
|
|
|
const getCacheExpiryTime = useCallback((widget: Widget): Date => {
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
const now = new Date();
|
2025-07-19 11:34:56 -06:00
|
|
|
const refreshMs =
|
|
|
|
|
widget.refreshFrequency *
|
|
|
|
|
(widget.refreshUnit === 'hours' ? 3600000 : 60000);
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
return new Date(now.getTime() + refreshMs);
|
2025-07-23 00:08:00 -06:00
|
|
|
}, []);
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
|
2025-07-19 11:34:56 -06:00
|
|
|
const refreshWidget = useCallback(
|
|
|
|
|
async (id: string, forceRefresh: boolean = false) => {
|
|
|
|
|
const widget = state.widgets.find((w) => w.id === id);
|
|
|
|
|
if (!widget) return;
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
|
2025-07-19 11:34:56 -06:00
|
|
|
// Check cache first (unless forcing refresh)
|
|
|
|
|
if (!forceRefresh && isWidgetCacheValid(widget)) {
|
|
|
|
|
const cache = getWidgetCache();
|
|
|
|
|
const cachedData = cache[widget.id];
|
|
|
|
|
setState((prev) => ({
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
...prev,
|
2025-07-19 11:34:56 -06:00
|
|
|
widgets: prev.widgets.map((w) =>
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
w.id === id
|
|
|
|
|
? {
|
|
|
|
|
...w,
|
2025-07-19 11:34:56 -06:00
|
|
|
content: cachedData.content,
|
|
|
|
|
lastUpdated: new Date(cachedData.lastFetched),
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
}
|
2025-07-19 11:34:56 -06:00
|
|
|
: w,
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
),
|
|
|
|
|
}));
|
2025-07-19 11:34:56 -06:00
|
|
|
return;
|
|
|
|
|
}
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
|
2025-07-19 11:34:56 -06:00
|
|
|
// Set loading state
|
|
|
|
|
setState((prev) => ({
|
|
|
|
|
...prev,
|
|
|
|
|
widgets: prev.widgets.map((w) =>
|
|
|
|
|
w.id === id ? { ...w, isLoading: true, error: null } : w,
|
|
|
|
|
),
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
// Check if prompt uses location variable and request permission if needed
|
|
|
|
|
let location: string | undefined;
|
|
|
|
|
if (widget.prompt.includes('{{location}}')) {
|
|
|
|
|
location = await requestLocationPermission();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Replace date/time variables on the client side
|
|
|
|
|
const processedPrompt = replaceDateTimeVariables(widget.prompt);
|
|
|
|
|
|
|
|
|
|
const response = await fetch('/api/dashboard/process-widget', {
|
|
|
|
|
method: 'POST',
|
|
|
|
|
headers: {
|
|
|
|
|
'Content-Type': 'application/json',
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify({
|
|
|
|
|
sources: widget.sources,
|
|
|
|
|
prompt: processedPrompt,
|
|
|
|
|
provider: widget.provider,
|
|
|
|
|
model: widget.model,
|
2025-07-23 00:08:00 -06:00
|
|
|
tool_names: widget.tool_names,
|
2025-07-19 11:34:56 -06:00
|
|
|
location,
|
|
|
|
|
}),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const result = await response.json();
|
|
|
|
|
const now = new Date();
|
|
|
|
|
|
|
|
|
|
if (result.success) {
|
|
|
|
|
// Update widget
|
|
|
|
|
setState((prev) => ({
|
|
|
|
|
...prev,
|
|
|
|
|
widgets: prev.widgets.map((w) =>
|
|
|
|
|
w.id === id
|
|
|
|
|
? {
|
|
|
|
|
...w,
|
|
|
|
|
isLoading: false,
|
|
|
|
|
content: result.content,
|
|
|
|
|
lastUpdated: now,
|
|
|
|
|
error: null,
|
|
|
|
|
}
|
|
|
|
|
: w,
|
|
|
|
|
),
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
// Cache the result
|
|
|
|
|
const cache = getWidgetCache();
|
|
|
|
|
cache[id] = {
|
|
|
|
|
content: result.content,
|
|
|
|
|
lastFetched: now,
|
|
|
|
|
expiresAt: getCacheExpiryTime(widget),
|
|
|
|
|
};
|
|
|
|
|
localStorage.setItem(
|
|
|
|
|
DASHBOARD_STORAGE_KEYS.CACHE,
|
|
|
|
|
JSON.stringify(cache),
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
setState((prev) => ({
|
|
|
|
|
...prev,
|
|
|
|
|
widgets: prev.widgets.map((w) =>
|
|
|
|
|
w.id === id
|
|
|
|
|
? {
|
|
|
|
|
...w,
|
|
|
|
|
isLoading: false,
|
|
|
|
|
error: result.error || 'Failed to refresh widget',
|
|
|
|
|
}
|
|
|
|
|
: w,
|
|
|
|
|
),
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
setState((prev) => ({
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
...prev,
|
2025-07-19 11:34:56 -06:00
|
|
|
widgets: prev.widgets.map((w) =>
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
w.id === id
|
|
|
|
|
? {
|
|
|
|
|
...w,
|
|
|
|
|
isLoading: false,
|
2025-07-19 11:34:56 -06:00
|
|
|
error: 'Network error: Failed to refresh widget',
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
}
|
2025-07-19 11:34:56 -06:00
|
|
|
: w,
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
),
|
|
|
|
|
}));
|
|
|
|
|
}
|
2025-07-19 11:34:56 -06:00
|
|
|
},
|
2025-07-23 00:08:00 -06:00
|
|
|
[state.widgets, isWidgetCacheValid, getCacheExpiryTime],
|
2025-07-19 11:34:56 -06:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const refreshAllWidgets = useCallback(
|
|
|
|
|
async (forceRefresh = false) => {
|
|
|
|
|
const activeWidgets = state.widgets.filter((w) => !w.isLoading);
|
|
|
|
|
|
|
|
|
|
if (state.settings.parallelLoading) {
|
|
|
|
|
// Refresh all widgets in parallel (force refresh)
|
|
|
|
|
await Promise.all(
|
|
|
|
|
activeWidgets.map((widget) => refreshWidget(widget.id, forceRefresh)),
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
// Refresh widgets sequentially (force refresh)
|
|
|
|
|
for (const widget of activeWidgets) {
|
|
|
|
|
await refreshWidget(widget.id, forceRefresh);
|
|
|
|
|
}
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
}
|
2025-07-19 11:34:56 -06:00
|
|
|
},
|
|
|
|
|
[state.widgets, state.settings.parallelLoading, refreshWidget],
|
|
|
|
|
);
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
|
|
|
|
|
const exportDashboard = useCallback(async (): Promise<string> => {
|
|
|
|
|
const dashboardConfig: DashboardConfig = {
|
|
|
|
|
widgets: state.widgets,
|
|
|
|
|
settings: state.settings,
|
|
|
|
|
lastExport: new Date(),
|
|
|
|
|
version: '1.0.0',
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return JSON.stringify(dashboardConfig, null, 2);
|
|
|
|
|
}, [state.widgets, state.settings]);
|
|
|
|
|
|
2025-07-19 11:34:56 -06:00
|
|
|
const importDashboard = useCallback(
|
|
|
|
|
async (configJson: string): Promise<void> => {
|
|
|
|
|
try {
|
|
|
|
|
const config: DashboardConfig = JSON.parse(configJson);
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
|
2025-07-19 11:34:56 -06:00
|
|
|
// Validate the config structure
|
|
|
|
|
if (!config.widgets || !Array.isArray(config.widgets)) {
|
|
|
|
|
throw new Error(
|
|
|
|
|
'Invalid dashboard configuration: missing or invalid widgets array',
|
|
|
|
|
);
|
|
|
|
|
}
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
|
2025-07-19 11:34:56 -06:00
|
|
|
// Process widgets and ensure they have valid IDs
|
|
|
|
|
const processedWidgets: Widget[] = config.widgets.map((widget) => ({
|
|
|
|
|
...widget,
|
|
|
|
|
id:
|
|
|
|
|
widget.id ||
|
|
|
|
|
Date.now().toString() + Math.random().toString(36).substr(2, 9),
|
|
|
|
|
lastUpdated: widget.lastUpdated ? new Date(widget.lastUpdated) : null,
|
|
|
|
|
isLoading: false,
|
|
|
|
|
content: widget.content || null,
|
|
|
|
|
error: null,
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
setState((prev) => ({
|
|
|
|
|
...prev,
|
|
|
|
|
widgets: processedWidgets,
|
|
|
|
|
settings: { ...prev.settings, ...config.settings },
|
|
|
|
|
}));
|
|
|
|
|
} catch (error) {
|
|
|
|
|
throw new Error(
|
|
|
|
|
`Failed to import dashboard: ${error instanceof Error ? error.message : 'Invalid JSON'}`,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
[],
|
|
|
|
|
);
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
|
|
|
|
|
const clearCache = useCallback(() => {
|
|
|
|
|
localStorage.removeItem(DASHBOARD_STORAGE_KEYS.CACHE);
|
|
|
|
|
}, []);
|
|
|
|
|
|
2025-07-19 11:34:56 -06:00
|
|
|
const updateSettings = useCallback(
|
|
|
|
|
(newSettings: Partial<DashboardConfig['settings']>) => {
|
|
|
|
|
setState((prev) => ({
|
|
|
|
|
...prev,
|
|
|
|
|
settings: { ...prev.settings, ...newSettings },
|
|
|
|
|
}));
|
|
|
|
|
},
|
|
|
|
|
[],
|
|
|
|
|
);
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
// State
|
|
|
|
|
widgets: state.widgets,
|
|
|
|
|
isLoading: state.isLoading,
|
|
|
|
|
error: state.error,
|
|
|
|
|
settings: state.settings,
|
2025-07-19 11:34:56 -06:00
|
|
|
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
// Widget management
|
|
|
|
|
addWidget,
|
|
|
|
|
updateWidget,
|
|
|
|
|
deleteWidget,
|
|
|
|
|
refreshWidget,
|
|
|
|
|
refreshAllWidgets,
|
2025-07-19 11:34:56 -06:00
|
|
|
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
// Storage management
|
|
|
|
|
exportDashboard,
|
|
|
|
|
importDashboard,
|
|
|
|
|
clearCache,
|
2025-07-19 11:34:56 -06:00
|
|
|
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
// Settings
|
|
|
|
|
updateSettings,
|
|
|
|
|
};
|
|
|
|
|
};
|