mirror of
https://github.com/node-red/node-red.git
synced 2025-12-27 07:31:07 +01:00
Merge pull request #5181 from node-red/event-log-widget
Add event-log widget to status bar
This commit is contained in:
@@ -15,11 +15,14 @@
|
||||
**/
|
||||
RED.eventLog = (function() {
|
||||
|
||||
var template = '<script type="text/x-red" data-template-name="_eventLog"><div class="form-row node-text-editor-row"><div style="height: 100%;min-height: 150px;" class="node-text-editor" id="red-ui-event-log-editor"></div></div></script>';
|
||||
const template = '<script type="text/x-red" data-template-name="_eventLog"><div class="form-row node-text-editor-row"><div style="height: 100%;min-height: 150px;" class="node-text-editor" id="red-ui-event-log-editor"></div></div></script>';
|
||||
|
||||
let eventLogEditor;
|
||||
let backlog = [];
|
||||
let shown = false;
|
||||
|
||||
const activeLogs = new Set()
|
||||
|
||||
var eventLogEditor;
|
||||
var backlog = [];
|
||||
var shown = false;
|
||||
|
||||
function appendLogLine(line) {
|
||||
backlog.push(line);
|
||||
@@ -38,6 +41,18 @@ RED.eventLog = (function() {
|
||||
init: function() {
|
||||
$(template).appendTo("#red-ui-editor-node-configs");
|
||||
RED.actions.add("core:show-event-log",RED.eventLog.show);
|
||||
|
||||
const statusWidget = $('<button type="button" class="red-ui-footer-button red-ui-event-log-status" style="line-height: normal"><img style="width: 80%" src="red/images/spin.svg"/></div></button>');
|
||||
statusWidget.on("click", function(evt) {
|
||||
RED.actions.invoke("core:show-event-log");
|
||||
})
|
||||
RED.statusBar.add({
|
||||
id: "red-ui-event-log-status",
|
||||
align: "right",
|
||||
element: statusWidget
|
||||
});
|
||||
// RED.statusBar.hide("red-ui-event-log-status");
|
||||
|
||||
},
|
||||
show: function() {
|
||||
if (shown) {
|
||||
@@ -98,6 +113,12 @@ RED.eventLog = (function() {
|
||||
},
|
||||
log: function(id,payload) {
|
||||
var ts = (new Date(payload.ts)).toISOString()+" ";
|
||||
if (!payload.end) {
|
||||
activeLogs.add(id)
|
||||
} else {
|
||||
activeLogs.delete(id);
|
||||
}
|
||||
|
||||
if (payload.type) {
|
||||
ts += "["+payload.type+"] "
|
||||
}
|
||||
@@ -111,6 +132,11 @@ RED.eventLog = (function() {
|
||||
appendLogLine(ts+line);
|
||||
})
|
||||
}
|
||||
if (activeLogs.size > 0) {
|
||||
RED.statusBar.show("red-ui-event-log-status");
|
||||
} else {
|
||||
RED.statusBar.hide("red-ui-event-log-status");
|
||||
}
|
||||
},
|
||||
startEvent: function(name) {
|
||||
backlog.push("");
|
||||
|
||||
@@ -78,7 +78,7 @@ module.exports = {
|
||||
stdout: stdout,
|
||||
stderr: stderr
|
||||
}
|
||||
emit && events.emit("event-log", {id:invocationId,payload:{ts: Date.now(),data:"rc="+code}});
|
||||
emit && events.emit("event-log", {id:invocationId,payload:{ts: Date.now(), data:"rc="+code, end: true}});
|
||||
|
||||
if (code === 0) {
|
||||
resolve(result)
|
||||
|
||||
Reference in New Issue
Block a user