mirror of
https://git.proxmox.com/git/proxmox-widget-toolkit
synced 2025-05-24 01:44:44 +00:00
add Realm model and RealmComboBox
copied from pve-manager, with adaptions for modern js (let, parameter destructuring,...) and dropped the not needed 'needOTP' method Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
82014ef6f1
commit
0391dee1a2
2
Makefile
2
Makefile
@ -16,6 +16,7 @@ JSSRC= \
|
|||||||
data/ObjectStore.js \
|
data/ObjectStore.js \
|
||||||
data/RRDStore.js \
|
data/RRDStore.js \
|
||||||
data/TimezoneStore.js \
|
data/TimezoneStore.js \
|
||||||
|
data/model/Realm.js \
|
||||||
form/DisplayEdit.js \
|
form/DisplayEdit.js \
|
||||||
form/ExpireDate.js \
|
form/ExpireDate.js \
|
||||||
form/IntegerField.js \
|
form/IntegerField.js \
|
||||||
@ -28,6 +29,7 @@ JSSRC= \
|
|||||||
form/RRDTypeSelector.js \
|
form/RRDTypeSelector.js \
|
||||||
form/BondModeSelector.js \
|
form/BondModeSelector.js \
|
||||||
form/NetworkSelector.js \
|
form/NetworkSelector.js \
|
||||||
|
form/RealmComboBox.js \
|
||||||
button/Button.js \
|
button/Button.js \
|
||||||
button/HelpButton.js \
|
button/HelpButton.js \
|
||||||
grid/ObjectGrid.js \
|
grid/ObjectGrid.js \
|
||||||
|
29
data/model/Realm.js
Normal file
29
data/model/Realm.js
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
Ext.define('pmx-domains', {
|
||||||
|
extend: "Ext.data.Model",
|
||||||
|
fields: [
|
||||||
|
'realm', 'type', 'comment', 'default',
|
||||||
|
{
|
||||||
|
name: 'tfa',
|
||||||
|
allowNull: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'descr',
|
||||||
|
convert: function(value, { data={} }) {
|
||||||
|
if (value) return Ext.String.htmlEncode(value);
|
||||||
|
|
||||||
|
let text = data.comment || data.realm;
|
||||||
|
|
||||||
|
if (data.tfa) {
|
||||||
|
text += ` (+ ${data.tfa})`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ext.String.htmlEncode(text);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
idProperty: 'realm',
|
||||||
|
proxy: {
|
||||||
|
type: 'proxmox',
|
||||||
|
url: "/api2/json/access/domains",
|
||||||
|
},
|
||||||
|
});
|
57
form/RealmComboBox.js
Normal file
57
form/RealmComboBox.js
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
Ext.define('Proxmox.form.RealmComboBox', {
|
||||||
|
extend: 'Ext.form.field.ComboBox',
|
||||||
|
alias: 'widget.pmxRealmComboBox',
|
||||||
|
|
||||||
|
controller: {
|
||||||
|
xclass: 'Ext.app.ViewController',
|
||||||
|
|
||||||
|
init: function(view) {
|
||||||
|
view.store.on('load', this.onLoad, view);
|
||||||
|
},
|
||||||
|
|
||||||
|
onLoad: function(store, records, success) {
|
||||||
|
if (!success) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var me = this;
|
||||||
|
var val = me.getValue();
|
||||||
|
if (!val || !me.store.findRecord('realm', val)) {
|
||||||
|
var def = 'pam';
|
||||||
|
Ext.each(records, function(rec) {
|
||||||
|
if (rec.data && rec.data.default) {
|
||||||
|
def = rec.data.realm;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
me.setValue(def);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
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',
|
||||||
|
|
||||||
|
store: {
|
||||||
|
model: 'pmx-domains',
|
||||||
|
autoLoad: true,
|
||||||
|
},
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user