From 738f3397b782b8801e9db48e9301090751b7198e Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Thu, 15 Aug 2013 02:56:43 -0700 Subject: [PATCH] Allow specific group to be selected. --- guacamole/src/main/webapp/scripts/admin-ui.js | 15 +++++++++ guacamole/src/main/webapp/scripts/guac-ui.js | 31 +++++++++++++++++++ guacamole/src/main/webapp/styles/ui.css | 2 +- 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/guacamole/src/main/webapp/scripts/admin-ui.js b/guacamole/src/main/webapp/scripts/admin-ui.js index af246e606..d8d2845fe 100644 --- a/guacamole/src/main/webapp/scripts/admin-ui.js +++ b/guacamole/src/main/webapp/scripts/admin-ui.js @@ -729,6 +729,9 @@ GuacAdmin.ConnectionEditor = function(connection, parameters) { var group_select = new GuacAdmin.ConnectionGroupSelect(GuacAdmin.cached_root_group); location_container.appendChild(group_select.getElement()); + // Pre-select current value + group_select.select(location_value); + // Update location when chosen group_select.onselect = function(group) { location_value = group; @@ -1058,6 +1061,9 @@ GuacAdmin.ConnectionGroupEditor = function(group, parameters) { var group_select = new GuacAdmin.ConnectionGroupSelect(GuacAdmin.cached_root_group); location_container.appendChild(group_select.getElement()); + // Pre-select current value + group_select.select(location_value); + // Update location when chosen group_select.onselect = function(selected_group) { @@ -1255,6 +1261,15 @@ GuacAdmin.ConnectionGroupSelect = function(group) { return container; }; + /** + * Pre-selects the given group. + * + * @param {GuacamoleService.ConnectionGroup} group The group to select. + */ + this.select = function(group) { + view.expand(group); + }; + }; GuacAdmin.reset = function() { diff --git a/guacamole/src/main/webapp/scripts/guac-ui.js b/guacamole/src/main/webapp/scripts/guac-ui.js index 11a102ae8..894651158 100644 --- a/guacamole/src/main/webapp/scripts/guac-ui.js +++ b/guacamole/src/main/webapp/scripts/guac-ui.js @@ -982,6 +982,12 @@ GuacUI.GroupView = function(root_group, flags) { */ var connection_checkboxes = {}; + /** + * Set of all list groups, indexed by associated group ID. + * @private + */ + var list_groups = {}; + /** * Set of all connection groups, indexed by ID. */ @@ -1125,6 +1131,30 @@ GuacUI.GroupView = function(root_group, flags) { }; + /** + * Expands the given group and all parent groups all the way up to root. + * + * @param {GuacamoleService.ConnectionGroup} group The group that should + * be expanded. + */ + this.expand = function(group) { + + // Skip current group - only need to expand parents + group = group.parent; + + // For each group all the way to root + while (group !== null) { + + // If list group exists, expand it + var list_group = list_groups[group.id]; + if (list_group) + list_group.expand(); + + group = group.parent; + } + + } + // Create pager for contents var pager = new GuacUI.Pager(list); pager.page_capacity = 20; @@ -1226,6 +1256,7 @@ GuacUI.GroupView = function(root_group, flags) { // Create element for group var list_group = new GuacUI.ListGroup(group.name); + list_groups[group.id] = list_group; GuacUI.addClass(list_group.getElement(), "list-item"); // Recursively add all children to the new element diff --git a/guacamole/src/main/webapp/styles/ui.css b/guacamole/src/main/webapp/styles/ui.css index 215eb01c9..d47f54c8c 100644 --- a/guacamole/src/main/webapp/styles/ui.css +++ b/guacamole/src/main/webapp/styles/ui.css @@ -215,7 +215,7 @@ div.section { margin-top: -1px; width: 3in; - max-height: 5in; + max-height: 2in; overflow: auto; border: 1px solid rgba(0, 0, 0, 0.5);