From b03d9ef16e4f7b071dad411589cef4145ee78398 Mon Sep 17 00:00:00 2001 From: "Jamie.Rees" Date: Tue, 29 Nov 2016 08:51:13 +0000 Subject: [PATCH] some small tweaks around #218 Just added the link to the settings and some angular improvements --- .../Users/UserManagementHelper.cs | 8 + .../Permissions/Permissions.cs | 3 + .../userManagementController.js | 30 ++- .../Views/Admin/UserManagementSettings.cshtml | 2 + .../Views/UserManagement/Index.cshtml | 207 ++++++++++-------- 5 files changed, 148 insertions(+), 102 deletions(-) diff --git a/PlexRequests.Core/Users/UserManagementHelper.cs b/PlexRequests.Core/Users/UserManagementHelper.cs index dc4c7b367..19827c79e 100644 --- a/PlexRequests.Core/Users/UserManagementHelper.cs +++ b/PlexRequests.Core/Users/UserManagementHelper.cs @@ -38,6 +38,14 @@ namespace PlexRequests.Core.Users { permission += (int)Permissions.ReportIssue; } + if (settings.UsersCanViewOnlyOwnRequests) + { + permission += (int)Permissions.UsersCanViewOnlyOwnRequests; + } + if (settings.UsersCanViewOnlyOwnIssues) + { + permission += (int)Permissions.UsersCanViewOnlyOwnIssues; + } return permission; diff --git a/PlexRequests.Helpers/Permissions/Permissions.cs b/PlexRequests.Helpers/Permissions/Permissions.cs index 6f6932ea6..74b20992e 100644 --- a/PlexRequests.Helpers/Permissions/Permissions.cs +++ b/PlexRequests.Helpers/Permissions/Permissions.cs @@ -31,6 +31,9 @@ using System.ComponentModel.DataAnnotations; namespace PlexRequests.Helpers.Permissions { [Flags] + //// + //// NOTE if any are added, make sure we change the UserManagementHelper + //// public enum Permissions { [Display(Name = "Access Administration Settings")] diff --git a/PlexRequests.UI/Content/app/userManagement/userManagementController.js b/PlexRequests.UI/Content/app/userManagement/userManagementController.js index a920739d4..e5ab7fd01 100644 --- a/PlexRequests.UI/Content/app/userManagement/userManagementController.js +++ b/PlexRequests.UI/Content/app/userManagement/userManagementController.js @@ -19,6 +19,8 @@ $scope.sortReverse = false; $scope.searchTerm = ""; + $scope.hideColumns = false; + $scope.error = { error: false, @@ -35,10 +37,7 @@ }); $scope.selectedUser = user[0]; - if (!open) { - $("#wrapper").toggleClass("toggled"); - open = true; - } + openSidebar(); } // Get all users in the system @@ -163,6 +162,11 @@ return closeSidebar(); } + $scope.redirectToSettings = function() { + var url = createBaseUrl(getBaseUrl(), '/admin/usermanagementsettings'); + window.location.href = url; + } + function removeUser(id, current) { $scope.users = $scope.users.filter(function (user) { return user.id !== id; @@ -176,6 +180,15 @@ if (open) { open = false; $("#wrapper").toggleClass("toggled"); + $scope.hideColumns = false; + } + } + + function openSidebar() { + if (!open) { + $("#wrapper").toggleClass("toggled"); + open = true; + $scope.hideColumns = true; } } @@ -189,12 +202,17 @@ entry.selected = false; }); } + + + function getBaseUrl() { + return $('#baseUrl').text(); + } + } function successCallback(message, type) { generateNotify(message, type); }; - angular.module('PlexRequests').controller('userManagementController', ["$scope", "userManagementService", "moment", controller]); -} ()); \ No newline at end of file +}()); \ No newline at end of file diff --git a/PlexRequests.UI/Views/Admin/UserManagementSettings.cshtml b/PlexRequests.UI/Views/Admin/UserManagementSettings.cshtml index 2ad015e72..09e3d94be 100644 --- a/PlexRequests.UI/Views/Admin/UserManagementSettings.cshtml +++ b/PlexRequests.UI/Views/Admin/UserManagementSettings.cshtml @@ -18,6 +18,8 @@ @Html.Checkbox(Model.AutoApproveTvShows, "AutoApproveTvShows", "Auto Approve TV Show Requests") @Html.Checkbox(Model.AutoApproveMusic, "AutoApproveMusic", "Auto Approve Music Requests") @Html.Checkbox(Model.ReportIssues, "ReportIssues", "Report Issues") + @Html.Checkbox(Model.UsersCanViewOnlyOwnIssues, "UsersCanViewOnlyOwnIssues", "Users can only view their own issues") + @Html.Checkbox(Model.UsersCanViewOnlyOwnRequests, "UsersCanViewOnlyOwnRequests", "Users can only view their own requests") diff --git a/PlexRequests.UI/Views/UserManagement/Index.cshtml b/PlexRequests.UI/Views/UserManagement/Index.cshtml index cfd0f12ec..fdb6014a3 100644 --- a/PlexRequests.UI/Views/UserManagement/Index.cshtml +++ b/PlexRequests.UI/Views/UserManagement/Index.cshtml @@ -8,9 +8,9 @@ {{spinnerActive}}