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 5E4B66A02D for ; Thu, 21 Jan 2021 16:52:10 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 551E413D68 for ; Thu, 21 Jan 2021 16:51:40 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (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 id C147113D36 for ; Thu, 21 Jan 2021 16:51:38 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 8E78E460AA for ; Thu, 21 Jan 2021 16:51:38 +0100 (CET) From: Stoiko Ivanov To: pmg-devel@lists.proxmox.com Date: Thu, 21 Jan 2021 16:51:07 +0100 Message-Id: <20210121155107.1971-7-s.ivanov@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210121155107.1971-1-s.ivanov@proxmox.com> References: <20210121155107.1971-1-s.ivanov@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.066 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust 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. [ietf.org] Subject: [pmg-devel] [PATCH pmg-gui v2 1/1] statistics: use new api structure for detailed stats 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, 21 Jan 2021 15:52:10 -0000 the detail api calls take the address for which to display the statistics as explicit parameter instead of component of the path if the path component is set to 'detail'. This makes it possible to accept '/' as part of an e-mail address which is allowed (in the local-part by RFC5322 [0], and accepted by postfix. [0] https://tools.ietf.org/html/rfc5322 Signed-off-by: Stoiko Ivanov --- v1->v2: * adapt to new api-structure * still pass url as parameter - passing undefined is handled specially (huge thanks to Dominik for noticing this after a 2 second glance :) js/ContactStatistics.js | 9 ++++----- js/ReceiverStatistics.js | 9 ++++----- js/SenderStatistics.js | 9 ++++----- js/StatStore.js | 11 +++++++++-- 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/js/ContactStatistics.js b/js/ContactStatistics.js index 6c9d2d4..8fc58b8 100644 --- a/js/ContactStatistics.js +++ b/js/ContactStatistics.js @@ -16,10 +16,10 @@ Ext.define('PMG.ContactDetails', { plugins: 'gridfilters', - setUrl: function(url, title) { + setUrl: function(url, detailaddress, title) { var me = this; - me.store.setUrl(url); + me.store.setUrl(url, { detailaddress: detailaddress }); me.store.setRemoteFilter(url !== undefined); Proxmox.Utils.setErrorMask(me, false); me.store.reload(); @@ -201,9 +201,8 @@ Ext.define('PMG.ContactStatistics', { var details = this.lookupReference('details'); if (selected.length > 0) { var contact = selected[0].data.contact; - var url = "/api2/json/statistics/contact/" + - encodeURIComponent(contact); - details.setUrl(url, '' + gettext('Contact') + ': ' + Ext.htmlEncode(contact)); + var url = "/api2/json/statistics/contact/detail"; + details.setUrl(url, contact, '' + gettext('Contact') + ': ' + Ext.htmlEncode(contact)); } else { details.setUrl(); } diff --git a/js/ReceiverStatistics.js b/js/ReceiverStatistics.js index 6378e06..069c2bf 100644 --- a/js/ReceiverStatistics.js +++ b/js/ReceiverStatistics.js @@ -16,10 +16,10 @@ Ext.define('PMG.ReceiverDetails', { plugins: 'gridfilters', - setUrl: function(url, title) { + setUrl: function(url, detailaddress, title) { var me = this; - me.store.setUrl(url); + me.store.setUrl(url, { detailaddress: detailaddress }); me.store.setRemoteFilter(url !== undefined); Proxmox.Utils.setErrorMask(me, false); me.store.reload(); @@ -212,10 +212,9 @@ Ext.define('PMG.ReceiverStatistics', { selectionChange: function(grid, selected, eOpts) { var details = this.lookupReference('details'); if (selected.length > 0) { + var url = "/api2/json/statistics/receiver/detail"; var receiver = selected[0].data.receiver; - var url = "/api2/json/statistics/receiver/" + - encodeURIComponent(receiver); - details.setUrl(url, '' + gettext('Receiver') + ': ' + Ext.htmlEncode(receiver)); + details.setUrl(url, receiver, '' + gettext('Receiver') + ': ' + Ext.htmlEncode(receiver)); } else { details.setUrl(); } diff --git a/js/SenderStatistics.js b/js/SenderStatistics.js index 43c5438..9b9f48d 100644 --- a/js/SenderStatistics.js +++ b/js/SenderStatistics.js @@ -16,10 +16,10 @@ Ext.define('PMG.SenderDetails', { plugins: 'gridfilters', - setUrl: function(url, title) { + setUrl: function(url, detailaddress, title) { var me = this; - me.store.setUrl(url); + me.store.setUrl(url, { detailaddress: detailaddress }); me.store.setRemoteFilter(url !== undefined); Proxmox.Utils.setErrorMask(me, false); me.store.reload(); @@ -201,9 +201,8 @@ Ext.define('PMG.SenderStatistics', { var details = this.lookupReference('details'); if (selected.length > 0) { var sender = selected[0].data.sender; - var url = "/api2/json/statistics/sender/" + - encodeURIComponent(sender); - details.setUrl(url, '' + gettext('Sender') + ': ' + Ext.htmlEncode(sender)); + var url = "/api2/json/statistics/sender/detail"; + details.setUrl(url, sender, '' + gettext('Sender') + ': ' + Ext.htmlEncode(sender)); } else { details.setUrl(); } diff --git a/js/StatStore.js b/js/StatStore.js index ec11777..0fc1d31 100644 --- a/js/StatStore.js +++ b/js/StatStore.js @@ -8,13 +8,17 @@ Ext.define('PMG.data.StatStore', { includeTimeSpan: false, - setUrl: function(url) { + setUrl: function(url, extraparam) { var me = this; me.proxy.abort(); // abort pending requests me.staturl = url; me.proxy.extraParams = {}; + if (extraparam !== undefined) { + me.proxy.extraParams = extraparam; + } + me.setData([]); }, @@ -38,7 +42,10 @@ Ext.define('PMG.data.StatStore', { } me.proxy.url = me.staturl; - me.proxy.extraParams = { starttime: ts.starttime, endtime: ts.endtime }; + Ext.apply(me.proxy.extraParams, { + starttime: ts.starttime, + endtime: ts.endtime, + }); var timespan = 3600; if (me.includeTimeSpan) { -- 2.20.1