]> git.proxmox.com Git - pmg-gui.git/blobdiff - js/RuleConfiguration.js
fix bug #1707: use correct units for deferred mail queue (minutes)
[pmg-gui.git] / js / RuleConfiguration.js
index 435c08ce0fa4f93525d6f7c929f0ccb68fd5773a..82e4c30157a2800f8362a4f5dc28cbbccd444ffb 100644 (file)
@@ -1,3 +1,8 @@
+/*global Proxmox*/
+/*jslint confusion: true*/
+/* bind is a function and object,
+ * callback is a function and string
+ */
 Ext.define('pmg-rule-list', {
     extend: 'Ext.data.Model',
     fields: [
@@ -16,7 +21,7 @@ Ext.define('PMG.RulesConfiguration', {
     layout: 'border',
     border: false,
     defaults: {
-       border: false,
+       border: false
     },
 
     controller: {
@@ -25,7 +30,7 @@ Ext.define('PMG.RulesConfiguration', {
        selectedRuleChange: function(grid, selected, eOpts) {
            var me = this;
            var infoPanel = me.lookupReference('infopanel');
-           var baseurl = undefined;
+           var baseurl = '';
 
            if (selected.length > 0) {
                baseurl = '/config/ruledb/rules/' + selected[0].data.id;
@@ -80,7 +85,7 @@ Ext.define('PMG.RulesConfiguration', {
            var 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();
@@ -91,6 +96,37 @@ Ext.define('PMG.RulesConfiguration', {
            win.show();
        },
 
+       onFactoryDefaults: function() {
+           var me = this;
+
+           Ext.Msg.confirm(
+               gettext('Confirm'),
+               gettext('Reset rule database to factory defaults?'),
+               function(button) {
+                   if (button !== 'yes') {
+                       return;
+                   }
+                   var url = '/config/ruledb';
+                   Proxmox.Utils.API2Request({
+                       url: '/config/ruledb',
+                       method: 'POST',
+                       waitMsgTarget: me.getView(),
+                       callback: function() {
+                           me.reload();
+                       },
+                       failure: function (response, opts) {
+                           Ext.Msg.alert(gettext('Error'), response.htmlStatus);
+                       }
+                   });
+               }
+           );
+       },
+
+       init: function(view) {
+           var grid = this.lookupReference('rulegrid');
+           Proxmox.Utils.monStoreErrors(grid, grid.getStore(), true);
+       },
+
        control: {
            'grid[reference=rulegrid]': {
                itemdblclick: 'showEditWindow',
@@ -106,7 +142,7 @@ Ext.define('PMG.RulesConfiguration', {
        data: {
            selectedRule: undefined,
            baseUrl: '/config/ruledb/rules'
-       },
+       }
     },
 
     items: [
@@ -129,7 +165,7 @@ Ext.define('PMG.RulesConfiguration', {
                        xtype: 'button',
                        text: gettext('Add'),
                        iconCls: 'fa fa-plus-circle',
-                       reference: 'addButton',
+                       reference: 'addButton'
                    },
                    {
                        xtype: 'proxmoxStdRemoveButton',
@@ -137,10 +173,15 @@ Ext.define('PMG.RulesConfiguration', {
                        iconCls: 'fa fa-minus-circle',
                        reference: 'removeButton',
                        callback: 'reload',
-                       getRecordName: function(rec) { return rec.data.name },
+                       getRecordName: function(rec) { return rec.data.name; },
                        bind: {
                            baseurl: '{baseUrl}'
                        }
+                   },
+                   '->',
+                   {
+                       text: gettext('Factory Defaults'),
+                       handler: 'onFactoryDefaults'
                    }
                ]
            },
@@ -165,7 +206,7 @@ Ext.define('PMG.RulesConfiguration', {
                        direction: 'DESC'
                    },
                    {
-                       property: 'name',
+                       property: 'name'
                    }
                ]
            },
@@ -175,16 +216,16 @@ Ext.define('PMG.RulesConfiguration', {
                {
                    text: 'Active',
                    dataIndex: 'active',
-                   hidden : true,
+                   hidden : true
                },
                {
                    text: 'Name',
                    dataIndex: 'name',
-                   flex: 1,
+                   flex: 1
                },
                {
                    text: 'Priority',
-                   dataIndex: 'priority',
+                   dataIndex: 'priority'
                },
                {
                    text: 'Direction',
@@ -192,33 +233,35 @@ Ext.define('PMG.RulesConfiguration', {
                    renderer: PMG.Utils.format_rule_direction
                },
                {
-                   text: 'Actions',
+                   text: '',
                    xtype: 'actioncolumn',
+                   align: 'center',
+                   width: 70,
                    items: [
                        {
-                           iconCls: 'x-fa fa-fw fa-pencil',
+                           iconCls: 'fa fa-fw fa-pencil',
                            tooltip: 'Edit',
                            handler: 'editIconClick'
                        },
                        {
                            getClass: function(val, meta, rec) {
-                               return 'x-fa fa-fw fa-' + (rec.get('active') ? 'toggle-on' : 'toggle-off');
+                               return 'fa fa-fw fa-' + (rec.get('active') ? 'toggle-on' : 'toggle-off');
                            },
                            getTip: function(val, meta, rec) {
                                return (rec.get('active') ? 'Deactivate' : 'Activate');
                            },
                            handler: 'toggleIconClick'
-                       },
+                       }
                    ]
                }
-           ],
+           ]
        },
        {
            region: 'east',
            reference: 'infopanel',
            xtype: 'pmgRuleInfo',
            split: true,
-           width: 440,
+           width: 440
        }
     ]
 });