]> git.proxmox.com Git - pve-manager.git/blobdiff - www/manager6/window/Restore.js
drop jslint lines
[pve-manager.git] / www / manager6 / window / Restore.js
index d32fae002a8e83777b84a60a7f4fa62b99ffe83d..f720eb3b35d732a0e6e634eb0acd1f66ac5ca83e 100644 (file)
@@ -1,5 +1,5 @@
 Ext.define('PVE.window.Restore', {
-    extend: 'Ext.window.Window', // fixme: PVE.window.Edit?
+    extend: 'Ext.window.Window', // fixme: Proxmox.window.Edit?
 
     resizable: false,
 
@@ -24,7 +24,11 @@ Ext.define('PVE.window.Restore', {
            value: '',
            fieldLabel: gettext('Storage'),
            storageContent: (me.vmtype === 'lxc') ? 'rootdir' : 'images',
-           allowBlank: true
+           // when restoring a container without specifying a storage, the backend defaults
+           // to 'local', which is unintuitive and 'rootdir' might not even be allowed on it
+           allowBlank: me.vmtype !== 'lxc',
+           emptyText: (me.vmtype === 'lxc') ? '' : gettext('From backup configuration'),
+           autoSelect: me.vmtype === 'lxc',
        });
 
        var IDfield;
@@ -38,7 +42,7 @@ Ext.define('PVE.window.Restore', {
            IDfield = Ext.create('PVE.form.GuestIDSelector', {
                name: 'vmid',
                guestType: me.vmtype,
-               loadNextGuestID: true,
+               loadNextFreeID: true,
                validateExists: false
            });
        }
@@ -50,14 +54,49 @@ Ext.define('PVE.window.Restore', {
                fieldLabel: gettext('Source')
            },
            storagesel,
-           IDfield
+           IDfield,
+           {
+               xtype: 'pveBandwidthField',
+               name: 'bwlimit',
+               backendUnit: 'KiB',
+               fieldLabel: gettext('Read Limit'),
+               emptyText: gettext('Defaults to target storage restore limit'),
+               autoEl: {
+                   tag: 'div',
+                   'data-qtip': gettext("Use '0' to disable all bandwidth limits.")
+               }
+           },
+           {
+               xtype: 'fieldcontainer',
+               layout: 'hbox',
+               items: [{
+                   xtype: 'proxmoxcheckbox',
+                   name: 'unique',
+                   fieldLabel: gettext('Unique'),
+                   hidden: !!me.vmid,
+                   flex: 1,
+                   autoEl: {
+                       tag: 'div',
+                       'data-qtip': gettext('Autogenerate unique properties, e.g., MAC addresses')
+                   },
+                   checked: false
+               },
+               {
+                   xtype: 'proxmoxcheckbox',
+                   name: 'start',
+                   flex: 1,
+                   fieldLabel: gettext('Start after restore'),
+                   labelWidth: 105,
+                   checked: false
+               }],
+           },
        ];
 
        if (me.vmtype === 'lxc') {
            items.push({
-               xtype: 'pvecheckbox',
+               xtype: 'proxmoxcheckbox',
                name: 'unprivileged',
-               value: '',
+               value: true,
                fieldLabel: gettext('Unprivileged container')
            });
        }
@@ -75,7 +114,7 @@ Ext.define('PVE.window.Restore', {
        var form = me.formPanel.getForm();
 
        var doRestore = function(url, params) {
-           PVE.Utils.API2Request({
+           Proxmox.Utils.API2Request({
                url: url,
                params: params,
                method: 'POST',
@@ -86,7 +125,7 @@ Ext.define('PVE.window.Restore', {
                success: function(response, options) {
                    var upid = response.result.data;
                    
-                   var win = Ext.create('PVE.window.TaskViewer', { 
+                   var win = Ext.create('Proxmox.window.TaskViewer', {
                        upid: upid
                    });
                    win.show();
@@ -98,14 +137,19 @@ Ext.define('PVE.window.Restore', {
        var submitBtn = Ext.create('Ext.Button', {
            text: gettext('Restore'),
            handler: function(){
-               var storage = storagesel.getValue();
                var values = form.getValues();
 
                var params = {
-                   storage: storage,
                    vmid: me.vmid || values.vmid,
                    force: me.vmid ? 1 : 0
                };
+               if (values.unique) { params.unique = 1; }
+               if (values.start) { params.start = 1; }
+               if (values.storage) { params.storage = values.storage; }
+
+               if (values.bwlimit !== undefined) {
+                   params.bwlimit = values.bwlimit;
+               }
 
                var url;
                var msg;
@@ -114,11 +158,11 @@ Ext.define('PVE.window.Restore', {
                    params.ostemplate = me.volid;
                    params.restore = 1;
                    if (values.unprivileged) { params.unprivileged = 1; }
-                   msg = PVE.Utils.format_task_description('vzrestore', params.vmid);
+                   msg = Proxmox.Utils.format_task_description('vzrestore', params.vmid);
                } else if (me.vmtype === 'qemu') {
                    url = '/nodes/' + me.nodename + '/qemu';
                    params.archive = me.volid;
-                   msg = PVE.Utils.format_task_description('qmrestore', params.vmid);
+                   msg = Proxmox.Utils.format_task_description('qmrestore', params.vmid);
                } else {
                    throw 'unknown VM type';
                }