mirror of
				https://github.com/gyurix1968/guacamole-client.git
				synced 2025-10-31 09:03:21 +00:00 
			
		
		
		
	GUACAMOLE-5: Include sharing profiles within connection management display.
This commit is contained in:
		| @@ -169,6 +169,30 @@ angular.module('settings').directive('guacSettingsConnections', [function guacSe | ||||
|  | ||||
|             }; | ||||
|  | ||||
|             /** | ||||
|              * Returns whether the current user can create new sharing profiles | ||||
|              * within the current data source. | ||||
|              * | ||||
|              * @return {Boolean} | ||||
|              *     true if the current user can create new sharing profiles | ||||
|              *     within the current data source, false otherwise. | ||||
|              */ | ||||
|             $scope.canCreateSharingProfiles = function canCreateSharingProfiles() { | ||||
|  | ||||
|                 // Abort if permissions have not yet loaded | ||||
|                 if (!$scope.permissions) | ||||
|                     return false; | ||||
|  | ||||
|                 // Can create sharing profiles if adminstrator or have explicit permission | ||||
|                 if (PermissionSet.hasSystemPermission($scope.permissions, PermissionSet.SystemPermissionType.ADMINISTER) | ||||
|                  || PermissionSet.hasSystemPermission($scope.permissions, PermissionSet.SystemPermissionType.CREATE_SHARING_PROFILE)) | ||||
|                      return true; | ||||
|  | ||||
|                 // Current data source does not allow sharing profile creation | ||||
|                 return false; | ||||
|  | ||||
|             }; | ||||
|  | ||||
|             /** | ||||
|              * Returns whether the current user can create new connections or | ||||
|              * connection groups or make changes to existing connections or | ||||
| @@ -188,7 +212,9 @@ angular.module('settings').directive('guacSettingsConnections', [function guacSe | ||||
|                     return false; | ||||
|  | ||||
|                 // Creating connections/groups counts as management | ||||
|                 if ($scope.canCreateConnections() || $scope.canCreateConnectionGroups()) | ||||
|                 if ($scope.canCreateConnections() | ||||
|                         || $scope.canCreateConnectionGroups() | ||||
|                         || $scope.canCreateSharingProfiles()) | ||||
|                     return true; | ||||
|  | ||||
|                 // Can manage connections if granted explicit update or delete | ||||
| @@ -206,6 +232,34 @@ angular.module('settings').directive('guacSettingsConnections', [function guacSe | ||||
|  | ||||
|             }; | ||||
|  | ||||
|             /** | ||||
|              * Returns whether the current user can update the connection having | ||||
|              * the given identifier within the current data source. | ||||
|              * | ||||
|              * @param {String} identifier | ||||
|              *     The identifier of the connection to check. | ||||
|              * | ||||
|              * @return {Boolean} | ||||
|              *     true if the current user can update the connection having the | ||||
|              *     given identifier within the current data source, false | ||||
|              *     otherwise. | ||||
|              */ | ||||
|             $scope.canUpdateConnection = function canUpdateConnection(identifier) { | ||||
|  | ||||
|                 // Abort if permissions have not yet loaded | ||||
|                 if (!$scope.permissions) | ||||
|                     return false; | ||||
|  | ||||
|                 // Can update the connection if adminstrator or have explicit permission | ||||
|                 if (PermissionSet.hasSystemPermission($scope.permissions, PermissionSet.SystemPermissionType.ADMINISTER) | ||||
|                  || PermissionSet.hasConnectionPermission($scope.permissions, PermissionSet.ObjectPermissionType.UPDATE, identifier)) | ||||
|                      return true; | ||||
|  | ||||
|                 // Current data sources does not allow the connection to be updated | ||||
|                 return false; | ||||
|  | ||||
|             }; | ||||
|  | ||||
|             /** | ||||
|              * Returns whether the current user can update the connection group | ||||
|              * having the given identifier within the current data source. | ||||
| @@ -276,6 +330,38 @@ angular.module('settings').directive('guacSettingsConnections', [function guacSe | ||||
|  | ||||
|             }; | ||||
|  | ||||
|             /** | ||||
|              * Adds connection-specific contextual actions to the given array of | ||||
|              * GroupListItems. Each contextual action will be represented by a | ||||
|              * new GroupListItem. | ||||
|              * | ||||
|              * @param {GroupListItem[]} items | ||||
|              *     The array of GroupListItems to which new GroupListItems | ||||
|              *     representing connection-specific contextual actions should | ||||
|              *     be added. | ||||
|              * | ||||
|              * @param {GroupListItem} [parent] | ||||
|              *     The GroupListItem representing the connection which contains | ||||
|              *     the given array of GroupListItems, if known. | ||||
|              */ | ||||
|             var addConnectionActions = function addConnectionActions(items, parent) { | ||||
|  | ||||
|                 // Do nothing if we lack permission to modify the parent at all | ||||
|                 if (parent && !$scope.canUpdateConnection(parent.identifier)) | ||||
|                     return; | ||||
|  | ||||
|                 // Add action for creating a child sharing profile, if the user | ||||
|                 // has permission to do so | ||||
|                 if ($scope.canCreateSharingProfiles()) | ||||
|                     items.push(new GroupListItem({ | ||||
|                         type        : 'new-sharing-profile', | ||||
|                         dataSource  : $scope.dataSource, | ||||
|                         weight      : 1, | ||||
|                         wrappedItem : parent | ||||
|                     })); | ||||
|  | ||||
|             }; | ||||
|  | ||||
|             /** | ||||
|              * Decorates the given GroupListItem, including all descendants, | ||||
|              * adding contextual actions. | ||||
| @@ -291,6 +377,11 @@ angular.module('settings').directive('guacSettingsConnections', [function guacSe | ||||
|                 if (item.type === GroupListItem.Type.CONNECTION_GROUP) | ||||
|                     addConnectionGroupActions(item.children, item); | ||||
|  | ||||
|                 // If the item is a connection, add actions specific to | ||||
|                 // connections | ||||
|                 else if (item.type === GroupListItem.Type.CONNECTION) | ||||
|                     addConnectionActions(item.children, item); | ||||
|  | ||||
|                 // Decorate all children | ||||
|                 angular.forEach(item.children, decorateItem); | ||||
|  | ||||
|   | ||||
| @@ -18,7 +18,8 @@ | ||||
|  */ | ||||
|  | ||||
| .settings.connections .connection-list .new-connection, | ||||
| .settings.connections .connection-list .new-connection-group { | ||||
| .settings.connections .connection-list .new-connection-group, | ||||
| .settings.connections .connection-list .new-sharing-profile { | ||||
|     opacity: 0.5; | ||||
|     font-style: italic; | ||||
| } | ||||
| @@ -28,7 +29,10 @@ | ||||
| .settings.connections .connection-list .new-connection a:visited, | ||||
| .settings.connections .connection-list .new-connection-group a, | ||||
| .settings.connections .connection-list .new-connection-group a:hover, | ||||
| .settings.connections .connection-list .new-connection-group a:visited { | ||||
| .settings.connections .connection-list .new-connection-group a:visited, | ||||
| .settings.connections .connection-list .new-sharing-profile a, | ||||
| .settings.connections .connection-list .new-sharing-profile a:hover, | ||||
| .settings.connections .connection-list .new-sharing-profile a:visited { | ||||
|     text-decoration:none; | ||||
|     color: black; | ||||
| } | ||||
|   | ||||
| @@ -1,4 +1,9 @@ | ||||
| <a ng-href="#/manage/{{item.dataSource}}/connectionGroups/{{item.identifier}}"> | ||||
|  | ||||
|     <!-- Connection group icon --> | ||||
|     <div class="icon type"></div> | ||||
|  | ||||
|     <!-- Connection group name --> | ||||
|     <span class="name">{{item.name}}</span> | ||||
|  | ||||
| </a> | ||||
|   | ||||
| @@ -0,0 +1,3 @@ | ||||
| <a ng-href="#/manage/{{item.dataSource}}/sharingProfiles/?parent={{item.wrappedItem.identifier}}"> | ||||
|     <span class="name">{{'SETTINGS_CONNECTIONS.ACTION_NEW_SHARING_PROFILE' | translate}}</span> | ||||
| </a> | ||||
| @@ -37,9 +37,11 @@ | ||||
|             templates="{ | ||||
|  | ||||
|                 'connection'       : 'app/settings/templates/connection.html', | ||||
|                 'sharing-profile'  : 'app/settings/templates/sharingProfile.html', | ||||
|                 'connection-group' : 'app/settings/templates/connectionGroup.html', | ||||
|  | ||||
|                 'new-connection'       : 'app/settings/templates/newConnection.html', | ||||
|                 'new-sharing-profile'  : 'app/settings/templates/newSharingProfile.html', | ||||
|                 'new-connection-group' : 'app/settings/templates/newConnectionGroup.html' | ||||
|  | ||||
|             }"/> | ||||
|   | ||||
| @@ -0,0 +1,9 @@ | ||||
| <a ng-href="#/manage/{{item.dataSource}}/sharingProfiles/{{item.identifier}}"> | ||||
|  | ||||
|     <!-- Sharing profile icon --> | ||||
|     <div class="icon type"></div> | ||||
|  | ||||
|     <!-- Sharing profile name --> | ||||
|     <span class="name">{{item.name}}</span> | ||||
|  | ||||
| </a> | ||||
		Reference in New Issue
	
	Block a user