From: Stoiko Ivanov Date: Mon, 16 Nov 2020 11:01:17 +0000 (+0100) Subject: refactor RestoreWindow for PBS X-Git-Url: https://git.proxmox.com/?p=pmg-gui.git;a=commitdiff_plain;h=7bcc34dbcf334a2d8c102c7678907c2d7825350f refactor RestoreWindow for PBS 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 --- diff --git a/js/BackupRestore.js b/js/BackupRestore.js index b66a80e..2c90f2e 100644 --- a/js/BackupRestore.js +++ b/js/BackupRestore.js @@ -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(); },