Last active
December 17, 2020 22:29
Revisions
-
TotallyInformation revised this gist
Dec 17, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ All of the front-end html, javascript and css is included in the flow so simply See if you can work out how to use the control outputs (output port #2 on the uibuilder node) to trigger a new quote when you reload the page. (_Hint: See the GitHub page for this example as it has another flow attached_). The real purpose of this flow is to help you learn a little bit about VueJS which is the default front-end framework provided with uibuilder v2 and v3. The front-end code is extremely simple so do take a look and see how it works. -
TotallyInformation revised this gist
Dec 17, 2020 . 1 changed file with 35 additions and 35 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,65 +2,65 @@ { "id": "3a85e836.06b698", "type": "comment", "z": "ff1a7711.244f48", "name": "uibuilder/Simple Example", "info": "[Front-End](/uib_simple)\n\nThis flow gets a \"quote of the day\" from the Internet and passes it\nto uibuilder. It caches the result so that if you reload the page,\nyou get the last result back. The quote is updated every 30 minutes\nduring the day and evening.\n\n\"Simple\" refers to the front-end code. While the flow looks a little\ncomplex, it really isn't. A trigger (repeating), an Internet request,\na cache and uibuilder. The link nodes loop the control output from\nuibuilder back to the cache.\n\n## Configuration\n\nUpdate the files:\n\n* `index.html`\n* `index.js`\n* `index.css`\n\nAccording to the example(s) in the 3 other comment nodes in this example.\n\nPress the button on the trigger to start the flow.", "x": 230, "y": 120, "wires": [] }, { "id": "7cf5c3b2.96006c", "type": "comment", "z": "ff1a7711.244f48", "name": "index.html", "info": "<!doctype html><html lang=\"en\"><head>\n <meta charset=\"utf-8\">\n <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n\n <title>uibuilder simple example</title>\n <meta name=\"description\" content=\"Node-RED uibuilder - Simple example using VueJS\">\n\n <link rel=\"icon\" href=\"./images/node-blue.ico\">\n\n <!-- Put your own custom styles in here -->\n <link rel=\"stylesheet\" href=\"./index.css\" media=\"all\">\n\n</head><body>\n <!-- The \"app\" element is where the code for dynamic updates is attached -->\n\t<div id=\"app\">\n\t <h1>A simple uibuilder page</h1>\n\t <p>\n\t The elements below are dynamically updated when you send\n\t a msg to your uibuilder node.\n\t </p>\n\t \n\t <div v-if=\"msg.payload\">\n\t <h2>Quote of the Day</h2>\n\t <blockquote>\n\t <i>{{ msg.payload.quote.body }}</i>\n \t <div>{{ msg.payload.quote.author }}</div>\n\t </blockquote>\n\t </div>\n\t \n\t <h2>The full msg object</h2>\n\t\t<code>{{ msg }}</code>\n\t\t\n\t</div>\n\n <!-- Vendor Libraries - Load in the right order -->\n <script src=\"../uibuilder/vendor/socket.io/socket.io.js\"></script>\n <script src=\"../uibuilder/vendor/vue/dist/vue.min.js\"></script>\n\n <!-- REQUIRED: Sets up Socket listeners, the uibuilder and msg objects -->\n <script src=\"./uibuilderfe.min.js\"></script>\n\n <!-- Put your own custom code in here -->\n <script src=\"./index.js\"></script>\n\n</body></html>", "x": 420, "y": 120, "wires": [], "icon": "node-red/parser-html.svg" }, { "id": "8f8bfd94.685e6", "type": "comment", "z": "ff1a7711.244f48", "name": "index.js", "info": "/* jshint browser: true, esversion: 5, asi: true */\n/*globals uibuilder, Vue */\n// @ts-nocheck\n/*\n Copyright (c) 2020 Julian Knight (Totally Information)\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n*/\n'use strict'\n\n/** @see https://github.com/TotallyInformation/node-red-contrib-uibuilder/wiki/Front-End-Library---available-properties-and-methods */\n\nvar app1 = new Vue({\n // The HTML element to attach to\n\tel: '#app',\n\t/** Pre-defined data\n\t * Anything defined here can be used in the HTML\n\t * if you update it, the HTML will automatically update\n\t */\n\tdata: {\n\t\tmsg: '[Nothing Recieved Yet]',\n\t},\n\n // Called after the Vue app has been created. A good place to put startup code\n created: function() {\n // **REQUIRED** Start uibuilder comms with Node-RED\n uibuilder.start()\n },\n\n // Called when Vue is fully loaded\n\tmounted: function() {\n\t\t// Keep a convenient reference to the Vue app\n\t\tvar vueApp = this\n\n /** Triggered when the node on the Node-RED server\n * recieves a (non-control) msg\n */\n\t\tuibuilder.onChange('msg', function(msg) {\n\t\t\tvueApp.msg = msg\n\t\t})\n\n\t\t// Send message back to node-red\n\t\t// uibuilder.send({payload:'some message'})\n\t},\n\t\n}) // --- End of the Vue app definition --- //\n\n// EOF", "x": 550, "y": 120, "wires": [], "icon": "font-awesome/fa-code" }, { "id": "8a35b840.a3b2d8", "type": "comment", "z": "ff1a7711.244f48", "name": "index.css", "info": "body {font-family: sans-serif; font-size: 120%;}\ndiv, p, code { margin:0.3em; padding: 0.3em;}\n\nblockquote i {\n font-size: 1.5em; color:grey; font-style: italic;\n}", "x": 680, "y": 120, "wires": [], "icon": "node-red/hash.svg" }, { "id": "2cf3f051.3dd33", "type": "debug", "z": "ff1a7711.244f48", "name": "simple-debug", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "x": 740, "y": 160, "wires": [] }, { "id": "eb95241.bca25d8", "type": "uibuilder", "z": "ff1a7711.244f48", "name": "Simple Example", "topic": "", "url": "uib_simple", @@ -69,8 +69,8 @@ "allowStyles": false, "copyIndex": true, "showfolder": false, "x": 530, "y": 180, "wires": [ [ "2cf3f051.3dd33" @@ -83,17 +83,17 @@ { "id": "70cf5aa5.9b03c4", "type": "inject", "z": "ff1a7711.244f48", "name": "", "repeat": "", "crontab": "", "once": false, "onceDelay": "", "topic": "", "payload": "", "payloadType": "str", "x": 150, "y": 180, "wires": [ [ "dcbb878b.7de8c8" @@ -103,37 +103,37 @@ { "id": "4e7c2860.c5c318", "type": "debug", "z": "ff1a7711.244f48", "name": "uib controls", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "x": 730, "y": 200, "wires": [] }, { "id": "16169222.b4d91e", "type": "debug", "z": "ff1a7711.244f48", "name": "qod-debug", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "x": 530, "y": 260, "wires": [] }, { "id": "dcbb878b.7de8c8", "type": "http request", "z": "ff1a7711.244f48", "name": "Quote of the day", "method": "GET", "ret": "obj", @@ -143,8 +143,8 @@ "persist": false, "proxy": "", "authType": "", "x": 310, "y": 180, "wires": [ [ "eb95241.bca25d8", -
TotallyInformation revised this gist
Sep 9, 2019 . 2 changed files with 67 additions and 67 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,49 @@ [ { "id": "3a85e836.06b698", "type": "comment", "z": "18cb249f.38bafb", "name": "uibuilder/Simple Example", "info": "[Front-End](/uib_simple)\n\nThis flow gets a \"quote of the day\" from the Internet and passes it\nto uibuilder. It caches the result so that if you reload the page,\nyou get the last result back. The quote is updated every 30 minutes\nduring the day and evening.\n\n\"Simple\" refers to the front-end code. While the flow looks a little\ncomplex, it really isn't. A trigger (repeating), an Internet request,\na cache and uibuilder. The link nodes loop the control output from\nuibuilder back to the cache.\n\n## Configuration\n\nUpdate the files:\n\n* `index.html`\n* `index.js`\n* `index.css`\n\nAccording to the example(s) in the 3 other comment nodes in this example.\n\nPress the button on the trigger to start the flow.", "x": 250, "y": 2040, "wires": [] }, { "id": "7cf5c3b2.96006c", "type": "comment", "z": "18cb249f.38bafb", "name": "index.html", "info": "<!doctype html>\n<html lang=\"en\"><head>\n <meta charset=\"utf-8\">\n <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n <meta name=\"viewport\" content=\"width=device-width, minimum-scale=1, initial-scale=1, user-scalable=yes\">\n\n <title>uibuilder simple example</title>\n <meta name=\"description\" content=\"Node-RED uibuilder - Simple example using VueJS\">\n\n <link rel=\"icon\" href=\"./images/node-blue.ico\">\n\n <!-- Put your own custom styles in here -->\n <link rel=\"stylesheet\" href=\"./index.css\" media=\"all\">\n\n</head><body>\n <!-- The \"app\" element is where the code for dynamic updates is attached -->\n\t<div id=\"app\">\n\t <h1>A simple uibuilder page</h1>\n\t <p>\n\t The elements below are dynamically updated when you send\n\t a msg to your uibuilder node.\n\t </p>\n\t \n\t <div v-if=\"msg.payload\">\n\t <h2>Quote of the Day</h2>\n\t <blockquote>\n\t <i>{{ msg.payload.quote.body }}</i>\n \t <div>{{ msg.payload.quote.author }}</div>\n\t </blockquote>\n\t </div>\n\t \n\t <h2>The full msg object</h2>\n\t\t<code>{{ msg }}</code>\n\t\t\n\t</div>\n\n <!-- Vendor Libraries - Load in the right order -->\n <script src=\"../uibuilder/vendor/socket.io/socket.io.js\"></script>\n <script src=\"../uibuilder/vendor/vue/dist/vue.min.js\"></script>\n\n <!-- REQUIRED: Sets up Socket listeners, the uibuilder and msg objects -->\n <script src=\"./uibuilderfe.min.js\"></script>\n\n <!-- Put your own custom code in here -->\n <script src=\"./index.js\"></script>\n\n</body></html>", "x": 440, "y": 2040, "wires": [], "icon": "node-red/parser-html.svg" }, { "id": "8f8bfd94.685e6", "type": "comment", "z": "18cb249f.38bafb", "name": "index.js", "info": "/* jshint browser: true, esversion: 5, asi: true */\n/*globals uibuilder, Vue */\n// @ts-nocheck\n/*\n Copyright (c) 2019 Julian Knight (Totally Information)\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n*/\n'use strict'\n\n/** @see https://github.com/TotallyInformation/node-red-contrib-uibuilder/wiki/Front-End-Library---available-properties-and-methods */\n\nvar app1 = new Vue({\n // The HTML element to attach to\n\tel: '#app',\n\t/** Pre-defined data\n\t * Anything defined here can be used in the HTML\n\t * if you update it, the HTML will automatically update\n\t */\n\tdata: {\n\t\tmsg: '[Nothing Recieved Yet]',\n\t},\n\n // This is called when Vue is fully loaded\n\tmounted: function() {\n\t // Start up uibuilder\n\t\tuibuilder.start()\n\t\t\n\t\t// Keep a convenient reference to the Vue app\n\t\tvar vueApp = this\n\n /** Triggered when the node on the Node-RED server\n * recieves a (non-control) msg\n */\n\t\tuibuilder.onChange('msg', function(msg) {\n\t\t\tvueApp.msg = msg\n\t\t})\n\n\t\t// Send message back to node-red\n\t\t// uibuilder.send({payload:'some message'})\n\n\t\t// Triggered on reciept of a control message from node-red\n\t\t//uibuilder.onChange('ctrlMsg', function(msg) {\n\t\t// console.log(msg)\n\t\t//})\n\t},\n\t\n}) // --- End of the Vue app definition --- //\n\n// EOF", "x": 570, "y": 2040, "wires": [], "icon": "font-awesome/fa-code" }, { "id": "8a35b840.a3b2d8", "type": "comment", "z": "18cb249f.38bafb", "name": "index.css", "info": "body {font-family: sans-serif; font-size: 120%;}\ndiv, p, code { margin:0.3em; padding: 0.3em;}\n\nblockquote i {\n font-size: 1.5em; color:grey; font-style: italic;\n}", "x": 700, "y": 2040, "wires": [], "icon": "node-red/hash.svg" }, { "id": "2cf3f051.3dd33", "type": "debug", "z": "18cb249f.38bafb", "name": "simple-debug", @@ -10,12 +53,12 @@ "tostatus": false, "complete": "true", "targetType": "full", "x": 760, "y": 2080, "wires": [] }, { "id": "eb95241.bca25d8", "type": "uibuilder", "z": "18cb249f.38bafb", "name": "Simple Example", @@ -26,19 +69,19 @@ "allowStyles": false, "copyIndex": true, "showfolder": false, "x": 550, "y": 2100, "wires": [ [ "2cf3f051.3dd33" ], [ "4e7c2860.c5c318" ] ] }, { "id": "70cf5aa5.9b03c4", "type": "inject", "z": "18cb249f.38bafb", "name": "", @@ -49,16 +92,16 @@ "crontab": "", "once": false, "onceDelay": "", "x": 170, "y": 2100, "wires": [ [ "dcbb878b.7de8c8" ] ] }, { "id": "4e7c2860.c5c318", "type": "debug", "z": "18cb249f.38bafb", "name": "uib controls", @@ -68,44 +111,12 @@ "tostatus": false, "complete": "true", "targetType": "full", "x": 750, "y": 2120, "wires": [] }, { "id": "16169222.b4d91e", "type": "debug", "z": "18cb249f.38bafb", "name": "qod-debug", @@ -115,12 +126,12 @@ "tostatus": false, "complete": "true", "targetType": "full", "x": 550, "y": 2180, "wires": [] }, { "id": "dcbb878b.7de8c8", "type": "http request", "z": "18cb249f.38bafb", "name": "Quote of the day", @@ -132,24 +143,13 @@ "persist": false, "proxy": "", "authType": "", "x": 330, "y": 2100, "wires": [ [ "eb95241.bca25d8", "16169222.b4d91e" ] ] } ] This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -100,7 +100,7 @@ "type": "comment", "z": "18cb249f.38bafb", "name": "index.js", "info": "/* jshint browser: true, esversion: 5, asi: true */\n/*globals uibuilder, Vue */\n// @ts-nocheck\n/*\n Copyright (c) 2019 Julian Knight (Totally Information)\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n*/\n'use strict'\n\n/** @see https://github.com/TotallyInformation/node-red-contrib-uibuilder/wiki/Front-End-Library---available-properties-and-methods */\n\nvar app1 = new Vue({\n // The HTML element to attach to\n\tel: '#app',\n\t/** Pre-defined data\n\t * Anything defined here can be used in the HTML\n\t * if you update it, the HTML will automatically update\n\t */\n\tdata: {\n\t\tmsg: '[Nothing Recieved Yet]',\n\t},\n\n // This is called when Vue is fully loaded\n\tmounted: function() {\n\t // Start up uibuilder\n\t\tuibuilder.start()\n\t\t\n\t\t// Keep a convenient reference to the Vue app\n\t\tvar vueApp = this\n\n /** Triggered when the node on the Node-RED server\n * recieves a (non-control) msg\n */\n\t\tuibuilder.onChange('msg', function(msg) {\n\t\t\tvueApp.msg = msg\n\t\t})\n\n\t\t// Send message back to node-red\n\t\t// uibuilder.send({payload:'some message'})\n\n\t\t// Triggered on reciept of a control message from node-red\n\t\t//uibuilder.onChange('ctrlMsg', function(msg) {\n\t\t// console.log(msg)\n\t\t//})\n\t},\n\t\n}) // --- End of the Vue app definition --- //\n\n// EOF", "x": 550, "y": 1680, "wires": [], -
TotallyInformation revised this gist
Sep 8, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ This simple flow will deliver a random quote of the day to a web URL using uibui All of the front-end html, javascript and css is included in the flow so simply add the flow and edit the front-end code using uibuilder's built-in editor. See if you can work out how to use the control outputs (output port #2 on the uibuilder node) to trigger a new quote when you reload the page. (_Hint: See the GitHub page for this example as it has another flow attached_). The real purpose of this flow is to help you learn a little bit about VueJS which is the default front-end framework provided with uibuilder v2. -
TotallyInformation revised this gist
Sep 8, 2019 . 2 changed files with 320 additions and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ This simple flow will deliver a random quote of the day to a web URL using uibui All of the front-end html, javascript and css is included in the flow so simply add the flow and edit the front-end code using uibuilder's built-in editor. See if you can work out how to use the control outputs (output port #2 on the uibuilder node) to trigger a new quote when you reload the page. (Hint: See the GitHub page for this as it has another flow attached). The real purpose of this flow is to help you learn a little bit about VueJS which is the default front-end framework provided with uibuilder v2. This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,319 @@ [ { "id": "ece9345a.f21808", "type": "debug", "z": "18cb249f.38bafb", "name": "simple-debug", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "x": 640, "y": 1720, "wires": [] }, { "id": "bad4b165.e6a08", "type": "uibuilder", "z": "18cb249f.38bafb", "name": "Simple Example", "topic": "", "url": "uib_simple", "fwdInMessages": false, "allowScripts": false, "allowStyles": false, "copyIndex": true, "showfolder": false, "x": 450, "y": 1740, "wires": [ [ "ece9345a.f21808" ], [ "bf35e77f.4a7978", "6eb39afc.539d54" ] ] }, { "id": "ba6581d8.f5fa2", "type": "inject", "z": "18cb249f.38bafb", "name": "Manual Start", "topic": "", "payload": "", "payloadType": "str", "repeat": "", "crontab": "*/30 9-22 * * *", "once": true, "onceDelay": "", "x": 155, "y": 1740, "wires": [ [ "eb406f24.13a48" ] ], "l": false }, { "id": "bf35e77f.4a7978", "type": "debug", "z": "18cb249f.38bafb", "name": "uib controls", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "x": 690, "y": 1760, "wires": [] }, { "id": "5b8a68be.588ec8", "type": "comment", "z": "18cb249f.38bafb", "name": "uibuilder/Simple Example", "info": "[Front-End](/uib_simple)\n\nThis flow gets a \"quote of the day\" from the Internet and passes it\nto uibuilder. It caches the result so that if you reload the page,\nyou get the last result back. The quote is updated every 30 minutes\nduring the day and evening.\n\n\"Simple\" refers to the front-end code. While the flow looks a little\ncomplex, it really isn't. A trigger (repeating), an Internet request,\na cache and uibuilder. The link nodes loop the control output from\nuibuilder back to the cache.\n\n## Configuration\n\nUpdate the files:\n\n* `index.html`\n* `index.js`\n* `index.css`\n\nAccording to the example(s) in the 3 other comment nodes in this example.\n\nPress the button on the trigger to start the flow.", "x": 230, "y": 1680, "wires": [] }, { "id": "4a7cc95e.3becd8", "type": "comment", "z": "18cb249f.38bafb", "name": "index.html", "info": "<!doctype html>\n<html lang=\"en\"><head>\n <meta charset=\"utf-8\">\n <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n <meta name=\"viewport\" content=\"width=device-width, minimum-scale=1, initial-scale=1, user-scalable=yes\">\n\n <title>uibuilder simple example</title>\n <meta name=\"description\" content=\"Node-RED uibuilder - Simple example using VueJS\">\n\n <link rel=\"icon\" href=\"./images/node-blue.ico\">\n\n <!-- Put your own custom styles in here -->\n <link rel=\"stylesheet\" href=\"./index.css\" media=\"all\">\n\n</head><body>\n <!-- The \"app\" element is where the code for dynamic updates is attached -->\n\t<div id=\"app\">\n\t <h1>A simple uibuilder page</h1>\n\t <p>\n\t The elements below are dynamically updated when you send\n\t a msg to your uibuilder node.\n\t </p>\n\t \n\t <div v-if=\"msg.payload\">\n\t <h2>Quote of the Day</h2>\n\t <blockquote>\n\t <i>{{ msg.payload.quote.body }}</i>\n \t <div>{{ msg.payload.quote.author }}</div>\n\t </blockquote>\n\t </div>\n\t \n\t <h2>The full msg object</h2>\n\t\t<code>{{ msg }}</code>\n\t\t\n\t</div>\n\n <!-- Vendor Libraries - Load in the right order -->\n <script src=\"../uibuilder/vendor/socket.io/socket.io.js\"></script>\n <script src=\"../uibuilder/vendor/vue/dist/vue.min.js\"></script>\n\n <!-- REQUIRED: Sets up Socket listeners, the uibuilder and msg objects -->\n <script src=\"./uibuilderfe.min.js\"></script>\n\n <!-- Put your own custom code in here -->\n <script src=\"./index.js\"></script>\n\n</body></html>", "x": 420, "y": 1680, "wires": [], "icon": "node-red/parser-html.svg" }, { "id": "1a004a18.d3c5e6", "type": "comment", "z": "18cb249f.38bafb", "name": "index.js", "info": "/* jshint browser: true, esversion: 5, asi: true */\n/*globals $, uibuilder */\n// @ts-nocheck\n/*\n Copyright (c) 2019 Julian Knight (Totally Information)\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n*/\n'use strict'\n\n/** @see https://github.com/TotallyInformation/node-red-contrib-uibuilder/wiki/Front-End-Library---available-properties-and-methods */\n\n// When JQuery is ready, update\n$( document ).ready(function() {\n /** **REQUIRED** Start uibuilder comms with Node-RED @since v2.0.0-dev3\n * Pass the namespace and ioPath variables if hosting page is not in the instance root folder\n * e.g. If you get continual `uibuilderfe:ioSetup: SOCKET CONNECT ERROR` error messages.\n * e.g. uibuilder.start('/nr/uib', '/nr/uibuilder/vendor/socket.io') // change to use your paths/names\n */\n uibuilder.start()\n\n // Initial set\n $('#msgsReceived').text( uibuilder.get('msgsReceived') )\n $('#msgsControl').text( uibuilder.get('msgsCtrl') )\n $('#msgsSent').text( uibuilder.get('msgsSent') )\n $('#socketConnectedState').text( uibuilder.get('ioConnected') )\n $('#feVersion').text( uibuilder.get('version') )\n\n // Turn on debugging (default is off)\n //uibuilder.debug(true)\n\n // If msg changes - msg is updated when a standard msg is received from Node-RED over Socket.IO\n // Note that you can also listen for 'msgsReceived' as they are updated at the same time\n // but newVal relates to the attribute being listened to.\n uibuilder.onChange('msg', function(newVal){\n console.info('property msg changed!')\n console.dir(newVal)\n $('#showMsg').text(JSON.stringify(newVal))\n //uibuilder.set('msgCopy', newVal)\n })\n\n // You can get attributes manually. Non-existent attributes return 'undefined'\n //console.dir(uibuilder.get('msg'))\n\n // You can also set things manually. See the list of attributes top of page.\n // You can add arbitrary attributes to the object, you cannot overwrite internal attributes\n\n // Try setting a restricted, internal attribute - see the warning in the browser console\n uibuilder.set('msg', 'You tried but failed!')\n\n // Remember that onChange functions don't trigger if you haven't set them\n // up BEFORE an attribute change.\n uibuilder.onChange('msgCopy', function(newVal){\n console.info('msgCopy changed. New value: ', newVal)\n })\n\n // Now try setting a new attribute - this will be an empty object because\n // msg won't yet have been received\n uibuilder.set('msgCopy', uibuilder.msg)\n // Hint: Try putting this set into the onChange for 'msg'\n\n // As noted, we could get the msg here too\n uibuilder.onChange('msgsReceived', function(newVal){\n console.info('New msg sent to us from Node-RED over Socket.IO. Total Count: ', newVal)\n $('#msgsReceived').text(newVal)\n // uibuilder.msg is a shortcut for uibuilder.get('msg')\n //$('#showMsg').text(JSON.stringify(uibuilder.msg))\n })\n\n // If Socket.IO connects/disconnects\n uibuilder.onChange('ioConnected', function(newVal){\n console.info('Socket.IO Connection Status Changed: ', newVal)\n $('#socketConnectedState').text(newVal)\n })\n\n // If a message is sent back to Node-RED\n uibuilder.onChange('msgsSent', function(newVal){\n console.info('New msg sent to Node-RED over Socket.IO. Total Count: ', newVal)\n $('#msgsSent').text(newVal)\n $('#showMsgSent').text(JSON.stringify(uibuilder.get('sentMsg')))\n })\n\n // If we receive a control message from Node-RED\n uibuilder.onChange('msgsCtrl', function(newVal){\n console.info('New control msg sent to us from Node-RED over Socket.IO. Total Count: ', newVal)\n $('#msgsControl').text(newVal)\n $('#showCtrlMsg').text(JSON.stringify(uibuilder.get('ctrlMsg')))\n })\n\n //Manually send a message back to Node-RED after 2 seconds\n window.setTimeout(function(){\n console.info('Sending a message back to Node-RED - after 2s delay')\n uibuilder.send( { 'topic':'uibuilderfe', 'payload':'I am a message sent from the uibuilder front end' } )\n }, 2000)\n\n}) // --- End of JQuery Ready --- //\n\n// EOF\n", "x": 550, "y": 1680, "wires": [], "icon": "font-awesome/fa-code" }, { "id": "ddf41d65.687", "type": "debug", "z": "18cb249f.38bafb", "name": "qod-debug", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "x": 410, "y": 1800, "wires": [] }, { "id": "eb406f24.13a48", "type": "http request", "z": "18cb249f.38bafb", "name": "GET", "method": "GET", "ret": "obj", "paytoqs": false, "url": "https://favqs.com/api/qotd", "tls": "", "persist": false, "proxy": "", "authType": "", "x": 250, "y": 1740, "wires": [ [ "ddf41d65.687", "8cfb4d87.519ba", "bad4b165.e6a08" ] ] }, { "id": "fa66e5de.8a81e8", "type": "comment", "z": "18cb249f.38bafb", "name": "index.css", "info": "body {font-family: sans-serif; font-size: 120%;}\ndiv, p, code { margin:0.3em; padding: 0.3em;}\n\nblockquote i {\n font-size: 1.5em; color:grey; font-style: italic;\n}", "x": 680, "y": 1680, "wires": [], "icon": "node-red/hash.svg" }, { "id": "83b1be67.1e3d3", "type": "link out", "z": "18cb249f.38bafb", "name": "uib_simple_ctrl_out", "links": [ "c65760d4.37dac" ], "x": 815, "y": 1800, "wires": [] }, { "id": "c65760d4.37dac", "type": "link in", "z": "18cb249f.38bafb", "name": "uib_simple_ctrl_in", "links": [ "83b1be67.1e3d3" ], "x": 155, "y": 1780, "wires": [ [ "eb406f24.13a48" ] ] }, { "id": "a7683dd2.9a4e5", "type": "file", "z": "18cb249f.38bafb", "name": "", "filename": "", "appendNewline": true, "createDir": false, "overwriteFile": "false", "encoding": "none", "x": 630, "y": 1620, "wires": [ [] ] }, { "id": "8cfb4d87.519ba", "type": "change", "z": "18cb249f.38bafb", "name": "", "rules": [ { "t": "set", "p": "filename", "pt": "msg", "to": "\"./quotes/\" & payload.quote.id & \".json\"", "tot": "jsonata" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 470, "y": 1620, "wires": [ [ "a7683dd2.9a4e5" ] ] }, { "id": "6eb39afc.539d54", "type": "switch", "z": "18cb249f.38bafb", "name": "client", "property": "from", "propertyType": "msg", "rules": [ { "t": "eq", "v": "client", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 610, "y": 1800, "wires": [ [ "1d092359.465b4d" ] ] }, { "id": "1d092359.465b4d", "type": "change", "z": "18cb249f.38bafb", "name": "delete", "rules": [ { "t": "delete", "p": "cacheControl", "pt": "msg" }, { "t": "delete", "p": "uibuilderCtrl", "pt": "msg" }, { "t": "delete", "p": "from", "pt": "msg" }, { "t": "delete", "p": "_socketId", "pt": "msg" }, { "t": "delete", "p": "_msgid", "pt": "msg" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 730, "y": 1800, "wires": [ [ "83b1be67.1e3d3" ] ] }, { "id": "8ed2c6e8.a5e258", "type": "comment", "z": "18cb249f.38bafb", "name": "Saves copies of all quotes ==>", "info": "To a `quotes` folder.", "x": 210, "y": 1620, "wires": [] }, { "id": "c0567834.0593b8", "type": "comment", "z": "18cb249f.38bafb", "name": "Shows a new quote if the page is reloaded", "info": "", "x": 720, "y": 1840, "wires": [] } ] -
TotallyInformation revised this gist
Sep 6, 2019 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,4 +10,6 @@ The front-end code is extremely simple so do take a look and see how it works. Many thanks to [bakman2](https://github.com/bakman2) for the inspiration. I will include this flow in the uibuilder examples in a future release. There are many more [examples for uibuilder on the WIKI](https://github.com/TotallyInformation/node-red-contrib-uibuilder/wiki), please check them out. -
TotallyInformation created this gist
Sep 6, 2019 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ This simple flow will deliver a random quote of the day to a web URL using uibuilder. All of the front-end html, javascript and css is included in the flow so simply add the flow and edit the front-end code using uibuilder's built-in editor. See if you can work out how to use the control outputs (output port #2 on the uibuilder node) to trigger a new quote when you reload the page. The real purpose of this flow is to help you learn a little bit about VueJS which is the default front-end framework provided with uibuilder v2. The front-end code is extremely simple so do take a look and see how it works. Many thanks to [bakman2](https://github.com/bakman2) for the inspiration. I will include this flow in the uibuilder examples in a future release. This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,155 @@ [ { "id": "ece9345a.f21808", "type": "debug", "z": "18cb249f.38bafb", "name": "simple-debug", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "x": 740, "y": 1680, "wires": [] }, { "id": "bad4b165.e6a08", "type": "uibuilder", "z": "18cb249f.38bafb", "name": "Simple Example", "topic": "", "url": "uib_simple", "fwdInMessages": false, "allowScripts": false, "allowStyles": false, "copyIndex": true, "showfolder": false, "x": 530, "y": 1700, "wires": [ [ "ece9345a.f21808" ], [ "bf35e77f.4a7978" ] ] }, { "id": "ba6581d8.f5fa2", "type": "inject", "z": "18cb249f.38bafb", "name": "", "topic": "", "payload": "", "payloadType": "str", "repeat": "", "crontab": "", "once": false, "onceDelay": "", "x": 150, "y": 1700, "wires": [ [ "eb406f24.13a48" ] ] }, { "id": "bf35e77f.4a7978", "type": "debug", "z": "18cb249f.38bafb", "name": "uib controls", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "x": 730, "y": 1720, "wires": [] }, { "id": "5b8a68be.588ec8", "type": "comment", "z": "18cb249f.38bafb", "name": "uibuilder/Simple Example", "info": "[Front-End](/uib_simple)\n\n## Configuration\n\nUpdate the files:\n\n* `index.html`\n* `index.js`\n* `index.css`\n\nAccording to the example(s) in the 3 other comment nodes in this example.", "x": 230, "y": 1640, "wires": [] }, { "id": "4a7cc95e.3becd8", "type": "comment", "z": "18cb249f.38bafb", "name": "index.html", "info": "<!doctype html>\n<html lang=\"en\"><head>\n <meta charset=\"utf-8\">\n <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n <meta name=\"viewport\" content=\"width=device-width, minimum-scale=1, initial-scale=1, user-scalable=yes\">\n\n <title>uibuilder simple example</title>\n <meta name=\"description\" content=\"Node-RED uibuilder - Simple example using VueJS\">\n\n <link rel=\"icon\" href=\"./images/node-blue.ico\">\n\n <!-- Put your own custom styles in here -->\n <link rel=\"stylesheet\" href=\"./index.css\" media=\"all\">\n\n</head><body>\n <!-- The \"app\" element is where the code for dynamic updates is attached -->\n\t<div id=\"app\">\n\t <h1>A simple uibuilder page</h1>\n\t <p>\n\t The elements below are dynamically updated when you send\n\t a msg to your uibuilder node.\n\t </p>\n\t \n\t <div v-if=\"msg.payload\">\n\t <h2>Quote of the Day</h2>\n\t <blockquote>\n\t <i>{{ msg.payload.quote.body }}</i>\n \t <div>{{ msg.payload.quote.author }}</div>\n\t </blockquote>\n\t </div>\n\t \n\t <h2>The full msg object</h2>\n\t\t<code>{{ msg }}</code>\n\t\t\n\t</div>\n\n <!-- Vendor Libraries - Load in the right order -->\n <script src=\"../uibuilder/vendor/socket.io/socket.io.js\"></script>\n <script src=\"../uibuilder/vendor/vue/dist/vue.min.js\"></script>\n\n <!-- REQUIRED: Sets up Socket listeners, the uibuilder and msg objects -->\n <script src=\"./uibuilderfe.min.js\"></script>\n\n <!-- Put your own custom code in here -->\n <script src=\"./index.js\"></script>\n\n</body></html>", "x": 420, "y": 1640, "wires": [], "icon": "node-red/parser-html.svg" }, { "id": "1a004a18.d3c5e6", "type": "comment", "z": "18cb249f.38bafb", "name": "index.js", "info": "/* jshint browser: true, esversion: 5, asi: true */\n/*globals $, uibuilder */\n// @ts-nocheck\n/*\n Copyright (c) 2019 Julian Knight (Totally Information)\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n*/\n'use strict'\n\n/** @see https://github.com/TotallyInformation/node-red-contrib-uibuilder/wiki/Front-End-Library---available-properties-and-methods */\n\n// When JQuery is ready, update\n$( document ).ready(function() {\n /** **REQUIRED** Start uibuilder comms with Node-RED @since v2.0.0-dev3\n * Pass the namespace and ioPath variables if hosting page is not in the instance root folder\n * e.g. If you get continual `uibuilderfe:ioSetup: SOCKET CONNECT ERROR` error messages.\n * e.g. uibuilder.start('/nr/uib', '/nr/uibuilder/vendor/socket.io') // change to use your paths/names\n */\n uibuilder.start()\n\n // Initial set\n $('#msgsReceived').text( uibuilder.get('msgsReceived') )\n $('#msgsControl').text( uibuilder.get('msgsCtrl') )\n $('#msgsSent').text( uibuilder.get('msgsSent') )\n $('#socketConnectedState').text( uibuilder.get('ioConnected') )\n $('#feVersion').text( uibuilder.get('version') )\n\n // Turn on debugging (default is off)\n //uibuilder.debug(true)\n\n // If msg changes - msg is updated when a standard msg is received from Node-RED over Socket.IO\n // Note that you can also listen for 'msgsReceived' as they are updated at the same time\n // but newVal relates to the attribute being listened to.\n uibuilder.onChange('msg', function(newVal){\n console.info('property msg changed!')\n console.dir(newVal)\n $('#showMsg').text(JSON.stringify(newVal))\n //uibuilder.set('msgCopy', newVal)\n })\n\n // You can get attributes manually. Non-existent attributes return 'undefined'\n //console.dir(uibuilder.get('msg'))\n\n // You can also set things manually. See the list of attributes top of page.\n // You can add arbitrary attributes to the object, you cannot overwrite internal attributes\n\n // Try setting a restricted, internal attribute - see the warning in the browser console\n uibuilder.set('msg', 'You tried but failed!')\n\n // Remember that onChange functions don't trigger if you haven't set them\n // up BEFORE an attribute change.\n uibuilder.onChange('msgCopy', function(newVal){\n console.info('msgCopy changed. New value: ', newVal)\n })\n\n // Now try setting a new attribute - this will be an empty object because\n // msg won't yet have been received\n uibuilder.set('msgCopy', uibuilder.msg)\n // Hint: Try putting this set into the onChange for 'msg'\n\n // As noted, we could get the msg here too\n uibuilder.onChange('msgsReceived', function(newVal){\n console.info('New msg sent to us from Node-RED over Socket.IO. Total Count: ', newVal)\n $('#msgsReceived').text(newVal)\n // uibuilder.msg is a shortcut for uibuilder.get('msg')\n //$('#showMsg').text(JSON.stringify(uibuilder.msg))\n })\n\n // If Socket.IO connects/disconnects\n uibuilder.onChange('ioConnected', function(newVal){\n console.info('Socket.IO Connection Status Changed: ', newVal)\n $('#socketConnectedState').text(newVal)\n })\n\n // If a message is sent back to Node-RED\n uibuilder.onChange('msgsSent', function(newVal){\n console.info('New msg sent to Node-RED over Socket.IO. Total Count: ', newVal)\n $('#msgsSent').text(newVal)\n $('#showMsgSent').text(JSON.stringify(uibuilder.get('sentMsg')))\n })\n\n // If we receive a control message from Node-RED\n uibuilder.onChange('msgsCtrl', function(newVal){\n console.info('New control msg sent to us from Node-RED over Socket.IO. Total Count: ', newVal)\n $('#msgsControl').text(newVal)\n $('#showCtrlMsg').text(JSON.stringify(uibuilder.get('ctrlMsg')))\n })\n\n //Manually send a message back to Node-RED after 2 seconds\n window.setTimeout(function(){\n console.info('Sending a message back to Node-RED - after 2s delay')\n uibuilder.send( { 'topic':'uibuilderfe', 'payload':'I am a message sent from the uibuilder front end' } )\n }, 2000)\n\n}) // --- End of JQuery Ready --- //\n\n// EOF\n", "x": 550, "y": 1640, "wires": [], "icon": "font-awesome/fa-code" }, { "id": "ddf41d65.687", "type": "debug", "z": "18cb249f.38bafb", "name": "qod-debug", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "x": 530, "y": 1780, "wires": [] }, { "id": "eb406f24.13a48", "type": "http request", "z": "18cb249f.38bafb", "name": "Quote of the day", "method": "GET", "ret": "obj", "paytoqs": false, "url": "https://favqs.com/api/qotd", "tls": "", "persist": false, "proxy": "", "authType": "", "x": 310, "y": 1700, "wires": [ [ "bad4b165.e6a08", "ddf41d65.687" ] ] }, { "id": "fa66e5de.8a81e8", "type": "comment", "z": "18cb249f.38bafb", "name": "index.css", "info": "body {font-family: sans-serif; font-size: 120%;}\ndiv, p, code { margin:0.3em; padding: 0.3em;}\n\nblockquote i {\n font-size: 1.5em; color:grey; font-style: italic;\n}", "x": 680, "y": 1640, "wires": [], "icon": "node-red/hash.svg" } ]