mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-09 22:51:22 +00:00
GUAC-1132: Update session management to use new active connection objects.
This commit is contained in:
@@ -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
|
||||
* 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',
|
||||
function tunnelService($http, authenticationService) {
|
||||
angular.module('rest').factory('activeConnectionService', ['$http', 'authenticationService',
|
||||
function activeConnectionService($http, authenticationService) {
|
||||
|
||||
var service = {};
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @returns {Promise.<Object.<String, ActiveTunnel>>}
|
||||
* A promise which will resolve with a map of @link{ActiveTunnel}
|
||||
* objects, where each key is the UUID of the corresponding tunnel.
|
||||
* @returns {Promise.<Object.<String, ActiveConnection>>}
|
||||
* A promise which will resolve with a map of @link{ActiveConnection}
|
||||
* objects, where each key is the identifier of the corresponding
|
||||
* active connection.
|
||||
*/
|
||||
service.getActiveTunnels = function getActiveTunnels() {
|
||||
service.getActiveConnections = function getActiveConnections() {
|
||||
|
||||
// Build HTTP parameters set
|
||||
var httpParameters = {
|
||||
@@ -47,46 +48,46 @@ angular.module('rest').factory('tunnelService', ['$http', 'authenticationService
|
||||
// Retrieve tunnels
|
||||
return $http({
|
||||
method : 'GET',
|
||||
url : 'api/tunnels',
|
||||
url : 'api/activeConnections',
|
||||
params : httpParameters
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Makes a request to the REST API to delete the tunnels having the given
|
||||
* UUIDs, effectively disconnecting the tunnels, returning a promise that
|
||||
* can be used for processing the results of the call.
|
||||
* Makes a request to the REST API to delete the active connections having
|
||||
* the given identifiers, effectively disconnecting them, returning a
|
||||
* promise that can be used for processing the results of the call.
|
||||
*
|
||||
* @param {String[]} uuids
|
||||
* The UUIDs of the tunnels to delete.
|
||||
* @param {String[]} identifiers
|
||||
* The identifiers of the active connections to delete.
|
||||
*
|
||||
* @returns {Promise}
|
||||
* A promise for the HTTP call which will succeed if and only if the
|
||||
* delete operation is successful.
|
||||
*/
|
||||
service.deleteActiveTunnels = function deleteActiveTunnels(uuids) {
|
||||
service.deleteActiveConnections = function deleteActiveConnections(identifiers) {
|
||||
|
||||
// Build HTTP parameters set
|
||||
var httpParameters = {
|
||||
token : authenticationService.getCurrentToken()
|
||||
};
|
||||
|
||||
// Convert provided array of UUIDs to a patch
|
||||
var tunnelPatch = [];
|
||||
uuids.forEach(function addTunnelPatch(uuid) {
|
||||
tunnelPatch.push({
|
||||
// Convert provided array of identifiers to a patch
|
||||
var activeConnectionPatch = [];
|
||||
identifiers.forEach(function addActiveConnectionPatch(identifier) {
|
||||
activeConnectionPatch.push({
|
||||
op : 'remove',
|
||||
path : '/' + uuid
|
||||
path : '/' + identifier
|
||||
});
|
||||
});
|
||||
|
||||
// Perform tunnel deletion via PATCH
|
||||
// Perform active connection deletion via PATCH
|
||||
return $http({
|
||||
method : 'PATCH',
|
||||
url : 'api/tunnels',
|
||||
url : 'api/activeConnections',
|
||||
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
|
||||
* associated with an active tunnel. Each tunnel denotes an active
|
||||
* connection, uniquely identified by the tunnel UUID.
|
||||
* associated with an active connection. Each active connection is
|
||||
* effectively a pairing of a connection and the user currently using it,
|
||||
* along with other information.
|
||||
*
|
||||
* @constructor
|
||||
* @param {ActiveTunnel|Object} [template={}]
|
||||
* @param {ActiveConnection|Object} [template={}]
|
||||
* 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
|
||||
template = template || {};
|
||||
|
||||
/**
|
||||
* The identifier of the connection associated with this tunnel.
|
||||
*
|
||||
* The identifier which uniquely identifies this specific active
|
||||
* connection.
|
||||
*
|
||||
* @type String
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @type Number
|
||||
@@ -56,28 +66,21 @@ angular.module('rest').factory('ActiveTunnel', [function defineActiveTunnel() {
|
||||
this.startDate = template.startDate;
|
||||
|
||||
/**
|
||||
* The remote host that initiated the tunnel, if known.
|
||||
* The remote host that initiated the connection, if known.
|
||||
*
|
||||
* @type String
|
||||
*/
|
||||
this.remoteHost = template.remoteHost;
|
||||
|
||||
/**
|
||||
* The username of the user associated with the tunnel.
|
||||
* The username of the user associated with the connection.
|
||||
*
|
||||
* @type String
|
||||
*/
|
||||
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