commit adc0de62d3d406eb46968f40fc9647818866be5e
Author: Karsten Loesing <karsten.loes...@gmx.net>
Date:   Sun Apr 24 16:05:05 2011 +0200

    Show default start and end dates for graphs.
---
 .../ernie/web/GraphsSubpagesServlet.java           |   12 ++++++++
 web/WEB-INF/network.jsp                            |   28 ++++++++++----------
 web/WEB-INF/packages.jsp                           |    4 +-
 web/WEB-INF/performance.jsp                        |   12 ++++----
 web/WEB-INF/users.jsp                              |    9 +++---
 5 files changed, 39 insertions(+), 26 deletions(-)

diff --git a/src/org/torproject/ernie/web/GraphsSubpagesServlet.java 
b/src/org/torproject/ernie/web/GraphsSubpagesServlet.java
index 2de2eac..f8dfba4 100644
--- a/src/org/torproject/ernie/web/GraphsSubpagesServlet.java
+++ b/src/org/torproject/ernie/web/GraphsSubpagesServlet.java
@@ -3,6 +3,7 @@ package org.torproject.ernie.web;
 import javax.servlet.*;
 import javax.servlet.http.*;
 import java.io.*;
+import java.text.*;
 import java.util.*;
 
 public class GraphsSubpagesServlet extends HttpServlet {
@@ -77,6 +78,17 @@ public class GraphsSubpagesServlet extends HttpServlet {
     /* Pass list of known countries in case we want to display them. */
     request.setAttribute("countries", this.knownCountries);
 
+    /* Pass the default start and end dates. */
+    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+    dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
+    Date defaultEndDate = new Date();
+    Date defaultStartDate = new Date(defaultEndDate.getTime()
+        - 90L * 24L * 60L * 60L * 1000L);
+    request.setAttribute("default_start_date",
+        dateFormat.format(defaultStartDate));
+    request.setAttribute("default_end_date",
+        dateFormat.format(defaultEndDate));
+
     /* Forward the request to the JSP that does all the hard work. */
     request.getRequestDispatcher(jsp).forward(request, response);
   }
diff --git a/web/WEB-INF/network.jsp b/web/WEB-INF/network.jsp
index 28a7c34..a1a5efe 100644
--- a/web/WEB-INF/network.jsp
+++ b/web/WEB-INF/network.jsp
@@ -27,10 +27,10 @@ bridges in the network.</p>
     <p>
     <label>Start date (yyyy-mm-dd):</label>
       <input type="text" name="start" size="10"
-             value="${networksize_start[0]}">
+             value="<c:choose><c:when test="${fn:length(networksize_start) == 
0}">${default_start_date}</c:when><c:otherwise>${networksize_start[0]}</c:otherwise></c:choose>">
     <label>End date (yyyy-mm-dd):</label>
       <input type="text" name="end" size="10"
-             value="${networksize_end[0]}">
+             value="<c:choose><c:when test="${fn:length(networksize_end) == 
0}">${default_end_date}</c:when><c:otherwise>${networksize_end[0]}</c:otherwise></c:choose>">
     </p><p>
       Resolution: <select name="dpi">
         <option value="72"<c:if test="${networksize_dpi[0] eq '72'}"> 
selected</c:if>>Screen - 576x360</option>
@@ -58,10 +58,10 @@ country.</p>
     <p>
     <label>Start date (yyyy-mm-dd):</label>
       <input type="text" name="start" size="10"
-             value="${relaycountries_start[0]}">
+             value="<c:choose><c:when test="${fn:length(relaycountries_start) 
== 
0}">${default_start_date}</c:when><c:otherwise>${relaycountries_start[0]}</c:otherwise></c:choose>">
     <label>End date (yyyy-mm-dd):</label>
       <input type="text" name="end" size="10"
-             value="${relaycountries_end[0]}">
+             value="<c:choose><c:when test="${fn:length(relaycountries_end) == 
0}">${default_end_date}</c:when><c:otherwise>${relaycountries_end[0]}</c:otherwise></c:choose>">
     </p><p>
       Source: <select name="country">
         <option value="all"<c:if test="${relaycountries_country[0] eq 'all'}"> 
selected</c:if>>All relays</option>
@@ -97,10 +97,10 @@ average number of relays with these flags assigned.</p>
     <p>
     <label>Start date (yyyy-mm-dd):</label>
       <input type="text" name="start" size="10"
-             value="${relayflags_start[0]}">
+             value="<c:choose><c:when test="${fn:length(relayflags_start) == 
0}">${default_start_date}</c:when><c:otherwise>${relayflags_start[0]}</c:otherwise></c:choose>">
     <label>End date (yyyy-mm-dd):</label>
       <input type="text" name="end" size="10"
-             value="${relayflags_end[0]}">
+             value="<c:choose><c:when test="${fn:length(relayflags_end) == 
0}">${default_end_date}</c:when><c:otherwise>${relayflags_end[0]}</c:otherwise></c:choose>">
     </p><p>
       <label>Relay flags: </label>
       <input type="checkbox" name="flag" value="Running"<c:if 
test="${fn:length(relayflags_flag) == 0 or fn:contains(fn:join(relayflags_flag, 
','), 'Running')}"> checked</c:if>> Running
@@ -140,10 +140,10 @@ version.</p>
     <p>
     <label>Start date (yyyy-mm-dd):</label>
       <input type="text" name="start" size="10"
