From 685aef83c9445ad0c2238da8fc5079f36277fb60 Mon Sep 17 00:00:00 2001 From: Julian Knight <1591850+TotallyInformation@users.noreply.github.com> Date: Sat, 28 Oct 2023 12:20:34 +0100 Subject: [PATCH 01/63] Typos --- nodes/libs/socket.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/nodes/libs/socket.js b/nodes/libs/socket.js index 5be86f29..16244d44 100644 --- a/nodes/libs/socket.js +++ b/nodes/libs/socket.js @@ -253,7 +253,7 @@ class UibSockets { return this._isConfigured } - // ? Consider adding isConfigered checks on each method? + // ? Consider adding isConfigured checks on each method? /** Output a msg to the front-end. * @param {object} msg The message to output, include msg._socketId to send to a single client @@ -293,7 +293,6 @@ class UibSockets { log.trace(`[uibuilder:socket.js:sendToFe:${url}] msg sent on to ALL clients. Channel: ${channel}. ${JSON.stringify(msg)}`) ioNs.emit(channel, msg) } - } // ---- End of sendToFe ---- // /** Output a normal msg to the front-end. Can override socketid From b0364b960ac9b746140fe10ed43d6a285f9d23a6 Mon Sep 17 00:00:00 2001 From: Julian Knight <1591850+TotallyInformation@users.noreply.github.com> Date: Sat, 28 Oct 2023 12:20:52 +0100 Subject: [PATCH 02/63] Comments --- nodes/libs/uiblib.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nodes/libs/uiblib.js b/nodes/libs/uiblib.js index 9d93e37e..05fa6c05 100644 --- a/nodes/libs/uiblib.js +++ b/nodes/libs/uiblib.js @@ -146,6 +146,7 @@ module.exports = { node.status(node.statusDisplay) }, // ---- End of setNodeStatus ---- // + // TODO Move to fs /** Replace template in front-end instance folder * @param {string} url The uib instance URL * @param {string} template Name of one of the built-in templates including 'blank' and 'external' @@ -177,6 +178,7 @@ module.exports = { if ( extTemplate ) extTemplate = extTemplate.trim() if ( extTemplate === undefined ) throw new Error('extTemplate is undefined') + // TODO Move degit processing to its own function. Don't need the emitter on uib // If template="external" & extTemplate not blank - use degit to load if ( template === 'external' ) { const degit = require('degit') From 34d511cab15b73fc7ad9cdc1ca2f96280822822a Mon Sep 17 00:00:00 2001 From: Julian Knight <1591850+TotallyInformation@users.noreply.github.com> Date: Sat, 28 Oct 2023 15:42:14 +0100 Subject: [PATCH 03/63] Add template switch. Add help. Integrate uib blank template and msg.template. --- docs/nodes/uib-html.md | 25 +++++++++--- nodes/uib-html/customNode.html | 66 ++++++++++++++++++++++++++++++- nodes/uib-html/customNode.js | 44 +++++++-------------- src/editor/uib-html/editor.js | 1 + src/editor/uib-html/help.html | 60 +++++++++++++++++++++++++++- src/editor/uib-html/template.html | 5 +++ 6 files changed, 165 insertions(+), 36 deletions(-) diff --git a/docs/nodes/uib-html.md b/docs/nodes/uib-html.md index 87d54d61..995d49bf 100644 --- a/docs/nodes/uib-html.md +++ b/docs/nodes/uib-html.md @@ -3,15 +3,30 @@ title: uib-html - Hydrate uibuilder msg._ui configuration data to HTML description: > Usage and configuration. created: 2023-02-05 16:31:39 -lastUpdated: 2023-08-28 18:22:08 +lastUpdated: 2023-10-28 15:33:18 --- -Available from uibuilder v6.6.0. +Available since uibuilder v6.6.0. -Initial release has no real configuration. - -Simply send the node a msg containing a `msg._ui` in accordance with the specifications listed here: [Dynamic, configuration-driven UI's (low-code)](Dynamic, configuration-driven UI's (low-code)). +Simply send the node a msg containing a `msg._ui` in accordance with the specifications listed here: [Dynamic, configuration-driven UI's (low-code)](client-docs/config-driven-ui). It will output a new msg containing the HTML in `msg.payload`. `msg._ui` is removed and all other msg properties are passed through. +## Optional template wrapper + +Generally though, the no-code and low-code `_ui` configurations relate to a specific area of the `body` of your HTML page. So the resulting HTML output from this node will be the same. In such cases, you will often want to wrap the output in a template - perhaps one that is a complete web page. By selecting the "Merge HTML Template?" flag, the node will wrap the generated HTML in a template. + +The template can be provided as an HTML string in the `msg.template` property. + +If that property does not exist on the incoming message, the node will use the current UIBUILDER "Blank" template which will give you a fully working UIBUILDER managed web page. In such a case, you can use the `uib-save` node to replace the existing `index.html` page or save as a new page as desired. + +If passing a template, you can use the core Node-RED `template` node to create the text and even include some data from Node-RED as needed. Of course, you could also read the text from an external file or even get it from a remote server. + +## Different uses for the output + +Use with the `uib-save` node is mentioned above. Of course, you can save manually using the core `file-out` node instead. + +However, you can use the output in other ways as well: +* As the HTML returned to an `http-out` core node. +* As the input to a Dashboard `ui-template` node for use with Dashboard. diff --git a/nodes/uib-html/customNode.html b/nodes/uib-html/customNode.html index 4918776f..0d50222c 100644 --- a/nodes/uib-html/customNode.html +++ b/nodes/uib-html/customNode.html @@ -59,6 +59,11 @@ + +
Currently no custom settings for this element type. @@ -29,10 +32,6 @@
- + + -/
"),-1!==e.indexOf("\\")&&(this.urlErrors.bslash="Cannot contain \\
"),-1!==e.indexOf(" ")&&(this.urlErrors.sp="Cannot contain spaces"),"_"===e.substring(0,1)&&(this.urlErrors.strtU="Cannot start with _
(underscore)"),"."===e.substring(0,1)&&(this.urlErrors.strtDot="Cannot start with .
(dot)"),"templates"===e.toLowerCase().substring(0,9)&&(this.urlErrors.templ='Cannot be "templates"'),"uibuilder"===e.toLowerCase()&&(this.urlErrors.uibname='Cannot be "uibuilder" (since v5)')),!0===this.urlDeployedDup&&(this.urlErrors.dup="Cannot be a URL already deployed"),!0===this.urlEditorDup&&(this.urlErrors.dup="Cannot be a URL already in use"),void 0!==e&&""!==e&&(this.folderExists=function(e){if(void 0===e)return!1;let o=!1;return $.ajax({type:"GET",async:!1,dataType:"json",url:"./uibuilder/admin/"+e,data:{cmd:"checkfolder"},success:function(e){o=e},error:function(e,t,i){"Not Found"!==i&&console.error("[uibuilder:queryFolderExists] Error "+t,i),o=!1}}),o}(e),!0===this.folderExists&&!0===this.urlChanged&&(i(">> folder already exists >>",this.url,this.id),RED.notify(`WARNING: The folder for the chosen URL (${e}) is already exists.
It will be adopted by this node.
You are renaming the url from ${this.url} to ${e}.
You MUST redeploy before doing anything else.
You are deleting a uibuilder instance with url ${this.url}.
Would you like to also delete the folder?
WARNING: This cannot be undone.
msg._ui
standard configuration data.
- Please try out the examples in the import library. + Please try out the examples in the import library. Documentation.
- Converts uibuilder low-code UI description data into HTML. Send a msg._ui
object to the node,
+ Converts UIBUILDER low-code UI description data into HTML. Send a msg._ui
object to the node,
the output will be HTML in msg.payload
.
Details.
uib-element
node instead.
-uib-element
node instead.
+ uibuilderfe
library.
-uibuilderfe
library.
+
+ With no msg.mode
set, sending another message will
+ automatically remove and replace the list.
+
+ To remove an existing list, set msg.mode
to "remove".
+ This will also clear the cache.
+
+ If node status is "Data Registered", when a new client connects to uibuilder, + it will immediately be sent a copy of the data so that all connected clients + have the same display. +
++ If you need to do more complex tasks such as update specific entries in the list, + set the node to just output the configuration and then use the documentation to + tweak it accordingly. +
+
- With no msg.mode
set, sending another message will
- automatically remove and replace the list.
-
- To remove an existing list, set msg.mode
to "remove".
- This will also clear the cache.
-
- If node status is "Data Registered", when a new client connects to uibuilder, - it will immediately be sent a copy of the data so that all connected clients - have the same display. -
-- If you need to do more complex tasks such as update specific entries in the list, - set the node to just output the configuration and then use the documentation to - tweak it accordingly. -
Save a file into a uibuilder instance folder.
++ Documentation. +