]> git.proxmox.com Git - pmg-gui.git/commitdiff
pbs: factor out remote add/edit window and panels
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 17 Nov 2020 18:30:48 +0000 (19:30 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 17 Nov 2020 18:30:48 +0000 (19:30 +0100)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
js/Makefile
js/PBSConfig.js
js/PBSRemoteEdit.js [new file with mode: 0644]

index 4b95d5520036bb6604eb7b0a6bc8139b882116f0..796c3321785697d1e0294bf001a723cd24e9572a 100644 (file)
@@ -38,6 +38,7 @@ JSSRC=                                                        \
        BackupConfiguration.js                          \
        BackupRestore.js                                \
        PBSSnapshotView.js                              \
+       PBSRemoteEdit.js                                \
        PBSConfig.js                                    \
        SystemConfiguration.js                          \
        MailProxyRelaying.js                            \
index 87654c8297c76e478deb8056839a19416cc235f4..63d43b7553b87aca0dd4360c029298e2f895a1e9 100644 (file)
@@ -1,204 +1,3 @@
-Ext.define('PMG.PBSInputPanel', {
-    extend: 'Ext.tab.Panel',
-    xtype: 'pmgPBSInputPanel',
-    mixins: ['Proxmox.Mixin.CBind'],
-
-    bodyPadding: 10,
-    remoteId: undefined,
-
-    cbindData: function(initialConfig) {
-       let me = this;
-
-       me.isCreate = initialConfig.isCreate || !initialConfig.remoteId;
-       return {
-           unsetValue: me.isCreate ? null : undefined,
-       };
-    },
-
-    items: [
-       {
-           xtype: 'inputpanel',
-           title: gettext('Backup Server'),
-           onGetValues: function(values) {
-               values.disable = values.enable ? 0 : 1;
-               delete values.enable;
-               return values;
-           },
-           column1: [
-               {
-                   xtype: 'pmxDisplayEditField',
-                   name: 'remote',
-                   cbind: {
-                       value: '{unsetValue}',
-                       editable: '{isCreate}',
-                   },
-                   fieldLabel: gettext('ID'),
-                   allowBlank: false,
-               },
-               {
-                   xtype: 'proxmoxtextfield',
-                   name: 'server',
-                   cbind: {
-                       value: '{unsetValue}',
-                   },
-                   vtype: 'DnsOrIp',
-                   fieldLabel: gettext('Server'),
-                   allowBlank: false,
-               },
-               {
-                   xtype: 'proxmoxtextfield',
-                   name: 'datastore',
-                   cbind: {
-                       value: '{unsetValue}',
-                   },
-                   fieldLabel: 'Datastore',
-                   allowBlank: false,
-               },
-           ],
-           column2: [
-               {
-                   xtype: 'proxmoxtextfield',
-                   name: 'username',
-                   cbind: {
-                       value: '{unsetValue}',
-                   },
-                   emptyText: gettext('Example') + ': admin@pbs',
-                   fieldLabel: gettext('Username'),
-                   regex: /\S+@\w+/,
-                   regexText: gettext('Example') + ': admin@pbs',
-                   allowBlank: false,
-               },
-               {
-                   xtype: 'proxmoxtextfield',
-                   inputType: 'password',
-                   name: 'password',
-                   cbind: {
-                       value: '{unsetValue}',
-                       allowBlank: '{!isCreate}',
-                       emptyText: (get) => get('isCreate') ? '' : gettext('Unchanged'),
-                   },
-                   fieldLabel: gettext('Password'),
-               },
-               {
-                   xtype: 'proxmoxcheckbox',
-                   name: 'enable',
-                   checked: true,
-                   uncheckedValue: 0,
-                   fieldLabel: gettext('Enable'),
-               },
-           ],
-           columnB: [
-               {
-                   xtype: 'proxmoxtextfield',
-                   name: 'fingerprint',
-                   cbind: {
-                       value: '{unsetValue}',
-                   },
-                   fieldLabel: gettext('Fingerprint'),
-                   emptyText: gettext('Server certificate SHA-256 fingerprint, required for self-signed certificates'),
-                   regex: /[A-Fa-f0-9]{2}(:[A-Fa-f0-9]{2}){31}/,
-                   regexText: gettext('Example') + ': AB:CD:EF:...',
-                   allowBlank: true,
-               },
-           ],
-       },
-       {
-           xtype: 'inputpanel',
-           title: gettext('Prune Options'),
-           defaults: {
-               // set nested, else we'd only set the defaults for the two column containers
-               defaults: {
-                   minValue: 1,
-                   labelWidth: 100,
-                   allowBlank: true,
-               },
-           },
-           column1: [
-               {
-                   xtype: 'proxmoxintegerfield',
-                   fieldLabel: gettext('Keep Last'),
-                   name: 'keep-last',
-                   cbind: { deleteEmpty: '{!isCreate}' },
-               },
-               {
-                   xtype: 'proxmoxintegerfield',
-                   fieldLabel: gettext('Keep Daily'),
-                   name: 'keep-daily',
-                   cbind: { deleteEmpty: '{!isCreate}' },
-               },
-               {
-                   xtype: 'proxmoxintegerfield',
-                   fieldLabel: gettext('Keep Monthly'),
-                   name: 'keep-monthly',
-                   cbind: { deleteEmpty: '{!isCreate}' },
-               },
-           ],
-           column2: [
-               {
-                   xtype: 'proxmoxintegerfield',
-                   fieldLabel: gettext('Keep Hourly'),
-                   name: 'keep-hourly',
-                   cbind: { deleteEmpty: '{!isCreate}' },
-               },
-               {
-                   xtype: 'proxmoxintegerfield',
-                   fieldLabel: gettext('Keep Weekly'),
-                   name: 'keep-weekly',
-                   cbind: { deleteEmpty: '{!isCreate}' },
-               },
-               {
-                   xtype: 'proxmoxintegerfield',
-                   fieldLabel: gettext('Keep Yearly'),
-                   name: 'keep-yearly',
-                   cbind: { deleteEmpty: '{!isCreate}' },
-               },
-           ],
-       },
-    ],
-});
-
-Ext.define('PMG.PBSEdit', {
-    extend: 'Proxmox.window.Edit',
-    xtype: 'pmgPBSEdit',
-
-    subject: 'Proxmox Backup Server',
-    isAdd: true,
-
-    bodyPadding: 0,
-
-    initComponent: function() {
-       let me = this;
-
-       me.isCreate = !me.remoteId;
-
-       me.method = 'POST';
-       me.url = '/api2/extjs/config/pbs';
-       if (!me.isCreate) {
-           me.url += `/${me.remoteId}`;
-           me.method = 'PUT';
-       }
-
-       me.items = [{
-           xtype: 'pmgPBSInputPanel',
-           isCreate: me.isCreate,
-           remoteId: me.remoteId,
-       }];
-
-       me.callParent();
-
-       if (!me.isCreate) {
-           me.load({
-               success: function(response, options) {
-                   let values = response.result.data;
-
-                   values.enable = values.disable ? 0 : 1;
-                   me.setValues(values);
-               },
-           });
-       }
-    },
-});
-
 Ext.define('PMG.PBSScheduleEdit', {
     extend: 'Proxmox.window.Edit',
     xtype: 'pmgPBSScheduleEdit',
diff --git a/js/PBSRemoteEdit.js b/js/PBSRemoteEdit.js
new file mode 100644 (file)
index 0000000..e478dbd
--- /dev/null
@@ -0,0 +1,200 @@
+Ext.define('PMG.PBSInputPanel', {
+    extend: 'Ext.tab.Panel',
+    xtype: 'pmgPBSInputPanel',
+    mixins: ['Proxmox.Mixin.CBind'],
+
+    bodyPadding: 10,
+    remoteId: undefined,
+
+    cbindData: function(initialConfig) {
+       let me = this;
+
+       me.isCreate = initialConfig.isCreate || !initialConfig.remoteId;
+       return {
+           unsetValue: me.isCreate ? null : undefined,
+       };
+    },
+
+    items: [
+       {
+           xtype: 'inputpanel',
+           title: gettext('Backup Server'),
+           onGetValues: function(values) {
+               values.disable = values.enable ? 0 : 1;
+               delete values.enable;
+               return values;
+           },
+           column1: [
+               {
+                   xtype: 'pmxDisplayEditField',
+                   name: 'remote',
+                   cbind: {
+                       value: '{unsetValue}',
+                       editable: '{isCreate}',
+                   },
+                   fieldLabel: gettext('ID'),
+                   allowBlank: false,
+               },
+               {
+                   xtype: 'proxmoxtextfield',
+                   name: 'server',
+                   cbind: {
+                       value: '{unsetValue}',
+                   },
+                   vtype: 'DnsOrIp',
+                   fieldLabel: gettext('Server'),
+                   allowBlank: false,
+               },
+               {
+                   xtype: 'proxmoxtextfield',
+                   name: 'datastore',
+                   cbind: {
+                       value: '{unsetValue}',
+                   },
+                   fieldLabel: 'Datastore',
+                   allowBlank: false,
+               },
+           ],
+           column2: [
+               {
+                   xtype: 'proxmoxtextfield',
+                   name: 'username',
+                   cbind: {
+                       value: '{unsetValue}',
+                   },
+                   emptyText: gettext('Example') + ': admin@pbs',
+                   fieldLabel: gettext('Username'),
+                   regex: /\S+@\w+/,
+                   regexText: gettext('Example') + ': admin@pbs',
+                   allowBlank: false,
+               },
+               {
+                   xtype: 'proxmoxtextfield',
+                   inputType: 'password',
+                   name: 'password',
+                   cbind: {
+                       value: '{unsetValue}',
+                       allowBlank: '{!isCreate}',
+                       emptyText: (get) => get('isCreate') ? '' : gettext('Unchanged'),
+                   },
+                   fieldLabel: gettext('Password'),
+               },
+               {
+                   xtype: 'proxmoxcheckbox',
+                   name: 'enable',
+                   checked: true,
+                   uncheckedValue: 0,
+                   fieldLabel: gettext('Enable'),
+               },
+           ],
+           columnB: [
+               {
+                   xtype: 'proxmoxtextfield',
+                   name: 'fingerprint',
+                   cbind: {
+                       value: '{unsetValue}',
+                   },
+                   fieldLabel: gettext('Fingerprint'),
+                   emptyText: gettext('Server certificate SHA-256 fingerprint, required for self-signed certificates'),
+                   regex: /[A-Fa-f0-9]{2}(:[A-Fa-f0-9]{2}){31}/,
+                   regexText: gettext('Example') + ': AB:CD:EF:...',
+                   allowBlank: true,
+               },
+           ],
+       },
+       {
+           xtype: 'inputpanel',
+           title: gettext('Prune Options'),
+           defaults: {
+               // set nested, else we'd only set the defaults for the two column containers
+               defaults: {
+                   minValue: 1,
+                   labelWidth: 100,
+                   allowBlank: true,
+               },
+           },
+           column1: [
+               {
+                   xtype: 'proxmoxintegerfield',
+                   fieldLabel: gettext('Keep Last'),
+                   name: 'keep-last',
+                   cbind: { deleteEmpty: '{!isCreate}' },
+               },
+               {
+                   xtype: 'proxmoxintegerfield',
+                   fieldLabel: gettext('Keep Daily'),
+                   name: 'keep-daily',
+                   cbind: { deleteEmpty: '{!isCreate}' },
+               },
+               {
+                   xtype: 'proxmoxintegerfield',
+                   fieldLabel: gettext('Keep Monthly'),
+                   name: 'keep-monthly',
+                   cbind: { deleteEmpty: '{!isCreate}' },
+               },
+           ],
+           column2: [
+               {
+                   xtype: 'proxmoxintegerfield',
+                   fieldLabel: gettext('Keep Hourly'),
+                   name: 'keep-hourly',
+                   cbind: { deleteEmpty: '{!isCreate}' },
+               },
+               {
+                   xtype: 'proxmoxintegerfield',
+                   fieldLabel: gettext('Keep Weekly'),
+                   name: 'keep-weekly',
+                   cbind: { deleteEmpty: '{!isCreate}' },
+               },
+               {
+                   xtype: 'proxmoxintegerfield',
+                   fieldLabel: gettext('Keep Yearly'),
+                   name: 'keep-yearly',
+                   cbind: { deleteEmpty: '{!isCreate}' },
+               },
+           ],
+       },
+    ],
+});
+
+Ext.define('PMG.PBSEdit', {
+    extend: 'Proxmox.window.Edit',
+    xtype: 'pmgPBSEdit',
+
+    subject: 'Proxmox Backup Server',
+    isAdd: true,
+
+    bodyPadding: 0,
+
+    initComponent: function() {
+       let me = this;
+
+       me.isCreate = !me.remoteId;
+
+       me.method = 'POST';
+       me.url = '/api2/extjs/config/pbs';
+       if (!me.isCreate) {
+           me.url += `/${me.remoteId}`;
+           me.method = 'PUT';
+       }
+
+       me.items = [{
+           xtype: 'pmgPBSInputPanel',
+           isCreate: me.isCreate,
+           remoteId: me.remoteId,
+       }];
+
+       me.callParent();
+
+       if (!me.isCreate) {
+           me.load({
+               success: function(response, options) {
+                   let values = response.result.data;
+
+                   values.enable = values.disable ? 0 : 1;
+                   me.setValues(values);
+               },
+           });
+       }
+    },
+});