From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id ED38D1FF15C for ; Fri, 19 Sep 2025 14:54:14 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id D828016ADC; Fri, 19 Sep 2025 14:54:30 +0200 (CEST) From: Dominik Csapak To: pmg-devel@lists.proxmox.com Date: Fri, 19 Sep 2025 14:54:11 +0200 Message-ID: <20250919125426.2547332-2-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250919125426.2547332-1-d.csapak@proxmox.com> References: <20250919125426.2547332-1-d.csapak@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.026 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pmg-devel] [PATCH 2/2] quarantine: spam info grid: group good and bad scores X-BeenThere: pmg-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Mail Gateway development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pmg-devel-bounces@lists.proxmox.com Sender: "pmg-devel" So there is a category for the bad and good scores separately, with separate sums to show. With this one can more easily see the negative scores compare vs the positive scores. One weird quirk I didn't found a solution to exists: If there are only positive or negative scores for a mail, we can't differentiate the group summary and the overall summary, so both currently would show 'Overall Spamscore'. This seems to be a limitation of how extjs calls the grouping renderer since there is no indication which one it is. Signed-off-by: Dominik Csapak --- js/SpamInfoGrid.js | 53 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/js/SpamInfoGrid.js b/js/SpamInfoGrid.js index 7bce0f4..9d91d36 100644 --- a/js/SpamInfoGrid.js +++ b/js/SpamInfoGrid.js @@ -4,7 +4,19 @@ Ext.define('PMG.grid.SpamInfoGrid', { store: { autoDestroy: true, - fields: ['desc', 'name', { type: 'number', name: 'score' }], + fields: [ + 'desc', + 'name', + { type: 'number', name: 'score' }, + { + type: 'bool', + name: 'good', + calculate: function (data) { + return data.score <= 0; + }, + }, + ], + groupField: 'good', proxy: { type: 'proxmox', root: 'data.spaminfo', @@ -27,6 +39,23 @@ Ext.define('PMG.grid.SpamInfoGrid', { hidden: true, features: [ + { + ftype: 'grouping', + enableGroupingMenu: false, + groupHeaderTpl: [ + '{groupValue:this.formatGroup}', + { + formatGroup: function (groupValue) { + if (groupValue) { + return gettext('Good Scores'); + } else { + return gettext('Bad Scores'); + } + }, + }, + ], + showSummaryRow: true, + }, { ftype: 'summary', }, @@ -41,8 +70,26 @@ Ext.define('PMG.grid.SpamInfoGrid', { text: gettext('Test Name'), dataIndex: 'name', flex: 1, - summaryType: 'count', - summaryRenderer: (_v) => gettext('Spamscore'), + summaryType: function (records) { + let sum = records.reduce((acc, cur) => acc + cur.data.score, 0); + return [sum, records.length]; + }, + summaryRenderer: function (value, _summaryData, _field, metaData) { + let me = this; + let overallcount = me.up('grid').getStore().count(); + let [sum, count] = value; + console.log(value); + + if (count === overallcount) { + return gettext('Overall Spamscore'); + } + + if (sum <= 0) { + return gettext('Good Scores Sum'); + } else { + return gettext('Bad Scores Sum'); + } + }, tdCls: 'txt-monospace', }, { -- 2.47.3 _______________________________________________ pmg-devel mailing list pmg-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel