add ACME forms

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>
This commit is contained in:
Wolfgang Bumiller 2021-03-16 11:24:19 +01:00 committed by Thomas Lamprecht
parent c0acd78475
commit 63be5c590f
2 changed files with 110 additions and 0 deletions

View 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 \

109
src/form/ACME.js Normal file
View File

@ -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);
},
});