mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-07 05:31:22 +00:00
GUAC-932: Save thumbnail upon disconnect.
This commit is contained in:
@@ -265,9 +265,6 @@ angular.module('home').controller('clientController', ['$scope', '$routeParams',
|
|||||||
// Show status dialog when client errors occur
|
// Show status dialog when client errors occur
|
||||||
$scope.$on('guacClientError', function clientErrorListener(event, client, status) {
|
$scope.$on('guacClientError', function clientErrorListener(event, client, status) {
|
||||||
|
|
||||||
// Disconnect
|
|
||||||
$scope.id = null;
|
|
||||||
|
|
||||||
// Determine translation name of error
|
// Determine translation name of error
|
||||||
var errorName = (status in CLIENT_ERRORS) ? status.toString(16).toUpperCase() : "DEFAULT";
|
var errorName = (status in CLIENT_ERRORS) ? status.toString(16).toUpperCase() : "DEFAULT";
|
||||||
|
|
||||||
@@ -293,6 +290,10 @@ angular.module('home').controller('clientController', ['$scope', '$routeParams',
|
|||||||
|
|
||||||
// Show new status only if disconnected
|
// Show new status only if disconnected
|
||||||
if (status === "closed") {
|
if (status === "closed") {
|
||||||
|
|
||||||
|
// Disconnect
|
||||||
|
$scope.id = null;
|
||||||
|
|
||||||
$scope.showStatus({
|
$scope.showStatus({
|
||||||
title: "client.status.closedStatusTitle",
|
title: "client.status.closedStatusTitle",
|
||||||
text: "client.status.tunnelStates." + status
|
text: "client.status.tunnelStates." + status
|
||||||
@@ -304,9 +305,6 @@ angular.module('home').controller('clientController', ['$scope', '$routeParams',
|
|||||||
// Show status dialog when tunnel errors occur
|
// Show status dialog when tunnel errors occur
|
||||||
$scope.$on('guacTunnelError', function tunnelErrorListener(event, tunnel, status) {
|
$scope.$on('guacTunnelError', function tunnelErrorListener(event, tunnel, status) {
|
||||||
|
|
||||||
// Disconnect
|
|
||||||
$scope.id = null;
|
|
||||||
|
|
||||||
// Determine translation name of error
|
// Determine translation name of error
|
||||||
var errorName = (status in TUNNEL_ERRORS) ? status.toString(16).toUpperCase() : "DEFAULT";
|
var errorName = (status in TUNNEL_ERRORS) ? status.toString(16).toUpperCase() : "DEFAULT";
|
||||||
|
|
||||||
|
@@ -125,6 +125,7 @@ angular.module('client').directive('guacClient', [function guacClient() {
|
|||||||
var $window = $injector.get('$window'),
|
var $window = $injector.get('$window'),
|
||||||
guacAudio = $injector.get('guacAudio'),
|
guacAudio = $injector.get('guacAudio'),
|
||||||
guacVideo = $injector.get('guacVideo'),
|
guacVideo = $injector.get('guacVideo'),
|
||||||
|
guacHistory = $injector.get('guacHistory'),
|
||||||
guacTunnelFactory = $injector.get('guacTunnelFactory'),
|
guacTunnelFactory = $injector.get('guacTunnelFactory'),
|
||||||
guacClientFactory = $injector.get('guacClientFactory'),
|
guacClientFactory = $injector.get('guacClientFactory'),
|
||||||
authenticationService = $injector.get('authenticationService');
|
authenticationService = $injector.get('authenticationService');
|
||||||
@@ -298,12 +299,37 @@ angular.module('client').directive('guacClient', [function guacClient() {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Connect to given ID whenever ID changes
|
// Connect to given ID whenever ID changes
|
||||||
$scope.$watch('id', function(id) {
|
$scope.$watch('id', function(id, previousID) {
|
||||||
|
|
||||||
// If a client is already attached, ensure it is disconnected
|
// If a client is already attached, ensure it is disconnected
|
||||||
if (client)
|
if (client)
|
||||||
client.disconnect();
|
client.disconnect();
|
||||||
|
|
||||||
|
// Update stored thumbnail of previous connection
|
||||||
|
if (previousID && display && display.getWidth() >= 0 && display.getHeight() >= 0) {
|
||||||
|
|
||||||
|
// Get screenshot
|
||||||
|
var canvas = display.flatten();
|
||||||
|
|
||||||
|
// Calculate scale of thumbnail (max 320x240, max zoom 100%)
|
||||||
|
var scale = Math.min(320 / canvas.width, 240 / canvas.height, 1);
|
||||||
|
|
||||||
|
// Create thumbnail canvas
|
||||||
|
var thumbnail = document.createElement("canvas");
|
||||||
|
thumbnail.width = canvas.width*scale;
|
||||||
|
thumbnail.height = canvas.height*scale;
|
||||||
|
|
||||||
|
// Scale screenshot to thumbnail
|
||||||
|
var context = thumbnail.getContext("2d");
|
||||||
|
context.drawImage(canvas,
|
||||||
|
0, 0, canvas.width, canvas.height,
|
||||||
|
0, 0, thumbnail.width, thumbnail.height
|
||||||
|
);
|
||||||
|
|
||||||
|
guacHistory.updateThumbnail(previousID, thumbnail.toDataURL("image/png"));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Only proceed if a new client is attached
|
// Only proceed if a new client is attached
|
||||||
if (!id)
|
if (!id)
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user