Commit 804b8573 authored by Axel Brand's avatar Axel Brand Committed by daeva

Gojara

- show number of registrations in gojara gateway registration overview
- show time passed since login when hovering over last login time of registration / session in Sec/Min/H/Days

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@13679 b35dd754-fafc-0310-a699-88a17e54d16e
parent 63e58d01
......@@ -40,6 +40,7 @@ public class DatabaseManager {
private static final String UPDATE_SESSION_ENTRY = "UPDATE ofGojaraSessions SET lastActivity = ? WHERE username = ? AND transport = ?";
private static final String GET_SESSION_ENTRIES_FOR_USERNAME = "SELECT * FROM ofGojaraSessions WHERE username = ? ORDER BY lastActivity DESC";
private static final String DELETE_SESSION_ENTRY = "DELETE FROM ofGojaraSessions WHERE username = ? AND transport = ?";
private static final String GET_SESSION_COUNT = "SELECT count(*) FROM ofGojaraSessions";
private DatabaseManager() {
/*
......@@ -398,4 +399,22 @@ public class DatabaseManager {
}
return result;
}
public int getNumberOfRegistrations() {
int result = 0;
Connection con = null;
PreparedStatement pstmt = null;
try {
con = DbConnectionManager.getConnection();
pstmt = con.prepareStatement(GET_SESSION_COUNT);
ResultSet rs = pstmt.executeQuery();
rs.next();
result = rs.getInt(1);
} catch (SQLException sqle) {
Log.error(sqle);
} finally {
DbConnectionManager.closeConnection(pstmt, con);
}
return result;
}
}
......@@ -170,4 +170,7 @@ public class TransportSessionManager {
return db.getAllSessionEntries(orderAttr, order);
}
public int getNumberOfRegistrations() {
return db.getNumberOfRegistrations();
}
}
package org.jivesoftware.openfire.plugin.gojara.utils;
import java.sql.Timestamp;
import java.util.Date;
import java.util.Map;
/**
* @author axel.frederik.brand
* Helper for generating specificly linked helper columns.
*/
public class JspColumnSortingHelper {
public class JspHelper {
/**
* @param column
......@@ -53,4 +55,22 @@ public class JspColumnSortingHelper {
}
return sortinglink;
}
/**
* Compares specified date to current date and returns String explaining how much Minutes / Hours / Days has passed since then
* @param oldDate
* @return
*/
public static String dateDifferenceHelper(Date oldDate) {
Timestamp stamp = new Timestamp(System.currentTimeMillis());
Date currentDate = new Date(stamp.getTime());
long diff = currentDate.getTime() - oldDate.getTime();
long diffSeconds = diff / 1000 % 60;
long diffMinutes = diff / (60 * 1000) % 60;
long diffHours = diff / (60 * 60 * 1000) % 24;
long diffDays = diff / (24 * 60 * 60 * 1000);
return "" + diffSeconds + " Seconds " + diffMinutes + " Minutes " + diffHours + " Hours " + diffDays + " Days ago";
}
}
......@@ -3,7 +3,7 @@
<%@ page
import="org.jivesoftware.openfire.plugin.gojara.database.SessionEntry"%>
<%@ page
import="org.jivesoftware.openfire.plugin.gojara.utils.JspColumnSortingHelper"%>
import="org.jivesoftware.openfire.plugin.gojara.utils.JspHelper"%>
<%@ page import="java.util.Map"%>
<%@ page import="java.util.HashMap"%>
<%@ page import="java.util.Set"%>
......@@ -55,8 +55,8 @@
<center>
<h5>Logintime 1970 means User did only register but never logged
in, propably because of invalid credentials.</h5>
<h5>Logintime 1970 means User did register but never logged in,
propably because of invalid credentials.</h5>
</center>
<br>
<%
......@@ -81,9 +81,9 @@
if (next_items > numOfSessions)
next_items = numOfSessions;
%>
<p>
Pages: [
Registrations total: <b><%=transportManager.getNumberOfRegistrations()%></b><br>
<br> Pages: [
<%
for (int i = 1; i <= numOfPages; i++) {
%>
......@@ -101,10 +101,10 @@
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<thead>
<tr>
<th nowrap><%=JspColumnSortingHelper.sortingHelperRegistrations("username", sortParams)%></th>
<th nowrap><%=JspColumnSortingHelper.sortingHelperRegistrations("transport", sortParams)%></th>
<th nowrap><%=JspHelper.sortingHelperRegistrations("username", sortParams)%></th>
<th nowrap><%=JspHelper.sortingHelperRegistrations("transport", sortParams)%></th>
<th nowrap>Resource active?</th>
<th nowrap><%=JspColumnSortingHelper.sortingHelperRegistrations("lastActivity", sortParams)%></th>
<th nowrap><%=JspHelper.sortingHelperRegistrations("lastActivity", sortParams)%></th>
<th nowrap>Unregister?</th>
</tr>
</thead>
......@@ -114,7 +114,8 @@
%>
<tr class="jive-odd">
<td><a
href="gojara-sessionDetails.jsp?username=<%=registration.getUsername()%>"><%=registration.getUsername()%></a></td>
href="gojara-sessionDetails.jsp?username=<%=registration.getUsername()%>"
title="Session Details for <%=registration.getUsername()%>"><%=registration.getUsername()%></a></td>
<td><%=registration.getTransport()%></td>
<td>
<%
......@@ -125,7 +126,8 @@
}
%>
</td>
<td><%=registration.getLast_activityAsDate()%></td>
<td
title="<%=JspHelper.dateDifferenceHelper(registration.getLast_activityAsDate())%>"><%=registration.getLast_activityAsDate()%></td>
<td><input type="checkbox"
name="<%=registration.getUsername()%>"
value="<%=registration.getTransport()%>"></td>
......@@ -141,7 +143,7 @@
<%
for (int i = 1; i <= numOfPages; i++) {
%>
<%="<a href=\"gojara-RegistrationsOverview?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
+ "</a>"%>
<%
......
......@@ -3,7 +3,7 @@
<%@ page
import="org.jivesoftware.openfire.plugin.gojara.sessions.GatewaySession"%>
<%@ page
import="org.jivesoftware.openfire.plugin.gojara.utils.JspColumnSortingHelper"%>
import="org.jivesoftware.openfire.plugin.gojara.utils.JspHelper"%>
<%@ page import="java.util.Map"%>
<%@ page import="java.util.HashMap"%>
<%@ page import="java.util.Set"%>
......@@ -54,7 +54,8 @@
<br>
<br>
<%
ArrayList<GatewaySession> gwSessions = transportManager.getSessionsSorted(sortParams.get("sortby"), sortParams.get("sortorder"));
ArrayList<GatewaySession> gwSessions = transportManager
.getSessionsSorted(sortParams.get("sortby"), sortParams.get("sortorder"));
int numOfSessions = gwSessions.size();
int numOfPages = numOfSessions / 100;
if (request.getParameter("page") != null) {
......@@ -90,9 +91,9 @@
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<thead>
<tr>
<th nowrap><%=JspColumnSortingHelper.sortingHelperSessions("username", sortParams)%></th>
<th nowrap><%=JspColumnSortingHelper.sortingHelperSessions("transport", sortParams)%></th>
<th nowrap><%=JspColumnSortingHelper.sortingHelperSessions("loginTime", sortParams)%></th>
<th nowrap><%=JspHelper.sortingHelperSessions("username", sortParams)%></th>
<th nowrap><%=JspHelper.sortingHelperSessions("transport", sortParams)%></th>
<th nowrap><%=JspHelper.sortingHelperSessions("loginTime", sortParams)%></th>
</tr>
</thead>
<tbody>
......@@ -101,9 +102,11 @@
%>
<tr class="jive-odd">
<td><a
href="gojara-sessionDetails.jsp?username=<%=gwsession.getUsername()%>"><%=gwsession.getUsername()%></a></td>
href="gojara-sessionDetails.jsp?username=<%=gwsession.getUsername()%>"
title="Session Details for <%=gwsession.getUsername()%>"><%=gwsession.getUsername()%></a></td>
<td><%=gwsession.getTransport()%></td>
<td><%=gwsession.getLastActivity()%></td>
<td
title="<%=JspHelper.dateDifferenceHelper(gwsession.getLastActivity())%>"><%=gwsession.getLastActivity()%></td>
</tr>
<%
}
......
......@@ -4,10 +4,13 @@
import="org.jivesoftware.openfire.plugin.gojara.sessions.TransportSessionManager"%>
<%@ page
import="org.jivesoftware.openfire.plugin.gojara.database.SessionEntry"%>
<%@ page
import="org.jivesoftware.openfire.plugin.gojara.utils.JspHelper"%>
<%@ page import="java.util.Map"%>
<%@ page import="java.util.Set"%>
<%@ page import="java.util.Date"%>
<%@ page import="java.util.ArrayList"%>
<%
TransportSessionManager transportManager = TransportSessionManager.getInstance();
String username = request.getParameter("username");
......@@ -72,7 +75,7 @@
%>
<tr class="jive-odd">
<td><%=gws.getTransport()%></td>
<td><%=gws.getLastActivity()%></td>
<td title="<%=JspHelper.dateDifferenceHelper(gws.getLastActivity()) %>"><%=gws.getLastActivity()%></td>
</tr>
<%
}
......@@ -118,15 +121,14 @@
<td>
<%
if (transportManager.isTransportActive(registration.getTransport())) {
%>
<img alt="Yes" src="/images/success-16x16.gif"> <%
%> <img alt="Yes" src="/images/success-16x16.gif"> <%
} else {
%>
<img alt="No" src="/images/error-16x16.gif"> <%
%> <img alt="No" src="/images/error-16x16.gif"> <%
}
%>
</td>
<td><%=registration.getLast_activityAsDate()%></td>
<td
title="<%=JspHelper.dateDifferenceHelper(registration.getLast_activityAsDate())%>"><%=registration.getLast_activityAsDate()%></td>
<td><input type="checkbox"
name="<%=registration.getUsername()%>"
value="<%=registration.getTransport()%>"></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