]> git.proxmox.com Git - pmg-gui.git/blobdiff - js/QuarantineView.js
check if load is successfull in GeneralMailStatistics
[pmg-gui.git] / js / QuarantineView.js
index 1417bc8a544fe9349b982ec0322d0036ad5cbecb..fd1e238cde2a70e0f584b4437801fc06f65a4978 100644 (file)
@@ -1,3 +1,4 @@
+/*global Proxmox*/
 Ext.define('PMG.QuarantineNavigationTree', {
     extend: 'Ext.list.Tree',
     xtype: 'quarantinenavigationtree',
@@ -9,7 +10,6 @@ Ext.define('PMG.QuarantineNavigationTree', {
     },
 
     store: {
-       xcalss: 'Ext.data.TreeStore',
        root: {
            expanded: true,
            children: [
@@ -21,15 +21,15 @@ Ext.define('PMG.QuarantineNavigationTree', {
                    children: [
                        {
                            text: gettext('Whitelist'),
-                           //iconCls: 'fa fa-cubes',
+                           iconCls: 'fa fa-file-o',
                            path: 'pmgUserWhitelist',
-                           leaf: true,
+                           leaf: true
                        },
                        {
                            text: gettext('Blacklist'),
-                           //iconCls: 'fa fa-cubes',
+                           iconCls: 'fa fa-file',
                            path: 'pmgUserBlacklist',
-                           leaf: true,
+                           leaf: true
                        }
                    ]
                }
@@ -56,8 +56,8 @@ Ext.define('PMG.QuarantineView', {
                action: 'changePath',
                before: 'beforeChangePath',
                 conditions : {
-                   ':path'    : '(?:([%a-zA-Z0-9\-\_\s,]+))',
-                   ':subpath' : '(?:(?::)([%a-zA-Z0-9\-\_\s,]+))?'
+                   ':path'    : '(?:([%a-zA-Z0-9\\-\\_\\s,]+))',
+                   ':subpath' : '(?:(?::)([%a-zA-Z0-9\\-\\_\\s,]+))?'
                }
            }
        },
@@ -79,12 +79,11 @@ Ext.define('PMG.QuarantineView', {
                subpath = subpath || 0;
                if (lastpanel.getActiveTab) {
                    // we assume lastpanel is a tabpanel
-                   if (lastpanel.getActiveTab().getItemId() === subpath) {
-                       // we are already there
-                   } else {
+                   if (lastpanel.getActiveTab().getItemId() !== subpath) {
                        // set the active tab
                        lastpanel.setActiveTab(subpath);
                    }
+                   // else we are already there
                }
                action.stop();
                return;
@@ -98,7 +97,7 @@ Ext.define('PMG.QuarantineView', {
            var contentpanel = me.lookupReference('contentpanel');
            var lastpanel = contentpanel.getLayout().getActiveItem();
 
-           var obj = contentpanel.add({ xtype: path });
+           var obj = contentpanel.add({ xtype: path, cselect: subpath });
            var treelist = me.lookupReference('navtree');
 
            treelist.suspendEvents();
@@ -136,21 +135,7 @@ Ext.define('PMG.QuarantineView', {
        },
 
        execQuarantineAction: function(qa) {
-           Proxmox.Utils.API2Request({
-               url: '/api2/extjs/quarantine/content',
-               params: {
-                   id: qa.cselect,
-                   action: qa.action
-               },
-               method: 'POST',
-               success: function(response) {
-                   Ext.Msg.alert(gettext('Info'), "Action " + qa.action + ' ' +
-                                 qa.cselect + ' successful');
-               },
-               failure: function(response, opts) {
-                   Ext.Msg.alert(gettext('Error'), response.htmlStatus);
-               }
-           });
+           PMG.Utils.doQuarantineAction(qa.action, qa.cselect);
        },
 
        control: {
@@ -163,7 +148,8 @@ Ext.define('PMG.QuarantineView', {
            var me = this;
 
            // load username
-           me.lookupReference('usernameinfo').update({username:Proxmox.UserName});
+           var username = Proxmox.UserName.replace(/\@quarantine$/, '');
+           me.lookupReference('usernameinfo').update({username: username});
 
            // show login on requestexception
            // fixme: what about other errors
@@ -174,15 +160,22 @@ Ext.define('PMG.QuarantineView', {
            });
 
            var qa = PMG.Utils.extractQuarantineAction();
+           var token;
            if (qa) {
-               var token = 'pmgSpamQuarantine';
+               token = 'pmgSpamQuarantine';
                if (qa.action === 'blacklist') { token = 'pmgUserBlacklist'; }
                if (qa.action === 'whitelist') { token = 'pmgUserWhitelist'; }
+               if (qa.cselect) {
+                   token += ':' + qa.cselect;
+               }
                this.redirectTo(token, true);
-               me.execQuarantineAction(qa);
+               if (qa.action) {
+                   me.execQuarantineAction(qa);
+               }
            } else {
                // select treeitem and load page from url fragment
-               var token = Ext.util.History.getToken() || 'pmgSpamQuarantine';
+               
+               token = Ext.util.History.getToken() || 'pmgSpamQuarantine';
                this.redirectTo(token, true);
            }
        }
@@ -190,7 +183,9 @@ Ext.define('PMG.QuarantineView', {
 
     plugins: 'viewport',
 
-    layout: 'border',
+    layout: {
+       type: 'border'
+    },
 
     items: [
        {
@@ -241,10 +236,12 @@ Ext.define('PMG.QuarantineView', {
        },
        {
            xtype: 'panel',
-           layout: 'card',
+           layout: {
+               type: 'card'
+           },
            region: 'center',
            border: false,
-           reference: 'contentpanel',
+           reference: 'contentpanel'
        }
     ]
 });