From 6c13efc93ad99ad481de465446641602026a9922 Mon Sep 17 00:00:00 2001 From: bartbutenaers Date: Sat, 21 Dec 2024 00:01:25 +0100 Subject: [PATCH 1/3] selectable header content --- docs/examples/chart-bar-election-grouped.json | 4 +-- docs/examples/chart-bar-finance-grouped.json | 4 +-- docs/examples/chart-bar-sw-characters.json | 4 +-- docs/examples/chart-histogram-bins.json | 4 +-- docs/examples/chart-histogram-categories.json | 4 +-- docs/examples/chart-histogram-series.json | 4 +-- docs/examples/chart-line-multiple.json | 4 +-- docs/examples/chart-line-timestamp.json | 4 +-- docs/examples/chart-pie-doughnut.json | 4 +-- docs/examples/chart-scatter-grouped.json | 4 +-- docs/examples/group-dialog-type.json | 4 +-- docs/examples/ui-button-hold.json | 4 +-- docs/examples/ui-text-suffix.json | 4 +-- nodes/config/locales/en-US/ui_base.json | 8 +++-- nodes/config/ui_base.html | 34 +++++++++++++------ nodes/config/ui_base.js | 11 ++++++ nodes/widgets/ui_form.js | 5 ++- ui/src/layouts/Baseline.vue | 8 ++++- 18 files changed, 77 insertions(+), 41 deletions(-) diff --git a/docs/examples/chart-bar-election-grouped.json b/docs/examples/chart-bar-election-grouped.json index 8319d53e5..d5a31aca9 100644 --- a/docs/examples/chart-bar-election-grouped.json +++ b/docs/examples/chart-bar-election-grouped.json @@ -144,7 +144,7 @@ "ui-notification" ], "showPathInSidebar": false, - "showPageTitle": false, + "headerContent": "none", "navigationStyle": "icon", "titleBarStyle": "default" }, @@ -166,4 +166,4 @@ "widgetGap": "12px" } } -] \ No newline at end of file +] diff --git a/docs/examples/chart-bar-finance-grouped.json b/docs/examples/chart-bar-finance-grouped.json index 596703521..3672b466f 100644 --- a/docs/examples/chart-bar-finance-grouped.json +++ b/docs/examples/chart-bar-finance-grouped.json @@ -144,7 +144,7 @@ "ui-notification" ], "showPathInSidebar": false, - "showPageTitle": false, + "headerContent": "none", "navigationStyle": "icon", "titleBarStyle": "default" }, @@ -166,4 +166,4 @@ "widgetGap": "12px" } } -] \ No newline at end of file +] diff --git a/docs/examples/chart-bar-sw-characters.json b/docs/examples/chart-bar-sw-characters.json index f81b11398..5f504c908 100644 --- a/docs/examples/chart-bar-sw-characters.json +++ b/docs/examples/chart-bar-sw-characters.json @@ -207,7 +207,7 @@ "ui-notification" ], "showPathInSidebar": false, - "showPageTitle": false, + "headerContent": "none", "navigationStyle": "icon", "titleBarStyle": "default" }, @@ -229,4 +229,4 @@ "widgetGap": "12px" } } -] \ No newline at end of file +] diff --git a/docs/examples/chart-histogram-bins.json b/docs/examples/chart-histogram-bins.json index 65ee7bd29..8234b095e 100644 --- a/docs/examples/chart-histogram-bins.json +++ b/docs/examples/chart-histogram-bins.json @@ -131,7 +131,7 @@ "ui-notification" ], "showPathInSidebar": false, - "showPageTitle": false, + "headerContent": "none", "navigationStyle": "icon", "titleBarStyle": "default" }, @@ -153,4 +153,4 @@ "widgetGap": "12px" } } -] \ No newline at end of file +] diff --git a/docs/examples/chart-histogram-categories.json b/docs/examples/chart-histogram-categories.json index 3c5e4b872..492dfd096 100644 --- a/docs/examples/chart-histogram-categories.json +++ b/docs/examples/chart-histogram-categories.json @@ -325,7 +325,7 @@ "ui-notification" ], "showPathInSidebar": false, - "showPageTitle": false, + "headerContent": "none", "navigationStyle": "icon", "titleBarStyle": "default" }, @@ -347,4 +347,4 @@ "widgetGap": "12px" } } -] \ No newline at end of file +] diff --git a/docs/examples/chart-histogram-series.json b/docs/examples/chart-histogram-series.json index 6b4f79bb1..fef1db871 100644 --- a/docs/examples/chart-histogram-series.json +++ b/docs/examples/chart-histogram-series.json @@ -183,7 +183,7 @@ "ui-notification" ], "showPathInSidebar": false, - "showPageTitle": false, + "headerContent": "none", "navigationStyle": "icon", "titleBarStyle": "default" }, @@ -205,4 +205,4 @@ "widgetGap": "12px" } } -] \ No newline at end of file +] diff --git a/docs/examples/chart-line-multiple.json b/docs/examples/chart-line-multiple.json index 2cc73cbb5..fc588e2f7 100644 --- a/docs/examples/chart-line-multiple.json +++ b/docs/examples/chart-line-multiple.json @@ -177,7 +177,7 @@ "ui-notification" ], "showPathInSidebar": false, - "showPageTitle": false, + "headerContent": "none", "navigationStyle": "icon", "titleBarStyle": "default" }, @@ -199,4 +199,4 @@ "widgetGap": "12px" } } -] \ No newline at end of file +] diff --git a/docs/examples/chart-line-timestamp.json b/docs/examples/chart-line-timestamp.json index 39104d60e..9323121c2 100644 --- a/docs/examples/chart-line-timestamp.json +++ b/docs/examples/chart-line-timestamp.json @@ -163,7 +163,7 @@ "ui-notification" ], "showPathInSidebar": false, - "showPageTitle": false, + "headerContent": "none", "navigationStyle": "icon", "titleBarStyle": "default" }, @@ -185,4 +185,4 @@ "widgetGap": "12px" } } -] \ No newline at end of file +] diff --git a/docs/examples/chart-pie-doughnut.json b/docs/examples/chart-pie-doughnut.json index 4d132f106..72284477b 100644 --- a/docs/examples/chart-pie-doughnut.json +++ b/docs/examples/chart-pie-doughnut.json @@ -251,7 +251,7 @@ "ui-notification" ], "showPathInSidebar": false, - "showPageTitle": false, + "headerContent": "none", "navigationStyle": "icon", "titleBarStyle": "default" }, @@ -273,4 +273,4 @@ "widgetGap": "12px" } } -] \ No newline at end of file +] diff --git a/docs/examples/chart-scatter-grouped.json b/docs/examples/chart-scatter-grouped.json index a15f49e1e..58b73be82 100644 --- a/docs/examples/chart-scatter-grouped.json +++ b/docs/examples/chart-scatter-grouped.json @@ -144,7 +144,7 @@ "ui-notification" ], "showPathInSidebar": false, - "showPageTitle": false, + "headerContent": "none", "navigationStyle": "icon", "titleBarStyle": "default" }, @@ -166,4 +166,4 @@ "widgetGap": "12px" } } -] \ No newline at end of file +] diff --git a/docs/examples/group-dialog-type.json b/docs/examples/group-dialog-type.json index 71e5fdc0f..49dca8590 100644 --- a/docs/examples/group-dialog-type.json +++ b/docs/examples/group-dialog-type.json @@ -162,7 +162,7 @@ "ui-notification" ], "showPathInSidebar": false, - "showPageTitle": false, + "headerContent": "none", "navigationStyle": "icon", "titleBarStyle": "default" }, @@ -212,4 +212,4 @@ "density": "default" } } -] \ No newline at end of file +] diff --git a/docs/examples/ui-button-hold.json b/docs/examples/ui-button-hold.json index ae8c19225..b2e249d36 100644 --- a/docs/examples/ui-button-hold.json +++ b/docs/examples/ui-button-hold.json @@ -237,7 +237,7 @@ "ui-notification" ], "showPathInSidebar": false, - "showPageTitle": false, + "headerContent": "none", "navigationStyle": "icon", "titleBarStyle": "default" }, @@ -260,4 +260,4 @@ "density": "default" } } -] \ No newline at end of file +] diff --git a/docs/examples/ui-text-suffix.json b/docs/examples/ui-text-suffix.json index f5fcd2b49..cd3b1f9d6 100644 --- a/docs/examples/ui-text-suffix.json +++ b/docs/examples/ui-text-suffix.json @@ -109,7 +109,7 @@ "ui-notification" ], "showPathInSidebar": false, - "showPageTitle": false, + "headerContent": "none", "navigationStyle": "default", "titleBarStyle": "default" }, @@ -131,4 +131,4 @@ "widgetGap": "6px" } } -] \ No newline at end of file +] diff --git a/nodes/config/locales/en-US/ui_base.json b/nodes/config/locales/en-US/ui_base.json index 9ffb0c767..68e989808 100644 --- a/nodes/config/locales/en-US/ui_base.json +++ b/nodes/config/locales/en-US/ui_base.json @@ -25,7 +25,11 @@ "titleBarStyleFixed": "Fixed", "sidebar": "Sidebar Options", "showPath": "Include Page Path in Label", - "showPageTitle": "Show Page Name in Header", + "headerContent": "Content", + "headerDashboard": "Dashboard name", + "headerPage": "Page name", + "headerDashboardPage": "Dashboard name (Page name)", + "headerNone": "None", "navigationStyle": "Style", "navigationStyleDefault": "Collapsing (default)", "navigationStyleFixed": "Fixed", @@ -63,4 +67,4 @@ "darkest": "var(--nrdb-node-darkest)" } } -} \ No newline at end of file +} diff --git a/nodes/config/ui_base.html b/nodes/config/ui_base.html index 1269d0ceb..492da5b6f 100644 --- a/nodes/config/ui_base.html +++ b/nodes/config/ui_base.html @@ -339,8 +339,8 @@ showPathInSidebar: { value: false }, - showPageTitle: { - value: true + headerContent: { + value: 'page' }, navigationStyle: { value: 'default' @@ -370,12 +370,19 @@ $('#node-config-input-titleBarStyle').val('default') } - // backward compatibility for including page name - if (this.showPageTitle === undefined) { - // set to true - this.showPageTitle = true - // update the jquery checkbox - $('#node-config-input-showPageTitle').prop('checked', true) + // backward compatibility for including header content + // The headerContent replaces the old (boolean) showPageTitle + if (this.headerContent === undefined) { + let showPageTitle = (this.showPageTitle === undefined) ? true : this.showPageTitle + + if (showPageTitle) { + this.headerContent = 'page' + $('#node-config-input-headerContent').val('page') + } + else { + this.headerContent = 'none' + $('#node-config-input-headerContent').val('none') + } } if (this.appIcon) { @@ -2437,9 +2444,14 @@ -
- - +
+ +
diff --git a/nodes/config/ui_base.js b/nodes/config/ui_base.js index 97dd6f4e9..9c922a02d 100644 --- a/nodes/config/ui_base.js +++ b/nodes/config/ui_base.js @@ -80,6 +80,17 @@ module.exports = function (RED) { config.notificationDisplayTime = 5 // Show for 5 seconds } + // The headerContent replaces the old (boolean) showPageTitle + if (!('headerContent' in config)) { + const showPageTitle = ('showPageTitle' in config) ? config.showPageTitle : true + + if (showPageTitle) { + config.headerContent = 'page' + } else { + config.headerContent = 'none' + } + } + // expose these properties at runtime node.acceptsClientConfig = config.acceptsClientConfig // which node types can be scoped to a specific client node.includeClientData = config.includeClientData // whether to include client data in msg payloads diff --git a/nodes/widgets/ui_form.js b/nodes/widgets/ui_form.js index df31e3b7c..8c73832e9 100644 --- a/nodes/widgets/ui_form.js +++ b/nodes/widgets/ui_form.js @@ -1,4 +1,5 @@ const statestore = require('../store/state.js') +const { appendTopic } = require('../utils/index.js') module.exports = function (RED) { function FormNode (config) { @@ -12,7 +13,7 @@ module.exports = function (RED) { const evts = { onAction: true, - beforeSend: function (msg) { + beforeSend: async function (msg) { if (msg.ui_update) { const update = msg.ui_update if (typeof update.label !== 'undefined') { @@ -32,6 +33,8 @@ module.exports = function (RED) { statestore.set(group.getBase(), node, msg, 'dropdownOptions', update.dropdownOptions) } } + + msg = await appendTopic(RED, config, node, msg) return msg } } diff --git a/ui/src/layouts/Baseline.vue b/ui/src/layouts/Baseline.vue index 6d0a17879..2322825e4 100644 --- a/ui/src/layouts/Baseline.vue +++ b/ui/src/layouts/Baseline.vue @@ -5,9 +5,15 @@ -