]>
git.proxmox.com Git - pve-manager.git/blob - www/manager6/dc/SecurityGroups.js
26172bf359670b1f0664848633a32ecc5e96e048
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 reload = function() {
104 let oldrec
= sm
.getSelection()[0];
105 store
.load((records
, operation
, success
) => {
107 let rec
= store
.findRecord('group', oldrec
.data
.group
, 0, false, true, true);
115 let run_editor = function() {
116 let rec
= sm
.getSelection()[0];
120 Ext
.create('PVE.SecurityGroupEdit', {
121 digest
: rec
.data
.digest
,
122 group_name
: rec
.data
.group
,
123 group_comment
: rec
.data
.comment
,
125 destroy
: () => reload(),
131 me
.editBtn
= new Proxmox
.button
.Button({
132 text
: gettext('Edit'),
137 me
.addBtn
= new Proxmox
.button
.Button({
138 text
: gettext('Create'),
139 handler: function() {
141 var win
= Ext
.create('PVE.SecurityGroupEdit', {});
143 win
.on('destroy', reload
);
147 me
.removeBtn
= Ext
.create('Proxmox.button.StdRemoveButton', {
149 baseurl
: me
.base_url
+ '/',
150 enableFn: function(rec
) {
151 return rec
&& me
.base_url
;
153 callback
: () => reload(),
158 tbar
: ['<b>' + gettext('Group') + ':</b>', me
.addBtn
, me
.removeBtn
, me
.editBtn
],
162 header
: gettext('Group'),
167 header
: gettext('Comment'),
168 dataIndex
: 'comment',
169 renderer
: Ext
.String
.htmlEncode
,
174 itemdblclick
: run_editor
,
175 select: function(_sm
, rec
) {
177 me
.rulePanel
= me
.up('panel').down('pveFirewallRules');
179 me
.rulePanel
.setBaseUrl(`/cluster/firewall/groups/${rec.data.group}`);
181 deselect: function() {
183 me
.rulePanel
= me
.up('panel').down('pveFirewallRules');
185 me
.rulePanel
.setBaseUrl(undefined);
197 Ext
.define('PVE.SecurityGroups', {
198 extend
: 'Ext.panel.Panel',
199 alias
: 'widget.pveSecurityGroups',
201 title
: 'Security Groups',
202 onlineHelp
: 'pve_firewall_security_groups',
208 xtype
: 'pveFirewallRules',
211 list_refs_url
: '/cluster/firewall/refs',
212 tbar_prefix
: '<b>' + gettext('Rules') + ':</b>',
216 xtype
: 'pveSecurityGroupList',
225 let sglist
= this.down('pveSecurityGroupList');
226 sglist
.fireEvent('show', sglist
);