Commit 155f7ee8 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

Finished first iteration.


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@1541 b35dd754-fafc-0310-a699-88a17e54d16e
parent f0220381
...@@ -15,33 +15,44 @@ ...@@ -15,33 +15,44 @@
java.util.Date, java.util.Date,
org.jivesoftware.admin.*, org.jivesoftware.admin.*,
java.text.DateFormat, java.text.DateFormat,
org.xmpp.packet.JID" org.xmpp.packet.JID,
org.jivesoftware.messenger.server.IncomingServerSession,
java.net.URLEncoder,
org.jivesoftware.messenger.component.ComponentSession"
errorPage="error.jsp" errorPage="error.jsp"
%> %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %> <%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %> <%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
<%!
final int DEFAULT_RANGE = 15;
final int[] RANGE_PRESETS = {15, 25, 50, 75, 100};
%>
<jsp:useBean id="admin" class="org.jivesoftware.util.WebManager" /> <jsp:useBean id="admin" class="org.jivesoftware.util.WebManager" />
<% admin.init(request, response, session, application, out ); %> <% admin.init(request, response, session, application, out ); %>
<% // Get parameters <% // Get parameters
int start = ParamUtils.getIntParameter(request,"start",0); int start = ParamUtils.getIntParameter(request,"start",0);
int range = ParamUtils.getIntParameter(request,"range",15); int range = ParamUtils.getIntParameter(request,"range",DEFAULT_RANGE);
boolean close = ParamUtils.getBooleanParameter(request,"close"); boolean close = ParamUtils.getBooleanParameter(request,"close");
String jid = ParamUtils.getParameter(request,"jid"); String jid = ParamUtils.getParameter(request,"jid");
// Get the user manager // Get the session manager
SessionManager sessionManager = admin.getSessionManager(); SessionManager sessionManager = admin.getSessionManager();
Collection<ComponentSession> sessions = sessionManager.getComponentSessions();
// Get the session count // Get the session count
int sessionCount = sessionManager.getSessionCount(); int sessionCount = sessions.size();
// Close a connection if requested // Close the external component connection
if (close) { if (close) {
JID address = new JID(jid);
try { try {
Session sess = sessionManager.getSession(address); Session sess = sessionManager.getComponentSession(jid);
sess.getConnection().close(); if (sess != null) {
sess.getConnection().close();
}
// wait one second // wait one second
Thread.sleep(1000L); Thread.sleep(1000L);
} }
...@@ -52,15 +63,15 @@ ...@@ -52,15 +63,15 @@
response.sendRedirect("component-session-summary.jsp?close=success"); response.sendRedirect("component-session-summary.jsp?close=success");
return; return;
} }
// paginator vars // paginator vars
int numPages = (int)Math.ceil((double)sessionCount/(double)range); int numPages = (int)Math.ceil((double)sessionCount/(double)range);
int curPage = (start/range) + 1; int curPage = (start/range) + 1;
int maxIndex = (start+range <= sessionCount ? start+range : sessionCount);
%> %>
<jsp:useBean id="pageinfo" scope="request" class="org.jivesoftware.admin.AdminPageBean" /> <jsp:useBean id="pageinfo" scope="request" class="org.jivesoftware.admin.AdminPageBean" />
<% // Title of this page and breadcrumbs <% // Title of this page and breadcrumbs
String title = LocaleUtils.getLocalizedString("session.summary.title"); String title = LocaleUtils.getLocalizedString("component.session.summary.title");
pageinfo.setTitle(title); pageinfo.setTitle(title);
pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb(LocaleUtils.getLocalizedString("global.main"), "index.jsp")); pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb(LocaleUtils.getLocalizedString("global.main"), "index.jsp"));
pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb(title, "component-session-summary.jsp")); pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb(title, "component-session-summary.jsp"));
...@@ -69,6 +80,161 @@ ...@@ -69,6 +80,161 @@
<jsp:include page="top.jsp" flush="true" /> <jsp:include page="top.jsp" flush="true" />
<jsp:include page="title.jsp" flush="true" /> <jsp:include page="title.jsp" flush="true" />
To be implemented soon! <% if ("success".equals(request.getParameter("close"))) { %>
<p class="jive-success-text">
<fmt:message key="component.session.summary.close" />
</p>
<% } %>
<fmt:message key="component.session.summary.active" />: <b><%= sessions.size() %></b>
<% if (numPages > 1) { %>
- <fmt:message key="global.showing" /> <%= (start+1) %>-<%= (start+range) %>
<% } %>
- <fmt:message key="component.session.summary.sessions_per_page" />:
<select size="1" onchange="location.href='component-session-summary.jsp?start=0&range=' + this.options[this.selectedIndex].value;">
<% for (int i=0; i<RANGE_PRESETS.length; i++) { %>
<option value="<%= RANGE_PRESETS[i] %>"
<%= (RANGE_PRESETS[i] == range ? "selected" : "") %>><%= RANGE_PRESETS[i] %></option>
<% } %>
</select>
</p>
<% if (numPages > 1) { %>
<p>
<fmt:message key="global.page" />:
[
<% for (int i=0; i<numPages; i++) {
String sep = ((i+1)<numPages) ? " " : "";
boolean isCurrent = (i+1) == curPage;
%>
<a href="component-session-summary.jsp?start=<%= (i*range) %>"
class="<%= ((isCurrent) ? "jive-current" : "") %>"
><%= (i+1) %></a><%= sep %>
<% } %>
]
</p>
<% } %>
</p>
<p>
<fmt:message key="component.session.summary.info" />
</p>
<div class="jive-table">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<thead>
<tr>
<th>&nbsp;</th>
<th nowrap><fmt:message key="component.session.label.domain" /></th>
<th nowrap><fmt:message key="component.session.label.name" /></th>
<th nowrap><fmt:message key="component.session.label.category" /></th>
<th nowrap><fmt:message key="component.session.label.type" /></th>
<th nowrap><fmt:message key="component.session.label.creation" /></th>
<th nowrap><fmt:message key="component.session.label.last_active" /></th>
<th nowrap><fmt:message key="component.session.label.close_connect" /></th>
</tr>
</thead>
<tbody>
<% // Check if no out/in connection to/from a remote server exists
if (sessions.isEmpty()) {
%>
<tr>
<td colspan="9">
<fmt:message key="component.session.summary.not_session" />
</td>
</tr>
<% } %>
<% int count = 0;
sessions = new ArrayList<ComponentSession>(sessions).subList(start, maxIndex);
for (ComponentSession componentSession : sessions) {
count++;
%>
<tr class="jive-<%= (((count % 2) == 0) ? "even" : "odd") %>">
<td width="1%" nowrap><%= count %></td>
<td width="43%" nowrap>
<a href="component-session-details.jsp?jid=<%= URLEncoder.encode(componentSession.getAddress().toString(), "UTF-8") %>" title="<fmt:message key="session.row.cliked" />"><%= componentSession.getAddress() %></a>
</td>
<td align="center" width="15%" nowrap>
<%= componentSession.getExternalComponent().getName() %>
</td>
<td align="center" width="10%" nowrap>
<%= componentSession.getExternalComponent().getCategory() %>
</td>
<td align="center" width="10%" nowrap>
<%= componentSession.getExternalComponent().getType() %>
</td>
<% Date creationDate = componentSession.getCreationDate();
Calendar creationCal = Calendar.getInstance();
creationCal.setTime(creationDate);
Date lastActiveDate = componentSession.getLastActiveDate();
Calendar lastActiveCal = Calendar.getInstance();
lastActiveCal.setTime(lastActiveDate);
Calendar nowCal = Calendar.getInstance();
boolean sameCreationDay = nowCal.get(Calendar.DAY_OF_YEAR) == creationCal.get(Calendar.DAY_OF_YEAR) && nowCal.get(Calendar.YEAR) == creationCal.get(Calendar.YEAR);
boolean sameActiveDay = nowCal.get(Calendar.DAY_OF_YEAR) == lastActiveCal.get(Calendar.DAY_OF_YEAR) && nowCal.get(Calendar.YEAR) == lastActiveCal.get(Calendar.YEAR);
%>
<td align="center" width="10%" nowrap>
<%= sameCreationDay ? JiveGlobals.formatTime(creationDate) : JiveGlobals.formatDateTime(creationDate) %>
</td>
<td align="center" width="10%" nowrap>
<%= sameActiveDay ? JiveGlobals.formatTime(lastActiveDate) : JiveGlobals.formatDateTime(lastActiveDate) %>
</td>
<td width="1%" nowrap align="center" style="border-right:1px #ccc solid;">
<a href="component-session-summary.jsp?jid=<%= URLEncoder.encode(componentSession.getAddress().toString(), "UTF-8") %>&close=true"
title="<fmt:message key="session.row.cliked_kill_session" />"
onclick="return confirm('<fmt:message key="session.row.confirm_close" />');"
><img src="images/delete-16x16.gif" width="16" height="16" border="0"></a>
</td>
</tr>
<% } %>
</tbody>
</table>
</div>
<% if (numPages > 1) { %>
<p>
<fmt:message key="global.pages" />:
[
<% for (int i=0; i<numPages; i++) {
String sep = ((i+1)<numPages) ? " " : "";
boolean isCurrent = (i+1) == curPage;
%>
<a href="component-session-summary.jsp?start=<%= (i*range) %>"
class="<%= ((isCurrent) ? "jive-current" : "") %>"
><%= (i+1) %></a><%= sep %>
<% } %>
]
</p>
<% } %>
<br>
<p>
<fmt:message key="component.session.summary.last_update" />: <%= JiveGlobals.formatDateTime(new Date()) %>
</p>
<jsp:include page="bottom.jsp" flush="true" /> <jsp:include page="bottom.jsp" flush="true" />
\ No newline at end of file
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