From c41b6774fd76bea2f2f376a3967356fdc338e745 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sat, 3 Aug 2019 19:52:39 -0700 Subject: [PATCH] GUACAMOLE-630: Allow parameters received via "argv" streams to be edited within the Guacamole menu. --- .../client/controllers/clientController.js | 40 ++++- .../webapp/app/client/templates/client.html | 8 + .../app/client/types/ManagedArgument.js | 152 ++++++++++++++++++ .../webapp/app/client/types/ManagedClient.js | 116 ++++++++++++- 4 files changed, 308 insertions(+), 8 deletions(-) create mode 100644 guacamole/src/main/webapp/app/client/types/ManagedArgument.js diff --git a/guacamole/src/main/webapp/app/client/controllers/clientController.js b/guacamole/src/main/webapp/app/client/controllers/clientController.js index 41c6ba6b7..b90f26365 100644 --- a/guacamole/src/main/webapp/app/client/controllers/clientController.js +++ b/guacamole/src/main/webapp/app/client/controllers/clientController.js @@ -27,6 +27,7 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams var ManagedClient = $injector.get('ManagedClient'); var ManagedClientState = $injector.get('ManagedClientState'); var ManagedFilesystem = $injector.get('ManagedFilesystem'); + var Protocol = $injector.get('Protocol'); var ScrollState = $injector.get('ScrollState'); // Required services @@ -248,7 +249,15 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams * * @type ScrollState */ - scrollState : new ScrollState() + scrollState : new ScrollState(), + + /** + * The current desired values of all editable connection parameters as + * a set of name/value pairs, including any changes made by the user. + * + * @type {Object.} + */ + connectionParameters : {} }; @@ -257,6 +266,16 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams $scope.menu.shown = false; }; + /** + * Applies any changes to connection parameters made by the user within the + * Guacamole menu. + */ + $scope.applyParameterChanges = function applyParameterChanges() { + angular.forEach($scope.menu.connectionParameters, function sendArgv(value, name) { + ManagedClient.setArgument($scope.client, name, value); + }); + }; + /** * The client which should be attached to the client UI. * @@ -429,12 +448,20 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams }); + // Update client state/behavior as visibility of the Guacamole menu changes $scope.$watch('menu.shown', function menuVisibilityChanged(menuShown, menuShownPreviousState) { - // Send clipboard data if menu is hidden - if (!menuShown && menuShownPreviousState) + // Send clipboard and argument value data once menu is hidden + if (!menuShown && menuShownPreviousState) { $scope.$broadcast('guacClipboard', $scope.client.clipboardData); - + $scope.applyParameterChanges(); + } + + // Obtain snapshot of current editable connection parameters when menu + // is opened + else if (menuShown) + $scope.menu.connectionParameters = ManagedClient.getArgumentModel($scope.client); + // Disable client keyboard if the menu is shown $scope.client.clientProperties.keyboardEnabled = !menuShown; @@ -805,6 +832,11 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams // Set client-specific menu actions $scope.clientMenuActions = [ DISCONNECT_MENU_ACTION ]; + /** + * @borrows Protocol.getNamespace + */ + $scope.getProtocolNamespace = Protocol.getNamespace; + /** * The currently-visible filesystem within the filesystem menu, if the * filesystem menu is open. If no filesystem is currently visible, this diff --git a/guacamole/src/main/webapp/app/client/templates/client.html b/guacamole/src/main/webapp/app/client/templates/client.html index ad85f234e..7690e7573 100644 --- a/guacamole/src/main/webapp/app/client/templates/client.html +++ b/guacamole/src/main/webapp/app/client/templates/client.html @@ -96,6 +96,14 @@ + + +