Commit 67ef4210 authored by Dietmar Maurer's avatar Dietmar Maurer

improve qemu backup dialog

parent 23237d94
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();
}
});
......
......@@ -46,7 +46,7 @@ Ext.define('PVE.qemu.Config', {
vmid: vmid
},
{
xtype: 'pveQemuBackup',
xtype: 'pveQemuBackupView',
title: 'Backup',
itemId: 'backup'
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment