]>
Commit | Line | Data |
---|---|---|
1 | Ext.define('pmg-spamassassin-database', { | |
2 | extend: 'Ext.data.Model', | |
3 | fields: [ | |
4 | 'channel', 'version', 'update_version', | |
5 | { name: 'update_avail', type: 'boolean' }, | |
6 | { name: 'last_updated', type: 'date', dateFormat: 'timestamp' }, | |
7 | ], | |
8 | idProperty: 'channel', | |
9 | }); | |
10 | ||
11 | Ext.define('PMG.SpamDetectorStatusGrid', { | |
12 | extend: 'Ext.grid.GridPanel', | |
13 | xtype: 'pmgSpamDetectorStatus', | |
14 | ||
15 | title: gettext('Status'), | |
16 | ||
17 | viewConfig: { | |
18 | trackOver: false, | |
19 | }, | |
20 | columns: [ | |
21 | { | |
22 | header: gettext('Channel'), | |
23 | sortable: true, | |
24 | flex: 1, | |
25 | dataIndex: 'channel', | |
26 | }, | |
27 | { | |
28 | header: gettext('Last Update'), | |
29 | sortable: true, | |
30 | flex: 2, | |
31 | dataIndex: 'last_updated', | |
32 | }, | |
33 | { | |
34 | header: gettext('Version'), | |
35 | flex: 1, | |
36 | sortable: true, | |
37 | dataIndex: 'version', | |
38 | }, | |
39 | { | |
40 | header: gettext('Update Available'), | |
41 | flex: 1, | |
42 | sortable: true, | |
43 | dataIndex: 'update_avail', | |
44 | renderer: function(value, metaData, record) { | |
45 | if (!value) { | |
46 | return Proxmox.Utils.noText; | |
47 | } else { | |
48 | return Proxmox.Utils.yesText + ' (' + record.data.update_version + ')'; | |
49 | } | |
50 | }, | |
51 | }, | |
52 | ], | |
53 | ||
54 | listeners: { | |
55 | activate: function() { | |
56 | var me = this; | |
57 | me.store.load(); | |
58 | }, | |
59 | }, | |
60 | ||
61 | tbar: [ | |
62 | { | |
63 | text: gettext('Update Now'), | |
64 | handler: function() { | |
65 | let view = this.up('grid'); | |
66 | Proxmox.Utils.API2Request({ | |
67 | url: '/nodes/' + Proxmox.NodeName + '/spamassassin/rules', | |
68 | method: 'POST', | |
69 | failure: function(response) { | |
70 | Ext.Msg.alert(gettext('Error'), response.htmlStatus); | |
71 | }, | |
72 | success: function(response) { | |
73 | const upid = response.result.data; | |
74 | ||
75 | let win = Ext.create('Proxmox.window.TaskViewer', { | |
76 | upid: upid, | |
77 | autoShow: true, | |
78 | }); | |
79 | view.mon(win, 'close', () => view.store.load()); | |
80 | }, | |
81 | }); | |
82 | }, | |
83 | }, | |
84 | ], | |
85 | ||
86 | initComponent: function() { | |
87 | var me = this; | |
88 | ||
89 | me.store = Ext.create('Ext.data.Store', { | |
90 | model: 'pmg-spamassassin-database', | |
91 | proxy: { | |
92 | type: 'proxmox', | |
93 | url: "/api2/json/nodes/" + Proxmox.NodeName + "/spamassassin/rules", | |
94 | }, | |
95 | sorters: { | |
96 | property: 'name', | |
97 | order: 'DESC', | |
98 | }, | |
99 | }); | |
100 | ||
101 | me.callParent(); | |
102 | ||
103 | Proxmox.Utils.monStoreErrors(me.getView(), me.store, true); | |
104 | }, | |
105 | }); |