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