mirror of
				https://github.com/gyurix1968/guacamole-client.git
				synced 2025-10-31 00:53:21 +00:00 
			
		
		
		
	GUAC-963: Update status dialog according to client state.
This commit is contained in:
		| @@ -27,8 +27,8 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams | ||||
|         function clientController($scope, $routeParams, $injector) { | ||||
|  | ||||
|     // Required types | ||||
|     var ClientProperties = $injector.get('ClientProperties'); | ||||
|     var ScrollState      = $injector.get('ScrollState'); | ||||
|     var ManagedClientState = $injector.get('ManagedClientState'); | ||||
|     var ScrollState        = $injector.get('ScrollState'); | ||||
|  | ||||
|     // Required services | ||||
|     var connectionGroupService = $injector.get('connectionGroupService'); | ||||
| @@ -391,83 +391,79 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams | ||||
|         delete keysCurrentlyPressed[keysym]; | ||||
|     }); | ||||
|  | ||||
|     // Show status dialog when client status changes | ||||
|     $scope.$on('guacClientStateChange', function clientStateChangeListener(event, client, status) { | ||||
|     // Show status dialog when connection status changes | ||||
|     $scope.$watch('client.clientState.connectionState', function clientStateChanged(connectionState) { | ||||
|  | ||||
|         // Show new status if not yet connected | ||||
|         if (status !== "connected") { | ||||
|         // Hide status if no known state | ||||
|         if (!connectionState) { | ||||
|             $scope.showStatus(false); | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|         // Get any associated status code | ||||
|         var status = $scope.client.clientState.statusCode; | ||||
|  | ||||
|         // Connecting  | ||||
|         if (connectionState === ManagedClientState.ConnectionState.CONNECTING | ||||
|          || connectionState === ManagedClientState.ConnectionState.WAITING) { | ||||
|             $scope.showStatus({ | ||||
|                 title: "CLIENT.DIALOG_HEADER_CONNECTING", | ||||
|                 text: "CLIENT.TEXT_CLIENT_STATUS_" + status.toUpperCase() | ||||
|                 text: "CLIENT.TEXT_CLIENT_STATUS_" + connectionState.toUpperCase() | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         // Hide status upon connecting | ||||
|         else | ||||
|             $scope.showStatus(false); | ||||
|         // Client error | ||||
|         else if (connectionState === ManagedClientState.ConnectionState.CLIENT_ERROR) { | ||||
|  | ||||
|     }); | ||||
|             // Determine translation name of error | ||||
|             var errorName = (status in CLIENT_ERRORS) ? status.toString(16).toUpperCase() : "DEFAULT"; | ||||
|  | ||||
|     // Show status dialog when client errors occur | ||||
|     $scope.$on('guacClientError', function clientErrorListener(event, client, status) { | ||||
|             // Determine whether the reconnect countdown applies | ||||
|             var countdown = (status in CLIENT_AUTO_RECONNECT) ? RECONNECT_COUNTDOWN : null; | ||||
|  | ||||
|         // Determine translation name of error | ||||
|         var errorName = (status in CLIENT_ERRORS) ? status.toString(16).toUpperCase() : "DEFAULT"; | ||||
|             // Show error status | ||||
|             $scope.showStatus({ | ||||
|                 className: "error", | ||||
|                 title: "CLIENT.DIALOG_HEADER_CONNECTION_ERROR", | ||||
|                 text: "CLIENT.ERROR_CLIENT_" + errorName, | ||||
|                 countdown: countdown, | ||||
|                 actions: [ RECONNECT_ACTION ] | ||||
|             }); | ||||
|  | ||||
|         // Determine whether the reconnect countdown applies | ||||
|         var countdown = (status in CLIENT_AUTO_RECONNECT) ? RECONNECT_COUNTDOWN : null; | ||||
|         } | ||||
|  | ||||
|         // Override any existing status | ||||
|         $scope.showStatus(false); | ||||
|         // Tunnel error | ||||
|         else if (connectionState === ManagedClientState.ConnectionState.TUNNEL_ERROR) { | ||||
|  | ||||
|         // Show error status | ||||
|         $scope.showStatus({ | ||||
|             className: "error", | ||||
|             title: "CLIENT.DIALOG_HEADER_CONNECTION_ERROR", | ||||
|             text: "CLIENT.ERROR_CLIENT_" + errorName, | ||||
|             countdown: countdown, | ||||
|             actions: [ RECONNECT_ACTION ] | ||||
|         }); | ||||
|             // Determine translation name of error | ||||
|             var errorName = (status in TUNNEL_ERRORS) ? status.toString(16).toUpperCase() : "DEFAULT"; | ||||
|  | ||||
|     }); | ||||
|             // Determine whether the reconnect countdown applies | ||||
|             var countdown = (status in TUNNEL_AUTO_RECONNECT) ? RECONNECT_COUNTDOWN : null; | ||||
|  | ||||
|     // Show status dialog when tunnel status changes | ||||
|     $scope.$on('guacTunnelStateChange', function tunnelStateChangeListener(event, tunnel, status) { | ||||
|             // Show error status | ||||
|             $scope.showStatus({ | ||||
|                 className: "error", | ||||
|                 title: "CLIENT.DIALOG_HEADER_CONNECTION_ERROR", | ||||
|                 text: "CLIENT.ERROR_TUNNEL_" + errorName, | ||||
|                 countdown: countdown, | ||||
|                 actions: [ RECONNECT_ACTION ] | ||||
|             }); | ||||
|  | ||||
|         // Show new status only if disconnected | ||||
|         if (status === "closed") { | ||||
|  | ||||
|             // Disconnect | ||||
|             $scope.id = null; | ||||
|         } | ||||
|  | ||||
|         // Disconnected | ||||
|         else if (connectionState === ManagedClientState.ConnectionState.DISCONNECTED) { | ||||
|             $scope.showStatus({ | ||||
|                 title: "CLIENT.DIALOG_HEADER_DISCONNECTED", | ||||
|                 text: "CLIENT.TEXT_TUNNEL_STATUS_" + status.toUpperCase() | ||||
|                 text: "CLIENT.TEXT_CLIENT_STATUS_" + connectionState.toUpperCase(), | ||||
|                 actions: [ RECONNECT_ACTION ] | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|     }); | ||||
|  | ||||
|     // Show status dialog when tunnel errors occur | ||||
|     $scope.$on('guacTunnelError', function tunnelErrorListener(event, tunnel, status) { | ||||
|  | ||||
|         // Determine translation name of error | ||||
|         var errorName = (status in TUNNEL_ERRORS) ? status.toString(16).toUpperCase() : "DEFAULT"; | ||||
|  | ||||
|         // Determine whether the reconnect countdown applies | ||||
|         var countdown = (status in TUNNEL_AUTO_RECONNECT) ? RECONNECT_COUNTDOWN : null; | ||||
|  | ||||
|         // Override any existing status | ||||
|         $scope.showStatus(false); | ||||
|  | ||||
|         // Show error status | ||||
|         $scope.showStatus({ | ||||
|             className: "error", | ||||
|             title: "CLIENT.DIALOG_HEADER_CONNECTION_ERROR", | ||||
|             text: "CLIENT.ERROR_TUNNEL_" + errorName, | ||||
|             countdown: countdown, | ||||
|             actions: [ RECONNECT_ACTION ] | ||||
|         }); | ||||
|         // Hide status for all other states | ||||
|         else | ||||
|             $scope.showStatus(false); | ||||
|  | ||||
|     }); | ||||
|  | ||||
| @@ -710,4 +706,12 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams | ||||
|         }); | ||||
|     }); | ||||
|  | ||||
|     // Clean up when view destroyed | ||||
|     $scope.$on('$destroy', function clientViewDestroyed() { | ||||
|  | ||||
|         // Hide any status dialog | ||||
|         $scope.showStatus(false); | ||||
|  | ||||
|     }); | ||||
|  | ||||
| }]); | ||||
|   | ||||
| @@ -288,7 +288,7 @@ angular.module('client').factory('ManagedClient', ['$rootScope', '$injector', | ||||
|                     // Connected | ||||
|                     case 3: | ||||
|                         ManagedClientState.setConnectionState(managedClient.clientState, | ||||
|                             ManagedClientState.ConnectionState.DISCONNECTED); | ||||
|                             ManagedClientState.ConnectionState.CONNECTED); | ||||
|                         break; | ||||
|  | ||||
|                     // Connecting, disconnecting, and disconnected are all | ||||
|   | ||||
| @@ -82,13 +82,13 @@ | ||||
|         "SECTION_HEADER_DISPLAY"      : "Display", | ||||
|         "SECTION_HEADER_MOUSE_MODE"   : "Mouse emulation mode", | ||||
|  | ||||
|         "TEXT_ZOOM_AUTO_FIT"            : "Automatically fit to browser window", | ||||
|         "TEXT_CLIENT_STATUS_IDLE"       : "Idle.", | ||||
|         "TEXT_CLIENT_STATUS_CONNECTING" : "Connecting to Guacamole...", | ||||
|         "TEXT_CLIENT_STATUS_WAITING"    : "Connected to Guacamole. Waiting for response...", | ||||
|         "TEXT_TUNNEL_STATUS_CLOSED"     :  "You have been disconnected. Reload the page to reconnect.", | ||||
|         "TEXT_RECONNECT_COUNTDOWN"      : "Reconnecting in {REMAINING} {REMAINING, plural, one{second} other{seconds}}...", | ||||
|         "TEXT_FILE_TRANSFER_PROGRESS"   : "{PROGRESS} {UNIT, select, b{B} kb{KB} mb{MB} gb{GB} other{}}", | ||||
|         "TEXT_ZOOM_AUTO_FIT"              : "Automatically fit to browser window", | ||||
|         "TEXT_CLIENT_STATUS_IDLE"         : "Idle.", | ||||
|         "TEXT_CLIENT_STATUS_CONNECTING"   : "Connecting to Guacamole...", | ||||
|         "TEXT_CLIENT_STATUS_DISCONNECTED" : "You have been disconnected.", | ||||
|         "TEXT_CLIENT_STATUS_WAITING"      : "Connected to Guacamole. Waiting for response...", | ||||
|         "TEXT_RECONNECT_COUNTDOWN"        : "Reconnecting in {REMAINING} {REMAINING, plural, one{second} other{seconds}}...", | ||||
|         "TEXT_FILE_TRANSFER_PROGRESS"     : "{PROGRESS} {UNIT, select, b{B} kb{KB} mb{MB} gb{GB} other{}}", | ||||
|  | ||||
|         "URL_OSK_LAYOUT" : "layouts/en-us-qwerty.xml" | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user