GUAC-1138 Implemented global active session filter against name, username, and remote host.

This commit is contained in:
James Muehlner
2015-03-25 22:01:18 -07:00
parent 88eb8dba24
commit 7966058928
5 changed files with 64 additions and 13 deletions

View File

@@ -54,6 +54,13 @@ angular.module('manage').controller('manageSessionsController', ['$scope', '$inj
*/ */
$scope.wrappers = null; $scope.wrappers = null;
/**
* The filter search string to use to restrict the displayed active sessions
*
* @type String
*/
$scope.filterSearchString = null;
/** /**
* StableSort instance which maintains the sort order of the visible * StableSort instance which maintains the sort order of the visible
* connection wrappers. * connection wrappers.
@@ -67,13 +74,6 @@ angular.module('manage').controller('manageSessionsController', ['$scope', '$inj
'name' 'name'
]); ]);
/**
* The root connection group of the connection group hierarchy.
*
* @type ConnectionGroup
*/
var rootGroup = null;
/** /**
* All active connections, if known, or null if active connections have not * All active connections, if known, or null if active connections have not
* yet been loaded. * yet been loaded.
@@ -83,11 +83,12 @@ angular.module('manage').controller('manageSessionsController', ['$scope', '$inj
var activeConnections = null; var activeConnections = null;
/** /**
* Map of all visible connections by object identifier. * Map of all visible connections by object identifier, or null if visible
* connections have not yet been loaded.
* *
* @type Object.<String, Connection> * @type Object.<String, Connection>
*/ */
var connections = {}; var connections = null;
/** /**
* Map of all currently-selected active connection wrappers by identifier. * Map of all currently-selected active connection wrappers by identifier.
@@ -118,7 +119,7 @@ angular.module('manage').controller('manageSessionsController', ['$scope', '$inj
* The connection group whose descendant connections should be added to * The connection group whose descendant connections should be added to
* the internal set of connections. * the internal set of connections.
*/ */
var addDescendantConnections = function addDescendantConnections(connectionGroup) { var addDescendantConnections = function addDescendantConnections(connectionGroup) {
// Add all child connections // Add all child connections
if (connectionGroup.childConnections) if (connectionGroup.childConnections)
@@ -168,8 +169,8 @@ angular.module('manage').controller('manageSessionsController', ['$scope', '$inj
.success(function connectionGroupReceived(retrievedRootGroup) { .success(function connectionGroupReceived(retrievedRootGroup) {
// Load connections from retrieved group tree // Load connections from retrieved group tree
rootGroup = retrievedRootGroup; connections = {};
addDescendantConnections(rootGroup); addDescendantConnections(retrievedRootGroup);
// Attempt to produce wrapped list of active connections // Attempt to produce wrapped list of active connections
wrapActiveConnections(); wrapActiveConnections();
@@ -351,5 +352,40 @@ angular.module('manage').controller('manageSessionsController', ['$scope', '$inj
delete selectedWrappers[wrapper.activeConnection.identifier]; delete selectedWrappers[wrapper.activeConnection.identifier];
}; };
/**
* A predicate to be used for filtering the active sessions based on a plain
* text search string. A wrapper will be considered a match iff the search string
* appears (case insensitive) in the connection name, username, or remote host.
*
* @param {ActiveConnectionWrapper} wrapper
* The wrapper to match against the search string..
*
* @returns {Boolean}
* true if the wrapper matches the specified search string, false otherwise.
*/
$scope.globalFilterPredicate = function globalFilterPredicate(wrapper) {
// If no search term is provided, always consider it a match
if (!$scope.filterSearchString)
return true;
// Convert to lower case for case insensitive matching
var searchString = $scope.filterSearchString.toLowerCase();
// Check to see if the search string matches the connection name
if (wrapper.name.toLowerCase().indexOf(searchString) !== -1)
return true;
// Check to see if the search string matches the username
if (wrapper.activeConnection.username.toLowerCase().indexOf(searchString) !== -1)
return true;
// Check to see if the search string matches the remote host
if (wrapper.activeConnection.remoteHost.toLowerCase().indexOf(searchString) !== -1)
return true;
return false;
};
}]); }]);

View File

@@ -76,3 +76,12 @@
.manage table.session-list th.sort-primary.sort-descending:after { .manage table.session-list th.sort-primary.sort-descending:after {
background-image: url('images/arrows/up.png'); background-image: url('images/arrows/up.png');
} }
.manage .sessions .filter{
background-image: url('images/magnifier.png');
background-repeat: no-repeat;
background-size: 1.75em;
padding-left: 1.75em;
width: 100%;
max-width: none;
}

View File

@@ -35,6 +35,10 @@ THE SOFTWARE.
<div class="action-buttons"> <div class="action-buttons">
<button class="delete-sessions danger" ng-disabled="!canDeleteSessions()" ng-click="deleteSessions()">{{'MANAGE_SESSION.ACTION_DELETE' | translate}}</button> <button class="delete-sessions danger" ng-disabled="!canDeleteSessions()" ng-click="deleteSessions()">{{'MANAGE_SESSION.ACTION_DELETE' | translate}}</button>
</div> </div>
<div>
<input class="filter" placeholder="{{'MANAGE_SESSION.FIELD_PLACEHOLDER_FILTER' | translate}}" type="text" ng-model="filterSearchString"/>
</div>
<!-- List of current user sessions --> <!-- List of current user sessions -->
<table class="session-list"> <table class="session-list">
@@ -78,7 +82,7 @@ THE SOFTWARE.
</p> </p>
<!-- Pager for session list --> <!-- Pager for session list -->
<guac-pager page="wrapperPage" page-size="25" items="wrappers | orderBy : wrapperOrder.predicate"></guac-pager> <guac-pager page="wrapperPage" page-size="25" items="wrappers | orderBy : wrapperOrder.predicate | filter : globalFilterPredicate"></guac-pager>
</div> </div>
</div> </div>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@@ -243,6 +243,8 @@
"DIALOG_HEADER_CONFIRM_DELETE" : "Kill Sessions", "DIALOG_HEADER_CONFIRM_DELETE" : "Kill Sessions",
"DIALOG_HEADER_ERROR" : "Error", "DIALOG_HEADER_ERROR" : "Error",
"FIELD_PLACEHOLDER_FILTER" : "Filter",
"HELP_SESSIONS" : "All currently-active Guacamole sessions are listed here. If you wish to kill one or more sessions, check the box next to those sessions and click \"Kill Sessions\". Killing a session will immediately disconnect the user from the associated connection.", "HELP_SESSIONS" : "All currently-active Guacamole sessions are listed here. If you wish to kill one or more sessions, check the box next to those sessions and click \"Kill Sessions\". Killing a session will immediately disconnect the user from the associated connection.",
"INFO_NO_SESSIONS" : "No active sessions", "INFO_NO_SESSIONS" : "No active sessions",