From: Dominik Csapak <d.csapak@proxmox.com>
To: pmg-devel@lists.proxmox.com
Subject: [pmg-devel] [PATCH 2/2] quarantine: spam info grid: group good and bad scores
Date: Fri, 19 Sep 2025 14:54:11 +0200 [thread overview]
Message-ID: <20250919125426.2547332-2-d.csapak@proxmox.com> (raw)
In-Reply-To: <20250919125426.2547332-1-d.csapak@proxmox.com>
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 <d.csapak@proxmox.com>
---
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
next prev parent reply other threads:[~2025-09-19 12:54 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-19 12:54 [pmg-devel] [PATCH 1/2] quarantine: spam info: make text selectable Dominik Csapak
2025-09-19 12:54 ` Dominik Csapak [this message]
2025-09-19 15:36 ` [pmg-devel] [PATCH 2/2] quarantine: spam info grid: group good and bad scores Thomas Lamprecht
2025-09-19 15:32 ` [pmg-devel] applied: [PATCH 1/2] quarantine: spam info: make text selectable Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250919125426.2547332-2-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pmg-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox