]>
git.proxmox.com Git - pmg-gui.git/blob - js/AttachmentGrid.js
1 Ext
.define('PMG.grid.AttachmentGrid', {
2 extend
: 'Ext.grid.GridPanel',
3 xtype
: 'pmgAttachmentGrid',
4 mixins
: ['Proxmox.Mixin.CBind'],
8 title
: gettext('Attachments'),
9 iconCls
: 'fa fa-paperclip',
20 fields
: ['name', 'content-type', 'size'],
27 xclass
: 'Ext.app.ViewController',
28 init: function(view
) {
29 view
.store
.on('load', this.onLoad
, this);
31 onLoad: function(store
, records
, success
) {
33 let view
= me
.getView();
35 view
.updateTitleStats(-1);
38 let totalSize
= records
.reduce((sum
, { data
}) => sum
+ data
.size
, 0);
39 view
.updateTitleStats(records
.length
, totalSize
);
43 updateTitleStats: function(count
, totalSize
) {
47 title
= Ext
.String
.format(gettext('{0} Attachements'), count
);
48 title
+= ` (${Proxmox.Utils.format_size(totalSize)})`;
53 title
= gettext('No Attachments');
61 setID: function(rec
) {
63 if (!rec
|| !rec
.data
|| !rec
.data
.id
) {
64 me
.getStore().removeAll();
67 var url
= '/api2/json/quarantine/listattachments?id=' + rec
.data
.id
;
68 me
.mailid
= rec
.data
.id
;
69 me
.store
.proxy
.setUrl(url
);
73 emptyText
: gettext('No Attachments'),
75 download: function() {
76 Ext
.Msg
.alert(arguments
);
81 text
: gettext('Filename'),
86 text
: gettext('Filetype'),
87 dataIndex
: 'content-type',
88 renderer
: PMG
.Utils
.render_filetype
,
92 text
: gettext('Size'),
93 renderer
: Proxmox
.Utils
.format_size
,
98 header
: gettext('Download'),
100 hidden
: '{!showDownloads}',
102 renderer: function(value
, mD
, rec
) {
104 let url
= `/api2/json/quarantine/download?mailid=${me.mailid}&attachmentid=${rec.data.id}`;
105 return `<a target='_blank' class='download' download='${rec.data.name}' href='${url}'>
106 <i class='fa fa-fw fa-download'</i>