mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-10 23:42:36 -07:00
More user management
This commit is contained in:
parent
f7bf2a2fe7
commit
3d2272cd91
3 changed files with 28 additions and 18 deletions
|
@ -25,6 +25,7 @@
|
|||
errorMessage: ""
|
||||
};
|
||||
|
||||
var ReadOnlyPermission = "Read Only User";
|
||||
var open = false;
|
||||
|
||||
// Select a user to populate on the right side
|
||||
|
@ -63,14 +64,12 @@
|
|||
|
||||
// Create a user, do some validation too
|
||||
$scope.addUser = function () {
|
||||
|
||||
if (!$scope.user.username || !$scope.user.password) {
|
||||
$scope.error.error = true;
|
||||
$scope.error.errorMessage = "Please provide a correct username and password";
|
||||
generateNotify($scope.error.errorMessage, 'warning');
|
||||
return;
|
||||
}
|
||||
|
||||
if ($scope.selectedPermissions.length === 0) {
|
||||
$scope.error.error = true;
|
||||
$scope.error.errorMessage = "Please select a permission";
|
||||
|
@ -78,6 +77,16 @@
|
|||
return;
|
||||
}
|
||||
|
||||
var hasReadOnly = $scope.selectedPermissions.indexOf(ReadOnlyPermission) !== -1;
|
||||
if (hasReadOnly) {
|
||||
if ($scope.selectedPermissions.length > 1) {
|
||||
$scope.error.error = true;
|
||||
$scope.error.errorMessage = "Cannot have the " + ReadOnlyPermission + " permission with other permissions.";
|
||||
generateNotify($scope.error.errorMessage, 'danger');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
userManagementService.addUser($scope.user, $scope.selectedPermissions, $scope.selectedFeatures)
|
||||
.then(function (data) {
|
||||
if (data.message) {
|
||||
|
@ -86,17 +95,8 @@
|
|||
} else {
|
||||
$scope.users.push(data.data); // Push the new user into the array to update the DOM
|
||||
$scope.user = {};
|
||||
$scope.selectedPermissions = {}; // Clear the checkboxes
|
||||
$scope.selectedFeatures = {};
|
||||
$scope.features.forEach(function (entry) {
|
||||
entry.selected = false;
|
||||
});
|
||||
$scope.permissions.forEach(function (entry) {
|
||||
entry.selected = false;
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
clearCheckboxes();
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -178,6 +178,17 @@
|
|||
$("#wrapper").toggleClass("toggled");
|
||||
}
|
||||
}
|
||||
|
||||
function clearCheckboxes() {
|
||||
$scope.selectedPermissions = {}; // Clear the checkboxes
|
||||
$scope.selectedFeatures = {};
|
||||
$scope.features.forEach(function (entry) {
|
||||
entry.selected = false;
|
||||
});
|
||||
$scope.permissions.forEach(function (entry) {
|
||||
entry.selected = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function successCallback(message, type) {
|
||||
|
|
|
@ -32,6 +32,7 @@ using Ninject.Modules;
|
|||
using PlexRequests.Core;
|
||||
using PlexRequests.Core.Migration;
|
||||
using PlexRequests.Core.StatusChecker;
|
||||
using PlexRequests.Core.Users;
|
||||
using PlexRequests.Helpers;
|
||||
using PlexRequests.Services.Interfaces;
|
||||
using PlexRequests.Services.Notification;
|
||||
|
@ -61,6 +62,7 @@ namespace PlexRequests.UI.NinjectModules
|
|||
Bind<IStatusChecker>().To<StatusChecker>();
|
||||
|
||||
Bind<ISecurityExtensions>().To<SecurityExtensions>();
|
||||
Bind<IUserHelper>().To<UserHelper>();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -25,9 +25,6 @@
|
|||
@Html.Checkbox(Model.RecentlyAddedNewsletter, "RecentlyAddedNewsletter", "Recently Added Newsletter");
|
||||
@Html.Checkbox(Model.RecentlyAddedNotification, "RecentlyAddedNotification", "Recently Added Notifications");
|
||||
|
||||
|
||||
|
||||
|
||||
<div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue