diff --git a/www/manager/qemu/Backup.js b/www/manager/qemu/Backup.js index a0ddc817..4a248789 100644 --- a/www/manager/qemu/Backup.js +++ b/www/manager/qemu/Backup.js @@ -1,7 +1,107 @@ Ext.define('PVE.qemu.Backup', { + extend: 'Ext.window.Window', + + resizable: false, + + initComponent : function() { + var me = this; + + if (!me.nodename) { + throw "no node name specified"; + } + + if (!me.vmid) { + throw "no VM ID specified"; + } + + var storagesel = Ext.create('PVE.form.StorageSelector', { + nodename: me.nodename, + name: 'storage', + value: me.storage, + fieldLabel: 'Storage', + storageContent: 'backup', + allowBlank: false + }); + + me.formPanel = Ext.create('Ext.form.Panel', { + bodyPadding: 10, + border: false, + fieldDefaults: { + labelWidth: 100, + anchor: '100%' + }, + items: [ + storagesel, + { + xtype: 'pvecheckbox', + name: 'compress', + uncheckedValue: 0, + value: 1, + fieldLabel: 'Compress' + }, + { + xtype: 'pvecheckbox', + name: 'snapshot', + uncheckedValue: 0, + value: 1, + fieldLabel: 'Snapshot mode' + } + ] + }); + + var form = me.formPanel.getForm(); + + var submitBtn = Ext.create('Ext.Button', { + text: 'Backup', + handler: function(){ + var storage = storagesel.getValue(); + var msg = 'Start backup to storage "' + storage + '"'; + var values = form.getValues(); + console.dir(me.vmid, me.nodename, values.online); + + PVE.Utils.API2Request({ + url: '/nodes/' + me.nodename + '/vzdump', + params: { + storage: storage, + vmid: me.vmid, + compress: values.compress, + snapshot: values.snapshot + }, + method: 'POST', + failure: function (response, opts) { + Ext.Msg.alert('Error',response.htmlStatus); + }, + success: function(response, options) { + var upid = response.result.data; + + var win = Ext.create('PVE.window.TaskViewer', { + upid: upid + }); + win.show(); + me.close(); + } + }); + } + }); + + Ext.apply(me, { + title: "Backup VM " + me.vmid, + width: 350, + modal: true, + layout: 'auto', + border: false, + items: [ me.formPanel ], + buttons: [ submitBtn ], + }); + + me.callParent(); + } +}); + +Ext.define('PVE.qemu.BackupView', { extend: 'Ext.grid.GridPanel', - alias: ['widget.pveQemuBackup'], + alias: ['widget.pveQemuBackupView'], initComponent : function() { @@ -58,36 +158,13 @@ Ext.define('PVE.qemu.Backup', { var backup_btn = new Ext.Button({ text: 'Backup now', - handler: function(){ - var storage = storagesel.getValue(); - var msg = 'Start backup to storage "' + storage + '"'; - Ext.Msg.confirm('Backup Confirmation', msg, function(btn) { - if (btn !== 'yes') { - return; - } - - PVE.Utils.API2Request({ - url: '/nodes/' + nodename + '/vzdump', - params: { - storage: storage, - vmid: vmid, - compress: 1, - snapshot: 1 - }, - method: 'POST', - failure: function (response, opts) { - Ext.Msg.alert('Error',response.htmlStatus); - }, - success: function(response, options) { - var upid = response.result.data; - - var win = Ext.create('PVE.window.TaskViewer', { - upid: upid - }); - win.show(); - } - }); + handler: function() { + var win = Ext.create('PVE.qemu.Backup', { + nodename: nodename, + vmid: vmid, + storage: storagesel.getValue() }); + win.show(); } }); diff --git a/www/manager/qemu/Config.js b/www/manager/qemu/Config.js index e274b526..2b542430 100644 --- a/www/manager/qemu/Config.js +++ b/www/manager/qemu/Config.js @@ -46,7 +46,7 @@ Ext.define('PVE.qemu.Config', { vmid: vmid }, { - xtype: 'pveQemuBackup', + xtype: 'pveQemuBackupView', title: 'Backup', itemId: 'backup' },