idProperty: 'id',
});
-Ext.define('PMG.AttachmentQuarantine', {
- extend: 'Ext.container.Container',
- xtype: 'pmgAttachmentQuarantine',
-
- border: false,
- layout: { type: 'border' },
-
- defaults: { border: false },
-
- controller: {
-
- xclass: 'Ext.app.ViewController',
-
- updatePreview: function(raw, rec) {
- var preview = this.lookupReference('preview');
+Ext.define('PMG.AttachmentQuarantineController', {
+ extend: 'PMG.controller.QuarantineController',
+ alias: 'controller.attachmentquarantine',
+ xtype: 'pmgAttachmentQuarantineController',
+
+ onSelectMail: function() {
+ let me = this;
+ let list = this.lookupReference('list');
+ let selection = list.selModel.getSelection();
+ if (selection.length <= 1) {
+ let rec = selection[0] || {};
+ me.lookup('attachmentlist').setID(rec);
+ }
- if (!rec || !rec.data || !rec.data.id) {
- preview.update('');
- preview.setDisabled(true);
- return;
- }
+ me.callParent();
+ },
- let url = `/api2/htmlmail/quarantine/content?id=${rec.data.id}`;
- if (raw) {
- url += '&raw=1';
- }
- preview.setDisabled(false);
- preview.update("<iframe frameborder=0 width=100% height=100% sandbox='allow-same-origin' src='" + url +"'></iframe>");
+ control: {
+ 'button[reference=raw]': {
+ click: 'toggleRaw',
},
-
- toggleRaw: function(button) {
- var me = this;
- var list = this.lookupReference('list');
- var rec = list.getSelection()[0] || {};
- me.lookup('mailinfo').setVisible(me.raw);
- me.raw = !me.raw;
- me.updatePreview(me.raw, rec);
+ 'pmgQuarantineList': {
+ selectionChange: 'onSelectMail',
},
+ },
- btnHandler: function(button, e) {
- var list = this.lookupReference('list');
- var selected = list.getSelection();
- if (!selected.length) {
- return;
- }
+});
- var action = button.reference;
+Ext.define('PMG.AttachmentQuarantine', {
+ extend: 'Ext.container.Container',
+ xtype: 'pmgAttachmentQuarantine',
- PMG.Utils.doQuarantineAction(action, selected[0].data.id, function() {
- list.getController().load();
- });
- },
+ border: false,
+ layout: { type: 'border' },
- onSelectMail: function() {
- let me = this;
- let list = me.lookup('list');
- let rec = list.getSelection()[0] || {};
- let mailinfo = me.lookup('mailinfo');
+ defaults: { border: false },
- me.updatePreview(me.raw || false, rec);
- me.lookup('attachmentlist').setID(rec);
- mailinfo.setVisible(!!rec.data && !me.raw);
- mailinfo.update(rec.data);
+ viewModel: {
+ parent: null,
+ data: {
+ mailid: '',
},
-
- control: {
- 'button[reference=raw]': {
- click: 'toggleRaw',
- },
- 'pmgQuarantineList': {
- selectionChange: 'onSelectMail',
- },
+ formulas: {
+ downloadMailURL: get => '/api2/json/quarantine/download?mailid=' + encodeURIComponent(get('mailid')),
},
-
},
-
+ controller: 'attachmentquarantine',
items: [
{
title: gettext('Attachment Quarantine'),
xtype: 'pmgQuarantineList',
emptyText: gettext('No data in database'),
+ selModel: 'checkboxmodel',
emailSelection: false,
reference: 'list',
region: 'west',
iconCls: 'fa fa-file-code-o',
},
'->',
+ {
+ xtype: 'button',
+ reference: 'download',
+ text: gettext('Download'),
+ setDownload: function(id) {
+ this.el.dom.download = id + ".eml";
+ },
+ bind: {
+ href: '{downloadMailURL}',
+ download: '{mailid}',
+ },
+ iconCls: 'fa fa-download',
+ },
{
reference: 'deliver',
text: gettext('Deliver'),
defaults: { border: false },
- controller: {
-
- xclass: 'Ext.app.ViewController',
-
- updatePreview: function(raw) {
- var list = this.lookupReference('list');
- var rec = list.selModel.getSelection()[0];
- var preview = this.lookupReference('preview');
-
- if (!rec || !rec.data || !rec.data.id) {
- preview.update('');
- preview.setDisabled(true);
- return;
- }
-
- let url = `/api2/htmlmail/quarantine/content?id=${rec.data.id}`;
- if (raw) {
- url += '&raw=1';
- }
- preview.setDisabled(false);
- preview.update("<iframe frameborder=0 width=100% height=100% sandbox='allow-same-origin' src='" + url +"'></iframe>");
- },
-
- toggleRaw: function(button) {
- var me = this;
- me.lookup('mailinfo').setVisible(me.raw);
- me.raw = !me.raw;
- me.updatePreview(me.raw);
+ viewModel: {
+ parent: null,
+ data: {
+ mailid: '',
},
-
- btnHandler: function(button, e) {
- var list = this.lookupReference('list');
- var selected = list.getSelection();
- if (!selected.length) {
- return;
- }
-
- var action = button.reference;
-
- PMG.Utils.doQuarantineAction(action, selected[0].data.id, function() {
- list.getController().load();
- });
+ formulas: {
+ downloadMailURL: get => '/api2/json/quarantine/download?mailid=' + encodeURIComponent(get('mailid')),
},
-
- onSelectMail: function() {
- var me = this;
- me.updatePreview(me.raw || false);
- let mailinfo = me.lookup('mailinfo');
- let list = me.lookup('list');
- let selection = list.getSelection();
- if (selection.length < 1) {
- mailinfo.setVisible(false);
- return;
- }
- mailinfo.setVisible(!me.raw);
- mailinfo.update(selection[0].data);
- },
-
- control: {
- 'button[reference=raw]': {
- click: 'toggleRaw',
- },
- 'pmgQuarantineList': {
- selectionChange: 'onSelectMail',
- },
- },
-
},
+ controller: 'quarantine',
items: [
{
title: gettext('Virus Quarantine'),
xtype: 'pmgQuarantineList',
emptyText: gettext('No data in database'),
+ selModel: 'checkboxmodel',
emailSelection: false,
reference: 'list',
region: 'west',
iconCls: 'fa fa-file-code-o',
},
'->',
+ {
+ xtype: 'button',
+ reference: 'download',
+ text: gettext('Download'),
+ setDownload: function(id) {
+ this.el.dom.download = id + ".eml";
+ },
+ bind: {
+ href: '{downloadMailURL}',
+ download: '{mailid}',
+ },
+ iconCls: 'fa fa-download',
+ },
{
reference: 'deliver',
text: gettext('Deliver'),