mirror of
				https://github.com/gyurix1968/guacamole-client.git
				synced 2025-10-31 00:53:21 +00:00 
			
		
		
		
	GUAC-963: Add support for file transfer errors.
This commit is contained in:
		| @@ -112,24 +112,6 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams | |||||||
|         0x031D: true |         0x031D: true | ||||||
|     }; |     }; | ||||||
|   |   | ||||||
|     /** |  | ||||||
|      * All upload error codes handled and passed off for translation. Any error |  | ||||||
|      * code not present in this list will be represented by the "DEFAULT" |  | ||||||
|      * translation. |  | ||||||
|      */ |  | ||||||
|     var UPLOAD_ERRORS = { |  | ||||||
|         0x0100: true, |  | ||||||
|         0x0201: true, |  | ||||||
|         0x0202: true, |  | ||||||
|         0x0203: true, |  | ||||||
|         0x0204: true, |  | ||||||
|         0x0205: true, |  | ||||||
|         0x0301: true, |  | ||||||
|         0x0303: true, |  | ||||||
|         0x0308: true, |  | ||||||
|         0x031D: true |  | ||||||
|     }; |  | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * All error codes for which automatic reconnection is appropriate when a |      * All error codes for which automatic reconnection is appropriate when a | ||||||
|      * tunnel error occurs. |      * tunnel error occurs. | ||||||
|   | |||||||
| @@ -46,6 +46,24 @@ angular.module('client').directive('guacFileTransfer', [function guacFileTransfe | |||||||
|             // Required types |             // Required types | ||||||
|             var ManagedFileTransferState = $injector.get('ManagedFileTransferState'); |             var ManagedFileTransferState = $injector.get('ManagedFileTransferState'); | ||||||
|  |  | ||||||
|  |             /** | ||||||
|  |              * All upload error codes handled and passed off for translation. | ||||||
|  |              * Any error code not present in this list will be represented by | ||||||
|  |              * the "DEFAULT" translation. | ||||||
|  |              */ | ||||||
|  |             var UPLOAD_ERRORS = { | ||||||
|  |                 0x0100: true, | ||||||
|  |                 0x0201: true, | ||||||
|  |                 0x0202: true, | ||||||
|  |                 0x0203: true, | ||||||
|  |                 0x0204: true, | ||||||
|  |                 0x0205: true, | ||||||
|  |                 0x0301: true, | ||||||
|  |                 0x0303: true, | ||||||
|  |                 0x0308: true, | ||||||
|  |                 0x031D: true | ||||||
|  |             }; | ||||||
|  |  | ||||||
|             /** |             /** | ||||||
|              * Returns the unit string that is most appropriate for the |              * Returns the unit string that is most appropriate for the | ||||||
|              * number of bytes transferred thus far - either 'gb', 'mb', 'kb', |              * number of bytes transferred thus far - either 'gb', 'mb', 'kb', | ||||||
| @@ -182,6 +200,37 @@ angular.module('client').directive('guacFileTransfer', [function guacFileTransfe | |||||||
|  |  | ||||||
|             }; |             }; | ||||||
|  |  | ||||||
|  |             /** | ||||||
|  |              * Returns whether an error has occurred. If an error has occurred, | ||||||
|  |              * the transfer is no longer active, and the text of the error can | ||||||
|  |              * be read from getErrorText(). | ||||||
|  |              * | ||||||
|  |              * @returns {Boolean} | ||||||
|  |              *     true if an error has occurred during transfer, false | ||||||
|  |              *     otherwise. | ||||||
|  |              */ | ||||||
|  |             $scope.hasError = function hasError() { | ||||||
|  |                 return $scope.transfer.transferState.streamState === ManagedFileTransferState.StreamState.ERROR; | ||||||
|  |             }; | ||||||
|  |  | ||||||
|  |             /** | ||||||
|  |              * Returns the text of the current error as a translation string. | ||||||
|  |              * | ||||||
|  |              * @returns {String} | ||||||
|  |              *     The name of the translation string containing the text | ||||||
|  |              *     associated with the current error. | ||||||
|  |              */ | ||||||
|  |             $scope.getErrorText = function getErrorText() { | ||||||
|  |  | ||||||
|  |                 // Determine translation name of error | ||||||
|  |                 var status = $scope.transfer.transferState.statusCode; | ||||||
|  |                 var errorName = (status in UPLOAD_ERRORS) ? status.toString(16).toUpperCase() : "DEFAULT"; | ||||||
|  |  | ||||||
|  |                 // Return translation string | ||||||
|  |                 return 'CLIENT.ERROR_UPLOAD_' + errorName; | ||||||
|  |  | ||||||
|  |             }; | ||||||
|  |  | ||||||
|         }] // end file transfer controller |         }] // end file transfer controller | ||||||
|  |  | ||||||
|     }; |     }; | ||||||
|   | |||||||
| @@ -32,6 +32,8 @@ | |||||||
|     overflow: hidden; |     overflow: hidden; | ||||||
|     width: 100%; |     width: 100%; | ||||||
|     margin-bottom: 0.5em; |     margin-bottom: 0.5em; | ||||||
|  |     font-family: monospace; | ||||||
|  |     font-weight: bold; | ||||||
| } | } | ||||||
|  |  | ||||||
| .transfer .text { | .transfer .text { | ||||||
| @@ -108,3 +110,20 @@ | |||||||
|     color: blue; |     color: blue; | ||||||
|     text-decoration: underline; |     text-decoration: underline; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | .error.transfer { | ||||||
|  |     background: #FDD; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | .error.transfer .progress { | ||||||
|  |     border-color: rgba(0, 0, 0, 0.125); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | .error.transfer .text, | ||||||
|  | .error.transfer .progress .bar { | ||||||
|  |     display: none; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | .error-text { | ||||||
|  |     margin-bottom: 0; | ||||||
|  | } | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| <div class="transfer" ng-class="{'in-progress': isInProgress(), 'savable': isSavable()}" ng-click="save()"> | <div class="transfer" ng-class="{'in-progress': isInProgress(), 'savable': isSavable(), 'error': hasError()}" ng-click="save()"> | ||||||
|     <!-- |     <!-- | ||||||
|        Copyright (C) 2014 Glyptodon LLC |        Copyright (C) 2014 Glyptodon LLC | ||||||
|  |  | ||||||
| @@ -30,4 +30,7 @@ | |||||||
|     <!-- Progress bar --> |     <!-- Progress bar --> | ||||||
|     <div class="progress"><div ng-style="{'width': getPercentDone() + '%'}" class="bar"></div></div> |     <div class="progress"><div ng-style="{'width': getPercentDone() + '%'}" class="bar"></div></div> | ||||||
|  |  | ||||||
|  |     <!-- Error text --> | ||||||
|  |     <p class="error-text" ng-show="hasError()">{{getErrorText() | translate}}</p> | ||||||
|  |      | ||||||
| </div> | </div> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user