Add initial ghost creation UI
This commit is contained in:
@@ -379,6 +379,39 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal set ghost -->
|
||||
<div class="modal fade" id="setGhostModal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">{{ 'users.setGhostDialog.title' | tr }}</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form name="setGhostForm" role="form" novalidate ng-submit="setGhost.submit()" autocomplete="off">
|
||||
|
||||
<div class="form-group" ng-class="{ 'has-error': setGhost.error }">
|
||||
<label class="control-label" for="setGhostPassword">{{ 'users.setGhost.password' | tr }}</label>
|
||||
<div class="control-label" ng-show="setGhost.error">
|
||||
<small ng-show="setGhost.error">{{ setGhost.error }}</small>
|
||||
</div>
|
||||
<div class="input-group">
|
||||
<input type="text" id="setGhostPassword" class="form-control" name="password" ng-model="setGhost.password" required/>
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-default" id="setGhostClipboardButton" type="button" data-clipboard-target="#setGhostPassword"><i class="fa fa-clipboard"></i></button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<input class="hide" type="submit" ng-disabled="setGhostForm.$invalid || setGhost.busy"/>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">{{ 'main.dialog.cancel' | tr }}</button>
|
||||
<button type="button" class="btn btn-success" ng-click="setGhost.submit()" ng-disabled="setGhostForm.$invalid || setGhost.busy"><i class="fa fa-circle-notch fa-spin" ng-show="setGhost.busy"></i> {{ 'main.dialog.save' | tr }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal external ldap -->
|
||||
<div class="modal fade" id="externalLdapModal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
@@ -553,6 +586,7 @@
|
||||
<button ng-show="isMe(user) && userInfo.role === 'owner' && user.role === 'owner' && !config.features.userRoles" class="btn btn-xs btn-default" ng-click="transferOwnership.show()" uib-tooltip="{{ 'users.users.transferOwnershipTooltip' | tr }}"><i class="fas fa-random"></i></button>
|
||||
<button ng-disabled="!canEdit(user) || isMe(user) || user.source" class="btn btn-xs btn-default" ng-click="invitation.show(user)" uib-tooltip="{{ 'users.users.invitationTooltip' | tr }}"><i class="fas fa-paper-plane"></i></button>
|
||||
<button ng-disabled="!canEdit(user) || isMe(user) || user.source" class="btn btn-xs btn-default" ng-click="passwordReset.show(user)" uib-tooltip="{{ 'users.users.resetPasswordTooltip' | tr }}"><i class="fas fa-key"></i></button>
|
||||
<button ng-show="userInfo.isAtLeastAdmin" class="btn btn-xs btn-default" ng-click="setGhost.show(user)" uib-tooltip="{{ 'users.users.setGhostTooltip' | tr }}"><i class="fas fa-user-secret"></i></button>
|
||||
<button ng-disabled="!canEdit(user)" class="btn btn-xs btn-default" ng-click="useredit.show(user)" uib-tooltip="{{ 'users.users.editUserTooltip' | tr }}"><i class="fa fa-pencil-alt"></i></button>
|
||||
<button ng-disabled="!canEdit(user) || isMe(user)" class="btn btn-xs btn-danger" ng-click="userremove.show(user)" uib-tooltip="{{ 'users.users.removeUserTooltip' | tr }}"><i class="far fa-trash-alt"></i></button>
|
||||
</td>
|
||||
|
||||
@@ -585,6 +585,46 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio
|
||||
}
|
||||
};
|
||||
|
||||
// https://stackoverflow.com/questions/1497481/javascript-password-generator
|
||||
function generatePassword() {
|
||||
var length = 12,
|
||||
charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
|
||||
retVal = "";
|
||||
for (var i = 0, n = charset.length; i < length; ++i) {
|
||||
retVal += charset.charAt(Math.floor(Math.random() * n));
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
$scope.setGhost = {
|
||||
busy: false,
|
||||
error: null,
|
||||
user: null,
|
||||
password: '',
|
||||
|
||||
show: function (user) {
|
||||
$scope.setGhost.busy = false;
|
||||
$scope.setGhost.error = null;
|
||||
$scope.setGhost.user = user;
|
||||
$scope.setGhost.password = generatePassword();
|
||||
|
||||
$('#setGhostModal').modal('show');
|
||||
},
|
||||
|
||||
submit: function () {
|
||||
$scope.setGhost.busy = true;
|
||||
|
||||
Client.setGhost($scope.setGhost.user.id, $scope.setGhost.password, null, function (error) {
|
||||
$scope.setGhost.busy = false;
|
||||
|
||||
if (error) {
|
||||
$scope.setGhost.error = error.message;
|
||||
return console.error(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$scope.directoryConfig = {
|
||||
editableUserProfiles: true,
|
||||
mandatory2FA: false,
|
||||
@@ -903,5 +943,27 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio
|
||||
$timeout(function () { $('#setupLinkButton').tooltip('hide'); }, 2000);
|
||||
});
|
||||
|
||||
var setGhostClipboardButton = new Clipboard('#setGhostClipboardButton');
|
||||
|
||||
setGhostClipboardButton.on('success', function(e) {
|
||||
$('#setGhostClipboardButton').tooltip({
|
||||
title: 'Copied!',
|
||||
trigger: 'manual'
|
||||
}).tooltip('show');
|
||||
|
||||
$timeout(function () { $('#setGhostClipboardButton').tooltip('hide'); }, 2000);
|
||||
|
||||
e.clearSelection();
|
||||
});
|
||||
|
||||
setGhostClipboardButton.on('error', function(/*e*/) {
|
||||
$('#setGhostClipboardButton').tooltip({
|
||||
title: 'Press Ctrl+C to copy',
|
||||
trigger: 'manual'
|
||||
}).tooltip('show');
|
||||
|
||||
$timeout(function () { $('#setGhostClipboardButton').tooltip('hide'); }, 2000);
|
||||
});
|
||||
|
||||
$('.modal-backdrop').remove();
|
||||
}]);
|
||||
|
||||
Reference in New Issue
Block a user