mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Improve diagnostics content
This commit is contained in:
@@ -1,27 +1,23 @@
|
||||
var apiUtils = require("@node-red/editor-api/lib/util");
|
||||
/** @type {runtime.RuntimeModule} */var runtimeAPI;
|
||||
|
||||
|
||||
let runtimeAPI;
|
||||
let settings;
|
||||
const apiUtil = require("../util");
|
||||
module.exports = {
|
||||
init: function(/** @type {runtime.RuntimeModule} */_runtimeAPI) {
|
||||
init: function(_settings, _runtimeAPI) {
|
||||
settings = _settings;
|
||||
runtimeAPI = _runtimeAPI;
|
||||
},
|
||||
getBasicReport: function(req, res) {
|
||||
var opts = {
|
||||
getReport: function(req, res) {
|
||||
const diagnosticsOptions = settings.diagnosticsOptions || {};
|
||||
const opts = {
|
||||
user: req.user,
|
||||
scope: "basic"
|
||||
scope: diagnosticsOptions.level || "basic"
|
||||
}
|
||||
runtimeAPI.diagnostics.get(opts).then(function(result) {
|
||||
res.json(result);
|
||||
});
|
||||
},
|
||||
getAdminReport: function(req, res) {
|
||||
var opts = {
|
||||
user: req.user,
|
||||
scope: "admin"
|
||||
if(diagnosticsOptions.enabled === false || diagnosticsOptions.enabled === "false") {
|
||||
apiUtil.rejectHandler(req, res, {message: "disabled", status: 403, code: "diagnosticsOptions.enabled" })
|
||||
} else {
|
||||
runtimeAPI.diagnostics.get(opts)
|
||||
.then(function(result) { res.json(result); })
|
||||
.catch(err => apiUtil.rejectHandler(req, res, err))
|
||||
}
|
||||
runtimeAPI.diagnostics.get(opts).then(function(result) {
|
||||
res.json(result);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ module.exports = {
|
||||
context.init(runtimeAPI);
|
||||
info.init(settings,runtimeAPI);
|
||||
plugins.init(runtimeAPI);
|
||||
diagnostics.init(runtimeAPI);
|
||||
diagnostics.init(settings, runtimeAPI);
|
||||
|
||||
var needsPermission = auth.needsPermission;
|
||||
|
||||
@@ -97,8 +97,7 @@ module.exports = {
|
||||
adminApp.get("/plugins", needsPermission("plugins.read"), plugins.getAll, apiUtil.errorHandler);
|
||||
adminApp.get("/plugins/messages", needsPermission("plugins.read"), plugins.getCatalogs, apiUtil.errorHandler);
|
||||
|
||||
adminApp.get("/diagnostics/basic", needsPermission("settings.read"), diagnostics.getBasicReport, apiUtil.errorHandler);
|
||||
adminApp.get("/diagnostics/admin", needsPermission("flows.write"), diagnostics.getAdminReport, apiUtil.errorHandler);
|
||||
adminApp.get("/diagnostics", needsPermission("diagnostics.read"), diagnostics.getReport, apiUtil.errorHandler);
|
||||
|
||||
return adminApp;
|
||||
}
|
||||
|
Reference in New Issue
Block a user