]>
git.proxmox.com Git - pve-manager.git/blob - www/manager6/dc/SecurityGroups.js
1 Ext
.define('pve-security-groups', {
2 extend
: 'Ext.data.Model',
4 fields
: ['group', 'comment', 'digest'],
8 Ext
.define('PVE.SecurityGroupEdit', {
9 extend
: 'Proxmox.window.Edit',
11 base_url
: "/cluster/firewall/groups",
15 initComponent: function() {
18 me
.isCreate
= me
.group_name
=== undefined;
22 me
.url
= '/api2/extjs' + me
.base_url
;
29 value
: me
.group_name
|| '',
30 fieldLabel
: gettext('Name'),
36 value
: me
.group_comment
|| '',
37 fieldLabel
: gettext('Comment'),
42 subject
= gettext('Security Group');
44 subject
= gettext('Security Group') + " '" + me
.group_name
+ "'";
52 var ipanel
= Ext
.create('Proxmox.panel.InputPanel', {
53 // InputPanel does not have a 'create' property, does it need a 'isCreate'
54 isCreate
: me
.isCreate
,
68 Ext
.define('PVE.SecurityGroupList', {
69 extend
: 'Ext.grid.Panel',
70 alias
: 'widget.pveSecurityGroupList',
73 stateId
: 'grid-securitygroups',
81 base_url
: "/cluster/firewall/groups",
83 initComponent: function() {
86 throw "no base_url specified";
89 let store
= new Ext
.data
.Store({
90 model
: 'pve-security-groups',
93 url
: '/api2/json' + me
.base_url
,
101 let sm
= Ext
.create('Ext.selection.RowModel', {});
103 let caps
= Ext
.state
.Manager
.get('GuiCap');
105 let reload = function() {
106 let oldrec
= sm
.getSelection()[0];
107 store
.load((records
, operation
, success
) => {
109 let rec
= store
.findRecord('group', oldrec
.data
.group
, 0, false, true, true);
117 let run_editor = function() {
118 let rec
= sm
.getSelection()[0];
122 Ext
.create('PVE.SecurityGroupEdit', {
123 digest
: rec
.data
.digest
,
124 group_name
: rec
.data
.group
,
125 group_comment
: rec
.data
.comment
,
127 destroy
: () => reload(),
133 me
.editBtn
= new Proxmox
.button
.Button({
134 text
: gettext('Edit'),
135 enableFn
: rec
=> !!caps
.dc
['Sys.Modify'],
140 me
.addBtn
= new Proxmox
.button
.Button({
141 text
: gettext('Create'),
142 disabled
: !caps
.dc
['Sys.Modify'],
143 handler: function() {
145 var win
= Ext
.create('PVE.SecurityGroupEdit', {});
147 win
.on('destroy', reload
);
151 me
.removeBtn
= Ext
.create('Proxmox.button.StdRemoveButton', {
153 baseurl
: me
.base_url
+ '/',
154 enableFn: function(rec
) {
155 if (!caps
.dc
['Sys.Modify']) {
158 return rec
&& me
.base_url
;
160 callback
: () => reload(),
165 tbar
: ['<b>' + gettext('Group') + ':</b>', me
.addBtn
, me
.removeBtn
, me
.editBtn
],
169 header
: gettext('Group'),
174 header
: gettext('Comment'),
175 dataIndex
: 'comment',
176 renderer
: Ext
.String
.htmlEncode
,
181 itemdblclick
: run_editor
,
182 select: function(_sm
, rec
) {
184 me
.rulePanel
= me
.up('panel').down('pveFirewallRules');
186 me
.rulePanel
.setBaseUrl(`/cluster/firewall/groups/${rec.data.group}`);
188 deselect: function() {
190 me
.rulePanel
= me
.up('panel').down('pveFirewallRules');
192 me
.rulePanel
.setBaseUrl(undefined);
204 Ext
.define('PVE.SecurityGroups', {
205 extend
: 'Ext.panel.Panel',
206 alias
: 'widget.pveSecurityGroups',
208 title
: 'Security Groups',
209 onlineHelp
: 'pve_firewall_security_groups',
215 xtype
: 'pveFirewallRules',
218 list_refs_url
: '/cluster/firewall/refs',
219 tbar_prefix
: '<b>' + gettext('Rules') + ':</b>',
223 xtype
: 'pveSecurityGroupList',
232 let sglist
= this.down('pveSecurityGroupList');
233 sglist
.fireEvent('show', sglist
);