Skip to content

Commit

Permalink
Merge pull request #70 from SaaShup/disable_editor
Browse files Browse the repository at this point in the history
add disable editor
  • Loading branch information
lvenier authored Apr 3, 2024
2 parents 4929388 + 7019891 commit 470db57
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 318 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ Agent to install on the docker server to manage containers though [netbox plugin

## Settings

go to the [nodered admin page](http://localhost:1880/nodered) to change the settings.
you can define username and password via envionment variable:
Go to the [nodered admin page](http://localhost:1880/nodered) to change the settings.
You can define username and password via envionment variable:
- API_USERNAME
- API_PASSWORD (NOTE: password should be a hash of node-red admin hash-pw)
- ADMIN_USERNAME
- ADMIN_PASSWORD (NOTE: password should be a hash of node-red admin hash-pw)

You can disable node-red editor by setting DISABLE_EDITOR to any value.

## Clean
```
docker stop netbox-docker-agent
Expand Down
2 changes: 1 addition & 1 deletion config.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"netbox_url":"","netbox_token":"","ui":1,"id":"","endpoint":"","flows":"0.6.5"}
{"netbox_url":"","netbox_token":"","ui":1,"id":"","endpoint":"","flows":"0.7.0"}
6 changes: 3 additions & 3 deletions flows.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
"t": "set",
"p": "payload.flows",
"pt": "msg",
"to": "0.6.5",
"to": "0.7.0",
"tot": "str"
},
{
Expand Down Expand Up @@ -248,7 +248,7 @@
"fieldType": "msg",
"format": "handlebars",
"syntax": "plain",
"template": "data = require(\"./package.json\")\n\nmodule.exports = {\n credentialSecret: \"saashup\",\n flowFile: \"flows.json\",\n flowFilePretty: true,\n adminAuth: {\n type: \"credentials\",\n users: [{\n username: process.env.ADMIN_USERNAME || \"admin\",\n password: process.env.ADMIN_PASSWORD || \"$2a$08$s.NFdSn4Gm4d7gHErya//e6O8RO1/3f7TZ7zflXJ9jfFV0cI6jGwK\",\n permissions: \"*\"\n }]\n },\n /*https: {\n key: require(\"fs\").readFileSync('/data/privkey.pem'),\n cert: require(\"fs\").readFileSync('/data/cert.pem')\n },\n requireHttps: true,*/\n httpNodeAuth: {\n user: process.env.API_USERNAME || \"admin\",\n pass: process.env.API_PASSWORD || \"$2a$08$s.NFdSn4Gm4d7gHErya//e6O8RO1/3f7TZ7zflXJ9jfFV0cI6jGwK\"\n },\n uiPort: process.env.PORT || 1880,\n httpStatic: [\n { path: '/usr/src/node-red/public', root: '/' },\n { path: '/usr/src/node-red/public/doc.html', root: '/doc' },\n { path: '/usr/src/node-red/public/openapi.yml', root: '/openapi' }\n ],\n httpAdminRoot: '/nodered',\n diagnostics: {\n enabled: true,\n ui: true,\n },\n runtimeState: {\n enabled: false,\n ui: false,\n },\n logging: {\n console: {\n level: \"info\",\n metrics: false,\n audit: false,\n handler: function(settings) {\n return function(msg) {\n const level = {\n 20: 'error',\n 30: 'warn',\n 40: 'info'\n };\n const lvl = \"level\" in msg ? msg.level : \"40\";\n\n delete msg.type;\n delete msg.z;\n delete msg.path;\n delete msg.name;\n delete msg.id;\n\n let line = `${data.name} level=${level[lvl]} version=${data.version}`;\n\n if (typeof msg.msg === 'object') {\n for (const key of Object.keys(msg.msg)) {\n line += ` ${key}=${JSON.stringify(msg.msg[key])}`;\n }\n } else {\n line += ` msg=` + JSON.stringify(msg.msg);\n }\n\n if (lvl <= 20) {\n return console.error(line);\n }\n\n return console.log(line);\n }\n }\n }\n },\n exportGlobalContextKeys: false,\n externalModules: {\n },\n editorTheme: {\n tours: false,\n palette: {\n },\n projects: {\n enabled: false,\n workflow: {\n mode: \"manual\"\n }\n },\n codeEditor: {\n lib: \"monaco\",\n options: {\n }\n },\n markdownEditor: {\n mermaid: {\n enabled: true\n }\n },\n },\n functionExternalModules: true,\n functionTimeout: 0,\n functionGlobalContext: {\n },\n debugMaxLength: 1000,\n mqttReconnectTime: 15000,\n serialReconnectTime: 15000\n}\n",
"template": "data = require(\"./package.json\")\n\nmodule.exports = {\n credentialSecret: \"saashup\",\n flowFile: \"flows.json\",\n flowFilePretty: true,\n adminAuth: {\n type: \"credentials\",\n users: [{\n username: process.env.ADMIN_USERNAME || \"admin\",\n password: process.env.ADMIN_PASSWORD || \"$2a$08$s.NFdSn4Gm4d7gHErya//e6O8RO1/3f7TZ7zflXJ9jfFV0cI6jGwK\",\n permissions: \"*\"\n }]\n },\n /*https: {\n key: require(\"fs\").readFileSync('/data/privkey.pem'),\n cert: require(\"fs\").readFileSync('/data/cert.pem')\n },\n requireHttps: true,*/\n httpNodeAuth: {\n user: process.env.API_USERNAME || \"admin\",\n pass: process.env.API_PASSWORD || \"$2a$08$s.NFdSn4Gm4d7gHErya//e6O8RO1/3f7TZ7zflXJ9jfFV0cI6jGwK\"\n },\n uiPort: process.env.PORT || 1880,\n disableEditor: process.env.DISABLE_EDITOR || false,\n httpStatic: [\n { path: '/usr/src/node-red/public', root: '/' },\n { path: '/usr/src/node-red/public/doc.html', root: '/doc' },\n { path: '/usr/src/node-red/public/openapi.yml', root: '/openapi' }\n ],\n httpAdminRoot: '/nodered',\n diagnostics: {\n enabled: true,\n ui: true,\n },\n runtimeState: {\n enabled: false,\n ui: false,\n },\n logging: {\n console: {\n level: \"info\",\n metrics: false,\n audit: false,\n handler: function(settings) {\n return function(msg) {\n const level = {\n 20: 'error',\n 30: 'warn',\n 40: 'info'\n };\n const lvl = \"level\" in msg ? msg.level : \"40\";\n\n delete msg.type;\n delete msg.z;\n delete msg.path;\n delete msg.name;\n delete msg.id;\n\n let line = `${data.name} level=${level[lvl]} version=${data.version}`;\n\n if (typeof msg.msg === 'object') {\n for (const key of Object.keys(msg.msg)) {\n line += ` ${key}=${JSON.stringify(msg.msg[key])}`;\n }\n } else {\n line += ` msg=` + JSON.stringify(msg.msg);\n }\n\n if (lvl <= 20) {\n return console.error(line);\n }\n\n return console.log(line);\n }\n }\n }\n },\n exportGlobalContextKeys: false,\n externalModules: {\n },\n editorTheme: {\n tours: false,\n palette: {\n },\n projects: {\n enabled: false,\n workflow: {\n mode: \"manual\"\n }\n },\n codeEditor: {\n lib: \"monaco\",\n options: {\n }\n },\n markdownEditor: {\n mermaid: {\n enabled: true\n }\n },\n },\n functionExternalModules: true,\n functionTimeout: 0,\n functionGlobalContext: {\n },\n debugMaxLength: 1000,\n mqttReconnectTime: 15000,\n serialReconnectTime: 15000\n}\n",
"output": "str",
"x": 460,
"y": 420,
Expand Down Expand Up @@ -5439,4 +5439,4 @@
]
]
}
]
]
Loading

0 comments on commit 470db57

Please sign in to comment.