To allow masking to be correctly handled, we use a counter variable to keep the mask visible until all tasks have been completed. Any errors that occurred will be displayed in a consolidated message box.
Includes a "confirm" dialog to not accidentally run a potentially large backup job. Curiously, the "pve-cluster-backup" data model seems to have been broken entirely. I'm not sure how it was working before, but the changes in this patch need it fixed, so include that as well (use "mode" instead of individual flags + "compress" is not a boolean). Signed-off-by: Stefan Reiter <s.rei...@proxmox.com> --- www/manager6/dc/Backup.js | 92 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 85 insertions(+), 7 deletions(-) diff --git a/www/manager6/dc/Backup.js b/www/manager6/dc/Backup.js index 79e9cace..a26ea63d 100644 --- a/www/manager6/dc/Backup.js +++ b/www/manager6/dc/Backup.js @@ -419,6 +419,62 @@ Ext.define('PVE.dc.BackupView', { win.show(); }; + var run_now_finished = function(errors) { + me.unmask(); + + if (errors !== undefined && errors.length > 0) { + Ext.Msg.alert('Error', 'Some errors have been encountered:<br />---<br />' + + errors.join('<br />---<br />')); + } + } + + var run_backup_now = function(job) { + job = Ext.clone(job); + + var allNodes = PVE.data.ResourceStore.getNodes(); + var jobNode = job.node; + + // Remove properties related to scheduling + delete job.enabled; + delete job.starttime; + delete job.dow; + delete job.id; + delete job.node; + job.all = job.all === true ? 1 : 0; + + var errors = []; + var inProgress = 0; + + me.mask(gettext('Please wait...'), 'x-mask-loading'); + + allNodes.forEach(node => { + if (node.status !== 'online' || + (jobNode !== undefined && jobNode !== node.node)) { + return; + } + + inProgress++; + Proxmox.Utils.API2Request({ + url: '/nodes/' + node.node + '/vzdump', + method: 'POST', + params: job, + failure: function (response, opts) { + errors.push(node.node + ': ' + response.htmlStatus); + inProgress--; + if (inProgress == 0) { + run_now_finished(errors); + } + }, + success: function (response, opts) { + inProgress--; + if (inProgress == 0) { + run_now_finished(errors); + } + } + }); + }); + } + var edit_btn = new Proxmox.button.Button({ text: gettext('Edit'), disabled: true, @@ -426,6 +482,31 @@ Ext.define('PVE.dc.BackupView', { handler: run_editor }); + var run_btn = new Proxmox.button.Button({ + text: gettext('Run now'), + disabled: true, + selModel: sm, + handler: function() { + var rec = sm.getSelection()[0]; + if (!rec) { + return; + } + + Ext.Msg.show({ + title: gettext('Confirm'), + icon: Ext.Msg.QUESTION, + msg: gettext('Start the selected backup job now?'), + buttons: Ext.Msg.YESNO, + callback: function(btn) { + if (btn !== 'yes') { + return; + } + run_backup_now(rec.data); + } + }); + } + }); + var remove_btn = Ext.create('Proxmox.button.StdRemoveButton', { selModel: sm, baseurl: '/cluster/backup', @@ -454,7 +535,8 @@ Ext.define('PVE.dc.BackupView', { } }, remove_btn, - edit_btn + edit_btn, + run_btn ], columns: [ { @@ -576,13 +658,9 @@ Ext.define('PVE.dc.BackupView', { fields: [ 'id', 'starttime', 'dow', 'storage', 'node', 'vmid', 'exclude', - 'mailto', 'pool', + 'mailto', 'pool', 'compress', 'mode', { name: 'enabled', type: 'boolean' }, - { name: 'all', type: 'boolean' }, - { name: 'snapshot', type: 'boolean' }, - { name: 'stop', type: 'boolean' }, - { name: 'suspend', type: 'boolean' }, - { name: 'compress', type: 'boolean' } + { name: 'all', type: 'boolean' } ] }); }); -- 2.20.1 _______________________________________________ pve-devel mailing list pve-devel@pve.proxmox.com https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel