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