From 33bdf20886ec65f16bd6d0cdb9c2296eadce7846 Mon Sep 17 00:00:00 2001 From: Steve-Mcl Date: Wed, 20 Nov 2024 08:57:38 +0000 Subject: [PATCH 1/3] Use an aHTTPS Agent and HTTPS scheme if RED.settings.https is set to something closes #1480 --- nodes/config/ui_base.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/nodes/config/ui_base.js b/nodes/config/ui_base.js index bc13c70f..4aadd7e5 100644 --- a/nodes/config/ui_base.js +++ b/nodes/config/ui_base.js @@ -1,3 +1,4 @@ +const { Agent } = require('https') const path = require('path') const axios = require('axios') @@ -1130,7 +1131,17 @@ module.exports = function (RED) { const host = RED.settings.uiHost const port = RED.settings.uiPort const httpAdminRoot = RED.settings.httpAdminRoot - const url = 'http://' + (`${host}:${port}/${httpAdminRoot}flows`).replace('//', '/') + let scheme = 'http://' + let httpsAgent + if (RED.settings.https) { + const https = (typeof RED.settings.https === 'function' ? RED.settings.https() : RED.settings.https) || {} + httpsAgent = new Agent({ + rejectUnauthorized: false, + ...https + }) + scheme = 'https://' + } + const url = scheme + (`${host}:${port}/${httpAdminRoot}flows`).replace('//', '/') console.log('url', url) // get request body const dashboardId = req.params.dashboardId @@ -1234,6 +1245,7 @@ module.exports = function (RED) { const getResponse = await axios.request({ method: 'GET', headers: getHeaders, + httpsAgent, url }) @@ -1314,6 +1326,7 @@ module.exports = function (RED) { const postResponse = await axios.request({ method: 'POST', headers: postHeaders, + httpsAgent, url, data: { flows, From 1771bbe77e72a8f5cb52fa0e3abaf700413d3e9c Mon Sep 17 00:00:00 2001 From: Steve-Mcl Date: Wed, 20 Nov 2024 10:08:02 +0000 Subject: [PATCH 2/3] handle async https settings --- nodes/config/ui_base.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/nodes/config/ui_base.js b/nodes/config/ui_base.js index 4aadd7e5..512f6155 100644 --- a/nodes/config/ui_base.js +++ b/nodes/config/ui_base.js @@ -1134,12 +1134,21 @@ module.exports = function (RED) { let scheme = 'http://' let httpsAgent if (RED.settings.https) { - const https = (typeof RED.settings.https === 'function' ? RED.settings.https() : RED.settings.https) || {} - httpsAgent = new Agent({ - rejectUnauthorized: false, - ...https - }) - scheme = 'https://' + let https = RED.settings.https + try { + if (typeof https === 'function') { + // since https() could return a promise / be async, we need to await it + // if however the function is actually sync, JS will auto wrap it in a promise and await it + https = await https() + } + httpsAgent = new Agent({ + rejectUnauthorized: false, + ...(https || {}) + }) + scheme = 'https://' + } catch (error) { + return res.status(500).json({ error: 'Error processing https settings' }) + } } const url = scheme + (`${host}:${port}/${httpAdminRoot}flows`).replace('//', '/') console.log('url', url) From c1b8f207daf9cb6d87978f25b086363f27eafc92 Mon Sep 17 00:00:00 2001 From: Steve-Mcl Date: Fri, 13 Dec 2024 14:41:06 +0000 Subject: [PATCH 3/3] fix slider widths --- ui/src/layouts/Group.vue | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/ui/src/layouts/Group.vue b/ui/src/layouts/Group.vue index 1cbb597d..af0a7fa1 100644 --- a/ui/src/layouts/Group.vue +++ b/ui/src/layouts/Group.vue @@ -116,17 +116,12 @@ export default { }, widgetStyles () { return (widget) => { - // `grid-template-columns: minmax(0, 1fr); grid-template-rows: repeat(${w.props.height}, minmax(var(--widget-row-height), auto)); grid-row-end: span ${w.props.height}; grid-column-end: span min(${ getWidgetWidth(w.props.width) }, var(--layout-columns))`" const styles = {} const height = widget.props.height || widget.layout.height const width = widget.props.width || widget.layout.width - if (height) { - styles['grid-row-end'] = `span ${height}` - styles['grid-template-rows'] = `repeat(${height}, minmax(var(--widget-row-height), auto))` - } - if (width) { - styles['grid-column-end'] = `span min(${this.getWidgetWidth(width)}, var(--layout-columns))` - } + styles['grid-row-end'] = `span ${height}` + styles['grid-template-rows'] = `repeat(${height}, minmax(var(--widget-row-height), auto))` + styles['grid-column-end'] = `span min(${this.getWidgetWidth(+width)}, var(--layout-columns))` return styles } } @@ -171,11 +166,11 @@ export default { return style }, getWidgetWidth (width) { - if (width) { + const w = +width // convert to number if it's a string + if (!isNaN(w) && w > 0) { return Math.min(width, this.columns) - } else { - return this.columns } + return this.columns }, addSpacer () { this.$store.dispatch('wysiwyg/addSpacer', {