You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by hu...@apache.org on 2020/09/08 10:20:06 UTC

[incubator-ponymail-foal] 03/03: Use search params to construct mbox URL

This is an automated email from the ASF dual-hosted git repository.

humbedooh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git

commit 8637d5c856aa3f291031cff658bb904d0764b825
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Tue Sep 8 12:19:51 2020 +0200

    Use search params to construct mbox URL
---
 webui/js/ponymail.js               | 7 +++++++
 webui/js/source/listview-header.js | 7 +++++++
 2 files changed, 14 insertions(+)

diff --git a/webui/js/ponymail.js b/webui/js/ponymail.js
index c034727..37b407e 100644
--- a/webui/js/ponymail.js
+++ b/webui/js/ponymail.js
@@ -2016,6 +2016,13 @@ function listview_header(state, json) {
     document.getElementById('listview_title').innerText = list_title + ":";
     let download = new HTML('button', { title: 'Download as mbox archive', download: 'true'}, new HTML('span', {class: 'glyphicon glyphicon-save'}, " "));
     document.getElementById('listview_title').inject(download);
+    download.addEventListener('click', () => {
+        dl_url = pm_config.apiURL + 'api/mbox.lua?';
+        for (let key in json.searchParams || {}) {
+            dl_url += key + "=" + encodeURIComponent(json.searchParams[key]) + "&";
+        }
+        location.href = dl_url;
+    });
     
     let chevrons = document.getElementById('listview_chevrons');
     let per_page = calc_per_page();
diff --git a/webui/js/source/listview-header.js b/webui/js/source/listview-header.js
index 80fe9fb..91ebf40 100644
--- a/webui/js/source/listview-header.js
+++ b/webui/js/source/listview-header.js
@@ -38,6 +38,13 @@ function listview_header(state, json) {
     document.getElementById('listview_title').innerText = list_title + ":";
     let download = new HTML('button', { title: 'Download as mbox archive', download: 'true'}, new HTML('span', {class: 'glyphicon glyphicon-save'}, " "));
     document.getElementById('listview_title').inject(download);
+    download.addEventListener('click', () => {
+        dl_url = pm_config.apiURL + 'api/mbox.lua?';
+        for (let key in json.searchParams || {}) {
+            dl_url += key + "=" + encodeURIComponent(json.searchParams[key]) + "&";
+        }
+        location.href = dl_url;
+    });
     
     let chevrons = document.getElementById('listview_chevrons');
     let per_page = calc_per_page();