GUACAMOLE-723: Sort connections in panel by last use.

This commit is contained in:
Michael Jumper
2019-04-02 09:20:45 -07:00
parent 19da6e32a2
commit 378cae57a7
3 changed files with 20 additions and 4 deletions

View File

@@ -492,6 +492,12 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
});
// Update last used timestamp when the active client changes
$scope.$watch('client', function clientChanged(client) {
if (client)
client.lastUsed = new Date().getTime();
});
// Update page icon when thumbnail changes
$scope.$watch('client.thumbnail.canvas', function thumbnailChanged(canvas) {
iconService.setIcons(canvas);

View File

@@ -6,12 +6,12 @@
<!-- List of connection thumbnails -->
<ul class="client-panel-connection-list">
<li ng-repeat="client in clients" class="client-panel-connection">
<a href="#/client/{{client.id}}">
<li ng-repeat="client in clients | toArray | orderBy: [ '-value.lastUsed', 'value.title' ]" class="client-panel-connection">
<a href="#/client/{{client.value.id}}">
<div class="thumbnail">
<guac-thumbnail client="client"></guac-thumbnail>
<guac-thumbnail client="client.value"></guac-thumbnail>
</div>
<div class="name">{{ client.title }}</div>
<div class="name">{{ client.value.title }}</div>
</a>
</li>
</ul>

View File

@@ -79,6 +79,16 @@ angular.module('client').factory('ManagedClient', ['$rootScope', '$injector',
*/
this.id = template.id;
/**
* The time that the connection was last brought to the foreground of
* the current tab, as the number of milliseconds elapsed since
* midnight of January 1, 1970 UTC. If the connection has not yet been
* viewed, this will be 0.
*
* @type Number
*/
this.lastUsed = template.lastUsed || 0;
/**
* The actual underlying Guacamole client.
*