Add support for connecting to groups.

This commit is contained in:
Michael Jumper
2013-08-15 00:09:18 -07:00
parent 06c242ec42
commit cd222e1dcf
3 changed files with 152 additions and 16 deletions

View File

@@ -108,6 +108,32 @@ GuacUI.removeClass = function(element, classname) {
};
/**
* Opens the connection group having the given ID in a new tab/window.
*
* @param {String} id The ID of the connection group to open.
* @param {String} parameters Any parameters that should be added to the URL,
* for sake of authentication.
*/
GuacUI.openConnectionGroup = function(id, parameters) {
// Get URL
var url = "client.xhtml?id=g/" + encodeURIComponent(id);
// Add parameters, if given
if (parameters)
url += "&" + parameters;
// Attempt to focus existing window
var current = window.open(null, id);
// If window did not already exist, set up as
// Guacamole client
if (!current.GuacUI)
window.open(url, id);
};
/**
* Opens the connection having the given ID in a new tab/window.
*
@@ -118,7 +144,7 @@ GuacUI.removeClass = function(element, classname) {
GuacUI.openConnection = function(id, parameters) {
// Get URL
var url = "client.xhtml?id=" + encodeURIComponent(id);
var url = "client.xhtml?id=c/" + encodeURIComponent(id);
// Add parameters, if given
if (parameters)

View File

@@ -197,6 +197,15 @@ GuacamoleRootUI.reset = function() {
GuacUI.openConnection(connection.id, GuacamoleRootUI.parameters);
};
// Open connection groups when clicked
group_view.ongroupclick = function(group) {
// Connect if balancing
if (group.type === GuacamoleService.ConnectionGroup.Type.BALANCING)
GuacUI.openConnectionGroup(group.id, GuacamoleRootUI.parameters);
};
// Save all connections for later reference
GuacamoleRootUI.connections = group_view.connections;