diff --git a/dashboard/public/index.html b/dashboard/public/index.html index 56d9df2..8af042a 100644 --- a/dashboard/public/index.html +++ b/dashboard/public/index.html @@ -312,7 +312,12 @@ const titles = { 'dashboard': 'Market Overview', 'analytics': 'Custom Report Builder', 'metadata': 'Entity Metadata' }; document.getElementById('pageTitle').innerText = titles[viewId]; - if (viewId === 'analytics') renderAnalyticsReport(); else fetchData(); + if (viewId === 'analytics') { + // If it's a fresh visit without params, we might want to reset or keep state + // renderAnalyticsReport(); + } else { + fetchData(); + } } function handlePresetChange() { @@ -323,12 +328,11 @@ function updateSubGroupOptions() { const x = document.getElementById('axisX').value; const sub = document.getElementById('axisSub'); - const container = document.getElementById('subGroupContainer'); - // Contextual Logic: If X is already a metadata field, don't allow it as series (too complex) - container.classList.remove('hidden'); + // Contextual Logic: If X is already a metadata field, don't allow it as series Array.from(sub.options).forEach(opt => { opt.disabled = (opt.value === x); + if (opt.value === x && sub.value === x) sub.value = ''; }); } @@ -357,9 +361,9 @@ if (!store.pinnedIsins.find(p => p.isin === isin)) { store.pinnedIsins.push({ isin, name }); updateFilterChips(); - // Close search document.getElementById('isinSearch').value = ''; document.getElementById('suggestions').classList.add('hidden'); + if (window.activeView === 'analytics') proceedToStep(5); } } @@ -376,8 +380,8 @@ ${p.isin} × `).join(''); - container.innerHTML = html; - pins.innerHTML = html; + if (container) container.innerHTML = html; + if (pins) pins.innerHTML = html; } function getDates() { @@ -424,6 +428,9 @@ const y = document.getElementById('axisY').value; const isins = store.pinnedIsins.map(p => p.isin).join(','); + // Validate that basic steps are done + if (!dates.from || !x || !y) return; + let url = `${API}/analytics?metric=${y}&group_by=${x}`; if (sub) url += `&sub_group_by=${sub}`; if (dates.from) url += `&date_from=${dates.from}`; @@ -504,7 +511,7 @@ '#8b5cf6', // Purple '#f97316', // Orange '#ec4899', // Pink - '#475569' // Slate + '#6366f1' // Indigo ]; charts.continent = new Chart(contCtx, { @@ -523,12 +530,18 @@ // --- Progressive Report Configuration --- function proceedToStep(n) { + // First, enable/show the step const step = document.getElementById(`step${n}`); if (step) { step.classList.remove('hidden'); setTimeout(() => step.classList.remove('opacity-50'), 50); } + + // Contextual Visibility Logic: If we are at step 2, handle custom date toggles if (n === 2) handlePresetChange(); + + // Auto-scroll logic if sidebar is long + if (n > 2) step.scrollIntoView({ behavior: 'smooth', block: 'center' }); } function checkCustomDates() { @@ -552,7 +565,7 @@ function fillMetadataTable() { const tbody = document.getElementById('metadataRows'); tbody.innerHTML = store.metadata.map(r => ` -