User management

pull/511/head
tidusjar 8 years ago
parent e77add75a1
commit d75e309e18

@ -9,6 +9,7 @@
$scope.selectedUser = {}; // User on the right side
$scope.selectedClaims = {};
$scope.sortType = "username";
$scope.sortReverse = false;
$scope.searchTerm = "";
@ -27,20 +28,20 @@
// Get all users in the system
$scope.getUsers = function () {
$scope.users = userManagementService.getUsers()
.then(function (data) {
$scope.users = data.data;
});
.then(function (data) {
$scope.users = data.data;
});
};
// Get the claims and populate the create dropdown
$scope.getClaims = function () {
userManagementService.getClaims()
.then(function (data) {
$scope.claims = data.data;
});
.then(function (data) {
$scope.claims = data.data;
});
}
// Create a user, do some validation too
// Create a user, do some validation too
$scope.addUser = function () {
if (!$scope.user.username || !$scope.user.password) {
@ -50,23 +51,35 @@
return;
}
userManagementService.addUser($scope.user, $scope.selectedClaims).then(function (data) {
if (data.message) {
$scope.error.error = true;
$scope.error.errorMessage = data.message;
} else {
$scope.users.push(data); // Push the new user into the array to update the DOM
$scope.user = {};
$scope.selectedClaims = {};
}
});
userManagementService.addUser($scope.user, $scope.selectedClaims)
.then(function (data) {
if (data.message) {
$scope.error.error = true;
$scope.error.errorMessage = data.message;
} else {
$scope.users.push(data); // Push the new user into the array to update the DOM
$scope.user = {};
$scope.selectedClaims = {};
}
});
};
$scope.$watch('claims|filter:{selected:true}', function (nv) {
$scope.selectedClaims = nv.map(function (claim) {
return claim.name;
});
}, true);
$scope.$watch('claims|filter:{selected:true}',
function (nv) {
$scope.selectedClaims = nv.map(function (claim) {
return claim.name;
});
},
true);
$scope.updateUser = function () {
}
function getBaseUrl() {
return $('#baseUrl').val();
}
// On page load

@ -5,6 +5,21 @@
return opts.inverse(this);
});
Function.prototype.bind = function (parent) {
var f = this;
var args = [];
for (var a = 1; a < arguments.length; a++) {
args[args.length] = arguments[a];
}
var temp = function () {
return f.apply(parent, args);
}
return (temp);
}
$(function () {

@ -8,21 +8,6 @@
return s;
}
Function.prototype.bind = function (parent) {
var f = this;
var args = [];
for (var a = 1; a < arguments.length; a++) {
args[args.length] = arguments[a];
}
var temp = function () {
return f.apply(parent, args);
}
return (temp);
}
$(function() {
$('[data-toggle="tooltip"]').tooltip();
});

@ -206,6 +206,20 @@ namespace PlexRequests.UI.Helpers
return helper.Raw(asset);
}
public static IHtmlString LoadUserManagementAssets(this HtmlHelpers helper)
{
var assetLocation = GetBaseUrl();
var content = GetContentUrl(assetLocation);
var controller = $"<script src=\"{content}/Content/app/userManagement/userManagementController.js?v={Assembly}\" type=\"text/javascript\"></script>";
controller += $"<script src=\"{content}/Content/app/userManagement/userManagementService.js?v={Assembly}\" type=\"text/javascript\"></script>";
return helper.Raw(controller);
}
public static IHtmlString LoadTableAssets(this HtmlHelpers helper)
{
var sb = new StringBuilder();

@ -16,6 +16,7 @@ namespace PlexRequests.UI.Models
public UserType Type { get; set; }
public string EmailAddress { get; set; }
public UserManagementPlexInformation PlexInfo { get; set; }
public string[] ClaimsArray { get; set; }
}
public class UserManagementPlexInformation

@ -63,7 +63,8 @@ namespace PlexRequests.UI.Modules
Claims = claimsString,
Username = user.UserName,
Type = UserType.LocalUser,
EmailAddress = userProps.EmailAddress
EmailAddress = userProps.EmailAddress,
ClaimsArray = claims
});
}

@ -50,6 +50,7 @@ namespace PlexRequests.UI.NinjectModules
Bind<ICustomUserMapper>().To<UserMapper>();
Bind<INotificationService>().To<NotificationService>().InSingletonScope();
Bind<INotificationEngine>().To<NotificationEngine>();
}
}
}

@ -1,8 +1,7 @@
@using PlexRequests.UI.Helpers
@inherits PlexRequests.UI.Helpers.AngularViewBase
<script src="~/Content/app/userManagement/userManagementController.js"></script>
<script src="~/Content/app/userManagement/userManagementService.js"></script>
@Html.LoadUserManagementAssets()
<div ng-controller="userManagementController" ng-init="init()">
<br />
@ -110,9 +109,27 @@
<div>
<strong>User Type: </strong><span ng-bind="selectedUser.type === 1 ? 'Local User' : 'Plex User'"></span>
</div>
</div>
<br/>
<br/>
<div ng-show="selectedUser.type === 1">
<!--Edit-->
<strong>Modify Roles:</strong>
<!--Load all claims-->
<div class="checkbox" ng-repeat="claim in claims">
<input id="claimCheckboxEdit_{{$id}}" class="checkbox-custom" name="selectedClaims[]" ng-checked="@*//TODO: Need to figure our how to preselect them*@" ng-model="claim.selected" type="checkbox" value="claim" />
<label for="claimCheckboxEdit_{{$id}}">{{claim.name}}</label>
</div>
<button ng-click="updateUser()" class="btn btn-primary-outline">Update</button>
</div>
</div> <!-- End of user side menu -->
</div>
Loading…
Cancel
Save