From e406a3bb8d8fc688b67249e15233dd6d35c9ef10 Mon Sep 17 00:00:00 2001 From: kd9lsv Date: Sun, 6 Oct 2024 00:06:41 -0500 Subject: [PATCH 1/2] Add log to function as comment node. --- generators/comment_log.js | 17 +++++++++++++++++ generators/index.js | 3 ++- index.js | 11 +++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 generators/comment_log.js diff --git a/generators/comment_log.js b/generators/comment_log.js new file mode 100644 index 0000000..625f80b --- /dev/null +++ b/generators/comment_log.js @@ -0,0 +1,17 @@ + //Add Comment Node + const utils = require('../utils') + + module.exports = function () { + const comment_id = utils.generateId() + const commentNode = { + "id": comment_id, + "type": "comment", + "z": "", + "name": "Migration Log", + "info": "", + "x": 10, + "y": 100, + "wires": [] + } + return commentNode + } diff --git a/generators/index.js b/generators/index.js index 7443563..8716612 100644 --- a/generators/index.js +++ b/generators/index.js @@ -1,4 +1,5 @@ module.exports = { generateUiTheme: require('./ui-theme'), - generateUiBase: require('./ui-base') + generateUiBase: require('./ui-base'), + generateCommentLog: require('./comment_log') } diff --git a/index.js b/index.js index 60567b2..5c99385 100644 --- a/index.js +++ b/index.js @@ -9,6 +9,10 @@ const MigrateDashboard = { const idMap = {} // map old IDs to new IDs so that we can update references to them const migratedFlow = [] + + const comment_log = generators.generateCommentLog(); + + let comment_string = "This is the comment log for the Node-Red Migration Page. As a rule of thumb, any node type that is listed in the README as \"Not Yet Supported\" could use help in migrating over. For more details please head to the [Github](https://github.com/FlowFuse/node-red-dashboard-2-migration) to help contribute. \n Any 1.0 nodes unable to successfully migrate are disabled to easily manually fix the issue. \n The following nodes were unable to automatically migrate: \n" // generate nodes we know D1.0 doesn't provide const base = generators.generateUiBase() @@ -37,6 +41,9 @@ const MigrateDashboard = { if (node.type.startsWith('ui_')) { // Unsupported UI node types, disable them console.log('Unable to automatically migrate ' + node.type + ' nodes currently. Disabling the node.') + // Develop String that will be added to Comment. + let log_string = " - "+node.name+' Type:'+node.type + "\n" + comment_string = comment_string + log_string node.d = true } @@ -44,6 +51,10 @@ const MigrateDashboard = { // Not a Dashboard 1.0 node, we can just return it as is migratedFlow.push(node) }) + + //Add Log to Comment Node then Node to flow. + comment_log.info = comment_string + migratedFlow.push(comment_log) // work smart, not hard let strJson = JSON.stringify(migratedFlow) From 20038acd06fee56473ad679c2a1cad59cf49bc21 Mon Sep 17 00:00:00 2001 From: Connor Dickey Date: Tue, 4 Feb 2025 10:09:00 -0600 Subject: [PATCH 2/2] Code Review Comments Co-authored-by: Joe Pavitt <99246719+joepavitt@users.noreply.github.com> --- generators/comment_log.js | 6 +++--- index.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/generators/comment_log.js b/generators/comment_log.js index 625f80b..8179d8a 100644 --- a/generators/comment_log.js +++ b/generators/comment_log.js @@ -1,5 +1,5 @@ - //Add Comment Node - const utils = require('../utils') +//Add Comment Node +const utils = require('../utils') module.exports = function () { const comment_id = utils.generateId() @@ -7,7 +7,7 @@ "id": comment_id, "type": "comment", "z": "", - "name": "Migration Log", + "name": "Dashboard 1.0 to 2.0 - Migration Log", "info": "", "x": 10, "y": 100, diff --git a/index.js b/index.js index 5c99385..7b6c191 100644 --- a/index.js +++ b/index.js @@ -12,7 +12,7 @@ const MigrateDashboard = { const comment_log = generators.generateCommentLog(); - let comment_string = "This is the comment log for the Node-Red Migration Page. As a rule of thumb, any node type that is listed in the README as \"Not Yet Supported\" could use help in migrating over. For more details please head to the [Github](https://github.com/FlowFuse/node-red-dashboard-2-migration) to help contribute. \n Any 1.0 nodes unable to successfully migrate are disabled to easily manually fix the issue. \n The following nodes were unable to automatically migrate: \n" + let comment_string = "This is the comment log for the Node-Red Migration Page. As a rule of thumb, any node type that is listed in the README as \"Not Yet Supported\" could use help in migrating over. For more details please head to the [Github](https://github.com/FlowFuse/node-red-dashboard-2-migration) to help contribute. \n Any 1.0 nodes unable to successfully migrate are kept in the flow, but disabled, to enable manual updating of the nodes. \n The following nodes were unable to automatically migrate: \n" // generate nodes we know D1.0 doesn't provide const base = generators.generateUiBase()