From 7334e76679960565b53105faed3b0089a659bd9b Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Fri, 16 Aug 2013 16:50:56 -0700 Subject: [PATCH] Allow GroupView to be filtered via arbitrary functions. --- guacamole/src/main/webapp/scripts/guac-ui.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/guacamole/src/main/webapp/scripts/guac-ui.js b/guacamole/src/main/webapp/scripts/guac-ui.js index 74eb1e58e..5a410c4ea 100644 --- a/guacamole/src/main/webapp/scripts/guac-ui.js +++ b/guacamole/src/main/webapp/scripts/guac-ui.js @@ -953,8 +953,14 @@ GuacUI.ListGroup = function(caption) { * within the view. * @param {Number} flags Any flags (such as MULTISELECT or SHOW_CONNECTIONS) * for modifying the behavior of this group view. + * @param {Function} group_filter Function which returns true if the given + * group should be displayed and false otherwise. + * @param {Function} connection_filter Function which returns true if the given + * connection should be displayed and false + * otherwise. */ -GuacUI.GroupView = function(root_group, flags) { +GuacUI.GroupView = function(root_group, flags, + group_filter, connection_filter) { /** * Reference to this GroupView. @@ -1208,6 +1214,10 @@ GuacUI.GroupView = function(root_group, flags) { */ function addConnection(connection, appendChild) { + // Do not add connection if filter says "no" + if (connection_filter && !connection_filter(connection)) + return; + group_view.connections[connection.id] = connection; // Add connection to connection list or parent group @@ -1264,6 +1274,10 @@ GuacUI.GroupView = function(root_group, flags) { */ function addGroup(group, appendChild) { + // Do not add group if filter says "no" + if (group_filter && !group_filter(group)) + return; + // Add group to groups collection group_view.groups[group.id] = group;