]> git.proxmox.com Git - pmg-gui.git/blame - js/AttachmentGrid.js
tree wide: eslint --fix
[pmg-gui.git] / js / AttachmentGrid.js
CommitLineData
c87d46fb 1Ext.define('PMG.grid.AttachmentGrid', {
0023ef6a
DC
2 extend: 'Ext.grid.GridPanel',
3 xtype: 'pmgAttachmentGrid',
4
5 store: {
6 autoDestroy: true,
c87d46fb 7 fields: ['name', 'content-type', 'size'],
0023ef6a
DC
8 proxy: {
9 type: 'proxmox',
c87d46fb 10 },
0023ef6a
DC
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 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';
54 url += '?mailid=' + me.mailid;
55 url += '&attachmentid=' + rec.data.id;
56 return "<a target='_blank' class='download' download='"+ rec.data.name +"' href='" +
57 url + "'><i class='fa fa-fw fa-download'</i></a>";
58 },
c87d46fb
TL
59 },
60 ],
0023ef6a 61});