Add the "Reload" and "CSV" buttons
[proteocache.git] / webapp / view / reportJobStatistics.jsp
index e515b73..09a3a87 100644 (file)
@@ -1,4 +1,3 @@
-<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 
 <%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
@@ -6,61 +5,58 @@
 <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
 
-<%@page import="java.util.ArrayList"%>
-
 <html>
 <jsp:include page="fragments/header.jsp" />
 <body>
        <div class="container">
                <jsp:include page="fragments/mainmenu.jsp" />
-               <spring:url value="/stat/oneday" var="onedayquery" />
+               <spring:url value="/stat/jobsoneday/results" var="oneday_query" />
+               <spring:url value="/stat/jobsdaily/results?date1=${date1}&date2=${date2}&option=${option}" var="the_query" />
+
+               <!-- reload and CSV buttons  -->
+               <ul class="nav navbar-nav navbar-right">
+                       <li>
+                       <a href="${the_query}" class="btn btn-default active">Reload</a>
+                       </li>
+                       <c:choose><c:when test="${csvfile != ''}">
+                       <li>
+                       <a id="forCSVfile" download="data.csv" href="data:application/csv;charset=utf-8,${csvfile}" class="btn btn-default active">CSV</a>
+                       </li>
+                       </c:when></c:choose>
+               </ul>
 
+       <div class="panel panel-default">
+       <div class="panel-heading">
                <c:choose>
-                       <c:when test="${flag == 'AllDates,off'}">
-                               <p  style="font-weight:bold;">Jobs statistics for the whole period</p>
+                       <c:when test="${option == 'AllDates,off'}">
+                               <p style="font-weight:bold;">Jobs statistics for the whole period (${ndays} days)</p>
                        </c:when>
                        <c:otherwise>
-                               <p  style="font-weight:bold;">
-                                       Jobs statistics for the time period: <c:out value="${data1}" /> to <c:out value="${data2}"/>
+                               <p style="font-weight:bold;">
+                               Jobs statistics for the time period: <c:out value="${date1}" /> to <c:out value="${date2}"/> (${ndays} days)
                                </p>
                        </c:otherwise>
                </c:choose>
-               <!-- <h3>For test only! Time execution: ${timeExecution} ms</h3>-->
-               <c:choose>
+       </div>
 
+       <div class="panel-body">
+               <c:choose>
                        <c:when test="${result == null}">
                                <p>No jobs for this period</p>
                        </c:when>
                        <c:otherwise>
-                               <c:set var="sum" value="0" />
-                               <c:set var="sumOK" value="0" />
-                               <c:set var="sumStopped" value="0" />
-                               <c:set var="sumError" value="0" />
-                               <c:set var="sumTimeOut" value="0" />
-                               <c:forEach items="${result}" var="res">
-                                       <c:set var="tot" value="${res.total}" />
-                                       <c:set var="sum" value="${sum + tot}" />
-                                       <c:set var="totOK" value="${res.totalOK}" />
-                                       <c:set var="sumOK" value="${sumOK + totOK}" />
-                                       <c:set var="totStopped" value="${res.totalStopped}" />
-                                       <c:set var="sumStopped" value="${sumStopped + totStopped}" />
-                                       <c:set var="totError" value="${res.totalError}" />
-                                       <c:set var="sumError" value="${sumError + totError}" />
-                                       <c:set var="totTimeOut" value="${res.totalTimeOut}" />
-                                       <c:set var="sumTimeOut" value="${sumTimeOut + totTimeOut}" />
-                               </c:forEach>
                                <div class="table-responsive">
                                <table class="table table-striped table-hover table-bordered">
                                        <thead>
                                                <tr style="text-align: center">
                                                        <th rowspan="2" style="text-align: center">Date</th>
-                                                       <th rowspan="2" style="text-align: center">Total <br/>number of jobs</th>
-                                                       <th colspan="5" style="text-align: center">Number of jobs</th>
+                                                       <th rowspan="2" style="text-align: center">Total number<br/> of jobs</th>
+                                                       <th colspan="5" style="text-align: center">Job Statistics</th>
                                                </tr>
                                                <tr>
                                                        <th style="text-align: center">Status "OK"</th>
                                                        <th style="text-align: center">Status "Stopped"</th>
-                                                       <th style="text-align: center">Status "Error"</th>
+                                                       <th style="text-align: center">Status "Internal Error"</th>
                                                        <th style="text-align: center">Status "Time out"</th>
                                                </tr>
                                        </thead>
                                        <tbody>
                                                <tr style="font-weight: bolder;">
                                                        <td style="text-align: center">Total:</td>
-                                                       <td style="text-align: right">${sum}</td>
-                                                       <td style="text-align: right">${sumOK}</td>
-                                                       <td style="text-align: right">${sumStopped}</td>
-                                                       <td style="text-align: right">${sumError}</td>
-                                                       <td style="text-align: right">${sumTimeOut}</td>
+                                                       <c:set var="total" value="${result.wholeTotal}"/>
+                                                       <td style="text-align: right">${total.total}</td>
+                                                       <td style="text-align: right">${total.totalOK}</td>
+                                                       <td style="text-align: right">${total.totalStopped}</td>
+                                                       <td style="text-align: right">${total.totalError}</td>
+                                                       <td style="text-align: right">${total.totalTimeOut}</td>
                                                </tr>
-                                               <c:forEach items="${result}" var="res">
+                                               <c:forEach items="${result.dateTotal}" var="res">
                                                        <tr>
-                                                               <td style="text-align: center">${res.date}</td>
-                                                               <td style="text-align: right">${res.total}</td>
-                                                               <td style="text-align: right"><a href="${onedayquery}?date=${res.date}">${res.totalOK}</a></td>
-                                                               <td style="text-align: right">${res.totalStopped}</td>
-                                                               <td style="text-align: right">${res.totalError}</td>
-                                                               <td style="text-align: right">${res.totalTimeOut}</td>
+                                                               <td style="text-align: center">${res.key}</td>
+                                                               <c:set var="value" value="${res.value}"/>
+                                                               <td style="text-align: right">${value.total}</td>
+                                                               <td style="text-align: right"><a href="${oneday_query}?date=${res.key}&status=OK">${value.totalOK}</a></td>
+                                                               <td style="text-align: right">
+                                                                       <c:choose>
+                                                                       <c:when test="${value.totalStopped == 0}">0</c:when>
+                                                                       <c:otherwise><a href="${oneday_query}?date=${res.key}&status=Stopped">${value.totalStopped}</a></c:otherwise>
+                                                                       </c:choose>
+                                                               </td>
+                                                               <td style="text-align: right">
+                                                                       <c:choose>
+                                                                       <c:when test="${value.totalError == 0}">0</c:when>
+                                                                       <c:otherwise><a href="${oneday_query}?date=${res.key}&status=JpredError">${value.totalError}</a></c:otherwise>
+                                                                       </c:choose>
+                                                               </td>
+                                                               <td style="text-align: right">
+                                                                       <c:choose>
+                                                                       <c:when test="${value.totalTimeOut == 0}">0</c:when>
+                                                                       <c:otherwise><a href="${oneday_query}?date=${res.key}&status=TimedOut">${value.totalTimeOut}</a></c:otherwise>
+                                                                       </c:choose>
+                                                               </td>
                                                        </tr>
                                                </c:forEach>
                                        </tbody>
                                </div>
                        </c:otherwise>
                </c:choose>
+       </div>
+       </div>
+
                <jsp:include page="fragments/footer.jsp" />
        </div>
 </body>