Github user necouchman commented on a diff in the pull request:
https://github.com/apache/incubator-guacamole-client/pull/194#discussion_r143099506
--- 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)
--- End diff --
Yeah, this is about where the code starts to get fun. This changes some of
the asynchronous nature of the JavaScript in here, which has some potential
performance impacts, and I'm not sure this is real clean. Suggestions?
---