]> git.proxmox.com Git - pmg-gui.git/blob - js/SpamInfoGrid.js
c9777d746ceabc0aa37a0ba0ef9f77faf843f55d
[pmg-gui.git] / js / SpamInfoGrid.js
1 Ext.define('PMG.grid.SpamInfoGrid', {
2 extend: 'Ext.grid.GridPanel',
3 xtype: 'pmgSpamInfoGrid',
4
5 store: {
6 autoDestroy: true,
7 fields: ['desc', 'name', { type: 'number', name: 'score' }],
8 proxy: {
9 type: 'proxmox',
10 root: 'data.spaminfo',
11 },
12 },
13
14 setID: function(rec) {
15 var me = this;
16 if (!rec || !rec.data || !rec.data.id) {
17 me.getStore().removeAll();
18 return;
19 }
20 var url = '/api2/json/quarantine/content?id=' + rec.data.id;
21 me.store.proxy.setUrl(url);
22 me.store.load();
23 },
24
25 emptyText: gettext('No Spam Info'),
26 hidden: true,
27
28 features: [{
29 ftype: 'summary',
30 }],
31
32 columns: [
33 {
34 text: gettext('Test Name'),
35 dataIndex: 'name',
36 flex: 2,
37 summaryType: 'count',
38 summaryRenderer: function(value, summaryData, dataIndex, metaData) {
39 return gettext('Spamscore');
40 },
41 },
42 {
43 text: gettext('Score'),
44 dataIndex: 'score',
45 align: 'right',
46 renderer: function(value, metaData) {
47 let color = value < 0 ? '#d7e9f6' : value > 0 ? '#f3d6d7' : '';
48 let fontWeight = value >= 3 ? '1000' : value >= 1.5 ? '600' : '';
49 metaData.tdStyle = `background-color: ${color}; font-weight: ${fontWeight};`;
50 return value;
51 },
52 summaryType: 'sum',
53 summaryRenderer: function(value, summaryData, dataIndex, metaData) {
54 return Ext.util.Format.round(value, 5);
55 },
56 },
57 {
58 text: gettext('Description'),
59 dataIndex: 'desc',
60 flex: 3,
61 },
62 ],
63 });