]>
Commit | Line | Data |
---|---|---|
e50f4acb | 1 | Ext.define('PMG.ClamAVDatabaseConfig', { |
41c05692 | 2 | extend: 'Proxmox.grid.ObjectGrid', |
e50f4acb | 3 | alias: ['widget.pmgClamAVDatabaseConfig'], |
41c05692 | 4 | |
5e453db7 DM |
5 | monStoreErrors: true, |
6 | ||
c87d46fb | 7 | initComponent: function() { |
41c05692 DM |
8 | var me = this; |
9 | ||
10 | me.add_text_row('dbmirror', gettext('Database Mirror'), | |
11 | { deleteEmpty: true, defaultValue: 'database.clamav.net' }); | |
41c05692 | 12 | |
816483a2 SI |
13 | me.add_boolean_row('scriptedupdates', gettext('Incremental Download'), |
14 | { defaultValue: 0 }); | |
13fe6e87 | 15 | |
e50f4acb | 16 | var baseurl = '/config/clamav'; |
41c05692 DM |
17 | |
18 | Ext.apply(me, { | |
41c05692 DM |
19 | url: '/api2/json' + baseurl, |
20 | editorConfig: { | |
573a6e8b | 21 | url: '/api2/extjs' + baseurl, |
c87d46fb | 22 | onlineHelp: 'pmgconfig_clamav', |
41c05692 DM |
23 | }, |
24 | interval: 5000, | |
25 | cwidth1: 200, | |
26 | listeners: { | |
c87d46fb TL |
27 | itemdblclick: me.run_editor, |
28 | }, | |
41c05692 DM |
29 | }); |
30 | ||
31 | me.callParent(); | |
32 | ||
41ab9005 | 33 | me.on('activate', me.rstore.startUpdate); |
41c05692 | 34 | me.on('destroy', me.rstore.stopUpdate); |
00564597 | 35 | me.on('deactivate', me.rstore.stopUpdate); |
c87d46fb | 36 | }, |
41c05692 | 37 | }); |
13fe6e87 DM |
38 | |
39 | Ext.define('pmg-clamav-database', { | |
e50f4acb | 40 | extend: 'Ext.data.Model', |
c87d46fb | 41 | fields: ['name', 'type', 'build_time', 'version', |
e50f4acb | 42 | { name: 'nsigs', type: 'integer' }], |
c87d46fb | 43 | idProperty: 'name', |
e50f4acb DM |
44 | }); |
45 | ||
46 | Ext.define('PMG.ClamAVDatabaseStatus', { | |
47 | extend: 'Ext.grid.GridPanel', | |
48 | alias: ['widget.pmgClamAVDatabaseStatus'], | |
49 | ||
50 | title: gettext('Status'), | |
51 | ||
52 | reload: function() { | |
53 | var me = this; | |
54 | ||
55 | me.store.load(); | |
56 | }, | |
57 | ||
c87d46fb | 58 | initComponent: function() { |
e50f4acb DM |
59 | var me = this; |
60 | ||
61 | me.store = new Ext.data.Store({ | |
13fe6e87 | 62 | model: 'pmg-clamav-database', |
e50f4acb DM |
63 | proxy: { |
64 | type: 'proxmox', | |
c87d46fb | 65 | url: "/api2/json/nodes/" + Proxmox.NodeName + "/clamav/database", |
e50f4acb DM |
66 | }, |
67 | sorters: { | |
68 | property: 'name', | |
18722987 | 69 | direction: 'ASC', |
c87d46fb | 70 | }, |
e50f4acb DM |
71 | }); |
72 | ||
e50f4acb DM |
73 | Ext.apply(me, { |
74 | viewConfig: { | |
c87d46fb | 75 | trackOver: false, |
e50f4acb DM |
76 | }, |
77 | columns: [ | |
78 | { | |
79 | header: gettext('Name'), | |
80 | sortable: true, | |
81 | flex: 1, | |
c87d46fb | 82 | dataIndex: 'name', |
e50f4acb DM |
83 | }, |
84 | { | |
85 | header: gettext('Build time'), | |
86 | sortable: true, | |
87 | flex: 2, | |
c87d46fb | 88 | dataIndex: 'build_time', |
e50f4acb DM |
89 | }, |
90 | { | |
91 | header: gettext('Version'), | |
92 | flex: 1, | |
93 | sortable: true, | |
c87d46fb | 94 | dataIndex: 'version', |
e50f4acb DM |
95 | }, |
96 | { | |
97 | header: gettext('Signatures'), | |
98 | flex: 1, | |
99 | sortable: true, | |
c87d46fb TL |
100 | dataIndex: 'nsigs', |
101 | }, | |
fdebab3d DC |
102 | ], |
103 | listeners: { | |
c87d46fb TL |
104 | activate: me.reload, |
105 | }, | |
e50f4acb | 106 | }); |
fdebab3d | 107 | |
e50f4acb DM |
108 | me.callParent(); |
109 | ||
decc6090 | 110 | Proxmox.Utils.monStoreErrors(me.getView(), me.store, true); |
c87d46fb | 111 | }, |
e50f4acb DM |
112 | }); |
113 | ||
114 | Ext.define('PMG.ClamAVDatabase', { | |
115 | extend: 'Ext.panel.Panel', | |
116 | alias: ['widget.pmgClamAVDatabase'], | |
117 | ||
118 | layout: { type: 'vbox', align: 'stretch' }, | |
119 | ||
c87d46fb | 120 | initComponent: function() { |
e50f4acb DM |
121 | var me = this; |
122 | ||
123 | var selModel = Ext.create('Ext.selection.RowModel', {}); | |
124 | var editPanel = Ext.create('PMG.ClamAVDatabaseConfig', { | |
125 | border: false, | |
126 | xtype: 'pmgClamAVDatabaseConfig', | |
c87d46fb | 127 | selModel: selModel, |
e50f4acb DM |
128 | }); |
129 | ||
13fe6e87 | 130 | var statusPanel = Ext.create('PMG.ClamAVDatabaseStatus', { |
decc6090 | 131 | border: false, |
c87d46fb | 132 | flex: 1, |
13fe6e87 DM |
133 | }); |
134 | ||
c87d46fb | 135 | var update_command = function() { |
13fe6e87 DM |
136 | Proxmox.Utils.API2Request({ |
137 | url: '/nodes/' + Proxmox.NodeName + '/clamav/database', | |
138 | method: 'POST', | |
139 | failure: function(response, opts) { | |
140 | Ext.Msg.alert(gettext('Error'), response.htmlStatus); | |
141 | }, | |
142 | success: function(response, opts) { | |
143 | var upid = response.result.data; | |
144 | ||
145 | var win = Ext.create('Proxmox.window.TaskViewer', { | |
c87d46fb | 146 | upid: upid, |
13fe6e87 DM |
147 | }); |
148 | win.show(); | |
131ba4f6 | 149 | me.mon(win, 'close', function() { statusPanel.reload(); }); |
c87d46fb | 150 | }, |
13fe6e87 DM |
151 | }); |
152 | }; | |
153 | ||
e50f4acb DM |
154 | me.tbar = [ |
155 | { | |
156 | text: gettext('Edit'), | |
157 | xtype: 'proxmoxButton', | |
158 | disabled: true, | |
131ba4f6 | 159 | handler: function() { editPanel.run_editor(); }, |
c87d46fb | 160 | selModel: selModel, |
e50f4acb DM |
161 | }, |
162 | { | |
163 | text: gettext('Update now'), | |
c87d46fb TL |
164 | handler: update_command, |
165 | }, | |
e50f4acb DM |
166 | ]; |
167 | ||
c87d46fb | 168 | me.items = [editPanel, statusPanel]; |
e50f4acb DM |
169 | |
170 | me.callParent(); | |
171 | ||
0641d180 DC |
172 | editPanel.relayEvents(me, ['activate', 'deactivate', 'destroy']); |
173 | statusPanel.relayEvents(me, ['activate', 'deactivate', 'destroy']); | |
c87d46fb | 174 | }, |
e50f4acb | 175 | }); |