-             value="${versions_start[0]}">
+             value="<c:choose><c:when test="${fn:length(versions_start) == 
0}">${default_start_date}</c:when><c:otherwise>${versions_start[0]}</c:otherwise></c:choose>">
     <label>End date (yyyy-mm-dd):</label>
       <input type="text" name="end" size="10"
-             value="${versions_end[0]}">
+             value="<c:choose><c:when test="${fn:length(versions_end) == 
0}">${default_end_date}</c:when><c:otherwise>${versions_end[0]}</c:otherwise></c:choose>">
     </p><p>
       Resolution: <select name="dpi">
         <option value="72"<c:if test="${versions_dpi[0] eq '72'}"> 
selected</c:if>>Screen - 576x360</option>
@@ -174,10 +174,10 @@ platform.</p>
     <p>
     <label>Start date (yyyy-mm-dd):</label>
       <input type="text" name="start" size="10"
-             value="${platforms_start[0]}">
+             value="<c:choose><c:when test="${fn:length(platforms_start) == 
0}">${default_start_date}</c:when><c:otherwise>${platforms_start[0]}</c:otherwise></c:choose>">
     <label>End date (yyyy-mm-dd):</label>
       <input type="text" name="end" size="10"
-             value="${platforms_end[0]}">
+             value="<c:choose><c:when test="${fn:length(platforms_end) == 
0}">${default_end_date}</c:when><c:otherwise>${platforms_end[0]}</c:otherwise></c:choose>">
     </p><p>
       Resolution: <select name="dpi">
         <option value="72"<c:if test="${platforms_dpi[0] eq '72'}"> 
selected</c:if>>Screen - 576x360</option>
@@ -209,10 +209,10 @@ in the network.</p>
     <p>
     <label>Start date (yyyy-mm-dd):</label>
       <input type="text" name="start" size="10"
-             value="${bandwidth_start[0]}">
+             value="<c:choose><c:when test="${fn:length(bandwidth_start) == 
0}">${default_start_date}</c:when><c:otherwise>${bandwidth_start[0]}</c:otherwise></c:choose>">
     <label>End date (yyyy-mm-dd):</label>
       <input type="text" name="end" size="10"
-             value="${bandwidth_end[0]}">
+             value="<c:choose><c:when test="${fn:length(bandwidth_end) == 
0}">${default_end_date}</c:when><c:otherwise>${bandwidth_end[0]}</c:otherwise></c:choose>">
     </p><p>
       Resolution: <select name="dpi">
         <option value="72"<c:if test="${bandwidth_dpi[0] eq '72'}"> 
