]>
Commit | Line | Data |
---|---|---|
c87d46fb | 1 | Ext.define('PMG.grid.SpamInfoGrid', { |
79a3f18d DC |
2 | extend: 'Ext.grid.GridPanel', |
3 | xtype: 'pmgSpamInfoGrid', | |
4 | ||
c8114985 DM |
5 | store: { |
6 | autoDestroy: true, | |
c87d46fb | 7 | fields: ['desc', 'name', { type: 'number', name: 'score' }], |
c8114985 DM |
8 | proxy: { |
9 | type: 'proxmox', | |
c87d46fb TL |
10 | root: 'data.spaminfo', |
11 | }, | |
282b960b | 12 | sorters: 'score', |
c8114985 DM |
13 | }, |
14 | ||
79a3f18d | 15 | setID: function(rec) { |
773489e3 TL |
16 | let me = this; |
17 | let id = rec?.data?.id; | |
18 | if (!id) { | |
79a3f18d DC |
19 | me.getStore().removeAll(); |
20 | return; | |
21 | } | |
773489e3 | 22 | me.store.proxy.setUrl(`/api2/json/quarantine/content?id=${id}`); |
c8114985 | 23 | me.store.load(); |
79a3f18d DC |
24 | }, |
25 | ||
26 | emptyText: gettext('No Spam Info'), | |
27 | hidden: true, | |
79a3f18d DC |
28 | |
29 | features: [{ | |
c87d46fb | 30 | ftype: 'summary', |
79a3f18d DC |
31 | }], |
32 | ||
33 | columns: [ | |
34 | { | |
35 | text: gettext('Test Name'), | |
36 | dataIndex: 'name', | |
63e00678 | 37 | flex: 1, |
79a3f18d | 38 | summaryType: 'count', |
773489e3 | 39 | summaryRenderer: _v => gettext('Spamscore'), |
ba889454 | 40 | tdCls: 'txt-monospace', |
79a3f18d DC |
41 | }, |
42 | { | |
43 | text: gettext('Score'), | |
44 | dataIndex: 'score', | |
45 | align: 'right', | |
ba889454 | 46 | tdCls: 'txt-monospace', |
146c46f0 TL |
47 | renderer: function(score, metaData) { |
48 | if (score === 0) { | |
49 | return score; | |
50 | } | |
51 | let absScore = Math.abs(score); | |
52 | let fontWeight = '400', background = score < 0 ? '#d7e9f6' : '#f3d6d7'; | |
53 | if (absScore >= 3) { | |
54 | fontWeight = '900'; | |
55 | background = score < 0 ? '#ACD1EC' : '#E8B0B2'; | |
56 | } else if (absScore >= 1.5) { | |
57 | fontWeight = '600'; | |
58 | } else if (absScore <= 0.1) { | |
59 | fontWeight = '200'; | |
60 | background = score < 0 ? '#EEF6FB' : '#FAEFF0'; | |
61 | } | |
62 | metaData.tdStyle = `font-weight: ${fontWeight};background-color: ${background};`; | |
63 | return score; | |
d5aca48e | 64 | }, |
79a3f18d | 65 | summaryType: 'sum', |
773489e3 | 66 | summaryRenderer: value => Ext.util.Format.round(value, 5), |
79a3f18d DC |
67 | }, |
68 | { | |
69 | text: gettext('Description'), | |
70 | dataIndex: 'desc', | |
63e00678 | 71 | flex: 2, |
c87d46fb TL |
72 | }, |
73 | ], | |
79a3f18d | 74 | }); |