GUAC-1140: Update sorting order when session column headers are clicked.

This commit is contained in:
Michael Jumper
2015-03-23 14:15:43 -07:00
parent 4d81272d42
commit 3c5a0b63f6
3 changed files with 37 additions and 35 deletions

View File

@@ -202,47 +202,37 @@ angular.module('manage').controller('manageSessionsController', ['$scope', '$inj
};
/**
* Returns whether the wrapped session list is sorted by username.
* Returns whether the wrapped session list is sorted by the given
* property.
*
* @param {String} property
* The name of the property to check.
*
* @returns {Boolean}
* true if the wrapped session list is sorted by username, false
* otherwise.
* true if the wrapped session list is sorted by the given property,
* false otherwise.
*/
$scope.sortedByUsername = function sortedByUsername() {
return $scope.wrapperOrder.primary === 'activeConnection.username';
$scope.isSortedBy = function isSortedBy(property) {
return $scope.wrapperOrder.primary === property;
};
/**
* Returns whether the wrapped session list is sorted by start date.
* Sets the primary sorting property to the given property, if not already
* set. If already set, the ascending/descending sort order is toggled.
*
* @returns {Boolean}
* true if the wrapped session list is sorted by start date, false
* otherwise.
* @param {String} property
* The name of the property to assign as the primary sorting property.
*/
$scope.sortedByStartDate = function sortedByStartDate() {
return $scope.wrapperOrder.primary === 'activeConnection.startDate';
};
$scope.toggleSort = function toggleSort(property) {
/**
* Returns whether the wrapped session list is sorted by remote host.
*
* @returns {Boolean}
* true if the wrapped session list is sorted by remote host, false
* otherwise.
*/
$scope.sortedByRemoteHost = function sortedByRemoteHost() {
return $scope.wrapperOrder.primary === 'activeConnection.remoteHost';
};
// Sort in ascending order by new property, if different
if (!$scope.isSortedBy(property))
$scope.wrapperOrder.reorder(property, false);
// Otherwise, toggle sort order
else
$scope.wrapperOrder.reorder(property, !$scope.wrapperOrder.descending);
/**
* Returns whether the wrapped session list is sorted by connection name.
*
* @returns {Boolean}
* true if the wrapped session list is sorted by connection name, false
* otherwise.
*/
$scope.sortedByConnectionName = function sortedByConnectionName() {
return $scope.wrapperOrder.primary === 'name';
};
/**

View File

@@ -44,6 +44,14 @@
text-align: center;
}
.manage table.session-list th {
cursor: pointer;
}
.manage table.session-list th.select-session {
cursor: auto;
}
.manage table.session-list th.sort-primary {
text-decoration: underline;
}

View File

@@ -41,16 +41,20 @@ THE SOFTWARE.
<thead>
<tr>
<th class="select-session"></th>
<th ng-class="{'sort-primary': sortedByUsername(), 'sort-descending': wrapperOrder.descending}">
<th ng-class="{'sort-primary': isSortedBy('activeConnection.username'), 'sort-descending': wrapperOrder.descending}"
ng-click="toggleSort('activeConnection.username')">
{{'MANAGE_SESSION.TABLE_HEADER_SESSION_USERNAME' | translate}}
</th>
<th ng-class="{'sort-primary': sortedByStartDate(), 'sort-descending': wrapperOrder.descending}">
<th ng-class="{'sort-primary': isSortedBy('activeConnection.startDate'), 'sort-descending': wrapperOrder.descending}"
ng-click="toggleSort('activeConnection.startDate')">
{{'MANAGE_SESSION.TABLE_HEADER_SESSION_STARTDATE' | translate}}
</th>
<th ng-class="{'sort-primary': sortedByRemoteHost(), 'sort-descending': wrapperOrder.descending}">
<th ng-class="{'sort-primary': isSortedBy('activeConnection.remoteHost'), 'sort-descending': wrapperOrder.descending}"
ng-click="toggleSort('activeConnection.remoteHost')">
{{'MANAGE_SESSION.TABLE_HEADER_SESSION_REMOTEHOST' | translate}}
</th>
<th ng-class="{'sort-primary': sortedByConnectionName(), 'sort-descending': wrapperOrder.descending}">
<th ng-class="{'sort-primary': isSortedBy('name'), 'sort-descending': wrapperOrder.descending}"
ng-click="toggleSort('name')">
{{'MANAGE_SESSION.TABLE_HEADER_SESSION_CONNECTION_NAME' | translate}}
</th>
</tr>