]>
git.proxmox.com Git - pve-manager.git/blob - www/manager/dc/SecurityGroups.js
1 Ext
.define('PVE.SecurityGroupEdit', {
2 extend
: 'PVE.window.Edit',
4 base_url
: "/cluster/firewall/groups",
8 initComponent : function() {
9 /*jslint confusion: true */
12 me
.create
= (me
.group_name
=== undefined);
16 me
.url
= '/api2/extjs' + me
.base_url
;
23 value
: me
.group_name
|| '',
24 fieldLabel
: gettext('Name'),
30 value
: me
.group_comment
|| '',
31 fieldLabel
: gettext('Comment')
36 subject
= gettext('Security Group');
38 subject
= gettext('Security Group') + " '" + me
.group_name
+ "'";
46 var ipanel
= Ext
.create('PVE.panel.InputPanel', {
61 Ext
.define('PVE.SecurityGroupList', {
62 extend
: 'Ext.grid.Panel',
63 alias
: 'widget.pveSecurityGroupList',
65 rule_panel
: undefined,
71 base_url
: "/cluster/firewall/groups",
73 initComponent: function() {
74 /*jslint confusion: true */
77 if (me
.rule_panel
== undefined) {
78 throw "no rule panel specified";
81 if (me
.base_url
== undefined) {
82 throw "no base_url specified";
85 var store
= new Ext
.data
.Store({
86 fields
: [ 'group', 'comment', 'digest' ],
89 url
: '/api2/json' + me
.base_url
98 var sm
= Ext
.create('Ext.selection.RowModel', {});
100 var reload = function() {
101 var oldrec
= sm
.getSelection()[0];
102 store
.load(function(records
, operation
, success
) {
104 var rec
= store
.findRecord('group', oldrec
.data
.group
);
112 var run_editor = function() {
113 var rec
= sm
.getSelection()[0];
117 var win
= Ext
.create('PVE.SecurityGroupEdit', {
118 digest
: rec
.data
.digest
,
119 group_name
: rec
.data
.group
,
120 group_comment
: rec
.data
.comment
123 win
.on('destroy', reload
);
126 me
.editBtn
= new PVE
.button
.Button({
127 text
: gettext('Edit'),
133 me
.addBtn
= new PVE
.button
.Button({
134 text
: gettext('Create'),
135 handler: function() {
137 var win
= Ext
.create('PVE.SecurityGroupEdit', {});
139 win
.on('destroy', reload
);
143 me
.removeBtn
= new PVE
.button
.Button({
144 text
: gettext('Remove'),
147 handler: function() {
148 var rec
= sm
.getSelection()[0];
149 if (!rec
|| !me
.base_url
) {
152 PVE
.Utils
.API2Request({
153 url
: me
.base_url
+ '/' + rec
.data
.group
,
156 failure: function(response
, options
) {
157 Ext
.Msg
.alert(gettext('Error'), response
.htmlStatus
);
166 tbar
: [ '<b>' + gettext('Group') + ':</b>', me
.addBtn
, me
.removeBtn
, me
.editBtn
],
169 { header
: gettext('Group'), dataIndex
: 'group', width
: 100 },
170 { header
: gettext('Comment'), dataIndex
: 'comment', renderer
: Ext
.String
.htmlEncode
, flex
: 1 }
173 itemdblclick
: run_editor
,
174 select: function(sm
, rec
) {
175 var url
= '/cluster/firewall/groups/' + rec
.data
.group
;
176 me
.rule_panel
.setBaseUrl(url
);
178 deselect: function() {
179 me
.rule_panel
.setBaseUrl(undefined);
191 Ext
.define('PVE.SecurityGroups', {
192 extend
: 'Ext.panel.Panel',
193 alias
: 'widget.pveSecurityGroups',
195 title
: 'Security Groups',
197 initComponent: function() {
200 var rule_panel
= Ext
.createWidget('pveFirewallRules', {
203 list_refs_url
: '/cluster/firewall/refs',
204 tbar_prefix
: '<b>' + gettext('Rules') + ':</b>',
209 var sglist
= Ext
.createWidget('pveSecurityGroupList', {
211 rule_panel
: rule_panel
,
220 items
: [ sglist
, rule_panel
],
223 sglist
.fireEvent('show', sglist
);