selected</c:if>>Screen - 576x360</option>
@@ -243,10 +243,10 @@ the number of written and read dir bytes by all 
relays.</p>
     <p>
     <label>Start date (yyyy-mm-dd):</label>
       <input type="text" name="start" size="10"
-             value="${dirbytes_start[0]}">
+             value="<c:choose><c:when test="${fn:length(dirbytes_start) == 
0}">${default_start_date}</c:when><c:otherwise>${dirbytes_start[0]}</c:otherwise></c:choose>">
     <label>End date (yyyy-mm-dd):</label>
       <input type="text" name="end" size="10"
-             value="${dirbytes_end[0]}">
+             value="<c:choose><c:when test="${fn:length(dirbytes_end) == 
0}">${default_end_date}</c:when><c:otherwise>${dirbytes_end[0]}</c:otherwise></c:choose>">
     </p><p>
       Resolution: <select name="dpi">
         <option value="72"<c:if test="${dirbytes_dpi[0] eq '72'}"> 
selected</c:if>>Screen - 576x360</option>
diff --git a/web/WEB-INF/packages.jsp b/web/WEB-INF/packages.jsp
index b4ecb5f..9a19aca 100644
--- a/web/WEB-INF/packages.jsp
+++ b/web/WEB-INF/packages.jsp
@@ -28,10 +28,10 @@ graph shows the number of packages requested from GetTor 
per day.</p>
     <p>
     <label>Start date (yyyy-mm-dd):</label>
       <input type="text" name="start" size="10"
-             value="${gettor_start[0]}">
+             value="<c:choose><c:when test="${fn:length(gettor_start) == 
0}">${default_start_date}</c:when><c:otherwise>${gettor_start[0]}</c:otherwise></c:choose>">
     <label>End date (yyyy-mm-dd):</label>
       <input type="text" name="end" size="10"
-             value="${gettor_end[0]}">
+             value="<c:choose><c:when test="${fn:length(gettor_end) == 
0}">${default_end_date}</c:when><c:otherwise>${gettor_end[0]}</c:otherwise></c:choose>">
     </p><p>
       Packages:
       <input type="radio" name="bundle" value="all" <c:if 
test="${fn:length(gettor_bundle) == 0 or gettor_bundle[0] eq 'all'}"> 
checked</c:if>> Total packages
diff --git a/web/WEB-INF/performance.jsp b/web/WEB-INF/performance.jsp
index 939beec..095bda2 100644
--- a/web/WEB-INF/performance.jsp
+++ b/web/WEB-INF/performance.jsp
@@ -29,10 +29,10 @@ quartile of request times.</p>
     <p>
     <label>Start date (yyyy-mm-dd):</label>
       <input type="text" name="start" size="10"
-             value="${torperf_start[0]}">
+             value="<c:choose><c:when test="${fn:length(torperf_start) == 
0}">${default_start_date}</c:when><c:otherwise>${torperf_start[0]}</c:otherwise></c:choose>">
     <label>End date (yyyy-mm-dd):</label>
       <input type="text" name="end" size="10"
-             value="${torperf_end[0]}">
+             value="<c:choose><c:when test="${fn:length(torperf_end) == 
0}">${default_end_date}</c:when><c:otherwise>${torperf_end[0]}</c:otherwise></c:choose>">
     </p><p>
       Source:
       <input type="radio" name="source" value="all"<c:if 
test="${fn:length(torperf_source) == 0 or torperf_source[0] eq 'all'}"> 
checked</c:if>> all
@@ -75,10 +75,10 @@ than 50 KiB (1 MiB, 5 MiB).</p>
     <p>
     <label>Start date (yyyy-mm-dd):</label>
       <input type="text" name="start" size="10"
