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