]> git.proxmox.com Git - proxmox-widget-toolkit.git/commitdiff
add ACME forms
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Tue, 16 Mar 2021 10:24:19 +0000 (11:24 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 16 Mar 2021 11:25:58 +0000 (12:25 +0100)
Mostly copied from PVE, but the user needs to set the URL
property so their stores can load the data, whereas in PVE
this was hardcoded.

API selector:
  needs its url to point to the challenge-schema url

Acme Account selector:
  needs its url to point to the acme account index

Acme Plugin selector:
  needs its url to point to the plugin index

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
src/Makefile
src/form/ACME.js [new file with mode: 0644]

index 3861bfc4ad088f54d5dc2fe86bd9c917fabf6822..d0435b84b7c53414470ac9c924de46fc0d4ac3d3 100644 (file)
@@ -35,6 +35,7 @@ JSSRC=                                        \
        form/DiskSelector.js            \
        form/MultiDiskSelector.js       \
        form/TaskTypeSelector.js        \
+       form/ACME.js                    \
        button/Button.js                \
        button/HelpButton.js            \
        grid/ObjectGrid.js              \
diff --git a/src/form/ACME.js b/src/form/ACME.js
new file mode 100644 (file)
index 0000000..8b93e30
--- /dev/null
@@ -0,0 +1,109 @@
+Ext.define('Proxmox.form.ACMEApiSelector', {
+    extend: 'Ext.form.field.ComboBox',
+    alias: 'widget.pmxACMEApiSelector',
+
+    fieldLabel: gettext('DNS API'),
+    displayField: 'name',
+    valueField: 'id',
+
+    store: {
+       model: 'proxmox-acme-challenges',
+       autoLoad: true,
+    },
+
+    triggerAction: 'all',
+    queryMode: 'local',
+    allowBlank: false,
+    editable: true,
+    forceSelection: true,
+    anyMatch: true,
+    selectOnFocus: true,
+
+    getSchema: function() {
+       let me = this;
+       let val = me.getValue();
+       if (val) {
+           let record = me.getStore().findRecord('id', val, 0, false, true, true);
+           if (record) {
+               return record.data.schema;
+           }
+       }
+       return {};
+    },
+
+    initComponent: function() {
+        let me = this;
+
+        if (!me.url) {
+            throw "no url given";
+        }
+
+        me.callParent();
+        me.getStore().getProxy().setUrl(me.url);
+    },
+});
+
+Ext.define('Proxmox.form.ACMEAccountSelector', {
+    extend: 'Ext.form.field.ComboBox',
+    alias: 'widget.pmxACMEAccountSelector',
+
+    displayField: 'name',
+    valueField: 'name',
+
+    store: {
+       model: 'proxmox-acme-accounts',
+       autoLoad: true,
+    },
+
+    triggerAction: 'all',
+    queryMode: 'local',
+    allowBlank: false,
+    editable: false,
+    forceSelection: true,
+
+    isEmpty: function() {
+       return this.getStore().getData().length === 0;
+    },
+
+    initComponent: function() {
+        let me = this;
+
+        if (!me.url) {
+            throw "no url given";
+        }
+
+        me.callParent();
+        me.getStore().getProxy().setUrl(me.url);
+    },
+});
+
+Ext.define('Proxmox.form.ACMEPluginSelector', {
+    extend: 'Ext.form.field.ComboBox',
+    alias: 'widget.pmxACMEPluginSelector',
+
+    fieldLabel: gettext('Plugin'),
+    displayField: 'plugin',
+    valueField: 'plugin',
+
+    store: {
+       model: 'proxmox-acme-plugins',
+       autoLoad: true,
+       filters: item => item.data.type === 'dns',
+    },
+
+    triggerAction: 'all',
+    queryMode: 'local',
+    allowBlank: false,
+    editable: false,
+
+    initComponent: function() {
+        let me = this;
+
+        if (!me.url) {
+            throw "no url given";
+        }
+
+        me.callParent();
+        me.getStore().getProxy().setUrl(me.url);
+    },
+});