From a99d9234ca97b06ae523b8e58908ef48f25d408b Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sat, 16 Feb 2013 14:47:12 -0800 Subject: [PATCH] Ticket #270: Parse history in GuacamoleService.Connections.list(). --- guacamole/src/main/webapp/scripts/service.js | 80 +++++++++++++++++++- 1 file changed, 79 insertions(+), 1 deletion(-) diff --git a/guacamole/src/main/webapp/scripts/service.js b/guacamole/src/main/webapp/scripts/service.js index 1f1cb8ebf..5ed482e21 100644 --- a/guacamole/src/main/webapp/scripts/service.js +++ b/guacamole/src/main/webapp/scripts/service.js @@ -46,6 +46,58 @@ GuacamoleService.Connection = function(protocol, id) { */ this.parameters = {}; + /** + * An array of GuacamoleService.Connection.Record listing the usage + * history of this connection. + */ + this.history = []; + +}; + +/** + * Creates a new GuacamoleService.Connection.Record describing a single + * session for the given username and having the given start/end times. + * + * @constructor + * @param {String} username The username of the user who used the connection. + * @param {Number} start The time that the connection began (in UNIX epoch + * milliseconds). + * @param {Number} end The time that the connection ended (in UNIX epoch + * milliseconds). This parameter is optional. + */ +GuacamoleService.Connection.Record = function(username, start, end) { + + /** + * The username of the user associated with this record. + * @type String + */ + this.username = username; + + /** + * The time the corresponding connection began. + * @type Date + */ + this.start = new Date(start); + + /** + * The time the corresponding connection terminated (if any). + * @type Date + */ + this.end = null; + + /** + * The duration of this connection, in seconds. This value is only + * defined if the end time is available. + * @type Number + */ + this.duration = null; + + // If end time given, intialize end time + if (end) { + this.end = new Date(end); + this.duration = (end - start) / 1000; + } + }; /** @@ -151,9 +203,11 @@ GuacamoleService.Connections = { connectionElement.getAttribute("id") ) + var j; + // Add parameter values for each pameter received var paramElements = connectionElement.getElementsByTagName("param"); - for (var j=0; j