[pmg-devel] [PATCH pmg-gui v2 2/3] refactor RestoreWindow for PBS
Stoiko Ivanov
s.ivanov at proxmox.com
Mon Nov 2 19:45:37 CET 2020
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 at proxmox.com>
---
js/BackupRestore.js | 59 +++++++++++++++++++++++----------------------
1 file changed, 30 insertions(+), 29 deletions(-)
diff --git a/js/BackupRestore.js b/js/BackupRestore.js
index 6c97230..996f128 100644
--- a/js/BackupRestore.js
+++ b/js/BackupRestore.js
@@ -26,40 +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(cb, value) {
- var me = this;
- me.up().down('field[name=statistic]').setDisabled(!value);
- },
- },
- },
- {
- xtype: 'proxmoxcheckbox',
- name: 'statistic',
- fieldLabel: gettext('Statistic'),
- },
- ],
initComponent: function() {
var 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(cb, value) {
+ me.up().down('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();
},
--
2.20.1
More information about the pmg-devel
mailing list