]>
git.proxmox.com Git - pmg-gui.git/blob - js/RuleConfiguration.js
2 /*jslint confusion: true*/
3 /* create is a function and boolean,
4 * bind is a function and object,
5 * callback is a function and string
7 Ext
.define('pmg-rule-list', {
8 extend
: 'Ext.data.Model',
11 { name
: 'active', type
: 'boolean' },
12 { name
: 'direction', type
: 'integer' },
13 { name
: 'priority', type
: 'integer' }
18 Ext
.define('PMG.RulesConfiguration', {
19 extend
: 'Ext.container.Container',
20 xtype
: 'pmgRuleConfiguration',
29 xclass
: 'Ext.app.ViewController',
31 selectedRuleChange: function(grid
, selected
, eOpts
) {
33 var infoPanel
= me
.lookupReference('infopanel');
36 if (selected
.length
> 0) {
37 baseurl
= '/config/ruledb/rules/' + selected
[0].data
.id
;
40 infoPanel
.getController().setBaseUrl(baseurl
);
43 editIconClick: function(gridView
, rowindex
, colindex
, column
, e
, record
) {
45 me
.showEditWindow(gridView
, record
);
48 showEditWindow: function(gridView
, record
) {
50 var win
= Ext
.create('PMG.RuleEditor', {
51 url
: '/api2/extjs/config/ruledb/rules/' + record
.data
.id
+ '/config',
54 gridView
.getStore().load();
62 toggleIconClick: function(gridView
, rowindex
, colindex
, column
, e
, record
) {
64 Proxmox
.Utils
.API2Request({
65 url
: '/config/ruledb/rules/' + record
.data
.id
+ '/config',
67 active
: record
.data
.active
? 0 : 1
70 callback: function() {
71 gridView
.getStore().load();
73 failure: function(response
, opts
) {
74 Ext
.Msg
.alert(gettext('Error'), response
.htmlStatus
);
81 me
.lookupReference('rulegrid').getStore().load();
86 var win
= Ext
.create('PMG.RuleEditor', {
87 url
: '/api2/extjs/config/ruledb/rules/',
92 me
.lookupReference('rulegrid').getStore().load();
100 init: function(view
) {
101 var grid
= this.lookupReference('rulegrid');
102 Proxmox
.Utils
.monStoreErrors(grid
, grid
.getStore(), true);
106 'grid[reference=rulegrid]': {
107 itemdblclick
: 'showEditWindow',
108 selectionchange
: 'selectedRuleChange'
110 'button[reference=addButton]': {
118 selectedRule
: undefined,
119 baseUrl
: '/config/ruledb/rules'
128 reference
: 'rulegrid',
132 selection
: '{selectedRule}'
141 text
: gettext('Add'),
142 iconCls
: 'fa fa-plus-circle',
143 reference
: 'addButton'
146 xtype
: 'proxmoxStdRemoveButton',
147 text
: gettext('Remove'),
148 iconCls
: 'fa fa-minus-circle',
149 reference
: 'removeButton',
151 getRecordName: function(rec
) { return rec
.data
.name
; },
160 getRowClass: function(record
, rowIndex
) {
161 return record
.get('active') ? 'enabled' : 'disabled';
167 model
: 'pmg-rule-list',
168 reference
: 'rulesStore',
171 url
: '/api2/json/config/ruledb/rules'
175 property
: 'priority',
184 sortableColumns
: false,
198 dataIndex
: 'priority'
202 dataIndex
: 'direction',
203 renderer
: PMG
.Utils
.format_rule_direction
207 xtype
: 'actioncolumn',
212 iconCls
: 'fa fa-fw fa-pencil',
214 handler
: 'editIconClick'
217 getClass: function(val
, meta
, rec
) {
218 return 'fa fa-fw fa-' + (rec
.get('active') ? 'toggle-on' : 'toggle-off');
220 getTip: function(val
, meta
, rec
) {
221 return (rec
.get('active') ? 'Deactivate' : 'Activate');
223 handler
: 'toggleIconClick'
231 reference
: 'infopanel',
232 xtype
: 'pmgRuleInfo',