mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-10 15:32:37 -07:00
small changes around the user management
This commit is contained in:
parent
c0641460f6
commit
ffe6bc41ac
6 changed files with 131 additions and 118 deletions
|
@ -1,9 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace PlexRequests.Api.Models.Plex
|
||||
{
|
||||
|
|
|
@ -54,7 +54,7 @@ namespace PlexRequests.Api.Models.Plex
|
|||
[XmlElement(ElementName = "Server")]
|
||||
public Server Server { get; set; }
|
||||
[XmlAttribute(AttributeName = "id")]
|
||||
public string Id { get; set; }
|
||||
public int Id { get; set; }
|
||||
[XmlAttribute(AttributeName = "title")]
|
||||
public string Title { get; set; }
|
||||
[XmlAttribute(AttributeName = "username")]
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
var controller = function ($scope, userManagementService) {
|
||||
|
||||
$scope.user = {}; // The local user to create
|
||||
$scope.user = {}; // The local user
|
||||
$scope.users = []; // list of users
|
||||
|
||||
$scope.error = false;
|
||||
|
@ -16,9 +16,6 @@
|
|||
};
|
||||
|
||||
$scope.addUser = function () {
|
||||
if ($scope.users.length === 0) {
|
||||
$scope.getUsers();
|
||||
}
|
||||
userManagementService.addUser($scope.user).then(function (data) {
|
||||
if (data.message) {
|
||||
$scope.error = true;
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
var userManagementService = function ($http) {
|
||||
|
||||
$http.defaults.headers.common['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8'; // Set default headers
|
||||
|
||||
var getUsers = function () {
|
||||
return $http.get('/usermanagement/users');
|
||||
};
|
||||
|
@ -11,10 +13,7 @@
|
|||
return $http({
|
||||
url: '/usermanagement/createuser',
|
||||
method: "POST",
|
||||
data: $.param(user),
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
|
||||
}
|
||||
data: $.param(user)
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
@ -29,6 +30,8 @@ namespace PlexRequests.UI.Modules
|
|||
|
||||
Get["/users", true] = async (x, ct) => await LoadUsers();
|
||||
Post["/createuser"] = x => CreateUser(Request.Form["userName"].ToString(), Request.Form["password"].ToString());
|
||||
Get["/local/{id}"] = x => LocalDetails((Guid)x.id);
|
||||
Get["/plex/{id}", true] = async (x,ct) => await PlexDetails((int)x.id);
|
||||
}
|
||||
|
||||
private ICustomUserMapper UserMapper { get; }
|
||||
|
@ -72,7 +75,7 @@ namespace PlexRequests.UI.Modules
|
|||
{
|
||||
Username = u.Username,
|
||||
Type = UserType.PlexUser,
|
||||
//Alias =
|
||||
Id = u.Id,
|
||||
Claims = "Requestor",
|
||||
EmailAddress = u.Email
|
||||
});
|
||||
|
@ -99,6 +102,36 @@ namespace PlexRequests.UI.Modules
|
|||
|
||||
return Response.AsJson(new JsonResponseModel { Result = false, Message = "Could not save user" });
|
||||
}
|
||||
|
||||
private Response LocalDetails(Guid id)
|
||||
{
|
||||
var localUser = UserMapper.GetUser(id);
|
||||
if (localUser != null)
|
||||
{
|
||||
return Response.AsJson(localUser);
|
||||
}
|
||||
|
||||
return Nancy.Response.NoBody;
|
||||
}
|
||||
|
||||
private async Task<Response> PlexDetails(int id)
|
||||
{
|
||||
var authSettings = await AuthSettings.GetSettingsAsync();
|
||||
if (!string.IsNullOrEmpty(authSettings.PlexAuthToken))
|
||||
{
|
||||
//Get Plex Users
|
||||
var plexUsers = PlexApi.GetUsers(authSettings.PlexAuthToken);
|
||||
|
||||
var selectedUser = plexUsers.User?.FirstOrDefault(x => x.Id == id);
|
||||
if (selectedUser != null)
|
||||
{
|
||||
return Response.AsJson(selectedUser);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return Nancy.Response.NoBody;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,18 +1,7 @@
|
|||
@using PlexRequests.UI.Helpers
|
||||
@inherits PlexRequests.UI.Helpers.AngularViewBase
|
||||
|
||||
@inherits PlexRequests.UI.Helpers.AngularViewBase
|
||||
|
||||
@Html.LoadTableAssets()
|
||||
@{
|
||||
var baseUrl = Html.GetBaseUrl().ToHtmlString();
|
||||
var url = string.Empty;
|
||||
if (!string.IsNullOrEmpty(baseUrl))
|
||||
{
|
||||
url = "/" + baseUrl;
|
||||
}
|
||||
}
|
||||
<script src="/Content/app/controllers/userManagement/userManagementController.js"></script>
|
||||
<script src="/Content/app/services/userManagement/userManagementService.js"></script>
|
||||
<script src="~/Content/app/controllers/userManagement/userManagementController.js"></script>
|
||||
<script src="~/Content/app/services/userManagement/userManagementService.js"></script>
|
||||
<div ng-controller="userManagementController" ng-init="getUsers()">
|
||||
|
||||
<br>
|
||||
|
@ -24,7 +13,7 @@
|
|||
<th>Id</th>
|
||||
<th>Username</th>
|
||||
<th>Email</th>
|
||||
<th>User T</th>
|
||||
<th>User Type</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue