From 2d8955405f007203fa1a3503d74092b46e9e1ffe Mon Sep 17 00:00:00 2001 From: BARTEMENT Tristan Date: Mon, 16 Dec 2024 10:49:31 +0100 Subject: [PATCH] assignValueChangeHandlers needs "constants" datanodes processed --- .../angular/modules/dashboard/services/edit-play-switch.js | 1 + front-end/source/kernel/base/xdash-main.js | 1 + front-end/source/kernel/dashboard/rendering/widget-viewer.js | 5 ----- front-end/source/kernel/runtime/xdash-runtime-main.js | 5 +++++ 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/front-end/source/angular/modules/dashboard/services/edit-play-switch.js b/front-end/source/angular/modules/dashboard/services/edit-play-switch.js index 7eeab8ca..aa20b593 100644 --- a/front-end/source/angular/modules/dashboard/services/edit-play-switch.js +++ b/front-end/source/angular/modules/dashboard/services/edit-play-switch.js @@ -15,6 +15,7 @@ export function showPlayMode() { const { dashboard, display, pages } = editorSingletons.widgetEditor.serialize(); widgetViewer.reset(); widgetViewer.deserialize({ dashboard, display, pages, connections: {} }); + widgetViewer.assignValueChangeHandlers(); } catch (e) { console.error(e); // FIXME ? diff --git a/front-end/source/kernel/base/xdash-main.js b/front-end/source/kernel/base/xdash-main.js index 33cc0cfc..1bd21201 100644 --- a/front-end/source/kernel/base/xdash-main.js +++ b/front-end/source/kernel/base/xdash-main.js @@ -190,6 +190,7 @@ export const Xdash = function () { htmlExport.navBarNotification = jsonObject.navBarNotification ?? false; datanodesManager.startScheduler(); + widgetViewer.assignValueChangeHandlers(); return true; } catch (ex) { diff --git a/front-end/source/kernel/dashboard/rendering/widget-viewer.js b/front-end/source/kernel/dashboard/rendering/widget-viewer.js index 578f8134..8c1a177f 100644 --- a/front-end/source/kernel/dashboard/rendering/widget-viewer.js +++ b/front-end/source/kernel/dashboard/rendering/widget-viewer.js @@ -154,11 +154,6 @@ class WidgetWiewer { for (const [instanceId, desc] of Object.entries(dashboard)) { this.#createWidget(desc.container.modelJsonId, instanceId, desc.layout); } - - // assign change value handlers - if (datanodesManager.getAllDataNodes().length != 0) { - this.assignValueChangeHandlers(); - } } reRenderWidget(instanceId) { diff --git a/front-end/source/kernel/runtime/xdash-runtime-main.js b/front-end/source/kernel/runtime/xdash-runtime-main.js index 7cd59048..749ad60e 100644 --- a/front-end/source/kernel/runtime/xdash-runtime-main.js +++ b/front-end/source/kernel/runtime/xdash-runtime-main.js @@ -194,6 +194,11 @@ export function loadDashboard(jsonContent) { widgetViewer.deserialize(jsonContent); datanodesManager.startScheduler(); + + // Not done during deserialize as we need startScheduler to be done. + // Specificaly, datanodes with "constant" values (en short, json variables) must be marked evaluated + // so that widgets can read a value instead of setting a default one. + widgetViewer.assignValueChangeHandlers(); }; // Main logic begins here