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 d4b1241f7d8183adc54f921e6222e636cc08a134
Author: Daniel Gruno <[email protected]>
AuthorDate: Tue Sep 21 19:02:54 2021 -0500

    rough in a header search feature
    
    this will need smoothing out, but works okay.
---
 webui/js/source/search.js           | 18 ++++++++++++++++--
 webui/js/source/sidebar-calendar.js | 11 +++++++++--
 webui/list.html                     |  6 ++++++
 3 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/webui/js/source/search.js b/webui/js/source/search.js
index 3d95d36..613a419 100644
--- a/webui/js/source/search.js
+++ b/webui/js/source/search.js
@@ -28,13 +28,27 @@ function search(query, date) {
         list = '*';
         global = true;
     }
+
+    let listid = '%s@%s'.format(list, domain);
+    let newhref = "list?%s:%s:%s".format(listid, date, query);
+
+    let header_from = document.getElementById('header_from');
+    let header_subject = document.getElementById('header_subject');
     let sURL = '%sapi/stats.lua?d=%s&list=%s&domain=%s&q=%s'.format(apiURL, 
date, list, domain, query);
+    if (header_from.value.length > 0) {
+        sURL += 
"&header_from=%s".format(encodeURIComponent(header_from.value));
+        newhref += "&header_from=%s".format(header_from.value);
+        header_from.value = "";
+    }
+    if (header_subject.value.length > 0) {
+        sURL += 
"&header_subject=%s".format(encodeURIComponent(header_subject.value));
+        newhref += "&header_subject=%s".format(header_subject.value);
+        header_subject.value = "";
+    }
     GET(sURL, renderListView, {
         search: true,
         global: global
     });
-    let listid = '%s@%s'.format(list, domain);
-    let newhref = "list?%s:%s:%s".format(listid, date, query);
     if (location.href !== newhref) {
         window.history.pushState({}, null, newhref);
     }
diff --git a/webui/js/source/sidebar-calendar.js 
b/webui/js/source/sidebar-calendar.js
index 64176f6..e54df16 100644
--- a/webui/js/source/sidebar-calendar.js
+++ b/webui/js/source/sidebar-calendar.js
@@ -168,10 +168,17 @@ function calendar_click(year, month) {
     let q = "";
     let calendar_current_list = current_list;
     let calendar_current_domain = current_domain;
-    if (current_json && current_json.searchParams && 
current_json.searchParams.q) {
-        q = current_json.searchParams.q;
+    if (current_json && current_json.searchParams) {
+        q = current_json.searchParams.q || "";
         calendar_current_list = current_json.searchParams.list;
         calendar_current_domain = current_json.searchParams.domain;
+        // Weave in header parameters
+        for (let key of Object.keys((current_json.searchParams || {}))) {
+            if (key.match(/^header_/)) {
+                let value = current_json.searchParams[key];
+                q += `&${key}=${value}`;
+            }
+        }
     }
     let newhref = "list?%s@%s:%u-%u".format(calendar_current_list, 
calendar_current_domain, year, month);
     if (q && q.length > 0) newhref += ":" + q;
diff --git a/webui/list.html b/webui/list.html
index 7699f46..d57cc6b 100644
--- a/webui/list.html
+++ b/webui/list.html
@@ -67,7 +67,13 @@ the License. -->
           <li><b>Date range:</b>
             <span id='drh'><input title="Click to change the date range" 
style="padding-left: 20px; border: none; cursor: url(images/daterange.ico), 
text; min-width: 200px; margin-right: 10px; background-color: transparent; 
font-size: 9pt;" name="d" id='d' data="lte=1M" value="Less than 1 month ago" 
onclick="datePicker(this);" readonly="readonly"/></span>
           </li>
+          <li class="divider"></li>
+          <li><b>Advanced filters:</b><br/>
+            <div style="display: inline-block; width: 120px;">Author: 
</div><span id='hd_from'><input title="Name or email address" style="min-width: 
200px; margin-right: 10px; background-color: white; font-size: 8pt;" 
name="header_from" id='header_from' value=""/></span><br/>
+            <div style="display: inline-block; width: 120px;">Subject: 
</div><span id='hd_subject'><input style="min-width: 200px; margin-right: 10px; 
background-color: white; font-size: 8pt;" name="header_subject" 
id='header_subject' value=""/></span><br/>
+          </li>
         </ul>
+
         
         <input type="text" name="q" id="q" placeholder="Search this list..." 
style="border-top: none; border-bottom: none;"/>
         <button type="submit" title="Search!" value="Search!" class="btn 
btn-primary"><span class="glyphicon glyphicon-search"> </span></button>

Reply via email to