feat: Add plot session creation event logging and enhance plot selection handling in PlotManager
This commit is contained in:
parent
3417056b06
commit
8ac87c8f98
|
@ -8152,8 +8152,26 @@
|
|||
"event_type": "application_started",
|
||||
"message": "Application initialization completed successfully",
|
||||
"details": {}
|
||||
},
|
||||
{
|
||||
"timestamp": "2025-08-15T23:05:23.049195",
|
||||
"level": "info",
|
||||
"event_type": "plot_session_created",
|
||||
"message": "Plot session 'UR29' created and started",
|
||||
"details": {
|
||||
"session_id": "plot_1_1755291923048_2",
|
||||
"variables": [
|
||||
"UR29_Brix",
|
||||
"UR29_ma",
|
||||
"AUX Blink_1.0S",
|
||||
"AUX Blink_1.6S"
|
||||
],
|
||||
"time_window": 36,
|
||||
"trigger_variable": null,
|
||||
"auto_started": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"last_updated": "2025-08-15T22:47:53.048381",
|
||||
"total_entries": 677
|
||||
"last_updated": "2025-08-15T23:05:23.049195",
|
||||
"total_entries": 678
|
||||
}
|
|
@ -455,7 +455,7 @@ export default function PlotManager() {
|
|||
setPlotsSchemaData(plotsSchemaResponse)
|
||||
setPlotVariablesSchemaData(plotVariablesSchemaResponse)
|
||||
|
||||
// Auto-select first plot if none selected
|
||||
// Auto-select first plot if none selected and plots are available
|
||||
if (!selectedPlotId && plotsData?.plots?.length > 0) {
|
||||
setSelectedPlotId(plotsData.plots[0].id)
|
||||
}
|
||||
|
@ -474,7 +474,7 @@ export default function PlotManager() {
|
|||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}, [selectedPlotId, toast])
|
||||
}, [toast]) // Removed selectedPlotId from dependencies to prevent unnecessary reloads
|
||||
|
||||
// Función para actualizar configuración de un plot específico sin recargar todo
|
||||
const updatePlotConfig = async (plotId, newConfig) => {
|
||||
|
@ -632,6 +632,13 @@ export default function PlotManager() {
|
|||
loadPlotData()
|
||||
}, [loadPlotData])
|
||||
|
||||
// Separate effect to handle auto-selection of first plot when plots are loaded
|
||||
useEffect(() => {
|
||||
if (!selectedPlotId && plotsConfig?.plots?.length > 0) {
|
||||
setSelectedPlotId(plotsConfig.plots[0].id)
|
||||
}
|
||||
}, [plotsConfig, selectedPlotId])
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<Card>
|
||||
|
@ -714,14 +721,23 @@ export default function PlotManager() {
|
|||
{/* Step 1: Plot Selector (Combo) */}
|
||||
<VStack spacing={4} align="stretch">
|
||||
<Box>
|
||||
<Text fontSize="sm" fontWeight="bold" mb={2}>
|
||||
<Text fontSize="lg" fontWeight="bold" mb={3}>
|
||||
🎯 Select Plot Session
|
||||
</Text>
|
||||
<Text fontSize="sm" color="gray.600" mb={3} fontStyle="italic">
|
||||
⚠️ Important: The variables configuration below depends on this selection
|
||||
</Text>
|
||||
<Select
|
||||
value={selectedPlotId}
|
||||
onChange={(e) => setSelectedPlotId(e.target.value)}
|
||||
onChange={(e) => {
|
||||
const newPlotId = e.target.value
|
||||
setSelectedPlotId(newPlotId)
|
||||
console.log(`🎯 Plot selection changed to: ${newPlotId}`)
|
||||
}}
|
||||
placeholder="Choose a plot to configure..."
|
||||
size="md"
|
||||
size="lg"
|
||||
fontSize="lg"
|
||||
fontWeight="semibold"
|
||||
>
|
||||
{getPlotDefinitions().map(plot => (
|
||||
<option key={plot.id} value={plot.id}>
|
||||
|
@ -741,7 +757,7 @@ export default function PlotManager() {
|
|||
<Box>
|
||||
<Divider mb={4} />
|
||||
<Text fontSize="sm" fontWeight="bold" mb={2}>
|
||||
⚙️ Configure Variables for Plot "{selectedPlotId}"
|
||||
⚙️ Configure Variables for Plot "{getPlotDefinitions().find(p => p.id === selectedPlotId)?.name || selectedPlotId}"
|
||||
</Text>
|
||||
|
||||
{/* Simplified schema for selected plot variables */}
|
||||
|
@ -754,7 +770,7 @@ export default function PlotManager() {
|
|||
properties: {
|
||||
variables: {
|
||||
type: "array",
|
||||
title: "Variables",
|
||||
title: `Variables for Plot: ${getPlotDefinitions().find(p => p.id === selectedPlotId)?.name || selectedPlotId}`,
|
||||
description: `Variables to display in plot ${selectedPlotId}`,
|
||||
items: {
|
||||
type: "object",
|
||||
|
@ -865,7 +881,7 @@ export default function PlotManager() {
|
|||
>
|
||||
<HStack spacing={2} mt={4}>
|
||||
<Button type="submit" colorScheme="red">
|
||||
💾 Save Variables for {selectedPlotId}
|
||||
💾 Save Variables for {getPlotDefinitions().find(p => p.id === selectedPlotId)?.name || selectedPlotId}
|
||||
</Button>
|
||||
<Button variant="outline" onClick={loadPlotData}>
|
||||
🔄 Reset
|
||||
|
|
|
@ -899,14 +899,23 @@ function DatasetManager() {
|
|||
{/* Step 1: Dataset Selector (Combo) */}
|
||||
<VStack spacing={4} align="stretch">
|
||||
<Box>
|
||||
<Text fontSize="sm" fontWeight="bold" mb={2}>
|
||||
<Text fontSize="lg" fontWeight="bold" mb={3}>
|
||||
🎯 Select Dataset
|
||||
</Text>
|
||||
<Text fontSize="sm" color="gray.600" mb={3} fontStyle="italic">
|
||||
⚠️ Important: The variables configuration below depends on this selection
|
||||
</Text>
|
||||
<Select
|
||||
value={selectedDatasetId}
|
||||
onChange={(e) => setSelectedDatasetId(e.target.value)}
|
||||
onChange={(e) => {
|
||||
const newDatasetId = e.target.value
|
||||
setSelectedDatasetId(newDatasetId)
|
||||
console.log(`🎯 Dataset selection changed to: ${newDatasetId}`)
|
||||
}}
|
||||
placeholder="Choose a dataset to configure..."
|
||||
size="md"
|
||||
size="lg"
|
||||
fontSize="lg"
|
||||
fontWeight="semibold"
|
||||
>
|
||||
{availableDatasets.map(dataset => (
|
||||
<option key={dataset.id} value={dataset.id}>
|
||||
|
@ -926,7 +935,7 @@ function DatasetManager() {
|
|||
<Box>
|
||||
<Divider mb={4} />
|
||||
<Text fontSize="sm" fontWeight="bold" mb={2}>
|
||||
⚙️ Configure Variables for Dataset "{selectedDatasetId}"
|
||||
⚙️ Configure Variables for Dataset "{availableDatasets.find(d => d.id === selectedDatasetId)?.name || selectedDatasetId}"
|
||||
</Text>
|
||||
|
||||
{/* Simplified schema for selected dataset variables */}
|
||||
|
@ -939,7 +948,7 @@ function DatasetManager() {
|
|||
properties: {
|
||||
variables: {
|
||||
type: "array",
|
||||
title: "Variables",
|
||||
title: `Variables for Dataset: ${availableDatasets.find(d => d.id === selectedDatasetId)?.name || selectedDatasetId}`,
|
||||
description: `PLC variables to record in dataset ${selectedDatasetId}`,
|
||||
items: {
|
||||
type: "object",
|
||||
|
@ -1234,7 +1243,7 @@ function DatasetManager() {
|
|||
>
|
||||
<HStack spacing={2} mt={4}>
|
||||
<Button type="submit" colorScheme="red">
|
||||
💾 Save Variables for {selectedDatasetId}
|
||||
💾 Save Variables for {availableDatasets.find(d => d.id === selectedDatasetId)?.name || selectedDatasetId}
|
||||
</Button>
|
||||
<Button variant="outline" onClick={loadDatasetData}>
|
||||
🔄 Reset
|
||||
|
|
Loading…
Reference in New Issue