GUACAMOLE-360: When joining an active connection, retrieve name and protocol from underlying connection.

This commit is contained in:
Michael Jumper
2019-08-10 18:24:32 -07:00
parent 04182391e9
commit 4768f66a8b
2 changed files with 71 additions and 15 deletions

View File

@@ -40,6 +40,7 @@ angular.module('client').factory('ManagedClient', ['$rootScope', '$injector',
var $q = $injector.get('$q');
var $rootScope = $injector.get('$rootScope');
var $window = $injector.get('$window');
var activeConnectionService = $injector.get('activeConnectionService');
var authenticationService = $injector.get('authenticationService');
var connectionGroupService = $injector.get('connectionGroupService');
var connectionService = $injector.get('connectionService');
@@ -600,6 +601,29 @@ angular.module('client').factory('ManagedClient', ['$rootScope', '$injector',
}, requestService.WARN);
}
// If using an active connection, pull corresponding connection, then
// pull connection name and protocol information from that
else if (clientIdentifier.type === ClientIdentifier.Types.ACTIVE_CONNECTION) {
activeConnectionService.getActiveConnection(clientIdentifier.dataSource, clientIdentifier.id)
.then(function activeConnectionRetrieved(activeConnection) {
// Attempt to retrieve connection details only if the
// underlying connection is known
if (activeConnection.connectionIdentifier) {
$q.all({
connection : connectionService.getConnection(clientIdentifier.dataSource, activeConnection.connectionIdentifier),
protocols : schemaService.getProtocols(clientIdentifier.dataSource)
})
.then(function dataRetrieved(values) {
managedClient.name = managedClient.title = values.connection.name;
managedClient.protocol = values.connection.protocol;
managedClient.forms = values.protocols[values.connection.protocol].connectionForms;
}, requestService.WARN);
}
}, requestService.WARN);
}
return managedClient;
};

View File

@@ -29,6 +29,38 @@ angular.module('rest').factory('activeConnectionService', ['$injector',
var service = {};
/**
* Makes a request to the REST API to get a single active connection,
* returning a promise that provides the corresponding
* @link{ActiveConnection} if successful.
*
* @param {String} dataSource
* The identifier of the data source to retrieve the active connection
* from.
*
* @param {String} id
* The identifier of the active connection.
*
* @returns {Promise.<ActiveConnection>}
* A promise which will resolve with a @link{ActiveConnection} upon
* success.
*/
service.getActiveConnection = function getActiveConnection(dataSource, id) {
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Retrieve active connection
return requestService({
method : 'GET',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/activeConnections/' + encodeURIComponent(id),
params : httpParameters
});
};
/**
* Makes a request to the REST API to get the list of active tunnels,
* returning a promise that provides a map of @link{ActiveConnection}