Commit d9e4780e authored by Axel Brand's avatar Axel Brand Committed by daeva

Goajra

- finally fixed Pagination for real this time. All major features of admin panel are done and tested.
- few minor changes in changelog / readme incoming, but this is probably the state 2.1 will be released in

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@13716 b35dd754-fafc-0310-a699-88a17e54d16e
parent e811c7c2
...@@ -48,7 +48,7 @@ GoJara Plugin Changelog ...@@ -48,7 +48,7 @@ GoJara Plugin Changelog
<ul> <ul>
<li>Added new functionality: "Admin Panel". See below for further info</li> <li>Added new functionality: "Admin Panel". See below for further info</li>
<li>active Sessions: see which users are currently connected to a transport and when they logged in.</li> <li>active Sessions: see which users are currently connected to a transport and time of login.</li>
<li>Session details: Overview of active Sessions and existing Registrations for specific User.</li> <li>Session details: Overview of active Sessions and existing Registrations for specific User.</li>
<li>Registration Overview: manage existing Registrations, even of users that never logged in (probably due to wrong credentials)</li> <li>Registration Overview: manage existing Registrations, even of users that never logged in (probably due to wrong credentials)</li>
<li>Spectrum2 Stats: Overview of Spectrum2 backend Statistics, uptime, used Memory, Memory Per User...</li> <li>Spectrum2 Stats: Overview of Spectrum2 backend Statistics, uptime, used Memory, Memory Per User...</li>
......
...@@ -171,10 +171,9 @@ public class GojaraAdminManager { ...@@ -171,10 +171,9 @@ public class GojaraAdminManager {
public void gatherGatewayStatistics() { public void gatherGatewayStatistics() {
if (refreshCooldown == 0) { if (refreshCooldown == 0) {
refreshCooldown = System.currentTimeMillis(); refreshCooldown = System.currentTimeMillis();
} else { } else if ((System.currentTimeMillis() - refreshCooldown) < 60000) {
// once a minute max // once a minute max
if ((System.currentTimeMillis() - refreshCooldown) < 60000) return;
return;
} }
refreshCooldown = System.currentTimeMillis(); refreshCooldown = System.currentTimeMillis();
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
GojaraAdminManager gojaraAdminManager = GojaraAdminManager.getInstance(); GojaraAdminManager gojaraAdminManager = GojaraAdminManager.getInstance();
//Helper object for generation of sorting links, column restriction is done in DatabaseManager //Helper object for generation of sorting links, column restriction is done in DatabaseManager
// we need this object so we cann pass the parameters around to our functions
Map<String, String> sortParams = new HashMap<String, String>(); Map<String, String> sortParams = new HashMap<String, String>();
if (request.getParameter("sortby") != null && request.getParameter("sortorder") != null) { if (request.getParameter("sortby") != null && request.getParameter("sortorder") != null) {
sortParams.put("sortby", request.getParameter("sortby")); sortParams.put("sortby", request.getParameter("sortby"));
...@@ -27,8 +28,6 @@ ...@@ -27,8 +28,6 @@
sortParams.put("sortby", "username"); sortParams.put("sortby", "username");
sortParams.put("sortorder", "ASC"); sortParams.put("sortorder", "ASC");
} }
//pagination
int current_page = 1;
%> %>
<html> <html>
...@@ -40,7 +39,7 @@ ...@@ -40,7 +39,7 @@
<div align="center"> <div align="center">
<ul style="list-style: none;padding:0;margin:0;"> <ul style="list-style: none;padding:0;margin:0;">
<% <%
//do unregisters if supplied //do unregisters if supplied, we do them here because we generate output that should be displayed
if (request.getParameterMap() != null) { if (request.getParameterMap() != null) {
String uninteresting_params = "sortorder sortby page"; String uninteresting_params = "sortorder sortby page";
for (Object key : request.getParameterMap().keySet()) { for (Object key : request.getParameterMap().keySet()) {
...@@ -73,26 +72,29 @@ ...@@ -73,26 +72,29 @@
</div> </div>
<br> <br>
<% <%
//Here we do our nice query //pagination logic
//get all records, we limit these later. Not all databes support limiting queries so we need to do it the bad way
ArrayList<SessionEntry> registrations = transportManager.getAllRegistrations(sortParams.get("sortby"), ArrayList<SessionEntry> registrations = transportManager.getAllRegistrations(sortParams.get("sortby"),
sortParams.get("sortorder")); sortParams.get("sortorder"));
int numOfSessions = registrations.size(); int numOfSessions = registrations.size();
int numOfPages = numOfSessions / 100; // 100 entries is exactly 1 page, 101 entries is 2 pages
int numOfPages = numOfSessions % 100 == 0 ? (numOfSessions / 100) : (1 + (numOfSessions / 100));
//lets check for validity if page parameter is supplied, set it to 1 if not in valid range
int current_page = 1;
if (request.getParameter("page") != null) { if (request.getParameter("page") != null) {
//lets check for validity
try { try {
current_page = Integer.parseInt(request.getParameter("page")); current_page = Integer.parseInt(request.getParameter("page"));
if (current_page < 1 || current_page > (numOfPages)) if (current_page < 1 || current_page > numOfPages)
current_page = 1; current_page = 1;
} catch (Exception e) { } catch (Exception e) {
} }
} }
// we now know current_page is in valid range, so set it for computation // we now know current_page is in valid range from supplied parameter or standard.
current_page -= 1;
numOfPages += 1;
// this will be our sublist starting index, 0, 100, 200 ... // this will be our sublist starting index, 0, 100, 200 ...
int current_index = current_page * 100; int current_index = (current_page -1)* 100;
//ending index, 99, 199 etc, when next items > numOfSessions we have reached last page, set proper index so we have no out of bounds //ending index, 100, 200 etc, when next items > numOfSessions we have reached last page, set proper index so we have no out of bounds
//ending index is excluded, so 0-100 is 0-99, e.g. item 1-100
int next_items = current_index + 100; int next_items = current_index + 100;
if (next_items > numOfSessions) if (next_items > numOfSessions)
next_items = numOfSessions; next_items = numOfSessions;
...@@ -103,8 +105,8 @@ ...@@ -103,8 +105,8 @@
for (int i = 1; i <= numOfPages; i++) { for (int i = 1; i <= numOfPages; i++) {
%> %>
<%="<a href=\"gojara-RegistrationsOverview.jsp?page=" + i + "&sortby=" + sortParams.get("sortby") + "&sortorder=" <%="<a href=\"gojara-RegistrationsOverview.jsp?page=" + i + "&sortby=" + sortParams.get("sortby") + "&sortorder="
+ sortParams.get("sortorder") + "\" class=\"" + ((current_page + 1) == i ? "jive-current" : "") + "\">" + i + sortParams.get("sortorder") + "\" class=\"" + (current_page == i ? "jive-current" : "") + "\">" + i
+ "</a>"%> + "</a>" %>
<% <%
} }
%> %>
...@@ -126,8 +128,7 @@ ...@@ -126,8 +128,7 @@
</thead> </thead>
<tbody> <tbody>
<% <%
// sublist TOindex has to be +1, so 0,100 is item 0 - 99 for (SessionEntry registration : registrations.subList(current_index, next_items)) {
for (SessionEntry registration : registrations.subList(0 , next_items)) {
%> %>
<tr class="jive-odd"> <tr class="jive-odd">
<td><a <td><a
...@@ -168,7 +169,7 @@ ...@@ -168,7 +169,7 @@
for (int i = 1; i <= numOfPages; i++) { for (int i = 1; i <= numOfPages; i++) {
%> %>
<%="<a href=\"gojara-RegistrationsOverview.jsp?page=" + i + "&sortby=" + sortParams.get("sortby") + "&sortorder=" <%="<a href=\"gojara-RegistrationsOverview.jsp?page=" + i + "&sortby=" + sortParams.get("sortby") + "&sortorder="
+ sortParams.get("sortorder") + "\" class=\"" + ((current_page + 1) == i ? "jive-current" : "") + "\">" + i + sortParams.get("sortorder") + "\" class=\"" + (current_page == i ? "jive-current" : "") + "\">" + i
+ "</a>"%> + "</a>"%>
<% <%
} }
......
...@@ -26,9 +26,6 @@ ...@@ -26,9 +26,6 @@
sortParams.put("sortby", "transport"); sortParams.put("sortby", "transport");
sortParams.put("sortorder", "ASC"); sortParams.put("sortorder", "ASC");
} }
//pagination
int current_page = 1;
%> %>
<html> <html>
<head> <head>
...@@ -59,24 +56,30 @@ ...@@ -59,24 +56,30 @@
<br> <br>
<br> <br>
<% <%
//pagination logic
//get all records, we limit these later as we have to sort them first
ArrayList<GatewaySession> gwSessions = transportManager ArrayList<GatewaySession> gwSessions = transportManager
.getSessionsSorted(sortParams.get("sortby"), sortParams.get("sortorder")); .getSessionsSorted(sortParams.get("sortby"), sortParams.get("sortorder"));
int numOfSessions = gwSessions.size(); int numOfSessions = gwSessions.size();
int numOfPages = numOfSessions / 100; // 100 entries is exactly 1 page, 101 entries is 2 pages
int numOfPages = numOfSessions % 100 == 0 ? (numOfSessions / 100) : (1 + (numOfSessions / 100));
//lets check for validity if page parameter is supplied, set it to 1 if not in valid range
int current_page = 1;
if (request.getParameter("page") != null) { if (request.getParameter("page") != null) {
//lets check for validity
try { try {
current_page = Integer.parseInt(request.getParameter("page")); current_page = Integer.parseInt(request.getParameter("page"));
if (current_page < 1 || current_page > (numOfPages)) if (current_page < 1 || current_page > numOfPages)
current_page = 1; current_page = 1;
} catch (Exception e) { } catch (Exception e) {
} }
} }
// we now know current_page is in valid range, so set it for computation // we now know current_page is in valid range from supplied parameter or standard.
current_page -= 1; // this will be our sublist starting index, 0, 100, 200 ...
numOfPages += 1; int current_index = (current_page -1)* 100;
int current_index = (current_page * 100); //ending index, 100, 200 etc, when next items > numOfSessions we have reached last page, set proper index so we have no out of bounds
int next_items= current_index + 100; //ending index is excluded, so 0-100 is 0-99, e.g. item 1-100
int next_items = current_index + 100;
if (next_items > numOfSessions) if (next_items > numOfSessions)
next_items = numOfSessions; next_items = numOfSessions;
%> %>
...@@ -86,7 +89,7 @@ ...@@ -86,7 +89,7 @@
for (int i = 1; i <= numOfPages; i++) { for (int i = 1; i <= numOfPages; i++) {
%> %>
<%="<a href=\"gojara-activeSessions.jsp?page=" + i + "&sortby=" + sortParams.get("sortby") + "&sortorder=" <%="<a href=\"gojara-activeSessions.jsp?page=" + i + "&sortby=" + sortParams.get("sortby") + "&sortorder="
+ sortParams.get("sortorder") + "\" class=\"" + ((current_page + 1) == i ? "jive-current" : "") + "\">" + i + sortParams.get("sortorder") + "\" class=\"" + (current_page == i ? "jive-current" : "") + "\">" + i
+ "</a>"%> + "</a>"%>
<% <%
} }
...@@ -129,7 +132,7 @@ ...@@ -129,7 +132,7 @@
for (int i = 1; i <= numOfPages; i++) { for (int i = 1; i <= numOfPages; i++) {
%> %>
<%="<a href=\"gojara-activeSessions.jsp?page=" + i + "&sortby=" + sortParams.get("sortby") + "&sortorder=" <%="<a href=\"gojara-activeSessions.jsp?page=" + i + "&sortby=" + sortParams.get("sortby") + "&sortorder="
+ sortParams.get("sortorder") + "\" class=\"" + ((current_page + 1) == i ? "jive-current" : "") + "\">" + i + sortParams.get("sortorder") + "\" class=\"" + (current_page == i ? "jive-current" : "") + "\">" + i
+ "</a>"%> + "</a>"%>
<% <%
} }
......
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
<tr class="jive-odd"> <tr class="jive-odd">
<td><%=gateway %> <% if (!gateway.contains(domain)) { %> <td><%=gateway %> <% if (!gateway.contains(domain)) { %>
<img alt="gateway configuration info" src="/images/header-help_new.gif" title="Component name does not include server name: <%=domain%>. <img alt="gateway configuration info" src="/images/header-help_new.gif" title="Component name does not include server name: <%=domain%>.
It should be configured like this: transport.server-name, e.g.: icq.<%=domain%>"> It should probably be configured like this: transport.server-name, e.g.: icq.<%=domain%>">
<% } %> <% } %>
</td> </td>
<td> <td>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment