From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 7E8218BCE7 for ; Thu, 27 Oct 2022 21:13:35 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 620712F36 for ; Thu, 27 Oct 2022 21:13:05 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Thu, 27 Oct 2022 21:13:03 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 6793744C62 for ; Thu, 27 Oct 2022 21:13:03 +0200 (CEST) From: Stoiko Ivanov To: pmg-devel@lists.proxmox.com Date: Thu, 27 Oct 2022 21:12:58 +0200 Message-Id: <20221027191258.11594-3-s.ivanov@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221027191258.11594-1-s.ivanov@proxmox.com> References: <20221027191258.11594-1-s.ivanov@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.174 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [rec.data, data.id, dom.download] Subject: [pmg-devel] [PATCH pmg-gui v2 2/2] quarantine: use new controller for virus and attachment quarantines X-BeenThere: pmg-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Mail Gateway development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Oct 2022 19:13:35 -0000 fixes #1674 (the comment about multiselect for the virus quarantine) fixes #3947 (multiselect for attachment quarantine) Signed-off-by: Stoiko Ivanov --- js/AttachmentQuarantine.js | 113 ++++++++++++++++--------------------- js/VirusQuarantine.js | 86 +++++++--------------------- 2 files changed, 70 insertions(+), 129 deletions(-) diff --git a/js/AttachmentQuarantine.js b/js/AttachmentQuarantine.js index 1e56420..8abfcad 100644 --- a/js/AttachmentQuarantine.js +++ b/js/AttachmentQuarantine.js @@ -18,87 +18,59 @@ Ext.define('pmg-attachment-list', { 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(""); + 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', @@ -163,6 +135,19 @@ Ext.define('PMG.AttachmentQuarantine', { 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'), diff --git a/js/VirusQuarantine.js b/js/VirusQuarantine.js index 4c1d0ba..47e055c 100644 --- a/js/VirusQuarantine.js +++ b/js/VirusQuarantine.js @@ -28,80 +28,23 @@ Ext.define('PMG.VirusQuarantine', { 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(""); - }, - - 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', @@ -172,6 +115,19 @@ Ext.define('PMG.VirusQuarantine', { 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'), -- 2.30.2