]> git.proxmox.com Git - pve-manager.git/blob - www/manager6/dc/AuthEditBase.js
ui: realm: clarify that the sync jobs really are for the realm
[pve-manager.git] / www / manager6 / dc / AuthEditBase.js
1 Ext.define('PVE.panel.AuthBase', {
2 extend: 'Proxmox.panel.InputPanel',
3 xtype: 'pveAuthBasePanel',
4
5 type: '',
6
7 onGetValues: function(values) {
8 let me = this;
9
10 if (!values.port) {
11 if (!me.isCreate) {
12 Proxmox.Utils.assemble_field_data(values, { 'delete': 'port' });
13 }
14 delete values.port;
15 }
16
17 if (me.isCreate) {
18 values.type = me.type;
19 }
20
21 return values;
22 },
23
24 initComponent: function() {
25 let me = this;
26
27 let options = PVE.Utils.authSchema[me.type];
28
29 if (!me.column1) { me.column1 = []; }
30 if (!me.column2) { me.column2 = []; }
31 if (!me.columnB) { me.columnB = []; }
32
33 // first field is name
34 me.column1.unshift({
35 xtype: me.isCreate ? 'textfield' : 'displayfield',
36 name: 'realm',
37 fieldLabel: gettext('Realm'),
38 value: me.realm,
39 allowBlank: false,
40 });
41
42 // last field is default'
43 me.column1.push({
44 xtype: 'proxmoxcheckbox',
45 fieldLabel: gettext('Default'),
46 name: 'default',
47 uncheckedValue: 0,
48 });
49
50 if (options.tfa) {
51 // last field of column2is tfa
52 me.column2.push({
53 xtype: 'pveTFASelector',
54 deleteEmpty: !me.isCreate,
55 });
56 }
57
58 me.columnB.push({
59 xtype: 'textfield',
60 name: 'comment',
61 fieldLabel: gettext('Comment'),
62 });
63
64 me.callParent();
65 },
66 });
67
68 Ext.define('PVE.dc.AuthEditBase', {
69 extend: 'Proxmox.window.Edit',
70
71 onlineHelp: 'pveum_authentication_realms',
72
73 isAdd: true,
74
75 fieldDefaults: {
76 labelWidth: 120,
77 },
78
79 initComponent: function() {
80 var me = this;
81
82 me.isCreate = !me.realm;
83
84 if (me.isCreate) {
85 me.url = '/api2/extjs/access/domains';
86 me.method = 'POST';
87 } else {
88 me.url = '/api2/extjs/access/domains/' + me.realm;
89 me.method = 'PUT';
90 }
91
92 let authConfig = PVE.Utils.authSchema[me.authType];
93 if (!authConfig) {
94 throw 'unknown auth type';
95 } else if (!authConfig.add && me.isCreate) {
96 throw 'trying to add non addable realm';
97 }
98
99 me.subject = authConfig.name;
100
101 let items;
102 let bodyPadding;
103 if (authConfig.syncipanel) {
104 bodyPadding = 0;
105 items = {
106 xtype: 'tabpanel',
107 region: 'center',
108 layout: 'fit',
109 bodyPadding: 10,
110 items: [
111 {
112 title: gettext('General'),
113 realm: me.realm,
114 xtype: authConfig.ipanel,
115 isCreate: me.isCreate,
116 type: me.authType,
117 },
118 {
119 title: gettext('Sync Options'),
120 realm: me.realm,
121 xtype: authConfig.syncipanel,
122 isCreate: me.isCreate,
123 type: me.authType,
124 },
125 ],
126 };
127 } else {
128 items = [{
129 realm: me.realm,
130 xtype: authConfig.ipanel,
131 isCreate: me.isCreate,
132 type: me.authType,
133 }];
134 }
135
136 Ext.apply(me, {
137 items,
138 bodyPadding,
139 });
140
141 me.callParent();
142
143 if (!me.isCreate) {
144 me.load({
145 success: function(response, options) {
146 var data = response.result.data || {};
147 // just to be sure (should not happen)
148 if (data.type !== me.authType) {
149 me.close();
150 throw "got wrong auth type";
151 }
152 me.setValues(data);
153 },
154 });
155 }
156 },
157 });