]> git.proxmox.com Git - pmg-gui.git/blobdiff - js/RuleConfiguration.js
utils: fix typo in url
[pmg-gui.git] / js / RuleConfiguration.js
index 94b19d45a4c2db1eeaaf6895f1ea6949e1737ed4..1209b1d587a86fefc5517e043d86790caf04a53b 100644 (file)
@@ -1,18 +1,12 @@
-/*global Proxmox*/
-/*jslint confusion: true*/
-/* create is a function and boolean,
- * bind is a function and object,
- * callback is a function and string
- */
 Ext.define('pmg-rule-list', {
     extend: 'Ext.data.Model',
     fields: [
        'id', 'name',
        { name: 'active', type: 'boolean' },
        { name: 'direction', type: 'integer' },
-       { name: 'priority', type: 'integer' }
+       { name: 'priority', type: 'integer' },
     ],
-    idProperty: 'id'
+    idProperty: 'id',
 });
 
 Ext.define('PMG.RulesConfiguration', {
@@ -22,49 +16,49 @@ Ext.define('PMG.RulesConfiguration', {
     layout: 'border',
     border: false,
     defaults: {
-       border: false
+       border: false,
     },
 
     controller: {
        xclass: 'Ext.app.ViewController',
 
        selectedRuleChange: function(grid, selected, eOpts) {
-           var me = this;
-           var infoPanel = me.lookupReference('infopanel');
-           var baseurl = '';
+           let me = this;
+           let infoPanel = me.lookupReference('infopanel');
+           let baseurl = '';
 
            if (selected.length > 0) {
-               baseurl = '/config/ruledb/rules/' + selected[0].data.id;
+               baseurl = `/config/ruledb/rules/${selected[0].data.id}`;
            }
 
            infoPanel.getController().setBaseUrl(baseurl);
        },
 
        editIconClick: function(gridView, rowindex, colindex, column, e, record) {
-           var me = this;
+           let me = this;
            me.showEditWindow(gridView, record);
        },
 
        showEditWindow: function(gridView, record) {
-           var me = this;
-           var win = Ext.create('PMG.RuleEditor', {
-               url: '/api2/extjs/config/ruledb/rules/' + record.data.id + '/config',
+           let me = this;
+           let win = Ext.create('PMG.RuleEditor', {
+               url: `/api2/extjs/config/ruledb/rules/${record.data.id}/config`,
                listeners: {
                    destroy: function() {
                        gridView.getStore().load();
-                   }
-               }
+                   },
+               },
            });
            win.load();
            win.show();
        },
 
        toggleIconClick: function(gridView, rowindex, colindex, column, e, record) {
-           var me = this;
+           let me = this;
            Proxmox.Utils.API2Request({
-               url: '/config/ruledb/rules/' + record.data.id + '/config',
+               url: `/config/ruledb/rules/${record.data.id}/config`,
                params: {
-                   active: record.data.active ? 0 : 1
+                   active: record.data.active ? 0 : 1,
                },
                method: 'PUT',
                callback: function() {
@@ -72,33 +66,33 @@ Ext.define('PMG.RulesConfiguration', {
                },
                failure: function(response, opts) {
                    Ext.Msg.alert(gettext('Error'), response.htmlStatus);
-               }
+               },
            });
        },
 
-       reload: function(){
-           var me = this;
+       reload: function() {
+           let me = this;
            me.lookupReference('rulegrid').getStore().load();
        },
 
        addRule: function() {
-           var me = this;
-           var win = Ext.create('PMG.RuleEditor', {
+           let me = this;
+           let win = Ext.create('PMG.RuleEditor', {
                url: '/api2/extjs/config/ruledb/rules/',
                method: 'POST',
-               create: true,
+               isCreate: true,
                listeners: {
                    destroy: function() {
                        me.lookupReference('rulegrid').getStore().load();
-                   }
-               }
+                   },
+               },
            });
            win.load();
            win.show();
        },
 
        onFactoryDefaults: function() {
-           var me = this;
+           let me = this;
 
            Ext.Msg.confirm(
                gettext('Confirm'),
@@ -107,7 +101,6 @@ Ext.define('PMG.RulesConfiguration', {
                    if (button !== 'yes') {
                        return;
                    }
-                   var url = '/config/ruledb';
                    Proxmox.Utils.API2Request({
                        url: '/config/ruledb',
                        method: 'POST',
@@ -115,35 +108,35 @@ Ext.define('PMG.RulesConfiguration', {
                        callback: function() {
                            me.reload();
                        },
-                       failure: function (response, opts) {
+                       failure: function(response, opts) {
                            Ext.Msg.alert(gettext('Error'), response.htmlStatus);
-                       }
+                       },
                    });
-               }
+               },
            );
        },
 
        init: function(view) {
-           var grid = this.lookupReference('rulegrid');
+           let grid = this.lookupReference('rulegrid');
            Proxmox.Utils.monStoreErrors(grid, grid.getStore(), true);
        },
 
        control: {
            'grid[reference=rulegrid]': {
                itemdblclick: 'showEditWindow',
-               selectionchange: 'selectedRuleChange'
+               selectionchange: 'selectedRuleChange',
            },
            'button[reference=addButton]': {
-               click: 'addRule'
-           }
-       }
+               click: 'addRule',
+           },
+       },
     },
 
     viewModel: {
        data: {
            selectedRule: undefined,
-           baseUrl: '/config/ruledb/rules'
-       }
+           baseUrl: '/config/ruledb/rules',
+       },
     },
 
     items: [
@@ -155,10 +148,10 @@ Ext.define('PMG.RulesConfiguration', {
            region: 'center',
 
            bind: {
-               selection: '{selectedRule}'
+               selection: '{selectedRule}',
            },
 
-           dockedItems:{
+           dockedItems: {
                xtype: 'toolbar',
                reference: 'mytb',
                items: [
@@ -166,7 +159,7 @@ Ext.define('PMG.RulesConfiguration', {
                        xtype: 'button',
                        text: gettext('Add'),
                        iconCls: 'fa fa-plus-circle',
-                       reference: 'addButton'
+                       reference: 'addButton',
                    },
                    {
                        xtype: 'proxmoxStdRemoveButton',
@@ -176,21 +169,21 @@ Ext.define('PMG.RulesConfiguration', {
                        callback: 'reload',
                        getRecordName: function(rec) { return rec.data.name; },
                        bind: {
-                           baseurl: '{baseUrl}'
-                       }
+                           baseurl: '{baseUrl}',
+                       },
                    },
                    '->',
                    {
                        text: gettext('Factory Defaults'),
-                       handler: 'onFactoryDefaults'
-                   }
-               ]
+                       handler: 'onFactoryDefaults',
+                   },
+               ],
            },
 
            viewConfig: {
                getRowClass: function(record, rowIndex) {
                    return record.get('active') ? 'enabled' : 'disabled';
-               }
+               },
            },
 
            store: {
@@ -199,17 +192,17 @@ Ext.define('PMG.RulesConfiguration', {
                reference: 'rulesStore',
                proxy: {
                    type: 'proxmox',
-                   url: '/api2/json/config/ruledb/rules'
+                   url: '/api2/json/config/ruledb/rules',
                },
                sorters: [
                    {
                        property: 'priority',
-                       direction: 'DESC'
+                       direction: 'DESC',
                    },
                    {
-                       property: 'name'
-                   }
-               ]
+                       property: 'name',
+                   },
+               ],
            },
 
            sortableColumns: false,
@@ -217,21 +210,22 @@ Ext.define('PMG.RulesConfiguration', {
                {
                    text: 'Active',
                    dataIndex: 'active',
-                   hidden : true
+                   hidden: true,
                },
                {
                    text: 'Name',
                    dataIndex: 'name',
-                   flex: 1
+                   flex: 1,
+                   renderer: Ext.htmlEncode,
                },
                {
                    text: 'Priority',
-                   dataIndex: 'priority'
+                   dataIndex: 'priority',
                },
                {
                    text: 'Direction',
                    dataIndex: 'direction',
-                   renderer: PMG.Utils.format_rule_direction
+                   renderer: PMG.Utils.format_rule_direction,
                },
                {
                    text: '',
@@ -242,27 +236,27 @@ Ext.define('PMG.RulesConfiguration', {
                        {
                            iconCls: 'fa fa-fw fa-pencil',
                            tooltip: 'Edit',
-                           handler: 'editIconClick'
+                           handler: 'editIconClick',
                        },
                        {
                            getClass: function(val, meta, rec) {
                                return 'fa fa-fw fa-' + (rec.get('active') ? 'toggle-on' : 'toggle-off');
                            },
                            getTip: function(val, meta, rec) {
-                               return (rec.get('active') ? 'Deactivate' : 'Activate');
+                               return rec.get('active') ? 'Deactivate' : 'Activate';
                            },
-                           handler: 'toggleIconClick'
-                       }
-                   ]
-               }
-           ]
+                           handler: 'toggleIconClick',
+                       },
+                   ],
+               },
+           ],
        },
        {
            region: 'east',
            reference: 'infopanel',
            xtype: 'pmgRuleInfo',
            split: true,
-           width: 440
-       }
-    ]
+           width: 440,
+       },
+    ],
 });