mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
Display active status of connections.
This commit is contained in:
@@ -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());
|
||||
|
||||
|
@@ -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);
|
||||
|
@@ -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<guac_connection.history.length; i++) {
|
||||
if (guac_connection.history[i].active)
|
||||
usage++;
|
||||
}
|
||||
|
||||
return usage;
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -64,8 +90,9 @@ GuacamoleService.Connection = function(protocol, id) {
|
||||
* milliseconds).
|
||||
* @param {Number} end The time that the connection ended (in UNIX epoch
|
||||
* milliseconds). This parameter is optional.
|
||||
* @param {Boolean} active Whether the connection is currently active.
|
||||
*/
|
||||
GuacamoleService.Connection.Record = function(username, start, end) {
|
||||
GuacamoleService.Connection.Record = function(username, start, end, active) {
|
||||
|
||||
/**
|
||||
* The username of the user associated with this record.
|
||||
@@ -85,6 +112,11 @@ GuacamoleService.Connection.Record = function(username, start, end) {
|
||||
*/
|
||||
this.end = null;
|
||||
|
||||
/**
|
||||
* Whether this connection is currently active.
|
||||
*/
|
||||
this.active = active;
|
||||
|
||||
/**
|
||||
* The duration of this connection, in seconds. This value is only
|
||||
* defined if the end time is available.
|
||||
@@ -268,7 +300,8 @@ GuacamoleService.Connections = {
|
||||
var record = new GuacamoleService.Connection.Record(
|
||||
recordElement.textContent,
|
||||
parseInt(recordElement.getAttribute("start")),
|
||||
parseInt(recordElement.getAttribute("end"))
|
||||
parseInt(recordElement.getAttribute("end")),
|
||||
recordElement.getAttribute("active") == "yes"
|
||||
);
|
||||
|
||||
// Append to connection history
|
||||
|
@@ -293,6 +293,12 @@ div#recent-connections div.connection {
|
||||
padding: 0.1em;
|
||||
}
|
||||
|
||||
.connection .usage {
|
||||
float: right;
|
||||
font-style: italic;
|
||||
color: gray;
|
||||
}
|
||||
|
||||
.connection .thumbnail {
|
||||
margin: 0.5em;
|
||||
}
|
||||
|
Reference in New Issue
Block a user