diff --git a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/connections/List.java b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/connections/List.java index abb7b40e9..9f6f47df3 100644 --- a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/connections/List.java +++ b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/connections/List.java @@ -154,6 +154,10 @@ public class List extends AuthenticatingHttpServlet { xml.writeAttribute("end", Long.toString(record.getEndDate().getTime())); + // Whether connection currently active + if (record.isActive()) + xml.writeAttribute("active", "yes"); + // User involved xml.writeCharacters(record.getUsername()); diff --git a/guacamole/src/main/webapp/scripts/guac-ui.js b/guacamole/src/main/webapp/scripts/guac-ui.js index 297d71a4d..f06f43c8d 100644 --- a/guacamole/src/main/webapp/scripts/guac-ui.js +++ b/guacamole/src/main/webapp/scripts/guac-ui.js @@ -463,6 +463,14 @@ GuacUI.Connection = function(connection) { caption.appendChild(protocol); caption.appendChild(name); + // Add active usages (if any) + var active_users = connection.currentUsage(); + if (active_users > 0) { + var usage = GuacUI.createChildElement(caption, "span", "usage"); + usage.textContent = "Currently in use by " + active_users + " user(s)"; + GuacUI.addClass(element, "in-use"); + } + // Assemble connection icon element.appendChild(thumbnail); element.appendChild(caption); diff --git a/guacamole/src/main/webapp/scripts/service.js b/guacamole/src/main/webapp/scripts/service.js index 0fe6b6df4..34daaaab7 100644 --- a/guacamole/src/main/webapp/scripts/service.js +++ b/guacamole/src/main/webapp/scripts/service.js @@ -31,6 +31,11 @@ var GuacamoleService = GuacamoleService || {}; */ GuacamoleService.Connection = function(protocol, id) { + /** + * Reference to this connection. + */ + var guac_connection = this; + /** * The protocol associated with this connection. */ @@ -52,6 +57,27 @@ GuacamoleService.Connection = function(protocol, id) { */ this.history = []; + /** + * Returns the number of active users of this connection (which may be + * multiple instances under the same user) by walking the history records. + * + * @return {Number} The number of active users of this connection. + */ + this.currentUsage = function() { + + // Number of users of this connection + var usage = 0; + + // Walk history counting active entries + for (var i=0; i