mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUACAMOLE-5: Add sharing support to the Guacamole client UI.
This commit is contained in:
@@ -28,6 +28,7 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
|
||||
var ManagedClientState = $injector.get('ManagedClientState');
|
||||
var ManagedFilesystem = $injector.get('ManagedFilesystem');
|
||||
var ScrollState = $injector.get('ScrollState');
|
||||
var UserCredentials = $injector.get('UserCredentials');
|
||||
|
||||
// Required services
|
||||
var $location = $injector.get('$location');
|
||||
@@ -36,6 +37,7 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
|
||||
var guacClientManager = $injector.get('guacClientManager');
|
||||
var guacNotification = $injector.get('guacNotification');
|
||||
var preferenceService = $injector.get('preferenceService');
|
||||
var tunnelService = $injector.get('tunnelService');
|
||||
var userPageService = $injector.get('userPageService');
|
||||
|
||||
/**
|
||||
@@ -235,6 +237,15 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
|
||||
*/
|
||||
$scope.client = guacClientManager.getManagedClient($routeParams.id, $routeParams.params);
|
||||
|
||||
/**
|
||||
* Map of all available sharing profiles for the current connection by
|
||||
* their identifiers. If this information is not yet available, or no such
|
||||
* sharing profiles exist, this will be an empty object.
|
||||
*
|
||||
* @type Object.<String, SharingProfile>
|
||||
*/
|
||||
$scope.sharingProfiles = {};
|
||||
|
||||
/**
|
||||
* Map of all currently pressed keys by keysym. If a particular key is
|
||||
* currently pressed, the value stored under that key's keysym within this
|
||||
@@ -406,6 +417,47 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
|
||||
|
||||
});
|
||||
|
||||
// Pull sharing profiles once the tunnel UUID is known
|
||||
$scope.$watch('client.tunnel.uuid', function retrieveSharingProfiles(uuid) {
|
||||
|
||||
// Only pull sharing profiles if tunnel UUID is actually available
|
||||
if (!uuid)
|
||||
return;
|
||||
|
||||
// Pull sharing profiles for the current connection
|
||||
tunnelService.getSharingProfiles(uuid)
|
||||
.success(function sharingProfilesRetrieved(sharingProfiles) {
|
||||
$scope.sharingProfiles = sharingProfiles;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* Produces a sharing link for the current connection using the given
|
||||
* sharing profile. The resulting sharing link, and any required login
|
||||
* information, will be displayed to the user once the various underlying
|
||||
* service calls succeed.
|
||||
*
|
||||
* @param {SharingProfile} sharingProfile
|
||||
* The sharing profile to use to generate the sharing link.
|
||||
*/
|
||||
$scope.share = function share(sharingProfile) {
|
||||
|
||||
// Retrieve sharing credentials for the sake of generating a share link
|
||||
tunnelService.getSharingCredentials($scope.client.tunnel.uuid, sharingProfile.identifier)
|
||||
.success(function sharingCredentialsReceived(sharingCredentials) {
|
||||
|
||||
// TODONT: COMPLETE HACK: Shove the share link into the clipboard
|
||||
var href = UserCredentials.getLink(sharingCredentials);
|
||||
$scope.client.clipboardData = {
|
||||
'type' : 'text/plain',
|
||||
'data' : href
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
// Track pressed keys, opening the Guacamole menu after Ctrl+Alt+Shift
|
||||
$scope.$on('guacKeydown', function keydownListener(event, keysym, keyboard) {
|
||||
|
||||
@@ -762,6 +814,26 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns whether the current user can share the current connection with
|
||||
* other users. A connection can be shared if and only if there is at least
|
||||
* one associated sharing profile.
|
||||
*
|
||||
* @returns {Boolean}
|
||||
* true if the current user can share the current connection with other
|
||||
* users, false otherwise.
|
||||
*/
|
||||
$scope.canShareConnection = function canShareConnection() {
|
||||
|
||||
// If there is at least one sharing profile, the connection can be shared
|
||||
for (var dummy in $scope.sharingProfiles)
|
||||
return true;
|
||||
|
||||
// Otherwise, sharing is not possible
|
||||
return false;
|
||||
|
||||
};
|
||||
|
||||
// Clean up when view destroyed
|
||||
$scope.$on('$destroy', function clientViewDestroyed() {
|
||||
|
||||
|
@@ -43,6 +43,11 @@
|
||||
<!-- Stationary header -->
|
||||
<div class="header">
|
||||
<h2>{{client.name}}</h2>
|
||||
<guac-menu title="'CLIENT.ACTION_SHARE' | translate" ng-show="canShareConnection()">
|
||||
<ul ng-repeat="sharingProfile in sharingProfiles">
|
||||
<li><a ng-click="share(sharingProfile)">{{sharingProfile.name}}</a></li>
|
||||
</ul>
|
||||
</guac-menu>
|
||||
<guac-user-menu local-actions="clientMenuActions"></guac-user-menu>
|
||||
</div>
|
||||
|
||||
|
@@ -24,6 +24,7 @@
|
||||
"ACTION_NAVIGATE_HOME" : "Home",
|
||||
"ACTION_SAVE" : "Save",
|
||||
"ACTION_SEARCH" : "Search",
|
||||
"ACTION_SHARE" : "Share",
|
||||
"ACTION_UPDATE_PASSWORD" : "Update Password",
|
||||
"ACTION_VIEW_HISTORY" : "History",
|
||||
|
||||
@@ -55,6 +56,7 @@
|
||||
"ACTION_NAVIGATE_HOME" : "@:APP.ACTION_NAVIGATE_HOME",
|
||||
"ACTION_RECONNECT" : "Reconnect",
|
||||
"ACTION_SAVE_FILE" : "@:APP.ACTION_SAVE",
|
||||
"ACTION_SHARE" : "@:APP.ACTION_SHARE",
|
||||
"ACTION_UPLOAD_FILES" : "Upload Files",
|
||||
|
||||
"DIALOG_HEADER_CONNECTING" : "Connecting",
|
||||
|
Reference in New Issue
Block a user