]> git.proxmox.com Git - pmg-gui.git/commitdiff
refactor RestoreWindow for PBS
authorStoiko Ivanov <s.ivanov@proxmox.com>
Mon, 16 Nov 2020 11:01:17 +0000 (12:01 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 17 Nov 2020 11:34:03 +0000 (12:34 +0100)
by moving the item definition to initComponent, and changing the check
for a provided filename, we can reuse the window for restores from PBS

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
js/BackupRestore.js

index b66a80ebc3ca374b244f8205e12707bf6c30ca27..2c90f2e6639c753fb2ae6cf0543f51048d939215 100644 (file)
@@ -26,39 +26,41 @@ Ext.define('PMG.RestoreWindow', {
     fieldDefaults: {
        labelWidth: 150,
     },
-    items: [
-       {
-           xtype: 'proxmoxcheckbox',
-           name: 'config',
-           fieldLabel: gettext('System Configuration'),
-       },
-       {
-           xtype: 'proxmoxcheckbox',
-           name: 'database',
-           value: 1,
-           uncheckedValue: 0,
-           fieldLabel: gettext('Rule Database'),
-           listeners: {
-               change: function(field, value) {
-                   field.nextSibling('field[name=statistic]').setDisabled(!value);
-               },
-           },
-       },
-       {
-           xtype: 'proxmoxcheckbox',
-           name: 'statistic',
-           fieldLabel: gettext('Statistic'),
-       },
-    ],
 
     initComponent: function() {
        let me = this;
 
-       if (!me.filename) {
-           throw "no filename given";
-       }
+       me.items = [
+           {
+               xtype: 'proxmoxcheckbox',
+               name: 'config',
+               fieldLabel: gettext('System Configuration'),
+           },
+           {
+               xtype: 'proxmoxcheckbox',
+               name: 'database',
+               value: 1,
+               uncheckedValue: 0,
+               fieldLabel: gettext('Rule Database'),
+               listeners: {
+                   change: function(field, value) {
+                       field.nextSibling('field[name=statistic]').setDisabled(!value);
+                   },
+               },
+           },
+           {
+               xtype: 'proxmoxcheckbox',
+               name: 'statistic',
+               fieldLabel: gettext('Statistic'),
+           },
+       ];
 
-       me.url = `/nodes/${Proxmox.NodeName}/backup/${encodeURIComponent(me.filename)}`;
+       let initurl = "/nodes/" + Proxmox.NodeName;
+       if (me.filename) {
+           me.url = initurl + "/backup/" + encodeURIComponent(me.filename);
+       } else {
+           throw "neither filename nor snapshot given";
+       }
 
        me.callParent();
     },