Backup.js 2.09 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
Ext.define('PVE.window.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";
	}

	if (!me.vmtype) {
	    throw "no VM type specified";
	}

	var storagesel = Ext.create('PVE.form.StorageSelector', {
	    nodename: me.nodename,
	    name: 'storage',
	    value: me.storage,
25
	    fieldLabel: gettext('Storage'),
26 27 28 29 30 31 32 33 34 35 36 37 38 39
	    storageContent: 'backup',
	    allowBlank: false
	});

	me.formPanel = Ext.create('Ext.form.Panel', {
	    bodyPadding: 10,
	    border: false,
	    fieldDefaults: {
		labelWidth: 100,
		anchor: '100%'
	    },
	    items: [
		storagesel,
		{
40
		    xtype: 'pveBackupModeSelector',
41
		    fieldLabel: gettext('Mode'),
42 43
		    value: 'snapshot',
		    name: 'mode'
44 45
		},
		{
46
		    xtype: 'pveCompressionSelector',
47
		    name: 'compress',
48
		    value: 'lzo',
49
		    fieldLabel: gettext('Compression')
50 51 52 53 54 55 56
		}
	    ]
	});

	var form = me.formPanel.getForm();

	var submitBtn = Ext.create('Ext.Button', {
57
	    text: gettext('Backup'),
58 59 60
	    handler: function(){
		var storage = storagesel.getValue();
		var values = form.getValues();
61
		var params = {
62 63 64 65
		    storage: storage,
		    vmid: me.vmid,
		    mode: values.mode,
		    remove: 0
66 67 68 69 70 71 72 73
		};
		if (values.compress) {
		    params.compress = values.compress;
		}

		PVE.Utils.API2Request({
		    url: '/nodes/' + me.nodename + '/vzdump',
		    params: params,
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
		    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();
		    }
		});
	    }
	});

91 92 93
	var title = gettext('Backup') + " " + 
	    ((me.vmtype === 'openvz') ? "CT" : "VM") +
	    " " + me.vmid;
94 95 96 97 98 99 100 101

	Ext.apply(me, {
	    title: title,
	    width: 350,
	    modal: true,
	    layout: 'auto',
	    border: false,
	    items: [ me.formPanel ],
Dietmar Maurer's avatar
Dietmar Maurer committed
102
	    buttons: [ submitBtn ]
103 104 105 106 107
	});

	me.callParent();
    }
});