]> git.proxmox.com Git - pmg-gui.git/blame - js/SpamDetectorStatus.js
user view: disable unlock TFA button initially
[pmg-gui.git] / js / SpamDetectorStatus.js
CommitLineData
66caa558
DC
1Ext.define('pmg-spamassassin-database', {
2 extend: 'Ext.data.Model',
3 fields: [
4 'channel', 'version', 'update_version',
5 { name: 'update_avail', type: 'boolean' },
c87d46fb 6 { name: 'last_updated', type: 'date', dateFormat: 'timestamp' },
66caa558 7 ],
c87d46fb 8 idProperty: 'channel',
66caa558
DC
9});
10
11Ext.define('PMG.SpamDetectorStatusGrid', {
12 extend: 'Ext.grid.GridPanel',
13 xtype: 'pmgSpamDetectorStatus',
14
15 title: gettext('Status'),
16
17 viewConfig: {
c87d46fb 18 trackOver: false,
66caa558
DC
19 },
20 columns: [
21 {
22 header: gettext('Channel'),
23 sortable: true,
24 flex: 1,
c87d46fb 25 dataIndex: 'channel',
66caa558
DC
26 },
27 {
28 header: gettext('Last Update'),
29 sortable: true,
30 flex: 2,
c87d46fb 31 dataIndex: 'last_updated',
66caa558
DC
32 },
33 {
34 header: gettext('Version'),
35 flex: 1,
36 sortable: true,
c87d46fb 37 dataIndex: 'version',
66caa558
DC
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 }
c87d46fb
TL
50 },
51 },
66caa558
DC
52 ],
53
54 listeners: {
55 activate: function() {
56 var me = this;
57 me.store.load();
c87d46fb 58 },
66caa558
DC
59 },
60
61 tbar: [
62 {
63 text: gettext('Update Now'),
64 handler: function() {
28eb60c0 65 let view = this.up('grid');
66caa558
DC
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) {
28eb60c0 73 const upid = response.result.data;
66caa558 74
28eb60c0 75 let win = Ext.create('Proxmox.window.TaskViewer', {
c87d46fb 76 upid: upid,
28eb60c0 77 autoShow: true,
66caa558 78 });
28eb60c0 79 view.mon(win, 'close', () => view.store.load());
c87d46fb 80 },
66caa558 81 });
c87d46fb
TL
82 },
83 },
66caa558
DC
84 ],
85
c87d46fb 86 initComponent: function() {
66caa558
DC
87 var me = this;
88
89 me.store = Ext.create('Ext.data.Store', {
90 model: 'pmg-spamassassin-database',
91 proxy: {
92 type: 'proxmox',
c87d46fb 93 url: "/api2/json/nodes/" + Proxmox.NodeName + "/spamassassin/rules",
66caa558
DC
94 },
95 sorters: {
96 property: 'name',
18722987 97 direction: 'ASC',
c87d46fb 98 },
66caa558
DC
99 });
100
101 me.callParent();
102
103 Proxmox.Utils.monStoreErrors(me.getView(), me.store, true);
c87d46fb 104 },
66caa558 105});