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