From: Stoiko Ivanov <s.ivanov@proxmox.com>
To: pmg-devel@lists.proxmox.com
Subject: [pmg-devel] [PATCH pmg-gui v2 1/1] statistics: use new api structure for detailed stats
Date: Thu, 21 Jan 2021 16:51:07 +0100 [thread overview]
Message-ID: <20210121155107.1971-7-s.ivanov@proxmox.com> (raw)
In-Reply-To: <20210121155107.1971-1-s.ivanov@proxmox.com>
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 <s.ivanov@proxmox.com>
---
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, '<b>' + gettext('Contact') + ':</b> ' + Ext.htmlEncode(contact));
+ var url = "/api2/json/statistics/contact/detail";
+ details.setUrl(url, contact, '<b>' + gettext('Contact') + ':</b> ' + 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, '<b>' + gettext('Receiver') + ':</b> ' + Ext.htmlEncode(receiver));
+ details.setUrl(url, receiver, '<b>' + gettext('Receiver') + ':</b> ' + 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, '<b>' + gettext('Sender') + ':</b> ' + Ext.htmlEncode(sender));
+ var url = "/api2/json/statistics/sender/detail";
+ details.setUrl(url, sender, '<b>' + gettext('Sender') + ':</b> ' + 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
prev parent reply other threads:[~2021-01-21 15:52 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-21 15:51 [pmg-devel] [PATCH pmg-api v2 0/5] allow / in local part of pmg-email-address Stoiko Ivanov
2021-01-21 15:51 ` [pmg-devel] [PATCH pmg-api v2 1/5] api: statistics: remove unneeded RESTEnvironment Stoiko Ivanov
2021-01-27 8:34 ` [pmg-devel] applied: " Thomas Lamprecht
2021-01-21 15:51 ` [pmg-devel] [PATCH pmg-api v2 2/5] api: statistics: refactor return for detail calls Stoiko Ivanov
2021-01-27 8:34 ` [pmg-devel] applied: " Thomas Lamprecht
2021-01-21 15:51 ` [pmg-devel] [PATCH pmg-api v2 3/5] api: statistics: refactor " Stoiko Ivanov
2021-01-27 8:34 ` [pmg-devel] applied: " Thomas Lamprecht
2021-01-21 15:51 ` [pmg-devel] [PATCH pmg-api v2] api: statistics: make email a parameter Stoiko Ivanov
2021-01-27 8:49 ` Thomas Lamprecht
2021-01-21 15:51 ` [pmg-devel] [PATCH pmg-api v2 5/5] utils: allow '/' inside email address localpart Stoiko Ivanov
2021-01-21 15:51 ` Stoiko Ivanov [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210121155107.1971-7-s.ivanov@proxmox.com \
--to=s.ivanov@proxmox.com \
--cc=pmg-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox