-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: display a description of module on mouseover when the user mouse over the name of module, it will show the tooltip text * feat: display a list of submodules in module manage tool display a list of submodules in module detail of module manage tool add the jump to node link of submodules * feat: create save in local button create save in local button in module manage tool get the module's configuration when the save button is clicked * feat: save the module in local save the module in local when click the 'save in local' button duplicate check for module name
- Loading branch information
Showing
2 changed files
with
206 additions
and
18 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 characters
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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
const path = require("path"), | ||
fs = require("fs-extra"); | ||
|
||
async function main() { | ||
const basePath = RED.settings.userDir; | ||
|
||
RED.httpAdmin.post("/save-selected-module", async function (req, res) { | ||
try { | ||
const moduleNodeList = req.body.moduleNodeList; | ||
const moduleFile = JSON.parse(moduleNodeList); | ||
const moduleName = moduleFile[0].name; | ||
|
||
let moduleFiles = await fs.readdirSync(path.join(basePath, "utils")); | ||
for (let file of moduleFiles) { | ||
if (file === moduleName) { | ||
return res.send({ | ||
msg: `The module name ${moduleName} already exists. Please rename it.`, | ||
type: "warning", | ||
timeout: 3000 | ||
}); | ||
} | ||
} | ||
|
||
const filePath = path.join(basePath, "utils", moduleName); | ||
fs.outputJSON(filePath, moduleFile) | ||
.then(() => { | ||
res.send({ | ||
msg: "The module has been successfully saved.", | ||
type: "success", | ||
timeout: 3000 | ||
}); | ||
}) | ||
.catch(() => { | ||
res.send({ | ||
msg: "An error occurred while saving the module.", | ||
type: "error", | ||
timeout: 3000 | ||
}); | ||
}); | ||
} catch (e) { | ||
res.status(404).send(); | ||
} | ||
}); | ||
} | ||
|
||
module.exports = function (_RED) { | ||
RED = _RED; | ||
main(); | ||
}; |