mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-10 15:11:22 +00:00
GUAC-1406: Add user filtering on settings tab.
This commit is contained in:
@@ -82,7 +82,8 @@ angular.module('manage').controller('manageUserController', ['$scope', '$injecto
|
||||
var selectedDataSource = $routeParams.dataSource;
|
||||
|
||||
/**
|
||||
* The username of the user being edited.
|
||||
* The username of the user being edited. If a new user is
|
||||
* being created, this will not be defined.
|
||||
*
|
||||
* @type String
|
||||
*/
|
||||
@@ -289,6 +290,22 @@ angular.module('manage').controller('manageUserController', ['$scope', '$injecto
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns whether the current user can edit the username of the user being
|
||||
* edited within the given data source.
|
||||
*
|
||||
* @param {String} [dataSource]
|
||||
* The identifier of the data source to check. If omitted, this will
|
||||
* default to the currently-selected data source.
|
||||
*
|
||||
* @returns {Boolean}
|
||||
* true if the current user can edit the username of the user being
|
||||
* edited, false otherwise.
|
||||
*/
|
||||
$scope.canEditUsername = function canEditUsername(dataSource) {
|
||||
return !username;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns whether the current user can save the user being edited within
|
||||
* the given data source. Saving will create or update that user depending
|
||||
@@ -423,31 +440,47 @@ angular.module('manage').controller('manageUserController', ['$scope', '$injecto
|
||||
$scope.attributes = attributes;
|
||||
});
|
||||
|
||||
// Pull user data
|
||||
dataSourceService.apply(userService.getUser, dataSources, username)
|
||||
.then(function usersReceived(users) {
|
||||
// Pull user data and permissions if we are editing an existing user
|
||||
if (username) {
|
||||
|
||||
// Get user for currently-selected data source
|
||||
$scope.users = users;
|
||||
$scope.user = users[selectedDataSource];
|
||||
// Pull user data
|
||||
dataSourceService.apply(userService.getUser, dataSources, username)
|
||||
.then(function usersReceived(users) {
|
||||
|
||||
// Create skeleton user if user does not exist
|
||||
if (!$scope.user)
|
||||
$scope.user = new User({
|
||||
'username' : username
|
||||
});
|
||||
// Get user for currently-selected data source
|
||||
$scope.users = users;
|
||||
$scope.user = users[selectedDataSource];
|
||||
|
||||
});
|
||||
// Create skeleton user if user does not exist
|
||||
if (!$scope.user)
|
||||
$scope.user = new User({
|
||||
'username' : username
|
||||
});
|
||||
|
||||
// Pull user permissions
|
||||
permissionService.getPermissions(selectedDataSource, username).success(function gotPermissions(permissions) {
|
||||
$scope.permissionFlags = PermissionFlagSet.fromPermissionSet(permissions);
|
||||
})
|
||||
});
|
||||
|
||||
// If permissions cannot be retrieved, use empty permissions
|
||||
.error(function permissionRetrievalFailed() {
|
||||
// Pull user permissions
|
||||
permissionService.getPermissions(selectedDataSource, username).success(function gotPermissions(permissions) {
|
||||
$scope.permissionFlags = PermissionFlagSet.fromPermissionSet(permissions);
|
||||
})
|
||||
|
||||
// If permissions cannot be retrieved, use empty permissions
|
||||
.error(function permissionRetrievalFailed() {
|
||||
$scope.permissionFlags = new PermissionFlagSet();
|
||||
});
|
||||
}
|
||||
|
||||
// Use skeleton data if we are creating a new user
|
||||
else {
|
||||
|
||||
// No users exist regardless of data source if there is no username
|
||||
$scope.users = {};
|
||||
|
||||
// Use skeleton user object with no associated permissions
|
||||
$scope.user = new User();
|
||||
$scope.permissionFlags = new PermissionFlagSet();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// Retrieve all connections for which we have ADMINISTER permission
|
||||
dataSourceService.apply(
|
||||
|
@@ -24,10 +24,6 @@
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.manage-user .username.header h2 {
|
||||
text-transform: none;
|
||||
}
|
||||
|
||||
.manage-user .page-tabs .page-list li.read-only a[href],
|
||||
.manage-user .page-tabs .page-list li.unlinked a[href],
|
||||
.manage-user .page-tabs .page-list li.linked a[href] {
|
||||
|
@@ -24,7 +24,7 @@ THE SOFTWARE.
|
||||
|
||||
<!-- User header and data source tabs -->
|
||||
<div class="username header">
|
||||
<h2>{{user.username}}</h2>
|
||||
<h2>{{'MANAGE_USER.SECTION_HEADER_EDIT_USER' | translate}}</h2>
|
||||
<guac-user-menu></guac-user-menu>
|
||||
</div>
|
||||
<div class="page-tabs">
|
||||
@@ -42,6 +42,13 @@ THE SOFTWARE.
|
||||
<!-- User password section -->
|
||||
<div class="section">
|
||||
<table class="properties">
|
||||
<tr>
|
||||
<th>{{'MANAGE_USER.FIELD_HEADER_USERNAME' | translate}}</th>
|
||||
<td>
|
||||
<input ng-show="canEditUsername()" ng-model="user.username" type="text"/>
|
||||
<span ng-hide="canEditUsername()">{{user.username}}</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{{'MANAGE_USER.FIELD_HEADER_PASSWORD' | translate}}</th>
|
||||
<td><input ng-model="user.password" type="password" /></td>
|
||||
|
Reference in New Issue
Block a user