Commit e9cdafae authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Added "last logout" column to users summary page. JM-595

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@5718 b35dd754-fafc-0310-a699-88a17e54d16e
parent 8a9b33c7
......@@ -124,6 +124,16 @@
## Added key: 'plugin.enterprise.dont.show'
## Added key: 'plugin.enterprise.installing'
## Added key: 'plugin.enterprise.installed'
##
## 3.1.1
## Added key: 'global.second'
## Added key: 'global.minute'
## Added key: 'global.less-minute'
## Added key: 'global.hour'
## Added key: 'global.hours'
## Added key: 'global.day'
## Added key: 'global.days'
## Added key: 'user.summary.last-logout'
# Wildfire
......@@ -412,8 +422,15 @@ global.main=Main
global.continue=Continue
global.none=None
global.refresh=Refresh
global.second=second
global.seconds=seconds
global.minute=minute
global.minutes=minutes
global.less-minute=Less than 1 minute
global.hour=hour
global.hours=hours
global.day=day
global.days=days
global.showing=Showing
global.pages=Pages
global.delete=Delete
......@@ -1729,6 +1746,7 @@ user.summary.total_user=Total Users
user.summary.sorted=Sorted by Username
user.summary.users_per_page=Users per page
user.summary.created=Created
user.summary.last-logout=Last Logout
user.summary.edit=Edit
user.summary.not_user=No users in the system.
......
......@@ -4,7 +4,7 @@
##
## For a full changelog, refer to the English bundle, wildfire_i18n_en.properties.
##
## Updated for release: 3.1.0
## Updated for release: 3.1.1
# Wildfire
......@@ -290,8 +290,15 @@ global.main=Principal
global.continue=Continuar
global.none=Ninguno
global.refresh=Refrescar
global.second=segundo
global.seconds=segundos
global.minute=minuto
global.minutes=minutos
global.less-minute=Menos de 1 minuto
global.hour=hora
global.hours=horas
global.day=d\u00eda
global.days=d\u00edas
global.showing=Mostrando
global.pages=P\u00e1ginas
global.delete=Borrar
......@@ -1493,6 +1500,7 @@ user.summary.total_user=Total de Usuarios
user.summary.sorted=Ordenados por Nombre de Usuario
user.summary.users_per_page=Usuarios por p\u00e1gina
user.summary.created=Creado
user.summary.last-logout=\u00daltima Salida
user.summary.edit=Editar
user.summary.not_user=No hay usuarios en el sistema.
......
......@@ -893,6 +893,52 @@ public class StringUtils {
return zeroPadString(Long.toString(date.getTime()), 15);
}
/**
* Returns a textual representation for the time that has elapsed.
*
* @param delta the elapsed time.
* @return textual representation for the time that has elapsed.
*/
public static String getElapsedTime(long delta) {
if (delta < JiveConstants.MINUTE) {
return LocaleUtils.getLocalizedString("global.less-minute");
}
else if (delta < JiveConstants.HOUR) {
long mins = delta / JiveConstants.MINUTE;
StringBuilder sb = new StringBuilder();
sb.append(mins).append(" ");
sb.append((mins==1) ? LocaleUtils.getLocalizedString("global.minute") : LocaleUtils.getLocalizedString("global.minutes"));
return sb.toString();
}
else if (delta < JiveConstants.DAY) {
long hours = delta / JiveConstants.HOUR;
delta -= hours * JiveConstants.HOUR;
long mins = delta / JiveConstants.MINUTE;
StringBuilder sb = new StringBuilder();
sb.append(hours).append(" ");
sb.append((hours == 1) ? LocaleUtils.getLocalizedString("global.hour") : LocaleUtils.getLocalizedString("global.hours"));
sb.append(", ");
sb.append(mins).append(" ");
sb.append((mins == 1) ? LocaleUtils.getLocalizedString("global.minute") : LocaleUtils.getLocalizedString("global.minutes"));
return sb.toString();
} else {
long days = delta / JiveConstants.DAY;
delta -= days * JiveConstants.DAY;
long hours = delta / JiveConstants.HOUR;
delta -= hours * JiveConstants.HOUR;
long mins = delta / JiveConstants.MINUTE;
StringBuilder sb = new StringBuilder();
sb.append(days).append(" ");
sb.append((days == 1) ? LocaleUtils.getLocalizedString("global.day") : LocaleUtils.getLocalizedString("global.days"));
sb.append(", ");
sb.append(hours).append(" ");
sb.append((hours == 1) ? LocaleUtils.getLocalizedString("global.hour") : LocaleUtils.getLocalizedString("global.hours"));
sb.append(", ");
sb.append(mins).append(" ");
sb.append((mins == 1) ? LocaleUtils.getLocalizedString("global.minute") : LocaleUtils.getLocalizedString("global.minutes"));
return sb.toString();
}
}
/**
* Returns a collection of Strings as a comma-delimitted list of strings.
*
......
......@@ -58,6 +58,10 @@ public class IQLastActivityHandler extends IQHandler implements ServerFeaturesPr
// The user is offline so answer the user's "last available time and the
// status message of the last unavailable presence received from the user"
long lastActivityTime = presenceManager.getLastActivity(user);
if (lastActivityTime > -1) {
// Convert it to seconds
lastActivityTime = lastActivityTime / 1000;
}
lastActivity.addAttribute("seconds", String.valueOf(lastActivityTime));
String lastStatus = presenceManager.getLastPresenceStatus(user);
if (lastStatus != null && lastStatus.length() > 0) {
......
......@@ -127,7 +127,7 @@ public class PresenceManagerImpl extends BasicModule implements PresenceManager
String offline = user.getProperties().get(LAST_ACTIVITY_PROP);
if (offline != null) {
try {
answer = (System.currentTimeMillis() - Long.parseLong(offline)) / 1000;
answer = (System.currentTimeMillis() - Long.parseLong(offline));
}
catch (NumberFormatException e) {
Log.error(LocaleUtils.getLocalizedString("admin.error"), e);
......
......@@ -9,8 +9,8 @@
--%>
<%@ page import="org.jivesoftware.admin.AdminConsole,
org.jivesoftware.util.JiveConstants,
org.jivesoftware.util.JiveGlobals"
org.jivesoftware.util.JiveGlobals,
org.jivesoftware.util.StringUtils"
%>
<%@ page import="org.jivesoftware.wildfire.XMPPServer"%>
<%@ page import="org.jivesoftware.wildfire.update.Update"%>
......@@ -121,37 +121,10 @@
<td class="c1"><fmt:message key="index.uptime" /></td>
<td>
<%
String uptimeDisplay = null;
if ("en".equals(JiveGlobals.getLocale().getLanguage())) {
long now = System.currentTimeMillis();
long lastStarted = webManager.getXMPPServer().getServerInfo().getLastStarted().getTime();
long uptime = now - lastStarted;
if (uptime < JiveConstants.MINUTE) {
uptimeDisplay = "Less than 1 minute";
}
else if (uptime < JiveConstants.HOUR) {
long mins = uptime / JiveConstants.MINUTE;
uptimeDisplay = mins + ((mins==1) ? " minute" : " minutes");
}
else if (uptime < JiveConstants.DAY) {
long hours = uptime / JiveConstants.HOUR;
uptime -= hours * JiveConstants.HOUR;
long mins = uptime / JiveConstants.MINUTE;
uptimeDisplay = hours + ((hours==1) ? " hour" : " hours" + ", " +
mins + ((mins==1) ? " minute" : " minutes"));
}
else {
long days = uptime / JiveConstants.DAY;
uptime -= days * JiveConstants.DAY;
long hours = uptime / JiveConstants.HOUR;
uptime -= hours * JiveConstants.HOUR;
long mins = uptime / JiveConstants.MINUTE;
uptimeDisplay = days + ((days==1) ? " day" : " days") + ", " +
hours + ((hours==1) ? " hour" : " hours") + ", " +
mins + ((mins==1) ? " minute" : " minutes");
}
}
long now = System.currentTimeMillis();
long lastStarted = webManager.getXMPPServer().getServerInfo().getLastStarted().getTime();
long uptime = now - lastStarted;
String uptimeDisplay = StringUtils.getElapsedTime(uptime);
%>
<% if (uptimeDisplay != null) { %>
......
......@@ -9,14 +9,17 @@
- a copy of which is included in this distribution.
--%>
<%@ page import="org.jivesoftware.util.*,
org.jivesoftware.wildfire.user.*,
java.util.*,
<%@ page import="org.jivesoftware.util.JiveGlobals,
org.jivesoftware.util.LocaleUtils,
org.jivesoftware.util.ParamUtils,
org.jivesoftware.util.StringUtils,
org.jivesoftware.wildfire.PresenceManager,
org.xmpp.packet.Presence,
java.net.URLEncoder,
org.jivesoftware.util.JiveGlobals"
org.jivesoftware.wildfire.user.User,
org.jivesoftware.wildfire.user.UserManager"
%><%@ page import="org.xmpp.packet.JID"%>
<%@ page import="org.xmpp.packet.Presence" %>
<%@ page import="java.net.URLEncoder" %>
<%@ page import="java.util.Collection" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
......@@ -154,6 +157,7 @@
<th nowrap><fmt:message key="user.create.username" /></th>
<th nowrap><fmt:message key="user.create.name" /></th>
<th nowrap><fmt:message key="user.summary.created" /></th>
<th nowrap><fmt:message key="user.summary.last-logout" /></th>
<% // Don't allow editing or deleting if users are read-only.
if (!UserManager.getUserProvider().isReadOnly()) { %>
<th nowrap><fmt:message key="user.summary.edit" /></th>
......@@ -209,14 +213,23 @@
<% } %>
</td>
<td width="30%">
<td width="23%">
<a href="user-properties.jsp?username=<%= URLEncoder.encode(user.getUsername(), "UTF-8") %>"><%= JID.unescapeNode(user.getUsername()) %></a>
</td>
<td width="40%">
<td width="33%">
<%= user.getName() %> &nbsp;
</td>
<td width="26%">
<td width="15%">
<%= JiveGlobals.formatDate(user.getCreationDate()) %>
</td>
<td width="25%">
<% long logoutTime = presenceManager.getLastActivity(user);
if (logoutTime > -1) {
out.println(StringUtils.getElapsedTime(logoutTime));
}
else {
out.println("&nbsp;");
} %>
</td>
<% // Don't allow editing or deleting if users are read-only.
if (!UserManager.getUserProvider().isReadOnly()) { %>
......
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