Github user necouchman commented on a diff in the pull request:
https://github.com/apache/guacamole-client/pull/194#discussion_r178081985
--- Diff: guacamole/src/main/webapp/app/client/types/ManagedClient.js ---
@@ -503,27 +504,70 @@ angular.module('client').factory('ManagedClient',
['$rootScope', '$injector',
// Parse connection details from ID
var clientIdentifier = ClientIdentifier.fromString(id);
- // Connect the Guacamole client
- getConnectString(clientIdentifier, connectionParameters)
- .then(function connectClient(connectString) {
- client.connect(connectString);
- });
-
+ var gettingConnectionData = $q.defer();
// If using a connection, pull connection name
- if (clientIdentifier.type === ClientIdentifier.Types.CONNECTION) {
- connectionService.getConnection(clientIdentifier.dataSource,
clientIdentifier.id)
- .success(function connectionRetrieved(connection) {
- managedClient.name = managedClient.title = connection.name;
- });
- }
-
+ if (clientIdentifier.type === ClientIdentifier.Types.CONNECTION)
+ gettingConnectionData =
connectionService.getConnection(clientIdentifier.dataSource,
clientIdentifier.id);
+
// If using a connection group, pull connection name
- else if (clientIdentifier.type ===
ClientIdentifier.Types.CONNECTION_GROUP) {
-
connectionGroupService.getConnectionGroup(clientIdentifier.dataSource,
clientIdentifier.id)
- .success(function connectionGroupRetrieved(group) {
- managedClient.name = managedClient.title = group.name;
+ else if (clientIdentifier.type ===
ClientIdentifier.Types.CONNECTION_GROUP)
+ gettingConnectionData =
connectionGroupService.getConnectionGroup(clientIdentifier.dataSource,
clientIdentifier.id);
+
+ else
+ gettingConnectionData.reject('Invalid connection type.');
+
+ // Get Connection Prompts
+ var gettingConnectionPrompts =
connectionService.getConnectionPrompts(clientIdentifier.dataSource,
clientIdentifier.id);
+
+ // When we've received connection data and prompts, display
prompts to user.
+ $q.all([gettingConnectionData,gettingConnectionPrompts])
+ .then(function connectClient(clientData) {
+
+ var connData = clientData[0].data;
+ var connPrompts = clientData[1].data;
+
+ // Display the prompts, then process them
+ guacPrompt.getUserInput(connPrompts,connData)
+ .then(function receivedUserInput(data) {
+
+ // Create a parameter string from the received data
+ var userData = '';
+ for (var key in data) {
+ var param = data[key];
+ for (var idx in param) {
+ var inst = param[idx];
+ if (userData != '')
+ userData += '&';
+ userData += key + '[' + idx + ']=' + inst;
--- End diff --
Slight change here - I had encoded everything, including parameter name,
which obviously didn't work. Instead I should do the encoding where you
suggested it :-). Should be fixed and working, now.
---