From 378cae57a7142db06582f8d13888215f5cfecb42 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Tue, 2 Apr 2019 09:20:45 -0700 Subject: [PATCH] GUACAMOLE-723: Sort connections in panel by last use. --- .../webapp/app/client/controllers/clientController.js | 6 ++++++ .../webapp/app/client/templates/guacClientPanel.html | 8 ++++---- .../src/main/webapp/app/client/types/ManagedClient.js | 10 ++++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/guacamole/src/main/webapp/app/client/controllers/clientController.js b/guacamole/src/main/webapp/app/client/controllers/clientController.js index 94da2e3ec..5ee084b6e 100644 --- a/guacamole/src/main/webapp/app/client/controllers/clientController.js +++ b/guacamole/src/main/webapp/app/client/controllers/clientController.js @@ -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); diff --git a/guacamole/src/main/webapp/app/client/templates/guacClientPanel.html b/guacamole/src/main/webapp/app/client/templates/guacClientPanel.html index e550c849f..00dfddef9 100644 --- a/guacamole/src/main/webapp/app/client/templates/guacClientPanel.html +++ b/guacamole/src/main/webapp/app/client/templates/guacClientPanel.html @@ -6,12 +6,12 @@ diff --git a/guacamole/src/main/webapp/app/client/types/ManagedClient.js b/guacamole/src/main/webapp/app/client/types/ManagedClient.js index a9bc3beac..288931175 100644 --- a/guacamole/src/main/webapp/app/client/types/ManagedClient.js +++ b/guacamole/src/main/webapp/app/client/types/ManagedClient.js @@ -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. *