-             value="${torperf_failures_start[0]}">
+             value="<c:choose><c:when 
test="${fn:length(torperf_failures_start) == 
0}">${default_start_date}</c:when><c:otherwise>${torperf_failures_start[0]}</c:otherwise></c:choose>">
     <label>End date (yyyy-mm-dd):</label>
       <input type="text" name="end" size="10"
-             value="${torperf_failures_end[0]}">
+             value="<c:choose><c:when test="${fn:length(torperf_failures_end) 
== 
0}">${default_end_date}</c:when><c:otherwise>${torperf_failures_end[0]}</c:otherwise></c:choose>">
     </p><p>
       Source:
       <input type="radio" name="source" value="all"<c:if 
test="${fn:length(torperf_failures_source) == 0 or torperf_failures_source[0] 
eq 'all'}"> checked</c:if>> all
@@ -126,10 +126,10 @@ classifying connections, read and write counters are 
reset for the next
     <p>
     <label>Start date (yyyy-mm-dd):</label>
       <input type="text" name="start" size="10"
-             value="${connbidirect_start[0]}">
+             value="<c:choose><c:when test="${fn:length(connbidirect_start) == 
0}">${default_start_date}</c:when><c:otherwise>${connbidirect_start[0]}</c:otherwise></c:choose>">
     <label>End date (yyyy-mm-dd):</label>
       <input type="text" name="end" size="10"
-             value="${connbidirect_end[0]}">
+             value="<c:choose><c:when test="${fn:length(connbidirect_end) == 
0}">${default_end_date}</c:when><c:otherwise>${connbidirect_end[0]}</c:otherwise></c:choose>">
     </p><p>
       Resolution: <select name="dpi">
         <option value="72"<c:if test="${connbidirect_dpi[0] eq '72'}"> 
selected</c:if>>Screen - 576x360</option>
diff --git a/web/WEB-INF/users.jsp b/web/WEB-INF/users.jsp
index 7ea45a5..60be8ab 100644
--- a/web/WEB-INF/users.jsp
+++ b/web/WEB-INF/users.jsp
@@ -1,4 +1,5 @@
 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"; %>
+<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"; %>
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
 <html>
 <head>
@@ -30,10 +31,10 @@ based on the requests seen by a few dozen directory 
mirrors.</p>
     <p>
     <label>Start date (yyyy-mm-dd):</label>
       <input type="text" name="start" size="10"
-             value="${direct_users_start[0]}">
+             value="<c:choose><c:when test="${fn:length(direct_users_start) == 
0}">${default_start_date}</c:when><c:otherwise>${direct_users_start[0]}</c:otherwise></c:choose>">
     <label>End date (yyyy-mm-dd):</label>
       <input type="text" name="end" size="10"
-             value="${direct_users_end[0]}">
+             value="<c:choose><c:when test="${fn:length(direct_users_end) == 
0}">${default_end_date}</c:when><c:otherwise>${direct_users_end[0]}</c:otherwise></c:choose>">
     </p><p>
       Source: <select name="country">
         <option value="all"<c:if test="${direct_users_country[0] eq 'all'}"> 
selected</c:if>>All users</option>
@@ -74,10 +75,10 @@ by a few hundred bridges.</p>
     <p>
     <label>Start date (yyyy-mm-dd):</label>
       <input type="text" name="start" size="10"
-             value="${bridge_users_start[0]}">
+             value="<c:choose><c:when test="${fn:length(bridge_users_start) == 
0}">${default_start_date}</c:when><c:otherwise>${bridge_users_start[0]}</c:otherwise></c:choose>">
     <label>End date (yyyy-mm-dd):</label>
       <input type="text" name="end" size="10"
-             value="${bridge_users_end[0]}">
+             value="<c:choose><c:when test="${fn:length(bridge_users_end) == 
0}">${default_end_date}</c:when><c:otherwise>${bridge_users_end[0]}</c:otherwise></c:choose>">
     </p><p>
       Source: <select name="country">
         <option value="all"<c:if test="${bridge_users_country[0] eq 'all'}"> 
selected</c:if>>All users</option>

_______________________________________________
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits

Reply via email to