mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-06-03 21:20:56 +00:00

since most people do not have many login realms to choose from, making this search/editable makes no sense but by making this non-editable, you can now click anywhere on the text to open the options, instead of only the little arrow Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
64 lines
1.5 KiB
JavaScript
64 lines
1.5 KiB
JavaScript
Ext.define('PVE.form.RealmComboBox', {
|
|
extend: 'Ext.form.field.ComboBox',
|
|
alias: ['widget.pveRealmComboBox'],
|
|
|
|
fieldLabel: gettext('Realm'),
|
|
name: 'realm',
|
|
queryMode: 'local',
|
|
allowBlank: false,
|
|
editable: false,
|
|
forceSelection: true,
|
|
autoSelect: false,
|
|
triggerAction: 'all',
|
|
valueField: 'realm',
|
|
displayField: 'descr',
|
|
getState: function() {
|
|
return { value: this.getValue() };
|
|
},
|
|
applyState : function(state) {
|
|
if (state && state.value) {
|
|
this.setValue(state.value);
|
|
}
|
|
},
|
|
stateEvents: [ 'select' ],
|
|
stateful: true, // last chosen auth realm is saved between page reloads
|
|
id: 'pveloginrealm', // We need stable ids when using stateful, not autogenerated
|
|
stateID: 'pveloginrealm',
|
|
|
|
needOTP: function(realm) {
|
|
var me = this;
|
|
// use exact match
|
|
var rec = me.store.findRecord('realm', realm, 0, false, false, true);
|
|
return rec && rec.data && rec.data.tfa ? rec.data.tfa : undefined;
|
|
},
|
|
|
|
initComponent: function() {
|
|
var me = this;
|
|
|
|
me.store = Ext.create('Ext.data.Store', {
|
|
model: 'pve-domains'
|
|
});
|
|
|
|
me.callParent();
|
|
|
|
me.store.load({
|
|
callback: function(r, o, success) {
|
|
if (success) {
|
|
var def = me.getValue();
|
|
if (!def || !me.store.findRecord('realm', def)) {
|
|
def = 'pam';
|
|
Ext.each(r, function(record) {
|
|
if (record.data && record.data["default"]) {
|
|
def = record.data.realm;
|
|
}
|
|
});
|
|
}
|
|
if (def) {
|
|
me.setValue(def);
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
});
|