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