]> git.proxmox.com Git - pve-manager.git/blob - www/manager6/dc/AuthEditBase.js
ui: indentation fix
[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.authType;
19 }
20
21 return values;
22 },
23
24 initComponent: function() {
25 let me = this;
26
27 if (!me.column1) { me.column1 = []; }
28 if (!me.column2) { me.column2 = []; }
29 if (!me.columnB) { me.columnB = []; }
30
31 // first field is name
32 me.column1.unshift({
33 xtype: me.isCreate ? 'textfield' : 'displayfield',
34 name: 'realm',
35 fieldLabel: gettext('Realm'),
36 value: me.realm,
37 allowBlank: false,
38 });
39
40 // last field is default'
41 me.column1.push({
42 xtype: 'proxmoxcheckbox',
43 fieldLabel: gettext('Default'),
44 name: 'default',
45 uncheckedValue: 0,
46 });
47
48 // last field of column2is tfa
49 me.column2.push({
50 xtype: 'pveTFASelector',
51 });
52
53 me.columnB.push({
54 xtype: 'textfield',
55 name: 'comment',
56 fieldLabel: gettext('Comment'),
57 });
58
59 me.callParent();
60 },
61 });
62
63 Ext.define('PVE.dc.AuthEditBase', {
64 extend: 'Proxmox.window.Edit',
65
66 isAdd: true,
67
68 fieldDefaults: {
69 labelWidth: 120,
70 },
71
72 initComponent: function() {
73 var me = this;
74
75 me.isCreate = !me.realm;
76
77 if (me.isCreate) {
78 me.url = '/api2/extjs/access/domains';
79 me.method = 'POST';
80 } else {
81 me.url = '/api2/extjs/access/domains/' + me.realm;
82 me.method = 'PUT';
83 }
84
85 let authConfig = PVE.Utils.authSchema[me.authType];
86 if (!authConfig) {
87 throw 'unknown auth type';
88 } else if (!authConfig.add && me.isCreate) {
89 throw 'trying to add non addable realm';
90 }
91
92 me.subject = authConfig.name;
93
94 Ext.apply(me, {
95 items: [{
96 realm: me.realm,
97 xtype: authConfig.ipanel,
98 isCreate: me.isCreate,
99 type: me.authType,
100 }],
101 });
102
103 me.callParent();
104
105 if (!me.isCreate) {
106 me.load({
107 success: function(response, options) {
108 var data = response.result.data || {};
109 // just to be sure (should not happen)
110 if (data.type !== me.authType) {
111 me.close();
112 throw "got wrong auth type";
113 }
114 me.setValues(data);
115 },
116 });
117 }
118 },
119 });