From a4f74b70ed49b943b1c8ac769a23e2734f1e9ddc Mon Sep 17 00:00:00 2001 From: Miguel Date: Fri, 15 Aug 2025 22:31:25 +0200 Subject: [PATCH] feat: Add confirmation dialog for deletion operations, enhance logging in symbol processor, and update button color schemes --- application_events.json | 11 +- frontend/src/components/PlotManager.jsx | 4 +- frontend/src/components/PlotManagerSimple.jsx | 104 ++++++++++++++++-- .../src/components/PlotRealtimeSession.jsx | 8 -- frontend/src/pages/Dashboard.jsx | 104 ++++++++++++++++-- utils/symbol_processor.py | 24 ++-- 6 files changed, 215 insertions(+), 40 deletions(-) diff --git a/application_events.json b/application_events.json index 7b1d5dc..16e5527 100644 --- a/application_events.json +++ b/application_events.json @@ -8138,8 +8138,15 @@ "active_datasets_count": 3, "csv_recording_active": false } + }, + { + "timestamp": "2025-08-15T21:25:51.900870", + "level": "info", + "event_type": "application_started", + "message": "Application initialization completed successfully", + "details": {} } ], - "last_updated": "2025-08-15T21:03:44.900837", - "total_entries": 675 + "last_updated": "2025-08-15T21:25:51.900870", + "total_entries": 676 } \ No newline at end of file diff --git a/frontend/src/components/PlotManager.jsx b/frontend/src/components/PlotManager.jsx index 63231da..cba91c1 100644 --- a/frontend/src/components/PlotManager.jsx +++ b/frontend/src/components/PlotManager.jsx @@ -49,7 +49,7 @@ import * as api from '../services/api' // Collapsible Form Component for Plot Definitions function CollapsiblePlotForm({ data, schema, uiSchema, onSave, title, icon, getItemLabel }) { - const [isOpen, setIsOpen] = useState(false) + const [isOpen, setIsOpen] = useState(true) const [formData, setFormData] = useState(data) useEffect(() => { @@ -577,7 +577,7 @@ export default function PlotManager() { + + + + + ) +} + // Collapsible Plot Items Form - Each item in the array is individually collapsible function CollapsiblePlotItemsForm({ data, schema, uiSchema, onSave, title, icon, getItemLabel, isExpanded, onToggleExpansion }) { const [formData, setFormData] = useState(data) const [expandedItems, setExpandedItems] = useState(new Set()) + const [confirmDelete, setConfirmDelete] = useState({ isOpen: false, index: null, itemName: '' }) useEffect(() => { // Solo actualizar formData si data realmente cambiรณ en contenido @@ -98,6 +154,28 @@ function CollapsiblePlotItemsForm({ data, schema, uiSchema, onSave, title, icon, else if (i > index) newExpanded.add(i - 1) }) setExpandedItems(newExpanded) + // Close confirmation dialog + setConfirmDelete({ isOpen: false, index: null, itemName: '' }) + } + + const handleDeleteClick = (index) => { + const item = items[index] + const itemName = getItemLabel ? getItemLabel(item) : (item.name || item.id || `Item ${index + 1}`) + setConfirmDelete({ + isOpen: true, + index, + itemName + }) + } + + const handleConfirmDelete = () => { + if (confirmDelete.index !== null) { + removeItem(confirmDelete.index) + } + } + + const handleCancelDelete = () => { + setConfirmDelete({ isOpen: false, index: null, itemName: '' }) } const saveChanges = async () => { @@ -141,7 +219,7 @@ function CollapsiblePlotItemsForm({ data, schema, uiSchema, onSave, title, icon, - @@ -186,7 +264,8 @@ function CollapsiblePlotItemsForm({ data, schema, uiSchema, onSave, title, icon, size="xs" colorScheme="red" variant="ghost" - onClick={() => removeItem(index)} + onClick={() => handleDeleteClick(index)} + title="Delete this item" > ๐Ÿ—‘๏ธ @@ -251,7 +330,8 @@ function CollapsiblePlotItemsForm({ data, schema, uiSchema, onSave, title, icon, size="xs" colorScheme="red" variant="ghost" - onClick={() => removeItem(index)} + onClick={() => handleDeleteClick(index)} + title="Delete this item" > ๐Ÿ—‘๏ธ @@ -280,6 +360,17 @@ function CollapsiblePlotItemsForm({ data, schema, uiSchema, onSave, title, icon, )} )} + + {/* Confirmation Dialog for Deletion */} + ) } @@ -306,9 +397,6 @@ function CollapsiblePlotChart({ plotDefinition, plotVariables, onConfigUpdate, o > {isExpanded ? 'Hide' : 'Show'} Chart - @@ -768,7 +856,7 @@ export default function PlotManager() { onChange={({ formData }) => updateSelectedPlotVariables(formData)} > - diff --git a/frontend/src/pages/Dashboard.jsx b/frontend/src/pages/Dashboard.jsx index 8b220d0..4f17a0a 100644 --- a/frontend/src/pages/Dashboard.jsx +++ b/frontend/src/pages/Dashboard.jsx @@ -43,7 +43,14 @@ import { AccordionButton, AccordionPanel, Collapse, - useDisclosure + useDisclosure, + Modal, + ModalOverlay, + ModalContent, + ModalHeader, + ModalFooter, + ModalBody, + ModalCloseButton } from '@chakra-ui/react' import { ChevronDownIcon, ChevronUpIcon } from '@chakra-ui/icons' import Form from '@rjsf/chakra-ui' @@ -56,10 +63,57 @@ import { VariableProvider, useVariableContext } from '../contexts/VariableContex import * as api from '../services/api' import { useCoordinatedPolling } from '../hooks/useCoordinatedConnection' +// Confirmation Dialog Component for deletion operations +function ConfirmationDialog({ isOpen, onClose, onConfirm, title, message, itemName, confirmButtonText = "Delete" }) { + return ( + + + + + + โš ๏ธ + {title} + + + + + + + {message} + + {itemName && ( + + + Item to delete: "{itemName}" + + + )} + + + + This action cannot be undone. Make sure you want to proceed. + + + + + + + + + + + ) +} + // Collapsible Array Items Form - Each item in the array is individually collapsible function CollapsibleArrayItemsForm({ data, schema, uiSchema, onSave, title, icon, getItemLabel }) { const [formData, setFormData] = useState(data) const [expandedItems, setExpandedItems] = useState(new Set()) + const [confirmDelete, setConfirmDelete] = useState({ isOpen: false, index: null, itemName: '' }) useEffect(() => { setFormData(data) @@ -117,6 +171,28 @@ function CollapsibleArrayItemsForm({ data, schema, uiSchema, onSave, title, icon else if (i > index) newExpanded.add(i - 1) }) setExpandedItems(newExpanded) + // Close confirmation dialog + setConfirmDelete({ isOpen: false, index: null, itemName: '' }) + } + + const handleDeleteClick = (index) => { + const item = items[index] + const itemName = getItemLabel ? getItemLabel(item) : (item.name || item.id || `Item ${index + 1}`) + setConfirmDelete({ + isOpen: true, + index, + itemName + }) + } + + const handleConfirmDelete = () => { + if (confirmDelete.index !== null) { + removeItem(confirmDelete.index) + } + } + + const handleCancelDelete = () => { + setConfirmDelete({ isOpen: false, index: null, itemName: '' }) } const saveChanges = () => { @@ -144,7 +220,7 @@ function CollapsibleArrayItemsForm({ data, schema, uiSchema, onSave, title, icon - @@ -186,7 +262,8 @@ function CollapsibleArrayItemsForm({ data, schema, uiSchema, onSave, title, icon size="xs" colorScheme="red" variant="ghost" - onClick={() => removeItem(index)} + onClick={() => handleDeleteClick(index)} + title="Delete this item" > ๐Ÿ—‘๏ธ @@ -214,6 +291,17 @@ function CollapsibleArrayItemsForm({ data, schema, uiSchema, onSave, title, icon )} + + {/* Confirmation Dialog for Deletion */} + ) } @@ -615,7 +703,7 @@ function ConfigurationPanel({ schemaData, formData, onFormChange, onSave, saving )} -