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
|
|
|
'use client';
|
|
|
|
|
|
2025-07-19 11:34:56 -06:00
|
|
|
import {
|
|
|
|
|
Dialog,
|
|
|
|
|
DialogPanel,
|
|
|
|
|
DialogTitle,
|
|
|
|
|
Transition,
|
|
|
|
|
TransitionChild,
|
|
|
|
|
} from '@headlessui/react';
|
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 { X, Plus, Trash2, Play, Save } from 'lucide-react';
|
|
|
|
|
import { Fragment, useState, useEffect } from 'react';
|
|
|
|
|
import MarkdownRenderer from '@/components/MarkdownRenderer';
|
|
|
|
|
import ModelSelector from '@/components/MessageInputActions/ModelSelector';
|
|
|
|
|
|
|
|
|
|
// 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 Source {
|
|
|
|
|
url: string;
|
|
|
|
|
type: 'Web Page' | 'HTTP Data';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface WidgetConfig {
|
|
|
|
|
id?: string;
|
|
|
|
|
title: string;
|
|
|
|
|
sources: Source[];
|
|
|
|
|
prompt: string;
|
|
|
|
|
provider: string;
|
|
|
|
|
model: string;
|
|
|
|
|
refreshFrequency: number;
|
|
|
|
|
refreshUnit: 'minutes' | 'hours';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface WidgetConfigModalProps {
|
|
|
|
|
isOpen: boolean;
|
|
|
|
|
onClose: () => void;
|
|
|
|
|
onSave: (config: WidgetConfig) => void;
|
|
|
|
|
editingWidget?: WidgetConfig | null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const WidgetConfigModal = ({
|
|
|
|
|
isOpen,
|
|
|
|
|
onClose,
|
|
|
|
|
onSave,
|
|
|
|
|
editingWidget,
|
|
|
|
|
}: WidgetConfigModalProps) => {
|
|
|
|
|
const [config, setConfig] = useState<WidgetConfig>({
|
|
|
|
|
title: '',
|
|
|
|
|
sources: [{ url: '', type: 'Web Page' }],
|
|
|
|
|
prompt: '',
|
|
|
|
|
provider: 'openai',
|
|
|
|
|
model: 'gpt-4',
|
|
|
|
|
refreshFrequency: 60,
|
|
|
|
|
refreshUnit: 'minutes',
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const [previewContent, setPreviewContent] = useState<string>('');
|
|
|
|
|
const [isPreviewLoading, setIsPreviewLoading] = useState(false);
|
2025-07-19 11:34:56 -06:00
|
|
|
const [selectedModel, setSelectedModel] = useState<{
|
|
|
|
|
provider: string;
|
|
|
|
|
model: string;
|
|
|
|
|
} | null>(null);
|
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
|
|
|
|
|
|
|
|
// Update config when editingWidget changes
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (editingWidget) {
|
|
|
|
|
setConfig({
|
|
|
|
|
title: editingWidget.title,
|
|
|
|
|
sources: editingWidget.sources,
|
|
|
|
|
prompt: editingWidget.prompt,
|
|
|
|
|
provider: editingWidget.provider,
|
|
|
|
|
model: editingWidget.model,
|
|
|
|
|
refreshFrequency: editingWidget.refreshFrequency,
|
|
|
|
|
refreshUnit: editingWidget.refreshUnit,
|
|
|
|
|
});
|
|
|
|
|
setSelectedModel({
|
|
|
|
|
provider: editingWidget.provider,
|
|
|
|
|
model: editingWidget.model,
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
// Reset to default values for new widget
|
|
|
|
|
setConfig({
|
|
|
|
|
title: '',
|
|
|
|
|
sources: [{ url: '', type: 'Web Page' }],
|
|
|
|
|
prompt: '',
|
|
|
|
|
provider: 'openai',
|
|
|
|
|
model: 'gpt-4',
|
|
|
|
|
refreshFrequency: 60,
|
|
|
|
|
refreshUnit: 'minutes',
|
|
|
|
|
});
|
|
|
|
|
setSelectedModel({
|
|
|
|
|
provider: 'openai',
|
|
|
|
|
model: 'gpt-4',
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}, [editingWidget]);
|
|
|
|
|
|
|
|
|
|
// Update config when model selection changes
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (selectedModel) {
|
2025-07-19 11:34:56 -06:00
|
|
|
setConfig((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,
|
|
|
|
|
provider: selectedModel.provider,
|
|
|
|
|
model: selectedModel.model,
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
}, [selectedModel]);
|
|
|
|
|
|
|
|
|
|
const handleSave = () => {
|
|
|
|
|
if (!config.title.trim() || !config.prompt.trim()) {
|
|
|
|
|
return; // TODO: Add proper validation feedback
|
|
|
|
|
}
|
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
|
|
|
onSave(config);
|
|
|
|
|
onClose();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handlePreview = async () => {
|
|
|
|
|
if (!config.prompt.trim()) {
|
|
|
|
|
setPreviewContent('Please enter a prompt before running preview.');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-19 11:34:56 -06:00
|
|
|
if (
|
|
|
|
|
config.sources.length === 0 ||
|
|
|
|
|
config.sources.every((s) => !s.url.trim())
|
|
|
|
|
) {
|
|
|
|
|
setPreviewContent(
|
|
|
|
|
'Please add at least one source URL before running preview.',
|
|
|
|
|
);
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setIsPreviewLoading(true);
|
|
|
|
|
try {
|
|
|
|
|
// Replace date/time variables on the client side
|
|
|
|
|
const processedPrompt = replaceDateTimeVariables(config.prompt);
|
|
|
|
|
|
|
|
|
|
const response = await fetch('/api/dashboard/process-widget', {
|
|
|
|
|
method: 'POST',
|
|
|
|
|
headers: {
|
|
|
|
|
'Content-Type': 'application/json',
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify({
|
2025-07-19 11:34:56 -06:00
|
|
|
sources: config.sources.filter((s) => s.url.trim()), // Only send sources with URLs
|
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
|
|
|
prompt: processedPrompt,
|
|
|
|
|
provider: config.provider,
|
|
|
|
|
model: config.model,
|
|
|
|
|
}),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const result = await response.json();
|
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 (result.success) {
|
|
|
|
|
setPreviewContent(result.content);
|
|
|
|
|
} else {
|
2025-07-19 11:34:56 -06:00
|
|
|
setPreviewContent(
|
|
|
|
|
`**Preview Error:** ${result.error || 'Unknown error occurred'}\n\n${result.content || ''}`,
|
|
|
|
|
);
|
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.error('Preview error:', error);
|
2025-07-19 11:34:56 -06:00
|
|
|
setPreviewContent(
|
|
|
|
|
`**Network Error:** Failed to connect to the preview service.\n\n${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
|
|
|
);
|
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
|
|
|
} finally {
|
|
|
|
|
setIsPreviewLoading(false);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const addSource = () => {
|
2025-07-19 11:34:56 -06:00
|
|
|
setConfig((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
|
|
|
sources: [...prev.sources, { url: '', type: 'Web Page' }],
|
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 removeSource = (index: number) => {
|
2025-07-19 11:34:56 -06:00
|
|
|
setConfig((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
|
|
|
sources: prev.sources.filter((_, i) => i !== index),
|
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 updateSource = (index: number, field: keyof Source, value: string) => {
|
2025-07-19 11:34:56 -06:00
|
|
|
setConfig((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
|
|
|
sources: prev.sources.map((source, i) =>
|
|
|
|
|
i === index ? { ...source, [field]: value } : source,
|
|
|
|
|
),
|
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 (
|
|
|
|
|
<Transition appear show={isOpen} as={Fragment}>
|
|
|
|
|
<Dialog as="div" className="relative z-50" onClose={onClose}>
|
|
|
|
|
<TransitionChild
|
|
|
|
|
as={Fragment}
|
|
|
|
|
enter="ease-out duration-300"
|
|
|
|
|
enterFrom="opacity-0"
|
|
|
|
|
enterTo="opacity-100"
|
|
|
|
|
leave="ease-in duration-200"
|
|
|
|
|
leaveFrom="opacity-100"
|
|
|
|
|
leaveTo="opacity-0"
|
|
|
|
|
>
|
|
|
|
|
<div className="fixed inset-0 bg-black bg-opacity-25" />
|
|
|
|
|
</TransitionChild>
|
|
|
|
|
|
|
|
|
|
<div className="fixed inset-0 overflow-y-auto">
|
|
|
|
|
<div className="flex min-h-full items-center justify-center p-4 text-center">
|
|
|
|
|
<TransitionChild
|
|
|
|
|
as={Fragment}
|
|
|
|
|
enter="ease-out duration-300"
|
|
|
|
|
enterFrom="opacity-0 scale-95"
|
|
|
|
|
enterTo="opacity-100 scale-100"
|
|
|
|
|
leave="ease-in duration-200"
|
|
|
|
|
leaveFrom="opacity-100 scale-100"
|
|
|
|
|
leaveTo="opacity-0 scale-95"
|
|
|
|
|
>
|
|
|
|
|
<DialogPanel className="w-full max-w-4xl transform overflow-hidden rounded-2xl bg-light-primary dark:bg-dark-primary p-6 text-left align-middle shadow-xl transition-all">
|
|
|
|
|
<DialogTitle
|
|
|
|
|
as="h3"
|
|
|
|
|
className="text-lg font-medium leading-6 text-black dark:text-white flex items-center justify-between"
|
|
|
|
|
>
|
|
|
|
|
{editingWidget ? 'Edit Widget' : 'Create New Widget'}
|
|
|
|
|
<button
|
|
|
|
|
onClick={onClose}
|
|
|
|
|
className="p-1 hover:bg-light-secondary dark:hover:bg-dark-secondary rounded"
|
|
|
|
|
>
|
|
|
|
|
<X size={20} />
|
|
|
|
|
</button>
|
|
|
|
|
</DialogTitle>
|
|
|
|
|
|
|
|
|
|
<div className="mt-4 grid grid-cols-1 lg:grid-cols-2 gap-6">
|
|
|
|
|
{/* Left Column - Configuration */}
|
|
|
|
|
<div className="space-y-4">
|
|
|
|
|
{/* Widget Title */}
|
|
|
|
|
<div>
|
|
|
|
|
<label className="block text-sm font-medium text-black dark:text-white mb-1">
|
|
|
|
|
Widget Title
|
|
|
|
|
</label>
|
|
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
value={config.title}
|
2025-07-19 11:34:56 -06:00
|
|
|
onChange={(e) =>
|
|
|
|
|
setConfig((prev) => ({
|
|
|
|
|
...prev,
|
|
|
|
|
title: e.target.value,
|
|
|
|
|
}))
|
|
|
|
|
}
|
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
|
|
|
className="w-full px-3 py-2 border border-light-200 dark:border-dark-200 rounded-md bg-light-primary dark:bg-dark-primary text-black dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-500"
|
|
|
|
|
placeholder="Enter widget title..."
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* Source URLs */}
|
|
|
|
|
<div>
|
|
|
|
|
<label className="block text-sm font-medium text-black dark:text-white mb-1">
|
|
|
|
|
Source URLs
|
|
|
|
|
</label>
|
|
|
|
|
<div className="space-y-2">
|
|
|
|
|
{config.sources.map((source, index) => (
|
|
|
|
|
<div key={index} className="flex gap-2">
|
|
|
|
|
<input
|
|
|
|
|
type="url"
|
|
|
|
|
value={source.url}
|
2025-07-19 11:34:56 -06:00
|
|
|
onChange={(e) =>
|
|
|
|
|
updateSource(index, 'url', e.target.value)
|
|
|
|
|
}
|
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
|
|
|
className="flex-1 px-3 py-2 border border-light-200 dark:border-dark-200 rounded-md bg-light-primary dark:bg-dark-primary text-black dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-500"
|
|
|
|
|
placeholder="https://example.com"
|
|
|
|
|
/>
|
|
|
|
|
<select
|
|
|
|
|
value={source.type}
|
2025-07-19 11:34:56 -06:00
|
|
|
onChange={(e) =>
|
|
|
|
|
updateSource(
|
|
|
|
|
index,
|
|
|
|
|
'type',
|
|
|
|
|
e.target.value as Source['type'],
|
|
|
|
|
)
|
|
|
|
|
}
|
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
|
|
|
className="px-3 py-2 border border-light-200 dark:border-dark-200 rounded-md bg-light-primary dark:bg-dark-primary text-black dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-500"
|
|
|
|
|
>
|
|
|
|
|
<option value="Web Page">Web Page</option>
|
|
|
|
|
<option value="HTTP Data">HTTP Data</option>
|
|
|
|
|
</select>
|
|
|
|
|
{config.sources.length > 1 && (
|
|
|
|
|
<button
|
|
|
|
|
onClick={() => removeSource(index)}
|
|
|
|
|
className="p-2 text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 rounded"
|
|
|
|
|
>
|
|
|
|
|
<Trash2 size={16} />
|
|
|
|
|
</button>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
))}
|
|
|
|
|
<button
|
|
|
|
|
onClick={addSource}
|
|
|
|
|
className="flex items-center gap-2 px-3 py-2 text-sm text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900/20 rounded"
|
|
|
|
|
>
|
|
|
|
|
<Plus size={16} />
|
|
|
|
|
Add Source
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* LLM Prompt */}
|
|
|
|
|
<div>
|
|
|
|
|
<label className="block text-sm font-medium text-black dark:text-white mb-1">
|
|
|
|
|
LLM Prompt
|
|
|
|
|
</label>
|
|
|
|
|
<textarea
|
|
|
|
|
value={config.prompt}
|
2025-07-19 11:34:56 -06:00
|
|
|
onChange={(e) =>
|
|
|
|
|
setConfig((prev) => ({
|
|
|
|
|
...prev,
|
|
|
|
|
prompt: e.target.value,
|
|
|
|
|
}))
|
|
|
|
|
}
|
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
|
|
|
rows={6}
|
|
|
|
|
className="w-full px-3 py-2 border border-light-200 dark:border-dark-200 rounded-md bg-light-primary dark:bg-dark-primary text-black dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-500"
|
|
|
|
|
placeholder="Enter your prompt here..."
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* Provider and Model Selection */}
|
|
|
|
|
<div>
|
|
|
|
|
<label className="block text-sm font-medium text-black dark:text-white mb-2">
|
|
|
|
|
Model & Provider
|
|
|
|
|
</label>
|
|
|
|
|
<ModelSelector
|
2025-07-19 11:34:56 -06:00
|
|
|
selectedModel={selectedModel}
|
|
|
|
|
setSelectedModel={setSelectedModel}
|
|
|
|
|
truncateModelName={false}
|
|
|
|
|
showModelName={true}
|
|
|
|
|
/>
|
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
|
|
|
<p className="text-xs text-gray-500 dark:text-gray-400 mt-1">
|
2025-07-19 11:34:56 -06:00
|
|
|
Select the AI model and provider to process your widget
|
|
|
|
|
content
|
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
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* Refresh Frequency */}
|
|
|
|
|
<div>
|
|
|
|
|
<label className="block text-sm font-medium text-black dark:text-white mb-1">
|
|
|
|
|
Refresh Frequency
|
|
|
|
|
</label>
|
|
|
|
|
<div className="flex gap-2">
|
|
|
|
|
<input
|
|
|
|
|
type="number"
|
|
|
|
|
min="1"
|
|
|
|
|
value={config.refreshFrequency}
|
2025-07-19 11:34:56 -06:00
|
|
|
onChange={(e) =>
|
|
|
|
|
setConfig((prev) => ({
|
|
|
|
|
...prev,
|
|
|
|
|
refreshFrequency: parseInt(e.target.value) || 1,
|
|
|
|
|
}))
|
|
|
|
|
}
|
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
|
|
|
className="flex-1 px-3 py-2 border border-light-200 dark:border-dark-200 rounded-md bg-light-primary dark:bg-dark-primary text-black dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-500"
|
|
|
|
|
/>
|
|
|
|
|
<select
|
|
|
|
|
value={config.refreshUnit}
|
2025-07-19 11:34:56 -06:00
|
|
|
onChange={(e) =>
|
|
|
|
|
setConfig((prev) => ({
|
|
|
|
|
...prev,
|
|
|
|
|
refreshUnit: e.target.value as
|
|
|
|
|
| 'minutes'
|
|
|
|
|
| 'hours',
|
|
|
|
|
}))
|
|
|
|
|
}
|
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
|
|
|
className="px-3 py-2 border border-light-200 dark:border-dark-200 rounded-md bg-light-primary dark:bg-dark-primary text-black dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-500"
|
|
|
|
|
>
|
|
|
|
|
<option value="minutes">Minutes</option>
|
|
|
|
|
<option value="hours">Hours</option>
|
|
|
|
|
</select>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* Right Column - Preview */}
|
|
|
|
|
<div className="space-y-4">
|
|
|
|
|
<div className="flex items-center justify-between">
|
|
|
|
|
<h4 className="text-sm font-medium text-black dark:text-white">
|
|
|
|
|
Preview
|
|
|
|
|
</h4>
|
|
|
|
|
<button
|
|
|
|
|
onClick={handlePreview}
|
|
|
|
|
disabled={isPreviewLoading}
|
|
|
|
|
className="flex items-center gap-2 px-3 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 disabled:opacity-50"
|
|
|
|
|
>
|
|
|
|
|
<Play size={16} />
|
|
|
|
|
{isPreviewLoading ? 'Loading...' : 'Run Preview'}
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
2025-07-19 11:34:56 -06:00
|
|
|
|
|
|
|
|
<div className="h-80 p-4 border border-light-200 dark:border-dark-200 rounded-md bg-light-secondary dark:bg-dark-secondary overflow-y-auto max-w-full">
|
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
|
|
|
{previewContent ? (
|
2025-07-19 11:34:56 -06:00
|
|
|
<div className="prose prose-sm dark:prose-invert max-w-full">
|
|
|
|
|
<MarkdownRenderer
|
|
|
|
|
thinkOverlay={true}
|
|
|
|
|
content={previewContent}
|
|
|
|
|
/>
|
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
|
|
|
</div>
|
|
|
|
|
) : (
|
|
|
|
|
<div className="text-sm text-black/50 dark:text-white/50 italic">
|
|
|
|
|
Click "Run Preview" to see how your widget will look
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* Variable Legend */}
|
|
|
|
|
<div className="text-xs text-black/70 dark:text-white/70">
|
|
|
|
|
<h5 className="font-medium mb-2">Available Variables:</h5>
|
|
|
|
|
<div className="space-y-1">
|
2025-07-19 11:34:56 -06:00
|
|
|
<div>
|
|
|
|
|
<code className="bg-light-200 dark:bg-dark-200 px-1 rounded">
|
|
|
|
|
{'{{current_utc_datetime}}'}
|
|
|
|
|
</code>{' '}
|
|
|
|
|
- Current UTC date and time
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<code className="bg-light-200 dark:bg-dark-200 px-1 rounded">
|
|
|
|
|
{'{{current_local_datetime}}'}
|
|
|
|
|
</code>{' '}
|
|
|
|
|
- Current local date and time
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<code className="bg-light-200 dark:bg-dark-200 px-1 rounded">
|
|
|
|
|
{'{{source_content_1}}'}
|
|
|
|
|
</code>{' '}
|
|
|
|
|
- Content from first source
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<code className="bg-light-200 dark:bg-dark-200 px-1 rounded">
|
|
|
|
|
{'{{source_content_2}}'}
|
|
|
|
|
</code>{' '}
|
|
|
|
|
- Content from second source
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<code className="bg-light-200 dark:bg-dark-200 px-1 rounded">
|
|
|
|
|
{'{{location}}'}
|
|
|
|
|
</code>{' '}
|
|
|
|
|
- Your current location
|
|
|
|
|
</div>
|
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
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* Action Buttons */}
|
|
|
|
|
<div className="mt-6 flex justify-end gap-3">
|
|
|
|
|
<button
|
|
|
|
|
onClick={onClose}
|
|
|
|
|
className="px-4 py-2 text-sm font-medium text-black dark:text-white bg-light-secondary dark:bg-dark-secondary hover:bg-light-200 dark:hover:bg-dark-200 rounded-md"
|
|
|
|
|
>
|
|
|
|
|
Cancel
|
|
|
|
|
</button>
|
|
|
|
|
<button
|
|
|
|
|
onClick={handleSave}
|
|
|
|
|
className="flex items-center gap-2 px-4 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-md"
|
|
|
|
|
>
|
|
|
|
|
<Save size={16} />
|
|
|
|
|
{editingWidget ? 'Update Widget' : 'Create Widget'}
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</DialogPanel>
|
|
|
|
|
</TransitionChild>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</Dialog>
|
|
|
|
|
</Transition>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default WidgetConfigModal;
|