mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-07 05:31:22 +00:00
GUAC-1132: Update session management to use new active connection objects.
This commit is contained in:
@@ -27,15 +27,15 @@ angular.module('manage').controller('manageSessionsController', ['$scope', '$inj
|
|||||||
function manageSessionsController($scope, $injector) {
|
function manageSessionsController($scope, $injector) {
|
||||||
|
|
||||||
// Required types
|
// Required types
|
||||||
var ActiveTunnelWrapper = $injector.get('ActiveTunnelWrapper');
|
var ActiveConnectionWrapper = $injector.get('ActiveConnectionWrapper');
|
||||||
var ConnectionGroup = $injector.get('ConnectionGroup');
|
var ConnectionGroup = $injector.get('ConnectionGroup');
|
||||||
|
|
||||||
// Required services
|
// Required services
|
||||||
var authenticationService = $injector.get('authenticationService');
|
var activeConnectionService = $injector.get('activeConnectionService');
|
||||||
var connectionGroupService = $injector.get('connectionGroupService');
|
var authenticationService = $injector.get('authenticationService');
|
||||||
var guacNotification = $injector.get('guacNotification');
|
var connectionGroupService = $injector.get('connectionGroupService');
|
||||||
var permissionService = $injector.get('permissionService');
|
var guacNotification = $injector.get('guacNotification');
|
||||||
var tunnelService = $injector.get('tunnelService');
|
var permissionService = $injector.get('permissionService');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The root connection group of the connection group hierarchy.
|
* The root connection group of the connection group hierarchy.
|
||||||
@@ -53,10 +53,10 @@ angular.module('manage').controller('manageSessionsController', ['$scope', '$inj
|
|||||||
$scope.permissions = null;
|
$scope.permissions = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The ActiveTunnelWrappers of all active sessions accessible by the current
|
* The ActiveConnectionWrappers of all active sessions accessible by the
|
||||||
* user, or null if the tunnels have not yet been loaded.
|
* current user, or null if the active sessions have not yet been loaded.
|
||||||
*
|
*
|
||||||
* @type ActiveTunnelWrapper[]
|
* @type ActiveConnectionWrapper[]
|
||||||
*/
|
*/
|
||||||
$scope.wrappers = null;
|
$scope.wrappers = null;
|
||||||
|
|
||||||
@@ -74,9 +74,9 @@ angular.module('manage').controller('manageSessionsController', ['$scope', '$inj
|
|||||||
$scope.connections = {};
|
$scope.connections = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map of all currently-selected tunnel wrappers by UUID.
|
* Map of all currently-selected active connection wrappers by identifier.
|
||||||
*
|
*
|
||||||
* @type Object.<String, ActiveTunnelWrapper>
|
* @type Object.<String, ActiveConnectionWrapper>
|
||||||
*/
|
*/
|
||||||
var selectedWrappers = {};
|
var selectedWrappers = {};
|
||||||
|
|
||||||
@@ -122,12 +122,12 @@ angular.module('manage').controller('manageSessionsController', ['$scope', '$inj
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Query active sessions
|
// Query active sessions
|
||||||
tunnelService.getActiveTunnels().success(function sessionsRetrieved(tunnels) {
|
activeConnectionService.getActiveConnections().success(function sessionsRetrieved(activeConnections) {
|
||||||
|
|
||||||
// Wrap all active tunnels for sake of display
|
// Wrap all active connections for sake of display
|
||||||
$scope.wrappers = [];
|
$scope.wrappers = [];
|
||||||
for (var tunnelUUID in tunnels) {
|
for (var identifier in activeConnections) {
|
||||||
$scope.wrappers.push(new ActiveTunnelWrapper(tunnels[tunnelUUID]));
|
$scope.wrappers.push(new ActiveConnectionWrapper(activeConnections[identifier]));
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -192,12 +192,12 @@ angular.module('manage').controller('manageSessionsController', ['$scope', '$inj
|
|||||||
var deleteSessionsImmediately = function deleteSessionsImmediately() {
|
var deleteSessionsImmediately = function deleteSessionsImmediately() {
|
||||||
|
|
||||||
// Perform deletion
|
// Perform deletion
|
||||||
tunnelService.deleteActiveTunnels(Object.keys(selectedWrappers))
|
activeConnectionService.deleteActiveConnections(Object.keys(selectedWrappers))
|
||||||
.success(function tunnelsDeleted() {
|
.success(function activeConnectionsDeleted() {
|
||||||
|
|
||||||
// Remove deleted tunnels from wrapper array
|
// Remove deleted connections from wrapper array
|
||||||
$scope.wrappers = $scope.wrappers.filter(function tunnelStillExists(wrapper) {
|
$scope.wrappers = $scope.wrappers.filter(function activeConnectionStillExists(wrapper) {
|
||||||
return !(wrapper.tunnel.uuid in selectedWrappers);
|
return !(wrapper.activeConnection.identifier in selectedWrappers);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Clear selection
|
// Clear selection
|
||||||
@@ -206,7 +206,7 @@ angular.module('manage').controller('manageSessionsController', ['$scope', '$inj
|
|||||||
})
|
})
|
||||||
|
|
||||||
// Notify of any errors
|
// Notify of any errors
|
||||||
.error(function tunnelDeletionFailed(error) {
|
.error(function activeConnectionDeletionFailed(error) {
|
||||||
guacNotification.showStatus({
|
guacNotification.showStatus({
|
||||||
'className' : 'error',
|
'className' : 'error',
|
||||||
'title' : 'MANAGE_SESSION.DIALOG_HEADER_ERROR',
|
'title' : 'MANAGE_SESSION.DIALOG_HEADER_ERROR',
|
||||||
@@ -239,7 +239,7 @@ angular.module('manage').controller('manageSessionsController', ['$scope', '$inj
|
|||||||
$scope.canDeleteSessions = function canDeleteSessions() {
|
$scope.canDeleteSessions = function canDeleteSessions() {
|
||||||
|
|
||||||
// We can delete sessions if at least one is selected
|
// We can delete sessions if at least one is selected
|
||||||
for (var tunnelUUID in selectedWrappers)
|
for (var identifier in selectedWrappers)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -247,20 +247,20 @@ angular.module('manage').controller('manageSessionsController', ['$scope', '$inj
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called whenever a tunnel wrapper changes selected status.
|
* Called whenever an active connection wrapper changes selected status.
|
||||||
*
|
*
|
||||||
* @param {ActiveTunnelWrapper} wrapper
|
* @param {ActiveConnectionWrapper} wrapper
|
||||||
* The wrapper whose selected status has changed.
|
* The wrapper whose selected status has changed.
|
||||||
*/
|
*/
|
||||||
$scope.wrapperSelectionChange = function wrapperSelectionChange(wrapper) {
|
$scope.wrapperSelectionChange = function wrapperSelectionChange(wrapper) {
|
||||||
|
|
||||||
// Add wrapper to map if selected
|
// Add wrapper to map if selected
|
||||||
if (wrapper.checked)
|
if (wrapper.checked)
|
||||||
selectedWrappers[wrapper.tunnel.uuid] = wrapper;
|
selectedWrappers[wrapper.activeConnection.identifier] = wrapper;
|
||||||
|
|
||||||
// Otherwise, remove wrapper from map
|
// Otherwise, remove wrapper from map
|
||||||
else
|
else
|
||||||
delete selectedWrappers[wrapper.tunnel.uuid];
|
delete selectedWrappers[wrapper.activeConnection.identifier];
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -52,10 +52,10 @@ THE SOFTWARE.
|
|||||||
<td class="select-session">
|
<td class="select-session">
|
||||||
<input ng-change="wrapperSelectionChange(wrapper)" type="checkbox" ng-model="wrapper.checked" />
|
<input ng-change="wrapperSelectionChange(wrapper)" type="checkbox" ng-model="wrapper.checked" />
|
||||||
</td>
|
</td>
|
||||||
<td>{{wrapper.tunnel.username}}</td>
|
<td>{{wrapper.activeConnection.username}}</td>
|
||||||
<td>{{wrapper.tunnel.startDate | date:'short'}}</td>
|
<td>{{wrapper.activeConnection.startDate | date:'short'}}</td>
|
||||||
<td>{{wrapper.tunnel.remoteHost}}</td>
|
<td>{{wrapper.activeConnection.remoteHost}}</td>
|
||||||
<td>{{connections[wrapper.tunnel.identifier].name}}</td>
|
<td>{{connections[wrapper.activeConnection.connectionIdentifier].name}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
@@ -21,30 +21,30 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A service for defining the ActiveTunnelWrapper class.
|
* A service for defining the ActiveConnectionWrapper class.
|
||||||
*/
|
*/
|
||||||
angular.module('manage').factory('ActiveTunnelWrapper', [
|
angular.module('manage').factory('ActiveConnectionWrapper', [
|
||||||
function defineActiveTunnelWrapper() {
|
function defineActiveConnectionWrapper() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper for ActiveTunnel which adds display-specific
|
* Wrapper for ActiveConnection which adds display-specific
|
||||||
* properties, such as a checked option.
|
* properties, such as a checked option.
|
||||||
*
|
*
|
||||||
* @constructor
|
* @constructor
|
||||||
* @param {ActiveTunnel} activeTunnel
|
* @param {ActiveConnection} activeConnection
|
||||||
* The ActiveTunnel to wrap.
|
* The ActiveConnection to wrap.
|
||||||
*/
|
*/
|
||||||
var ActiveTunnelWrapper = function ActiveTunnelWrapper(activeTunnel) {
|
var ActiveConnectionWrapper = function ActiveConnectionWrapper(activeConnection) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The wrapped ActiveTunnel.
|
* The wrapped ActiveConnection.
|
||||||
*
|
*
|
||||||
* @type ActiveTunnel
|
* @type ActiveConnection
|
||||||
*/
|
*/
|
||||||
this.tunnel = activeTunnel;
|
this.activeConnection = activeConnection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A flag indicating that the tunnel has been selected.
|
* A flag indicating that the active connection has been selected.
|
||||||
*
|
*
|
||||||
* @type Boolean
|
* @type Boolean
|
||||||
*/
|
*/
|
||||||
@@ -52,6 +52,6 @@ angular.module('manage').factory('ActiveTunnelWrapper', [
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return ActiveTunnelWrapper;
|
return ActiveConnectionWrapper;
|
||||||
|
|
||||||
}]);
|
}]);
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Glyptodon LLC
|
* Copyright (C) 2015 Glyptodon LLC
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@@ -21,23 +21,24 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service for operating on tunnels via the REST API.
|
* Service for operating on active connections via the REST API.
|
||||||
*/
|
*/
|
||||||
angular.module('rest').factory('tunnelService', ['$http', 'authenticationService',
|
angular.module('rest').factory('activeConnectionService', ['$http', 'authenticationService',
|
||||||
function tunnelService($http, authenticationService) {
|
function activeConnectionService($http, authenticationService) {
|
||||||
|
|
||||||
var service = {};
|
var service = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes a request to the REST API to get the list of active tunnels,
|
* Makes a request to the REST API to get the list of active tunnels,
|
||||||
* returning a promise that provides a map of @link{ActiveTunnel}
|
* returning a promise that provides a map of @link{ActiveConnection}
|
||||||
* objects if successful.
|
* objects if successful.
|
||||||
*
|
*
|
||||||
* @returns {Promise.<Object.<String, ActiveTunnel>>}
|
* @returns {Promise.<Object.<String, ActiveConnection>>}
|
||||||
* A promise which will resolve with a map of @link{ActiveTunnel}
|
* A promise which will resolve with a map of @link{ActiveConnection}
|
||||||
* objects, where each key is the UUID of the corresponding tunnel.
|
* objects, where each key is the identifier of the corresponding
|
||||||
|
* active connection.
|
||||||
*/
|
*/
|
||||||
service.getActiveTunnels = function getActiveTunnels() {
|
service.getActiveConnections = function getActiveConnections() {
|
||||||
|
|
||||||
// Build HTTP parameters set
|
// Build HTTP parameters set
|
||||||
var httpParameters = {
|
var httpParameters = {
|
||||||
@@ -47,46 +48,46 @@ angular.module('rest').factory('tunnelService', ['$http', 'authenticationService
|
|||||||
// Retrieve tunnels
|
// Retrieve tunnels
|
||||||
return $http({
|
return $http({
|
||||||
method : 'GET',
|
method : 'GET',
|
||||||
url : 'api/tunnels',
|
url : 'api/activeConnections',
|
||||||
params : httpParameters
|
params : httpParameters
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes a request to the REST API to delete the tunnels having the given
|
* Makes a request to the REST API to delete the active connections having
|
||||||
* UUIDs, effectively disconnecting the tunnels, returning a promise that
|
* the given identifiers, effectively disconnecting them, returning a
|
||||||
* can be used for processing the results of the call.
|
* promise that can be used for processing the results of the call.
|
||||||
*
|
*
|
||||||
* @param {String[]} uuids
|
* @param {String[]} identifiers
|
||||||
* The UUIDs of the tunnels to delete.
|
* The identifiers of the active connections to delete.
|
||||||
*
|
*
|
||||||
* @returns {Promise}
|
* @returns {Promise}
|
||||||
* A promise for the HTTP call which will succeed if and only if the
|
* A promise for the HTTP call which will succeed if and only if the
|
||||||
* delete operation is successful.
|
* delete operation is successful.
|
||||||
*/
|
*/
|
||||||
service.deleteActiveTunnels = function deleteActiveTunnels(uuids) {
|
service.deleteActiveConnections = function deleteActiveConnections(identifiers) {
|
||||||
|
|
||||||
// Build HTTP parameters set
|
// Build HTTP parameters set
|
||||||
var httpParameters = {
|
var httpParameters = {
|
||||||
token : authenticationService.getCurrentToken()
|
token : authenticationService.getCurrentToken()
|
||||||
};
|
};
|
||||||
|
|
||||||
// Convert provided array of UUIDs to a patch
|
// Convert provided array of identifiers to a patch
|
||||||
var tunnelPatch = [];
|
var activeConnectionPatch = [];
|
||||||
uuids.forEach(function addTunnelPatch(uuid) {
|
identifiers.forEach(function addActiveConnectionPatch(identifier) {
|
||||||
tunnelPatch.push({
|
activeConnectionPatch.push({
|
||||||
op : 'remove',
|
op : 'remove',
|
||||||
path : '/' + uuid
|
path : '/' + identifier
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Perform tunnel deletion via PATCH
|
// Perform active connection deletion via PATCH
|
||||||
return $http({
|
return $http({
|
||||||
method : 'PATCH',
|
method : 'PATCH',
|
||||||
url : 'api/tunnels',
|
url : 'api/activeConnections',
|
||||||
params : httpParameters,
|
params : httpParameters,
|
||||||
data : tunnelPatch
|
data : activeConnectionPatch
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
@@ -21,34 +21,44 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service which defines the ActiveTunnel class.
|
* Service which defines the ActiveConnection class.
|
||||||
*/
|
*/
|
||||||
angular.module('rest').factory('ActiveTunnel', [function defineActiveTunnel() {
|
angular.module('rest').factory('ActiveConnection', [function defineActiveConnection() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The object returned by REST API calls when representing the data
|
* The object returned by REST API calls when representing the data
|
||||||
* associated with an active tunnel. Each tunnel denotes an active
|
* associated with an active connection. Each active connection is
|
||||||
* connection, uniquely identified by the tunnel UUID.
|
* effectively a pairing of a connection and the user currently using it,
|
||||||
|
* along with other information.
|
||||||
*
|
*
|
||||||
* @constructor
|
* @constructor
|
||||||
* @param {ActiveTunnel|Object} [template={}]
|
* @param {ActiveConnection|Object} [template={}]
|
||||||
* The object whose properties should be copied within the new
|
* The object whose properties should be copied within the new
|
||||||
* ActiveTunnel.
|
* ActiveConnection.
|
||||||
*/
|
*/
|
||||||
var ActiveTunnel = function ActiveTunnel(template) {
|
var ActiveConnection = function ActiveConnection(template) {
|
||||||
|
|
||||||
// Use empty object by default
|
// Use empty object by default
|
||||||
template = template || {};
|
template = template || {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The identifier of the connection associated with this tunnel.
|
* The identifier which uniquely identifies this specific active
|
||||||
*
|
* connection.
|
||||||
|
*
|
||||||
* @type String
|
* @type String
|
||||||
*/
|
*/
|
||||||
this.identifier = template.identifier;
|
this.identifier = template.identifier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The time that the tunnel began, in seconds since
|
* The identifier of the connection associated with this active
|
||||||
|
* connection.
|
||||||
|
*
|
||||||
|
* @type String
|
||||||
|
*/
|
||||||
|
this.connectionIdentifier = template.connectionIdentifier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The time that the connection began, in seconds since
|
||||||
* 1970-01-01 00:00:00 UTC.
|
* 1970-01-01 00:00:00 UTC.
|
||||||
*
|
*
|
||||||
* @type Number
|
* @type Number
|
||||||
@@ -56,28 +66,21 @@ angular.module('rest').factory('ActiveTunnel', [function defineActiveTunnel() {
|
|||||||
this.startDate = template.startDate;
|
this.startDate = template.startDate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The remote host that initiated the tunnel, if known.
|
* The remote host that initiated the connection, if known.
|
||||||
*
|
*
|
||||||
* @type String
|
* @type String
|
||||||
*/
|
*/
|
||||||
this.remoteHost = template.remoteHost;
|
this.remoteHost = template.remoteHost;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The username of the user associated with the tunnel.
|
* The username of the user associated with the connection.
|
||||||
*
|
*
|
||||||
* @type String
|
* @type String
|
||||||
*/
|
*/
|
||||||
this.username = template.username;
|
this.username = template.username;
|
||||||
|
|
||||||
/**
|
|
||||||
* The UUID which uniquely identifies the tunnel.
|
|
||||||
*
|
|
||||||
* @type String
|
|
||||||
*/
|
|
||||||
this.uuid = template.uuid;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return ActiveTunnel;
|
return ActiveConnection;
|
||||||
|
|
||||||
}]);
|
}]);
|
Reference in New Issue
Block a user