mirror of
				https://github.com/gyurix1968/guacamole-client.git
				synced 2025-10-30 00:23:21 +00:00 
			
		
		
		
	GUAC-932: Update history entries when client directive is destroyed.
This commit is contained in:
		| @@ -315,15 +315,18 @@ angular.module('client').directive('guacClient', [function guacClient() { | |||||||
|              * CONNECT / RECONNECT |              * CONNECT / RECONNECT | ||||||
|              */ |              */ | ||||||
|  |  | ||||||
|             // Connect to given ID whenever ID changes |             /** | ||||||
|             $scope.$watch('id', function(id, previousID) { |              * Store the thumbnail of the currently connected client within | ||||||
|  |              * the connection history under the given ID. If the client is not | ||||||
|                 // If a client is already attached, ensure it is disconnected |              * connected, or if no ID is given, this function has no effect. | ||||||
|                 if (client) |              * | ||||||
|                     client.disconnect(); |              * @param {String} id | ||||||
|  |              *     The ID of the history entry to update. | ||||||
|  |              */ | ||||||
|  |             var updateHistoryEntry = function updateHistoryEntry(id) { | ||||||
|  |  | ||||||
|                 // Update stored thumbnail of previous connection  |                 // Update stored thumbnail of previous connection  | ||||||
|                 if (previousID && display && display.getWidth() > 0 && display.getHeight() > 0) { |                 if (id && display && display.getWidth() > 0 && display.getHeight() > 0) { | ||||||
|  |  | ||||||
|                     // Get screenshot |                     // Get screenshot | ||||||
|                     var canvas = display.flatten(); |                     var canvas = display.flatten(); | ||||||
| @@ -343,10 +346,22 @@ angular.module('client').directive('guacClient', [function guacClient() { | |||||||
|                         0, 0, thumbnail.width, thumbnail.height |                         0, 0, thumbnail.width, thumbnail.height | ||||||
|                     ); |                     ); | ||||||
|  |  | ||||||
|                     guacHistory.updateThumbnail(previousID, thumbnail.toDataURL("image/png")); |                     guacHistory.updateThumbnail(id, thumbnail.toDataURL("image/png")); | ||||||
|  |  | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
|  |             }; | ||||||
|  |  | ||||||
|  |             // Connect to given ID whenever ID changes | ||||||
|  |             $scope.$watch('id', function(id, previousID) { | ||||||
|  |  | ||||||
|  |                 // If a client is already attached, ensure it is disconnected | ||||||
|  |                 if (client) | ||||||
|  |                     client.disconnect(); | ||||||
|  |  | ||||||
|  |                 // Update stored thumbnail of previous connection | ||||||
|  |                 updateHistoryEntry(previousID); | ||||||
|  |  | ||||||
|                 // Only proceed if a new client is attached |                 // Only proceed if a new client is attached | ||||||
|                 if (!id) |                 if (!id) | ||||||
|                     return; |                     return; | ||||||
| @@ -385,6 +400,14 @@ angular.module('client').directive('guacClient', [function guacClient() { | |||||||
|  |  | ||||||
|             }); |             }); | ||||||
|  |  | ||||||
|  |             // Clean up when client directive is destroyed | ||||||
|  |             $scope.$on('$destroy', function destroyClient() { | ||||||
|  |  | ||||||
|  |                 // Update stored thumbnail of current connection | ||||||
|  |                 updateHistoryEntry($scope.id); | ||||||
|  |  | ||||||
|  |             }); | ||||||
|  |  | ||||||
|             /* |             /* | ||||||
|              * MOUSE EMULATION |              * MOUSE EMULATION | ||||||
|              */ |              */ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user