pmg-gui/js/AttachmentGrid.js
Thomas Lamprecht 28eb60c0bd eslint fixes
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-10-30 14:08:16 +01:00

61 lines
1.3 KiB
JavaScript

Ext.define('PMG.grid.AttachmentGrid', {
extend: 'Ext.grid.GridPanel',
xtype: 'pmgAttachmentGrid',
store: {
autoDestroy: true,
fields: ['name', 'content-type', 'size'],
proxy: {
type: 'proxmox',
},
},
setID: function(rec) {
var me = this;
if (!rec || !rec.data || !rec.data.id) {
me.getStore().removeAll();
return;
}
var url = '/api2/json/quarantine/listattachments?id=' + rec.data.id;
me.mailid = rec.data.id;
me.store.proxy.setUrl(url);
me.store.load();
},
emptyText: gettext('No Attachments'),
download: function() {
Ext.Msg.alert(arguments);
},
columns: [
{
text: gettext('Filename'),
dataIndex: 'name',
flex: 1,
},
{
text: gettext('Filetype'),
dataIndex: 'content-type',
renderer: PMG.Utils.render_filetype,
flex: 1,
},
{
text: gettext('Size'),
renderer: Proxmox.Utils.format_size,
dataIndex: 'size',
flex: 1,
},
{
header: gettext('Download'),
renderer: function(value, mD, rec) {
var me = this;
let url = `/api2/json/quarantine/download?mailid=${me.mailid}&attachmentid=${rec.data.id}`;
return `<a target='_blank' class='download' download='${rec.data.name}' href='${url}'>
<i class='fa fa-fw fa-download'</i>
</a>`;
},
},
],
});