mirror of
				https://github.com/gyurix1968/guacamole-client.git
				synced 2025-10-31 09:03:21 +00:00 
			
		
		
		
	GUAC-1138: Move common sorting logic into StableSort.
This commit is contained in:
		| @@ -108,6 +108,40 @@ angular.module('list').factory('StableSort', [ | ||||
|  | ||||
|         }; | ||||
|  | ||||
|         /** | ||||
|          * Returns whether the sort order is primarily determined by the given | ||||
|          * property. | ||||
|          * | ||||
|          * @param {String} property | ||||
|          *     The name of the property to check. | ||||
|          * | ||||
|          * @returns {Boolean} | ||||
|          *     true if the sort order is primarily determined by the given | ||||
|          *     property, false otherwise. | ||||
|          */ | ||||
|         this.isSortedBy = function isSortedBy(property) { | ||||
|             return stableSort.primary === property; | ||||
|         }; | ||||
|  | ||||
|         /** | ||||
|          * Sets the primary sorting property to the given property, if not already | ||||
|          * set. If already set, the ascending/descending sort order is toggled. | ||||
|          * | ||||
|          * @param {String} property | ||||
|          *     The name of the property to assign as the primary sorting property. | ||||
|          */ | ||||
|         this.togglePrimary = function togglePrimary(property) { | ||||
|  | ||||
|             // Sort in ascending order by new property, if different | ||||
|             if (!stableSort.isSortedBy(property)) | ||||
|                 stableSort.reorder(property, false); | ||||
|  | ||||
|             // Otherwise, toggle sort order | ||||
|             else | ||||
|                 stableSort.reorder(property, !stableSort.descending); | ||||
|  | ||||
|         }; | ||||
|  | ||||
|     }; | ||||
|  | ||||
|     return StableSort; | ||||
|   | ||||
| @@ -195,40 +195,6 @@ angular.module('manage').controller('manageSessionsController', ['$scope', '$inj | ||||
|  | ||||
|     }; | ||||
|  | ||||
|     /** | ||||
|      * 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 the given property, | ||||
|      *     false otherwise. | ||||
|      */ | ||||
|     $scope.isSortedBy = function isSortedBy(property) { | ||||
|         return $scope.wrapperOrder.primary === property; | ||||
|     }; | ||||
|  | ||||
|     /** | ||||
|      * Sets the primary sorting property to the given property, if not already | ||||
|      * set. If already set, the ascending/descending sort order is toggled. | ||||
|      * | ||||
|      * @param {String} property | ||||
|      *     The name of the property to assign as the primary sorting property. | ||||
|      */ | ||||
|     $scope.toggleSort = function toggleSort(property) { | ||||
|  | ||||
|         // 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); | ||||
|  | ||||
|     }; | ||||
|  | ||||
|     /** | ||||
|      * An action to be provided along with the object sent to showStatus which | ||||
|      * closes the currently-shown status dialog. | ||||
|   | ||||
| @@ -45,20 +45,20 @@ THE SOFTWARE. | ||||
|             <thead> | ||||
|                 <tr> | ||||
|                     <th class="select-session"></th> | ||||
|                     <th ng-class="{'sort-primary': isSortedBy('activeConnection.username'), 'sort-descending': wrapperOrder.descending}" | ||||
|                         ng-click="toggleSort('activeConnection.username')"> | ||||
|                     <th ng-class="{'sort-primary': wrapperOrder.isSortedBy('activeConnection.username'), 'sort-descending': wrapperOrder.descending}" | ||||
|                         ng-click="wrapperOrder.toggleSort('activeConnection.username')"> | ||||
|                         {{'MANAGE_SESSION.TABLE_HEADER_SESSION_USERNAME' | translate}} | ||||
|                     </th> | ||||
|                     <th ng-class="{'sort-primary': isSortedBy('activeConnection.startDate'), 'sort-descending': wrapperOrder.descending}" | ||||
|                         ng-click="toggleSort('activeConnection.startDate')"> | ||||
|                     <th ng-class="{'sort-primary': wrapperOrder.isSortedBy('activeConnection.startDate'), 'sort-descending': wrapperOrder.descending}" | ||||
|                         ng-click="wrapperOrder.toggleSort('activeConnection.startDate')"> | ||||
|                         {{'MANAGE_SESSION.TABLE_HEADER_SESSION_STARTDATE' | translate}} | ||||
|                     </th> | ||||
|                     <th ng-class="{'sort-primary': isSortedBy('activeConnection.remoteHost'), 'sort-descending': wrapperOrder.descending}" | ||||
|                         ng-click="toggleSort('activeConnection.remoteHost')"> | ||||
|                     <th ng-class="{'sort-primary': wrapperOrder.isSortedBy('activeConnection.remoteHost'), 'sort-descending': wrapperOrder.descending}" | ||||
|                         ng-click="wrapperOrder.toggleSort('activeConnection.remoteHost')"> | ||||
|                         {{'MANAGE_SESSION.TABLE_HEADER_SESSION_REMOTEHOST' | translate}} | ||||
|                     </th> | ||||
|                     <th ng-class="{'sort-primary': isSortedBy('name'), 'sort-descending': wrapperOrder.descending}" | ||||
|                         ng-click="toggleSort('name')"> | ||||
|                     <th ng-class="{'sort-primary': wrapperOrder.isSortedBy('name'), 'sort-descending': wrapperOrder.descending}" | ||||
|                         ng-click="wrapperOrder.toggleSort('name')"> | ||||
|                         {{'MANAGE_SESSION.TABLE_HEADER_SESSION_CONNECTION_NAME' | translate}} | ||||
|                     </th> | ||||
|                 </tr> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user