mirror of
https://git.proxmox.com/git/proxmox-widget-toolkit
synced 2025-10-17 16:11:08 +00:00
add window/AuthEditBase from PVE
basically a straight copy, with the exception that it references Proxmox.Utils.authSchema instead of PVE.Utils.authSchema Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
e455399aef
commit
6a504e1995
@ -71,6 +71,7 @@ JSSRC= \
|
||||
window/ACMEPluginEdit.js \
|
||||
window/ACMEDomains.js \
|
||||
window/FileBrowser.js \
|
||||
window/AuthEditBase.js \
|
||||
node/APT.js \
|
||||
node/APTRepositories.js \
|
||||
node/NetworkEdit.js \
|
||||
|
88
src/window/AuthEditBase.js
Normal file
88
src/window/AuthEditBase.js
Normal file
@ -0,0 +1,88 @@
|
||||
Ext.define('Proxmox.window.AuthEditBase', {
|
||||
extend: 'Proxmox.window.Edit',
|
||||
|
||||
isAdd: true,
|
||||
|
||||
fieldDefaults: {
|
||||
labelWidth: 120,
|
||||
},
|
||||
|
||||
initComponent: function() {
|
||||
var me = this;
|
||||
|
||||
me.isCreate = !me.realm;
|
||||
|
||||
if (me.isCreate) {
|
||||
me.url = '/api2/extjs/access/domains';
|
||||
me.method = 'POST';
|
||||
} else {
|
||||
me.url = '/api2/extjs/access/domains/' + me.realm;
|
||||
me.method = 'PUT';
|
||||
}
|
||||
|
||||
let authConfig = Proxmox.Utils.authSchema[me.authType];
|
||||
if (!authConfig) {
|
||||
throw 'unknown auth type';
|
||||
} else if (!authConfig.add && me.isCreate) {
|
||||
throw 'trying to add non addable realm';
|
||||
}
|
||||
|
||||
me.subject = authConfig.name;
|
||||
|
||||
let items;
|
||||
let bodyPadding;
|
||||
if (authConfig.syncipanel) {
|
||||
bodyPadding = 0;
|
||||
items = {
|
||||
xtype: 'tabpanel',
|
||||
region: 'center',
|
||||
layout: 'fit',
|
||||
bodyPadding: 10,
|
||||
items: [
|
||||
{
|
||||
title: gettext('General'),
|
||||
realm: me.realm,
|
||||
xtype: authConfig.ipanel,
|
||||
isCreate: me.isCreate,
|
||||
type: me.authType,
|
||||
},
|
||||
{
|
||||
title: gettext('Sync Options'),
|
||||
realm: me.realm,
|
||||
xtype: authConfig.syncipanel,
|
||||
isCreate: me.isCreate,
|
||||
type: me.authType,
|
||||
},
|
||||
],
|
||||
};
|
||||
} else {
|
||||
items = [{
|
||||
realm: me.realm,
|
||||
xtype: authConfig.ipanel,
|
||||
isCreate: me.isCreate,
|
||||
type: me.authType,
|
||||
}];
|
||||
}
|
||||
|
||||
Ext.apply(me, {
|
||||
items,
|
||||
bodyPadding,
|
||||
});
|
||||
|
||||
me.callParent();
|
||||
|
||||
if (!me.isCreate) {
|
||||
me.load({
|
||||
success: function(response, options) {
|
||||
var data = response.result.data || {};
|
||||
// just to be sure (should not happen)
|
||||
if (data.type !== me.authType) {
|
||||
me.close();
|
||||
throw "got wrong auth type";
|
||||
}
|
||||
me.setValues(data);
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
Loading…
Reference in New Issue
Block a user