[pmg-devel] [PATCH 2/2] quarantine: spam info grid: group good and bad scores
Dominik Csapak
d.csapak at proxmox.com
Fri Sep 19 14:54:11 CEST 2025
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 at 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
More information about the pmg-devel
mailing list