From 6e21be6523865eb03ba90f056b8dd260bf05d17a Mon Sep 17 00:00:00 2001 From: DiTus Date: Wed, 25 Feb 2026 23:52:50 +0100 Subject: [PATCH] Fix indicator panel UI bugs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fixed expand button not working (added data-id attribute) - Removed duplicate empty Parameters section - Fixed preset rendering (incorrect variable reference preset→p) - Added resetIndicator function to reset params to defaults - Added removeIndicator function tied to Remove button - Fixed preset display bug causing reference error --- .../static/js/ui/indicators-panel-new.js | 60 +++++++++---------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/src/api/dashboard/static/js/ui/indicators-panel-new.js b/src/api/dashboard/static/js/ui/indicators-panel-new.js index c6505bd..8d30383 100644 --- a/src/api/dashboard/static/js/ui/indicators-panel-new.js +++ b/src/api/dashboard/static/js/ui/indicators-panel-new.js @@ -238,7 +238,7 @@ function renderActiveIndicator(indicator) { - @@ -320,31 +320,6 @@ function renderIndicatorConfig(indicator, meta) { `).join('')} ` : ''} - - - ${meta?.inputs && meta.inputs.length > 0 ? ` -
-
Parameters
- ${meta.inputs.map(input => ` -${console.log("[DEBUG] Input:", input.name, "value:", indicator.params[input.name])}` - - ${input.type === 'select' ? - `` : - `` - } -
- `).join('')} - - ` : ''}
@@ -369,13 +344,13 @@ function renderIndicatorPresets(indicator, meta) {
${presets.map(p => { const isApplied = meta.inputs.every(input => - (indicator.params[input.name] === (preset.values?.[input.name] ?? input.default)) + (indicator.params[input.name] === (p.values?.[input.name] ?? input.default)) ); return ` -
- ${preset.name} - +
+ ${p.name} +
`; }).join('')} @@ -851,11 +826,36 @@ export function drawIndicatorsOnChart() { }); } +function resetIndicator(id) { + const indicator = activeIndicators.find(a => a.id === id); + if (!indicator) return; + + const IndicatorClass = IR[indicator.type]; + if (!IndicatorClass) return; + + const instance = new IndicatorClass({ type: indicator.type, params: {}, name: '' }); + const meta = instance.getMetadata(); + if (!meta || !meta.inputs) return; + + meta.inputs.forEach(input => { + indicator.params[input.name] = input.default; + }); + + renderIndicatorPanel(); + drawIndicatorsOnChart(); +} + +function removeIndicator(id) { + removeIndicatorById(id); +} + // Export functions for module access export { addIndicator, removeIndicatorById }; // Legacy compatibility functions window.renderIndicatorList = renderIndicatorPanel; +window.resetIndicator = resetIndicator; +window.removeIndicator = removeIndicator; window.toggleIndicator = addIndicator; window.showIndicatorConfig = function(id) { const ind = activeIndicators.find(a => a.id === id);