Add initial ghost creation UI
This commit is contained in:
@@ -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