mirror of
				https://github.com/gyurix1968/guacamole-client.git
				synced 2025-10-31 00:53:21 +00:00 
			
		
		
		
	GUAC-963: Manage file uploads.
This commit is contained in:
		| @@ -620,100 +620,6 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams | ||||
|         }); | ||||
|     }); | ||||
|  | ||||
|     // Mapping of upload stream index to notification object | ||||
|     var uploadNotifications = {}; | ||||
|      | ||||
|     // Mapping of upload stream index to notification ID | ||||
|     var uploadNotificationIDs = {}; | ||||
|      | ||||
|     $scope.$on('guacClientFileUploadStart', function handleClientFileUploadStart(event, guacClient, streamIndex, mimetype, filename, length) { | ||||
|         $scope.$apply(function() { | ||||
|              | ||||
|             var notification = { | ||||
|                 className  : 'upload', | ||||
|                 title      : 'CLIENT.DIALOG_TITLE_FILE_TRANSFER', | ||||
|                 text       : filename | ||||
|             }; | ||||
|              | ||||
|             uploadNotifications[streamIndex]   = notification; | ||||
|             uploadNotificationIDs[streamIndex] = $scope.addNotification(notification); | ||||
|              | ||||
|         }); | ||||
|     }); | ||||
|  | ||||
|     $scope.$on('guacClientFileUploadProgress', function handleClientFileUploadProgress(event, guacClient, streamIndex, mimetype, filename, length, offset) { | ||||
|         $scope.$apply(function() { | ||||
|              | ||||
|             var notification = uploadNotifications[streamIndex]; | ||||
|             if (notification) | ||||
|                 notification.progress = getFileProgress('CLIENT.TEXT_FILE_TRANSFER_PROGRESS', offset, length); | ||||
|              | ||||
|         }); | ||||
|     }); | ||||
|      | ||||
|     $scope.$on('guacClientFileUploadEnd', function handleClientFileUploadEnd(event, guacClient, streamIndex, mimetype, filename, length) { | ||||
|         $scope.$apply(function() { | ||||
|  | ||||
|             var notification = uploadNotifications[streamIndex]; | ||||
|             var notificationID = uploadNotificationIDs[streamIndex]; | ||||
|              | ||||
|             /** | ||||
|              * Close the notification. | ||||
|              */ | ||||
|             var closeNotification = function closeNotification() { | ||||
|                 $scope.removeNotification(notificationID); | ||||
|                 delete uploadNotifications[streamIndex]; | ||||
|                 delete uploadNotificationIDs[streamIndex]; | ||||
|             }; | ||||
|              | ||||
|             // Show that the file has uploaded successfully | ||||
|             if (notificationID && notification) { | ||||
|                 delete notification.progress; | ||||
|                 notification.actions = [ | ||||
|                     { | ||||
|                         name       : 'CLIENT.ACTION_ACKNOWLEDGE', | ||||
|                         callback   : closeNotification | ||||
|                     } | ||||
|                 ]; | ||||
|             } | ||||
|  | ||||
|         }); | ||||
|     }); | ||||
|      | ||||
|     $scope.$on('guacClientFileUploadError', function handleClientFileUploadError(event, guacClient, streamIndex, mimetype, fileName, length, status) { | ||||
|         $scope.$apply(function() { | ||||
|  | ||||
|             var notification = uploadNotifications[streamIndex]; | ||||
|             var notificationID = uploadNotificationIDs[streamIndex]; | ||||
|  | ||||
|             // Determine translation name of error | ||||
|             var errorName = (status in UPLOAD_ERRORS) ? status.toString(16).toUpperCase() : "DEFAULT"; | ||||
|  | ||||
|             /** | ||||
|              * Close the notification. | ||||
|              */ | ||||
|             var closeNotification = function closeNotification() { | ||||
|                 $scope.removeNotification(notificationID); | ||||
|                 delete uploadNotifications[streamIndex]; | ||||
|                 delete uploadNotificationIDs[streamIndex]; | ||||
|             }; | ||||
|  | ||||
|             // Show that the file upload has failed | ||||
|             if (notificationID && notification) { | ||||
|                 delete notification.progress; | ||||
|                 notification.actions = [ | ||||
|                     { | ||||
|                         name       : 'CLIENT.ACTION_ACKNOWLEDGE', | ||||
|                         callback   : closeNotification | ||||
|                     } | ||||
|                 ]; | ||||
|                 notification.text = "CLIENT.ERROR_UPLOAD_" + errorName; | ||||
|                 notification.className = "upload error"; | ||||
|             } | ||||
|              | ||||
|         }); | ||||
|     }); | ||||
|  | ||||
|     // Clean up when view destroyed | ||||
|     $scope.$on('$destroy', function clientViewDestroyed() { | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user