mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-08-14 15:58:20 +00:00
ui: dc/backup: refactor and fix run-job-now
rather than reducing the total job count during execution (and that not for all cases) do some checks first and pass only the known good nodes to the for-each-node-POST-request loop, so we can omit all checks there. Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
448454ffcd
commit
a0fecb88ba
@ -420,9 +420,7 @@ Ext.define('PVE.dc.BackupView', {
|
|||||||
var run_backup_now = function(job) {
|
var run_backup_now = function(job) {
|
||||||
job = Ext.clone(job);
|
job = Ext.clone(job);
|
||||||
|
|
||||||
var allNodes = PVE.data.ResourceStore.getNodes();
|
let jobNode = job.node;
|
||||||
var jobNode = job.node;
|
|
||||||
|
|
||||||
// Remove properties related to scheduling
|
// Remove properties related to scheduling
|
||||||
delete job.enabled;
|
delete job.enabled;
|
||||||
delete job.starttime;
|
delete job.starttime;
|
||||||
@ -431,56 +429,53 @@ Ext.define('PVE.dc.BackupView', {
|
|||||||
delete job.node;
|
delete job.node;
|
||||||
job.all = job.all === true ? 1 : 0;
|
job.all = job.all === true ? 1 : 0;
|
||||||
|
|
||||||
var errors = [];
|
let allNodes = PVE.data.ResourceStore.getNodes();
|
||||||
var jobCount = jobNode === undefined ? allNodes.length : 1;
|
let nodes = allNodes.filter(node => node.status === 'online').map(node => node.node);
|
||||||
var inProgress = jobCount;
|
let errors = [];
|
||||||
|
|
||||||
|
if (jobNode !== undefined) {
|
||||||
|
if (!nodes.includes(jobNode)) {
|
||||||
|
Ext.Msg.alert('Error', "Node '"+ jobNode +"' from backup job isn't online!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
nodes = [ jobNode ];
|
||||||
|
} else {
|
||||||
|
let unkownNodes = allNodes.filter(node => node.status !== 'online');
|
||||||
|
if (unkownNodes.length > 0)
|
||||||
|
errors.push(unkownNodes.map(node => node.node + ": " + gettext("Node is offline")));
|
||||||
|
}
|
||||||
|
let jobTotalCount = nodes.length, jobsStarted = 0;
|
||||||
|
|
||||||
Ext.Msg.show({
|
Ext.Msg.show({
|
||||||
title: gettext('Please wait...'),
|
title: gettext('Please wait...'),
|
||||||
closable: false,
|
closable: false,
|
||||||
progress: true
|
progress: true,
|
||||||
|
progressText: '0/' + jobTotalCount,
|
||||||
});
|
});
|
||||||
Ext.Msg.updateProgress(0, '0/' + jobCount);
|
|
||||||
|
|
||||||
var postRequest = function () {
|
let postRequest = function () {
|
||||||
inProgress++;
|
jobsStarted++;
|
||||||
|
Ext.Msg.updateProgress(jobsStarted / jobTotalCount, jobsStarted + '/' + jobTotalCount);
|
||||||
|
|
||||||
Ext.Msg.updateProgress(inProgress/jobCount,
|
if (jobsStarted == jobTotalCount) {
|
||||||
inProgress + '/' + jobCount);
|
|
||||||
|
|
||||||
if (inProgress == jobCount) {
|
|
||||||
Ext.Msg.hide();
|
Ext.Msg.hide();
|
||||||
if (errors !== undefined && errors.length > 0) {
|
if (errors.length > 0) {
|
||||||
Ext.Msg.alert('Error', 'Some errors have been encountered:<br />---<br />'
|
Ext.Msg.alert('Error', 'Some errors have been encountered:<br />' + errors.join('<br />'));
|
||||||
+ errors.join('<br />---<br />'));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
allNodes.forEach(node => {
|
nodes.forEach(node => Proxmox.Utils.API2Request({
|
||||||
if (jobNode !== undefined && jobNode !== node.node) {
|
url: '/nodes/' + node + '/vzdump',
|
||||||
return;
|
method: 'POST',
|
||||||
}
|
params: job,
|
||||||
|
failure: function (response, opts) {
|
||||||
if (node.status !== 'online') {
|
errors.push(node + ': ' + response.htmlStatus);
|
||||||
errors.push(node.node + ": " + gettext("Node is offline"));
|
postRequest();
|
||||||
return;
|
},
|
||||||
}
|
success: postRequest
|
||||||
|
}));
|
||||||
inProgress--;
|
};
|
||||||
|
|
||||||
Proxmox.Utils.API2Request({
|
|
||||||
url: '/nodes/' + node.node + '/vzdump',
|
|
||||||
method: 'POST',
|
|
||||||
params: job,
|
|
||||||
failure: function (response, opts) {
|
|
||||||
errors.push(node.node + ': ' + response.htmlStatus);
|
|
||||||
postRequest();
|
|
||||||
},
|
|
||||||
success: postRequest
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
var edit_btn = new Proxmox.button.Button({
|
var edit_btn = new Proxmox.button.Button({
|
||||||
text: gettext('Edit'),
|
text: gettext('Edit'),
|
||||||
|
Loading…
Reference in New Issue
Block a user