Add npm install timeout notification

part of https://github.com/node-red/node-red/issues/4622
This commit is contained in:
Ben Hardill 2024-04-18 11:27:32 +01:00
parent 9a3cb0b2b5
commit 1fdc600ecd
No known key found for this signature in database
GPG Key ID: 74DD076979ABB1E7
2 changed files with 25 additions and 5 deletions

View File

@ -668,7 +668,8 @@
"remove": "Remove",
"update": "Update"
}
}
},
"timeout": "<p>Install continuing the background, Nodes will appear in palette when complete.</p><p>Or you can monitor the install logs</p>"
}
},
"sidebar": {

View File

@ -133,7 +133,7 @@ RED.palette.editor = (function() {
}).done(function(data,textStatus,xhr) {
callback();
}).fail(function(xhr,textStatus,err) {
callback(xhr);
callback(xhr,textStatus,err);
});
}
function removeNodeModule(id,callback) {
@ -143,7 +143,7 @@ RED.palette.editor = (function() {
}).done(function(data,textStatus,xhr) {
callback();
}).fail(function(xhr,textStatus,err) {
callback(xhr);
callback(xhr, textStatus, err);
})
}
@ -1270,9 +1270,28 @@ RED.palette.editor = (function() {
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,entry.pkg_url,function(xhr) {
installNodeModule(entry.id,entry.version,entry.pkg_url,function(xhr, textStatus,err) {
spinner.remove();
if (xhr) {
if (err && xhr.status === 504) {
var notification = RED.notify(RED._("palette.editor.timeout"), {
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");
}
}
]
})
} else if (xhr) {
if (xhr.responseJSON) {
var notification = RED.notify(RED._('palette.editor.errors.installFailed',{module: entry.id,message:xhr.responseJSON.message}),{
type: 'error',