Ext.define('PVE.node.ACMEAccountCreate', {
extend: 'Proxmox.window.Edit',
+ mixins: ['Proxmox.Mixin.CBind'],
- width: 400,
+ width: 450,
title: gettext('Register Account'),
isCreate: true,
method: 'POST',
submitText: gettext('Register'),
url: '/cluster/acme/account',
showTaskViewer: true,
+ defaultExists: false,
items: [
{
xtype: 'proxmoxtextfield',
- fieldLabel: gettext('Name'),
+ fieldLabel: gettext('Account Name'),
name: 'name',
- emptyText: 'default',
- allowBlank: true,
+ cbind: {
+ emptyText: (get) => get('defaultExists') ? '' : 'default',
+ allowBlank: (get) => !get('defaultExists'),
+ },
+ },
+ {
+ xtype: 'textfield',
+ name: 'contact',
+ vtype: 'email',
+ allowBlank: false,
+ fieldLabel: gettext('E-Mail'),
},
{
xtype: 'proxmoxComboGrid',
idProperty: ['name'],
proxy: {
type: 'proxmox',
- url: '/api2/json/cluster/acme/directories'
+ url: '/api2/json/cluster/acme/directories',
},
sorters: {
property: 'name',
- order: 'ASC'
- }
+ order: 'ASC',
+ },
},
listConfig: {
columns: [
{
header: gettext('Name'),
dataIndex: 'name',
- flex: 1
+ flex: 1,
},
{
header: gettext('URL'),
dataIndex: 'url',
- flex: 1
- }
- ]
+ flex: 1,
+ },
+ ],
},
listeners: {
change: function(combogrid, value) {
disp.setValue(gettext('Loading'));
field.setValue(undefined);
checkbox.setValue(undefined);
+ checkbox.setHidden(true);
Proxmox.Utils.API2Request({
url: '/cluster/acme/tos',
method: 'GET',
params: {
- directory: value
+ directory: value,
},
success: function(response, opt) {
- me.up('window').down('#tos_url').setValue(response.result.data);
- me.up('window').down('#tos_url_display').setValue(response.result.data);
+ field.setValue(response.result.data);
+ disp.setValue(response.result.data);
+ checkbox.setHidden(false);
},
failure: function(response, opt) {
Ext.Msg.alert(gettext('Error'), response.htmlStatus);
- }
+ },
});
- }
- }
+ },
+ },
},
{
xtype: 'displayfield',
itemId: 'tos_url_display',
- fieldLabel: gettext('Terms of Service'),
renderer: PVE.Utils.render_optional_url,
- name: 'tos_url_display'
+ name: 'tos_url_display',
},
{
xtype: 'hidden',
itemId: 'tos_url',
- name: 'tos_url'
+ name: 'tos_url',
},
{
xtype: 'proxmoxcheckbox',
itemId: 'tos_checkbox',
- fieldLabel: gettext('Accept TOS'),
+ boxLabel: gettext('Accept TOS'),
submitValue: false,
validateValue: function(value) {
if (value && this.checked) {
return true;
}
return false;
- }
+ },
},
- {
- xtype: 'textfield',
- name: 'contact',
- vtype: 'email',
- allowBlank: false,
- fieldLabel: gettext('E-Mail')
- }
- ]
+ ],
});
width: 600,
fieldDefaults: {
- labelWidth: 140
+ labelWidth: 140,
},
title: gettext('Account'),
{
xtype: 'displayfield',
fieldLabel: gettext('E-Mail'),
- name: 'email'
+ name: 'email',
},
{
xtype: 'displayfield',
fieldLabel: gettext('Created'),
- name: 'createdAt'
+ name: 'createdAt',
},
{
xtype: 'displayfield',
fieldLabel: gettext('Status'),
- name: 'status'
+ name: 'status',
},
{
xtype: 'displayfield',
fieldLabel: gettext('Directory'),
renderer: PVE.Utils.render_optional_url,
- name: 'directory'
+ name: 'directory',
},
{
xtype: 'displayfield',
fieldLabel: gettext('Terms of Services'),
renderer: PVE.Utils.render_optional_url,
- name: 'tos'
- }
+ name: 'tos',
+ },
],
initComponent: function() {
data.createdAt = data.account.createdAt;
data.status = data.account.status;
me.setValues(data);
- }
+ },
});
- }
+ },
});
Ext.define('PVE.node.ACMEDomainEdit', {
viewModel: {
data: {
- account: undefined,
+ domaincount: 0,
+ account: undefined, // the account we display
+ configaccount: undefined, // the account set in the config
accountEditable: false,
accountsAvailable: false,
},
formulas: {
+ canOrder: (get) => !!get('account') && get('domaincount') > 0,
editBtnIcon: (get) => 'fa black fa-' + (get('accountEditable') ? 'check' : 'pencil'),
accountTextHidden: (get) => get('accountEditable') || !get('accountsAvailable'),
accountValueHidden: (get) => !get('accountEditable') || !get('accountsAvailable'),
onAccountsLoad: function(store, records, success) {
let me = this;
let vm = me.getViewModel();
+ let configaccount = vm.get('configaccount');
vm.set('accountsAvailable', records.length > 0);
if (me.autoChangeAccount && records.length > 0) {
me.changeAccount(records[0].data.name, () => {
me.reload();
});
me.autoChangeAccount = false;
+ } else if (configaccount) {
+ if (store.findExact('name', configaccount) !== -1) {
+ vm.set('account', configaccount);
+ } else {
+ vm.set('account', null);
+ }
}
},
reference: 'order',
text: gettext('Order Certificates Now'),
bind: {
- disabled: '{!accountsAvailable}',
+ disabled: '{!canOrder}',
},
handler: 'order',
},
{
xtype: 'displayfield',
reference: 'accounttext',
+ renderer: (val) => val || Proxmox.Utils.NoneText,
bind: {
value: '{account}',
hidden: '{accountTextHidden}',
// account changed, and we do not edit currently, load again to verify
if (oldaccount !== account && !vm.get('accountEditable')) {
- Proxmox.Utils.API2Request({
- url: `/cluster/acme/account/${account}`,
- waitMsgTarget: me,
- success: function(response, opt) {
- vm.set('account', account);
- },
- failure: function(response, opt) {
- vm.set('account', Proxmox.Utils.NoneText);
- },
- });
+ vm.set('configaccount', account);
+ me.lookup('accountselector').store.load();
}
for (let i = 0; i < PVE.Utils.acmedomain_count; i++) {
data.push(record);
}
+ vm.set('domaincount', data.length);
me.store.loadData(data, false);
},
me.callParent();
me.mon(me.rstore, 'load', 'updateStore', me);
Proxmox.Utils.monStoreErrors(me, me.rstore);
+ me.on('destroy', me.rstore.stopUpdate, me.rstore);
},
});