]> git.proxmox.com Git - pmg-gui.git/blame - js/AttachmentGrid.js
quarantines: add attachment grid to spam and virus quarantine
[pmg-gui.git] / js / AttachmentGrid.js
CommitLineData
c87d46fb 1Ext.define('PMG.grid.AttachmentGrid', {
0023ef6a
DC
2 extend: 'Ext.grid.GridPanel',
3 xtype: 'pmgAttachmentGrid',
1a96ec32
DC
4 mixins: ['Proxmox.Mixin.CBind'],
5
6 showDownloads: true,
0023ef6a
DC
7
8 store: {
9 autoDestroy: true,
c87d46fb 10 fields: ['name', 'content-type', 'size'],
0023ef6a
DC
11 proxy: {
12 type: 'proxmox',
c87d46fb 13 },
0023ef6a
DC
14 },
15
16 setID: function(rec) {
17 var me = this;
18 if (!rec || !rec.data || !rec.data.id) {
19 me.getStore().removeAll();
20 return;
21 }
22 var url = '/api2/json/quarantine/listattachments?id=' + rec.data.id;
23 me.mailid = rec.data.id;
24 me.store.proxy.setUrl(url);
25 me.store.load();
26 },
27
28 emptyText: gettext('No Attachments'),
29
30 download: function() {
28eb60c0 31 Ext.Msg.alert(arguments);
0023ef6a
DC
32 },
33
34 columns: [
35 {
36 text: gettext('Filename'),
37 dataIndex: 'name',
38 flex: 1,
39 },
40 {
41 text: gettext('Filetype'),
42 dataIndex: 'content-type',
43 renderer: PMG.Utils.render_filetype,
44 flex: 1,
45 },
46 {
47 text: gettext('Size'),
48 renderer: Proxmox.Utils.format_size,
49 dataIndex: 'size',
50 flex: 1,
51 },
52 {
53 header: gettext('Download'),
1a96ec32
DC
54 cbind: {
55 hidden: '{!showDownloads}',
56 },
0023ef6a
DC
57 renderer: function(value, mD, rec) {
58 var me = this;
28eb60c0
TL
59 let url = `/api2/json/quarantine/download?mailid=${me.mailid}&attachmentid=${rec.data.id}`;
60 return `<a target='_blank' class='download' download='${rec.data.name}' href='${url}'>
61 <i class='fa fa-fw fa-download'</i>
62 </a>`;
0023ef6a 63 },
c87d46fb
TL
64 },
65 ],
0023ef6a 66});