Allow specific group to be selected.

This commit is contained in:
Michael Jumper
2013-08-15 02:56:43 -07:00
parent 27eb3066f2
commit 738f3397b7
3 changed files with 47 additions and 1 deletions

View File

@@ -729,6 +729,9 @@ GuacAdmin.ConnectionEditor = function(connection, parameters) {
var group_select = new GuacAdmin.ConnectionGroupSelect(GuacAdmin.cached_root_group); var group_select = new GuacAdmin.ConnectionGroupSelect(GuacAdmin.cached_root_group);
location_container.appendChild(group_select.getElement()); location_container.appendChild(group_select.getElement());
// Pre-select current value
group_select.select(location_value);
// Update location when chosen // Update location when chosen
group_select.onselect = function(group) { group_select.onselect = function(group) {
location_value = group; location_value = group;
@@ -1058,6 +1061,9 @@ GuacAdmin.ConnectionGroupEditor = function(group, parameters) {
var group_select = new GuacAdmin.ConnectionGroupSelect(GuacAdmin.cached_root_group); var group_select = new GuacAdmin.ConnectionGroupSelect(GuacAdmin.cached_root_group);
location_container.appendChild(group_select.getElement()); location_container.appendChild(group_select.getElement());
// Pre-select current value
group_select.select(location_value);
// Update location when chosen // Update location when chosen
group_select.onselect = function(selected_group) { group_select.onselect = function(selected_group) {
@@ -1255,6 +1261,15 @@ GuacAdmin.ConnectionGroupSelect = function(group) {
return container; 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() { GuacAdmin.reset = function() {

View File

@@ -982,6 +982,12 @@ GuacUI.GroupView = function(root_group, flags) {
*/ */
var connection_checkboxes = {}; 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. * 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 // Create pager for contents
var pager = new GuacUI.Pager(list); var pager = new GuacUI.Pager(list);
pager.page_capacity = 20; pager.page_capacity = 20;
@@ -1226,6 +1256,7 @@ GuacUI.GroupView = function(root_group, flags) {
// Create element for group // Create element for group
var list_group = new GuacUI.ListGroup(group.name); var list_group = new GuacUI.ListGroup(group.name);
list_groups[group.id] = list_group;
GuacUI.addClass(list_group.getElement(), "list-item"); GuacUI.addClass(list_group.getElement(), "list-item");
// Recursively add all children to the new element // Recursively add all children to the new element

View File

@@ -215,7 +215,7 @@ div.section {
margin-top: -1px; margin-top: -1px;
width: 3in; width: 3in;
max-height: 5in; max-height: 2in;
overflow: auto; overflow: auto;
border: 1px solid rgba(0, 0, 0, 0.5); border: 1px solid rgba(0, 0, 0, 0.5);