]>
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',
22 boxLabel
: gettext('Show All Parts'),
23 boxLabelAlgign
: 'before',
25 change: function(checkBox
, value
) {
26 let store
= this.up('pmgAttachmentGrid').getStore();
30 property
: 'content-disposition',
41 fields
: ['name', 'content-type', 'size', 'content-disposition'],
46 property
: 'content-disposition',
52 xclass
: 'Ext.app.ViewController',
53 init: function(view
) {
54 view
.store
.on('load', this.onLoad
, this);
56 onLoad: function(store
, records
, success
) {
58 let view
= me
.getView();
60 view
.updateTitleStats(-1);
63 let attachments
= records
.filter(({ data
}) => data
['content-disposition'] === 'attachment');
64 let totalSize
= attachments
.reduce((sum
, { data
}) => sum
+ data
.size
, 0);
65 view
.updateTitleStats(attachments
.length
, totalSize
);
69 updateTitleStats: function(count
, totalSize
) {
73 title
= Ext
.String
.format(gettext('{0} Attachments'), count
);
74 title
+= ` (${Proxmox.Utils.format_size(totalSize)})`;
79 title
= gettext('No Attachments');
87 setID: function(rec
) {
89 if (!rec
|| !rec
.data
|| !rec
.data
.id
) {
90 me
.getStore().removeAll();
93 var url
= '/api2/json/quarantine/listattachments?id=' + rec
.data
.id
;
94 me
.mailid
= rec
.data
.id
;
95 me
.store
.proxy
.setUrl(url
);
99 emptyText
: gettext('No Attachments'),
101 download: function() {
102 Ext
.Msg
.alert(arguments
);
107 text
: gettext('Filename'),
112 text
: gettext('Filetype'),
113 dataIndex
: 'content-type',
114 renderer
: PMG
.Utils
.render_filetype
,
118 text
: gettext('Size'),
119 renderer
: Proxmox
.Utils
.render_size
,
124 header
: gettext('Download'),
126 hidden
: '{!showDownloads}',
128 renderer: function(value
, mD
, rec
) {
130 let url
= `/api2/json/quarantine/download?mailid=${me.mailid}&attachmentid=${rec.data.id}`;
131 return `<a target='_blank' class='download' download='${rec.data.name}' href='${url}'>
132 <i class='fa fa-fw fa-download'</i>