2022-03-29 21:59:35 +02:00
|
|
|
|
|
|
|
RED.diagnostics = (function () {
|
|
|
|
|
|
|
|
function init() {
|
|
|
|
if (RED.settings.get('diagnostics.ui', true) === false) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
RED.actions.add("core:show-system-info", function () { show(); });
|
|
|
|
}
|
|
|
|
|
|
|
|
function show() {
|
|
|
|
$.ajax({
|
|
|
|
headers: {
|
|
|
|
"Accept": "application/json"
|
|
|
|
},
|
|
|
|
cache: false,
|
|
|
|
url: 'diagnostics',
|
|
|
|
success: function (data) {
|
|
|
|
var json = JSON.stringify(data || {}, "", 4);
|
|
|
|
if (json === "{}") {
|
|
|
|
json = "{\n\n}";
|
|
|
|
}
|
|
|
|
RED.editor.editJSON({
|
2022-04-27 13:05:20 +02:00
|
|
|
title: RED._('diagnostics.title'),
|
2022-03-29 21:59:35 +02:00
|
|
|
value: json,
|
|
|
|
requireValid: true,
|
|
|
|
readOnly: true,
|
2022-04-27 13:52:01 +02:00
|
|
|
toolbarButtons: [
|
2022-03-29 21:59:35 +02:00
|
|
|
{
|
2022-04-26 17:24:13 +02:00
|
|
|
text: RED._('clipboard.export.copy'),
|
2022-03-29 21:59:35 +02:00
|
|
|
icon: 'fa fa-copy',
|
|
|
|
click: function () {
|
2022-04-26 17:24:13 +02:00
|
|
|
RED.clipboard.copyText(json, $(this), RED._('clipboard.copyMessageValue'))
|
2022-03-29 21:59:35 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2022-04-26 17:24:13 +02:00
|
|
|
text: RED._('clipboard.download'),
|
2022-03-29 21:59:35 +02:00
|
|
|
icon: 'fa fa-download',
|
|
|
|
click: function () {
|
|
|
|
var element = document.createElement('a');
|
|
|
|
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(json));
|
|
|
|
element.setAttribute('download', "system-info.json");
|
|
|
|
element.style.display = 'none';
|
|
|
|
document.body.appendChild(element);
|
|
|
|
element.click();
|
|
|
|
document.body.removeChild(element);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
]
|
|
|
|
});
|
|
|
|
},
|
|
|
|
error: function (jqXHR, textStatus, errorThrown) {
|
|
|
|
console.log("Unexpected error loading system info:", jqXHR.status, textStatus, errorThrown);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
init: init,
|
|
|
|
};
|
|
|
|
})();
|