]> 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 a28fa875b73c3197966d555ff10261a8c8c7f333..82e4c30157a2800f8362a4f5dc28cbbccd444ffb 100644 (file)
@@ -1,7 +1,6 @@
 /*global Proxmox*/
 /*jslint confusion: true*/
-/* create is a function and boolean,
- * bind is a function and object,
+/* bind is a function and object,
  * callback is a function and string
  */
 Ext.define('pmg-rule-list', {
@@ -31,7 +30,7 @@ Ext.define('PMG.RulesConfiguration', {
        selectedRuleChange: function(grid, selected, eOpts) {
            var me = this;
            var infoPanel = me.lookupReference('infopanel');
-           var baseurl;
+           var baseurl = '';
 
            if (selected.length > 0) {
                baseurl = '/config/ruledb/rules/' + selected[0].data.id;
@@ -86,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();
@@ -97,6 +96,32 @@ 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);
@@ -148,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'
                    }
                ]
            },