]> git.proxmox.com Git - pmg-gui.git/blobdiff - js/SpamInfoGrid.js
quarantines: mail filter: add clear trigger
[pmg-gui.git] / js / SpamInfoGrid.js
index dee33cbcb2335cc3f1cb5843d40d9eccdf533526..a806ea30578d9479d521a7f45d4428829d624cf3 100644 (file)
@@ -13,13 +13,13 @@ Ext.define('PMG.grid.SpamInfoGrid', {
     },
 
     setID: function(rec) {
-       var me = this;
-       if (!rec || !rec.data || !rec.data.id) {
+       let me = this;
+       let id = rec?.data?.id;
+       if (!id) {
            me.getStore().removeAll();
            return;
        }
-       var url = '/api2/json/quarantine/content?id=' + rec.data.id;
-       me.store.proxy.setUrl(url);
+       me.store.proxy.setUrl(`/api2/json/quarantine/content?id=${id}`);
        me.store.load();
     },
 
@@ -34,31 +34,41 @@ Ext.define('PMG.grid.SpamInfoGrid', {
        {
            text: gettext('Test Name'),
            dataIndex: 'name',
-           flex: 2,
+           flex: 1,
            summaryType: 'count',
-           summaryRenderer: function(value, summaryData, dataIndex, metaData) {
-               return gettext('Spamscore');
-           },
+           summaryRenderer: _v => gettext('Spamscore'),
+           tdCls: 'txt-monospace',
        },
        {
            text: gettext('Score'),
            dataIndex: 'score',
            align: 'right',
-           renderer: function(value, metaData) {
-               let color = value < 0 ? '#d7e9f6' : value > 0 ? '#f3d6d7' : '';
-               let fontWeight = value >= 3 ? '1000' : value >= 1.5 ? '600' : '';
-               metaData.tdStyle = `background-color: ${color}; font-weight: ${fontWeight};`;
-               return value;
+           tdCls: 'txt-monospace',
+           renderer: function(score, metaData) {
+               if (score === 0) {
+                   return score;
+               }
+               let absScore = Math.abs(score);
+               let fontWeight = '400', background = score < 0 ? '#d7e9f6' : '#f3d6d7';
+               if (absScore >= 3) {
+                   fontWeight = '900';
+                   background = score < 0 ? '#ACD1EC' : '#E8B0B2';
+               } else if (absScore >= 1.5) {
+                   fontWeight = '600';
+               } else if (absScore <= 0.1) {
+                   fontWeight = '200';
+                   background = score < 0 ? '#EEF6FB' : '#FAEFF0';
+               }
+               metaData.tdStyle = `font-weight: ${fontWeight};background-color: ${background};`;
+               return score;
            },
            summaryType: 'sum',
-           summaryRenderer: function(value, summaryData, dataIndex, metaData) {
-               return Ext.util.Format.round(value, 5);
-           },
+           summaryRenderer: value => Ext.util.Format.round(value, 5),
        },
        {
            text: gettext('Description'),
            dataIndex: 'desc',
-           flex: 3,
+           flex: 2,
        },
     ],
 });