mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Add event log to editor
Shows output from git pull/push and npm install in the editor
This commit is contained in:
@@ -215,6 +215,10 @@
|
||||
"plusNMore": "+ __count__ more"
|
||||
}
|
||||
},
|
||||
"eventLog": {
|
||||
"title": "Event log",
|
||||
"view": "View log"
|
||||
},
|
||||
"diff": {
|
||||
"unresolvedCount": "__count__ unresolved conflict",
|
||||
"unresolvedCount_plural": "__count__ unresolved conflicts",
|
||||
|
@@ -19,7 +19,8 @@
|
||||
"ctrl-alt-r": "core:show-remote-diff",
|
||||
"ctrl-alt-n": "core:new-project",
|
||||
"ctrl-alt-o": "core:open-project",
|
||||
"ctrl-g v": "core:show-version-control-tab"
|
||||
"ctrl-g v": "core:show-version-control-tab",
|
||||
"ctrl-shift-l": "core:show-event-log"
|
||||
},
|
||||
"workspace": {
|
||||
"backspace": "core:delete-selection",
|
||||
|
@@ -398,6 +398,10 @@ var RED = (function() {
|
||||
// Refresh flow library to ensure any examples are updated
|
||||
RED.library.loadFlowLibrary();
|
||||
});
|
||||
RED.comms.subscribe("event-log/#", function(topic,payload) {
|
||||
var id = topic.substring(9);
|
||||
RED.eventLog.log(id,payload);
|
||||
});
|
||||
}
|
||||
|
||||
function showAbout() {
|
||||
@@ -436,6 +440,7 @@ var RED = (function() {
|
||||
// null,
|
||||
{id:"menu-item-palette",label:RED._("menu.label.palette.show"),toggle:true,onselect:"core:toggle-palette", selected: true},
|
||||
{id:"menu-item-sidebar",label:RED._("menu.label.sidebar.show"),toggle:true,onselect:"core:toggle-sidebar", selected: true},
|
||||
{id:"menu-item-event-log",label:RED._("eventLog.title"),onselect:"core:show-event-log"},
|
||||
null
|
||||
]});
|
||||
menuOptions.push(null);
|
||||
@@ -483,6 +488,7 @@ var RED = (function() {
|
||||
RED.library.init();
|
||||
RED.keyboard.init();
|
||||
RED.palette.init();
|
||||
RED.eventLog.init();
|
||||
if (RED.settings.theme('palette.editable') !== false) {
|
||||
RED.palette.editor.init();
|
||||
} else {
|
||||
|
121
packages/node_modules/@node-red/editor-client/src/js/ui/event-log.js
vendored
Normal file
121
packages/node_modules/@node-red/editor-client/src/js/ui/event-log.js
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
/**
|
||||
* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
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="event-log-editor"></div></div></script>';
|
||||
|
||||
var eventLogEditor;
|
||||
var backlog = [];
|
||||
var shown = false;
|
||||
|
||||
function appendLogLine(line) {
|
||||
backlog.push(line);
|
||||
if (backlog.length > 500) {
|
||||
backlog = backlog.slice(-500);
|
||||
}
|
||||
if (eventLogEditor) {
|
||||
eventLogEditor.getSession().insert({
|
||||
row: eventLogEditor.getSession().getLength(),
|
||||
column: 0
|
||||
}, "\n" + line);
|
||||
eventLogEditor.scrollToLine(eventLogEditor.getSession().getLength());
|
||||
}
|
||||
}
|
||||
return {
|
||||
init: function() {
|
||||
$(template).appendTo(document.body);
|
||||
RED.actions.add("core:show-event-log",RED.eventLog.show);
|
||||
},
|
||||
show: function() {
|
||||
if (shown) {
|
||||
return;
|
||||
}
|
||||
shown = true;
|
||||
var type = "_eventLog"
|
||||
|
||||
var trayOptions = {
|
||||
title: RED._("eventLog.title"),
|
||||
width: Infinity,
|
||||
buttons: [
|
||||
{
|
||||
id: "node-dialog-close",
|
||||
text: RED._("common.label.close"),
|
||||
click: function() {
|
||||
RED.tray.close();
|
||||
}
|
||||
}
|
||||
],
|
||||
resize: function(dimensions) {
|
||||
var rows = $("#dialog-form>div:not(.node-text-editor-row)");
|
||||
var editorRow = $("#dialog-form>div.node-text-editor-row");
|
||||
var height = $("#dialog-form").height();
|
||||
for (var i=0;i<rows.size();i++) {
|
||||
height -= $(rows[i]).outerHeight(true);
|
||||
}
|
||||
height -= (parseInt($("#dialog-form").css("marginTop"))+parseInt($("#dialog-form").css("marginBottom")));
|
||||
$(".node-text-editor").css("height",height+"px");
|
||||
eventLogEditor.resize();
|
||||
},
|
||||
open: function(tray) {
|
||||
var trayBody = tray.find('.editor-tray-body');
|
||||
var dialogForm = RED.editor.buildEditForm(tray.find('.editor-tray-body'),'dialog-form',type,'editor');
|
||||
eventLogEditor = RED.editor.createEditor({
|
||||
id: 'event-log-editor',
|
||||
value: backlog.join("\n"),
|
||||
lineNumbers: false,
|
||||
readOnly: true,
|
||||
options: {
|
||||
showPrintMargin: false
|
||||
}
|
||||
});
|
||||
setTimeout(function() {
|
||||
eventLogEditor.scrollToLine(eventLogEditor.getSession().getLength());
|
||||
},200);
|
||||
dialogForm.i18n();
|
||||
},
|
||||
close: function() {
|
||||
eventLogEditor.destroy();
|
||||
eventLogEditor = null;
|
||||
shown = false;
|
||||
},
|
||||
show: function() {}
|
||||
}
|
||||
RED.tray.show(trayOptions);
|
||||
},
|
||||
log: function(id,payload) {
|
||||
var ts = (new Date(payload.ts)).toISOString()+" ";
|
||||
if (payload.type) {
|
||||
ts += "["+payload.type+"] "
|
||||
}
|
||||
if (payload.data) {
|
||||
var data = payload.data;
|
||||
if (data.endsWith('\n')) {
|
||||
data = data.substring(0,data.length-1);
|
||||
}
|
||||
var lines = data.split(/\n/);
|
||||
lines.forEach(function(line) {
|
||||
appendLogLine(ts+line);
|
||||
})
|
||||
}
|
||||
},
|
||||
startEvent: function(name) {
|
||||
backlog.push("");
|
||||
backlog.push("-----------------------------------------------------------");
|
||||
backlog.push((new Date()).toISOString()+" "+name);
|
||||
backlog.push("");
|
||||
}
|
||||
}
|
||||
})();
|
@@ -863,11 +863,35 @@ RED.palette.editor = (function() {
|
||||
class: "primary palette-module-install-confirm-button-update",
|
||||
click: function() {
|
||||
var spinner = RED.utils.addSpinnerOverlay(container, true);
|
||||
var buttonRow = $('<div style="position: relative;bottom: calc(50% + 17px); padding-right: 10px;text-align: right;"></div>').appendTo(spinner);
|
||||
$('<button class="editor-button"></button>').text(RED._("eventLog.view")).appendTo(buttonRow).click(function(evt) {
|
||||
evt.preventDefault();
|
||||
RED.actions.invoke("core:show-event-log");
|
||||
});
|
||||
RED.eventLog.startEvent(RED._("palette.editor.confirm.button.install")+" : "+entry.name+" "+version);
|
||||
installNodeModule(entry.name,version,function(xhr) {
|
||||
spinner.remove();
|
||||
if (xhr) {
|
||||
if (xhr.responseJSON) {
|
||||
RED.notify(RED._('palette.editor.errors.updateFailed',{module: entry.name,message:xhr.responseJSON.message}));
|
||||
var notification = RED.notify(RED._('palette.editor.errors.updateFailed',{module: entry.name,message:xhr.responseJSON.message}),{
|
||||
type: 'error',
|
||||
modal: true,
|
||||
fixed: true,
|
||||
buttons: [
|
||||
{
|
||||
text: RED._("common.label.close"),
|
||||
click: function() {
|
||||
notification.close();
|
||||
}
|
||||
},{
|
||||
text: RED._("eventLog.view"),
|
||||
click: function() {
|
||||
notification.close();
|
||||
RED.actions.invoke("core:show-event-log");
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
}
|
||||
done(xhr);
|
||||
@@ -898,12 +922,35 @@ RED.palette.editor = (function() {
|
||||
class: "primary palette-module-install-confirm-button-remove",
|
||||
click: function() {
|
||||
var spinner = RED.utils.addSpinnerOverlay(container, true);
|
||||
var buttonRow = $('<div style="position: relative;bottom: calc(50% + 17px); padding-right: 10px;text-align: right;"></div>').appendTo(spinner);
|
||||
$('<button class="editor-button"></button>').text(RED._("eventLog.view")).appendTo(buttonRow).click(function(evt) {
|
||||
evt.preventDefault();
|
||||
RED.actions.invoke("core:show-event-log");
|
||||
});
|
||||
RED.eventLog.startEvent(RED._("palette.editor.confirm.button.remove")+" : "+entry.name);
|
||||
removeNodeModule(entry.name, function(xhr) {
|
||||
spinner.remove();
|
||||
if (xhr) {
|
||||
if (xhr.responseJSON) {
|
||||
RED.notify(RED._('palette.editor.errors.removeFailed',{module: entry.name,message:xhr.responseJSON.message}));
|
||||
}
|
||||
var notification = RED.notify(RED._('palette.editor.errors.removeFailed',{module: entry.name,message:xhr.responseJSON.message}),{
|
||||
type: 'error',
|
||||
modal: true,
|
||||
fixed: true,
|
||||
buttons: [
|
||||
{
|
||||
text: RED._("common.label.close"),
|
||||
click: function() {
|
||||
notification.close();
|
||||
}
|
||||
},{
|
||||
text: RED._("eventLog.view"),
|
||||
click: function() {
|
||||
notification.close();
|
||||
RED.actions.invoke("core:show-event-log");
|
||||
}
|
||||
}
|
||||
]
|
||||
}); }
|
||||
}
|
||||
})
|
||||
notification.close();
|
||||
@@ -940,11 +987,36 @@ RED.palette.editor = (function() {
|
||||
class: "primary palette-module-install-confirm-button-install",
|
||||
click: function() {
|
||||
var spinner = RED.utils.addSpinnerOverlay(container, true);
|
||||
|
||||
var buttonRow = $('<div style="position: relative;bottom: calc(50% + 17px); padding-right: 10px;text-align: right;"></div>').appendTo(spinner);
|
||||
$('<button class="editor-button"></button>').text(RED._("eventLog.view")).appendTo(buttonRow).click(function(evt) {
|
||||
evt.preventDefault();
|
||||
RED.actions.invoke("core:show-event-log");
|
||||
});
|
||||
RED.eventLog.startEvent(RED._("palette.editor.confirm.button.install")+" : "+entry.id+" "+entry.version);
|
||||
installNodeModule(entry.id,entry.version,function(xhr) {
|
||||
spinner.remove();
|
||||
if (xhr) {
|
||||
if (xhr.responseJSON) {
|
||||
RED.notify(RED._('palette.editor.errors.installFailed',{module: entry.id,message:xhr.responseJSON.message}));
|
||||
var notification = RED.notify(RED._('palette.editor.errors.installFailed',{module: entry.id,message:xhr.responseJSON.message}),{
|
||||
type: 'error',
|
||||
modal: true,
|
||||
fixed: true,
|
||||
buttons: [
|
||||
{
|
||||
text: RED._("common.label.close"),
|
||||
click: function() {
|
||||
notification.close();
|
||||
}
|
||||
},{
|
||||
text: RED._("eventLog.view"),
|
||||
click: function() {
|
||||
notification.close();
|
||||
RED.actions.invoke("core:show-event-log");
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
}
|
||||
done(xhr);
|
||||
|
@@ -870,7 +870,13 @@ RED.sidebar.versionControl = (function() {
|
||||
.click(function(e) {
|
||||
e.preventDefault();
|
||||
var spinner = utils.addSpinnerOverlay(remoteBox).addClass("projects-dialog-spinner-contain");
|
||||
var buttonRow = $('<div style="position: relative; bottom: 60px;"></div>').appendTo(spinner);
|
||||
$('<button class="editor-button"></button>').text(RED._("eventLog.view")).appendTo(buttonRow).click(function(evt) {
|
||||
evt.preventDefault();
|
||||
RED.actions.invoke("core:show-event-log");
|
||||
});
|
||||
var activeProject = RED.projects.getActiveProject();
|
||||
RED.eventLog.startEvent("Push changes"+(activeProject.git.branches.remoteAlt?(" : "+activeProject.git.branches.remoteAlt):""));
|
||||
var url = "projects/"+activeProject.name+"/push";
|
||||
if (activeProject.git.branches.remoteAlt) {
|
||||
url+="/"+activeProject.git.branches.remoteAlt;
|
||||
@@ -914,7 +920,13 @@ RED.sidebar.versionControl = (function() {
|
||||
var pullRemote = function(options) {
|
||||
options = options || {};
|
||||
var spinner = utils.addSpinnerOverlay(remoteBox).addClass("projects-dialog-spinner-contain");
|
||||
var buttonRow = $('<div style="position: relative; bottom: 60px;"></div>').appendTo(spinner);
|
||||
$('<button class="editor-button"></button>').text(RED._("eventLog.view")).appendTo(buttonRow).click(function(evt) {
|
||||
evt.preventDefault();
|
||||
RED.actions.invoke("core:show-event-log");
|
||||
});
|
||||
var activeProject = RED.projects.getActiveProject();
|
||||
RED.eventLog.startEvent("Pull changes"+(activeProject.git.branches.remoteAlt?(" : "+activeProject.git.branches.remoteAlt):""));
|
||||
var url = "projects/"+activeProject.name+"/pull";
|
||||
if (activeProject.git.branches.remoteAlt) {
|
||||
url+="/"+activeProject.git.branches.remoteAlt;
|
||||
|
@@ -6,3 +6,16 @@
|
||||
border-top-right-radius: 4px;
|
||||
border-bottom-right-radius: 4px;
|
||||
}
|
||||
|
||||
#event-log-editor {
|
||||
.ace_scroller {
|
||||
background: #444;
|
||||
color: #dd9;
|
||||
}
|
||||
.ace_active-line {
|
||||
background: #666 !important;
|
||||
}
|
||||
.ace_selection {
|
||||
background: #999 !important;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user