]>
git.proxmox.com Git - pmg-gui.git/blob - js/VirusQuarantine.js
1 /*jslint confusion: true*/
2 /*format is a string and a function*/
3 Ext
.define('pmg-virus-list', {
4 extend
: 'Ext.data.Model',
5 fields
: ['id', 'envelope_sender', 'from', 'sender', 'receiver', 'subject',
6 { type
: 'integer', name
: 'bytes' },
7 { type
: 'string', name
: 'virusname' },
8 { type
: 'date', dateFormat
: 'timestamp', name
: 'time' },
12 convert: function(v
, rec
) {
13 return Ext
.Date
.format(rec
.get('time'), 'Y-m-d');
19 url
: "/api2/json/quarantine/virus",
24 Ext
.define('PMG.VirusQuarantine', {
25 extend
: 'Ext.container.Container',
26 xtype
: 'pmgVirusQuarantine',
29 layout
: { type
: 'border' },
31 defaults
: { border
: false },
35 xclass
: 'Ext.app.ViewController',
37 updatePreview: function(raw
) {
38 var list
= this.lookupReference('list');
39 var rec
= list
.selModel
.getSelection()[0];
40 var preview
= this.lookupReference('preview');
42 if (!rec
|| !rec
.data
|| !rec
.data
.id
) {
44 preview
.setDisabled(true);
48 var url
= '/api2/htmlmail/quarantine/content?id=' + rec
.data
.id
+ (raw
?'&raw=1':'');
49 preview
.setDisabled(false);
50 preview
.update("<iframe frameborder=0 width=100% height=100% sandbox='allow-same-origin' src='" + url
+"'></iframe>");
53 toggleRaw: function(button
) {
55 me
.lookup('mailinfo').setVisible(me
.raw
);
57 me
.updatePreview(me
.raw
);
60 btnHandler: function(button
, e
) {
61 var list
= this.lookupReference('list');
62 var selected
= list
.getSelection();
63 if (!selected
.length
) {
67 var action
= button
.reference
;
69 PMG
.Utils
.doQuarantineAction(action
, selected
[0].data
.id
, function() {
70 list
.getController().load();
74 onSelectMail: function() {
76 me
.updatePreview(me
.raw
|| false);
77 let mailinfo
= me
.lookup('mailinfo');
78 let list
= me
.lookup('list');
79 let selection
= list
.getSelection();
80 if (selection
.length
< 1) {
81 mailinfo
.setVisible(false);
84 mailinfo
.setVisible(!me
.raw
);
85 mailinfo
.update(selection
[0].data
);
89 'button[reference=raw]': {
92 'pmgQuarantineList': {
93 selectionChange
: 'onSelectMail',
101 title
: gettext('Virus Quarantine'),
102 xtype
: 'pmgQuarantineList',
103 emptyText
: gettext('No data in database'),
104 emailSelection
: false,
111 model
: 'pmg-virus-list',
122 header
: gettext('Sender/Subject'),
123 dataIndex
: 'subject',
124 renderer
: PMG
.Utils
.sender_renderer
,
128 header
: gettext('Virus'),
129 dataIndex
: 'virusname',
134 header
: gettext('Size') + ' (KB)',
135 renderer: function(v
) { return Ext
.Number
.toFixed(v
/1024, 0); },
141 header
: gettext('Date'),
147 header
: gettext('Time'),
154 title
: gettext('Selected Mail'),
158 reference
: 'preview',
168 text
: gettext('Toggle Raw'),
170 iconCls
: 'fa fa-file-code-o',
174 reference
: 'deliver',
175 text
: gettext('Deliver'),
176 iconCls
: 'fa fa-paper-plane-o',
177 handler
: 'btnHandler',
181 text
: gettext('Delete'),
182 iconCls
: 'fa fa-trash-o',
183 handler
: 'btnHandler',
188 xtype
: 'pmgMailInfo',
190 reference
: 'mailinfo',