devexpress #2
@ -1,4 +1,4 @@
|
|||||||
#nullable enable
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
@ -11,7 +11,6 @@ namespace UserService.DatabaseLayer.DataModels
|
|||||||
|
|
||||||
public class SecurityGroup : Member
|
public class SecurityGroup : Member
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class User : Member
|
public class User : Member
|
||||||
@ -23,8 +22,6 @@ namespace UserService.DatabaseLayer.DataModels
|
|||||||
public string FullName => $"{FirstName} {LastName}";
|
public string FullName => $"{FirstName} {LastName}";
|
||||||
|
|
||||||
public IEnumerable<UserMember> MemberOf { get; set; } = new List<UserMember>();
|
public IEnumerable<UserMember> MemberOf { get; set; } = new List<UserMember>();
|
||||||
|
|
||||||
public User Clone() => (User)MemberwiseClone();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class UserMember
|
public class UserMember
|
||||||
@ -45,7 +42,7 @@ namespace UserService.DatabaseLayer.DataModels
|
|||||||
public ICollection<UserMember> Members { get; set; } = new List<UserMember>();
|
public ICollection<UserMember> Members { get; set; } = new List<UserMember>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract class Node
|
public abstract class Node : ICloneable
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[Required] public string CommonName { get; set; } = null!;
|
[Required] public string CommonName { get; set; } = null!;
|
||||||
@ -58,5 +55,8 @@ namespace UserService.DatabaseLayer.DataModels
|
|||||||
{
|
{
|
||||||
return $"[{GetType().Name}] {Id:D5} {CommonName}";
|
return $"[{GetType().Name}] {Id:D5} {CommonName}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public virtual object Clone() => MemberwiseClone();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Security.Cryptography.X509Certificates;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
@ -8,7 +10,7 @@ using UserService.DatabaseLayer.DataModels;
|
|||||||
|
|
||||||
namespace UserService.DatabaseLayer.Repository
|
namespace UserService.DatabaseLayer.Repository
|
||||||
{
|
{
|
||||||
public class BaseRepository<T> where T : class
|
public class BaseRepository<T> where T : Node
|
||||||
{
|
{
|
||||||
private readonly Func<UserServiceDbContext, DbSet<T>> _context;
|
private readonly Func<UserServiceDbContext, DbSet<T>> _context;
|
||||||
|
|
||||||
@ -20,7 +22,7 @@ namespace UserService.DatabaseLayer.Repository
|
|||||||
public async Task<IReadOnlyList<T>> GetAllAsync(CancellationToken token = default)
|
public async Task<IReadOnlyList<T>> GetAllAsync(CancellationToken token = default)
|
||||||
{
|
{
|
||||||
await using var db = new UserServiceDbContext();
|
await using var db = new UserServiceDbContext();
|
||||||
return await _context(db).ToListAsync(token);
|
return await _context(db).Include(x => x.Parent).ToListAsync(token);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<T?> GetAsync(Expression<Func<T, bool>> predicate, CancellationToken token = default)
|
public async Task<T?> GetAsync(Expression<Func<T, bool>> predicate, CancellationToken token = default)
|
||||||
|
BIN
UserService.db
BIN
UserService.db
Binary file not shown.
@ -1,65 +0,0 @@
|
|||||||
@page "/counter"
|
|
||||||
@using UserService.DatabaseLayer.DataModels
|
|
||||||
@using UserService.DatabaseLayer.Repository
|
|
||||||
@using System.Collections
|
|
||||||
@inject IOrganizationUnitsRepository OuRepository
|
|
||||||
|
|
||||||
<h1>Tree</h1>
|
|
||||||
|
|
||||||
@if (_organizationUnits == null)
|
|
||||||
{
|
|
||||||
<p>
|
|
||||||
<em>Loading...</em>
|
|
||||||
</p>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<DxFormLayout>
|
|
||||||
<DxFormLayoutItem Caption="Navigation" ColSpanMd="3">
|
|
||||||
<Template>
|
|
||||||
<DxTreeView Data="@_organizationUnits"
|
|
||||||
TextExpression="@(dataItem => ((Node)dataItem).CommonName)" AllowSelectNodes="true" SelectionChanged="@OnSelectionChanged"
|
|
||||||
ChildrenExpression="@(dataItem => GetNodeChildren(dataItem))" >
|
|
||||||
</DxTreeView>
|
|
||||||
|
|
||||||
</Template>
|
|
||||||
</DxFormLayoutItem>
|
|
||||||
|
|
||||||
<DxFormLayoutItem Caption="Selected:" ColSpanMd="9">
|
|
||||||
<Template>
|
|
||||||
@if (_selectedOu != null)
|
|
||||||
{
|
|
||||||
<h1>@_selectedOu.CommonName</h1>
|
|
||||||
}
|
|
||||||
</Template>
|
|
||||||
</DxFormLayoutItem>
|
|
||||||
|
|
||||||
</DxFormLayout>
|
|
||||||
|
|
||||||
}
|
|
||||||
@code {
|
|
||||||
private IReadOnlyList<OrganizationUnit> _organizationUnits;
|
|
||||||
private OrganizationUnit _selectedOu;
|
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
|
||||||
{
|
|
||||||
_organizationUnits = (await OuRepository.GetAllAsync().ConfigureAwait(false)).Where(x=> x.Parent is null).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnSelectionChanged(TreeViewNodeEventArgs args)
|
|
||||||
{
|
|
||||||
_selectedOu = args.NodeInfo.DataItem as OrganizationUnit;
|
|
||||||
}
|
|
||||||
|
|
||||||
private IEnumerable GetNodeChildren(object dataItem)
|
|
||||||
{
|
|
||||||
if (dataItem is OrganizationUnit organizationUnit)
|
|
||||||
{
|
|
||||||
foreach (var organizationUnitChild in organizationUnit.Children)
|
|
||||||
{
|
|
||||||
yield return organizationUnitChild;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
29
UserService/Pages/Directory.razor
Normal file
29
UserService/Pages/Directory.razor
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
@page "/directory"
|
||||||
|
@using UserService.DatabaseLayer.DataModels
|
||||||
|
@using UserService.DatabaseLayer.Repository
|
||||||
|
@inject IOrganizationUnitsRepository OuRepository
|
||||||
|
|
||||||
|
<h1>TODO</h1>
|
||||||
|
|
||||||
|
@if (_organizationUnits == null)
|
||||||
|
{
|
||||||
|
<p>
|
||||||
|
<em>Loading...</em>
|
||||||
|
</p>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
@code {
|
||||||
|
private IReadOnlyList<OrganizationUnit> _organizationUnits;
|
||||||
|
private OrganizationUnit _selectedOu;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
_organizationUnits = (await OuRepository.GetAllAsync().ConfigureAwait(false)).Where(x=> x.Parent is null).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -1,105 +1,8 @@
|
|||||||
@page "/"
|
@page "/"
|
||||||
@using UserService.DatabaseLayer.DataModels
|
|
||||||
@using UserService.DatabaseLayer.Repository
|
|
||||||
@inject IUsersRepository UsersRepository
|
|
||||||
|
|
||||||
|
|
||||||
<h1>User service</h1>
|
<h1>User service</h1>
|
||||||
|
|
||||||
@if (_users == null)
|
|
||||||
{
|
|
||||||
<p>
|
|
||||||
<em>Loading...</em>
|
|
||||||
</p>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<table class="table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Common Name</th>
|
|
||||||
<th>Full name</th>
|
|
||||||
<th>Description</th>
|
|
||||||
<th>E-Mail</th>
|
|
||||||
<th>Is active</th>
|
|
||||||
<th> </th>
|
|
||||||
<th> </th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
@foreach (var user in _users)
|
|
||||||
{
|
|
||||||
<tr>
|
|
||||||
<td>@user.CommonName</td>
|
|
||||||
<td>@user.FullName</td>
|
|
||||||
<td>@user.Description</td>
|
|
||||||
<td>@user.EMail</td>
|
|
||||||
<td>@user.IsActive</td>
|
|
||||||
<td><a href="" @onclick="@(e => EditUser(user))">edit</a></td>
|
|
||||||
<td><a href="" @onclick="@(e => DeleteUser(user))">delete</a></td>
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<MatButton @onclick="@(e => EditUser(new User()))">Create user</MatButton>
|
|
||||||
}
|
|
||||||
|
|
||||||
<MatDialog @bind-IsOpen="@_dialogIsOpen">
|
|
||||||
@if (_userToEdit != null)
|
|
||||||
{
|
|
||||||
<MatDialogTitle>@(_userToEdit.Id == 0 ? "New" : "Edit") @_userToEdit.CommonName (@_userToEdit.Id)</MatDialogTitle>
|
|
||||||
<MatDialogContent>
|
|
||||||
<MatTextField Label="Common name" @bind-Value="@_userToEdit.CommonName" ReadOnly="@(_userToEdit.Id != 0)"></MatTextField>
|
|
||||||
<p />
|
|
||||||
<MatTextField Label="First name" @bind-Value="@_userToEdit.FirstName"></MatTextField>
|
|
||||||
<MatTextField Label="Last name" @bind-Value="@_userToEdit.LastName"></MatTextField>
|
|
||||||
<p />
|
|
||||||
<MatTextField Label="Description" @bind-Value="@_userToEdit.Description"></MatTextField>
|
|
||||||
<p />
|
|
||||||
<MatTextField Label="E-Mail" @bind-Value="@_userToEdit.EMail"></MatTextField>
|
|
||||||
<MatCheckbox Label="Is active" @bind-Value="@_userToEdit.IsActive"></MatCheckbox>
|
|
||||||
</MatDialogContent>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<MatDialogTitle>No securityGroup selected</MatDialogTitle>
|
|
||||||
}
|
|
||||||
<MatDialogActions>
|
|
||||||
<MatButton OnClick="@(e => { _dialogIsOpen = false; })">No Thanks</MatButton>
|
|
||||||
<MatButton OnClick="@OkClick">OK</MatButton>
|
|
||||||
</MatDialogActions>
|
|
||||||
</MatDialog>
|
|
||||||
|
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
bool _dialogIsOpen;
|
|
||||||
User? _userToEdit;
|
|
||||||
|
|
||||||
private IReadOnlyList<User> _users;
|
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
|
||||||
{
|
|
||||||
_users = await UsersRepository.GetAllAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void EditUser(User user)
|
|
||||||
{
|
|
||||||
_dialogIsOpen = true;
|
|
||||||
_userToEdit = user.Clone();
|
|
||||||
}
|
|
||||||
|
|
||||||
async Task OkClick()
|
|
||||||
{
|
|
||||||
await UsersRepository.UpdateAsync(_userToEdit).ConfigureAwait(false);
|
|
||||||
await OnInitializedAsync().ConfigureAwait(false);
|
|
||||||
_dialogIsOpen = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task DeleteUser(User user)
|
|
||||||
{
|
|
||||||
await UsersRepository.DeleteAsync(user).ConfigureAwait(false);
|
|
||||||
await OnInitializedAsync().ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
95
UserService/Pages/SecurityGroups.razor
Normal file
95
UserService/Pages/SecurityGroups.razor
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
@page "/securitygroups"
|
||||||
|
@using UserService.DatabaseLayer.DataModels
|
||||||
|
@using UserService.DatabaseLayer.Repository
|
||||||
|
@inject ISecurityGroupsRepository SecurityGroupsRepository
|
||||||
|
@inject IOrganizationUnitsRepository OrganizationUnits
|
||||||
|
|
||||||
|
|
||||||
|
<h1>Table of all security groups</h1>
|
||||||
|
|
||||||
|
@if (_securityGroups == null)
|
||||||
|
{
|
||||||
|
<p>
|
||||||
|
<em>Loading...</em>
|
||||||
|
</p>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<MatTable Items="@_securityGroups" class="mat-elevation-z5">
|
||||||
|
<MatTableHeader>
|
||||||
|
<th style="width: 30%">Common Name</th>
|
||||||
|
<th style="width: 20%">Description</th>
|
||||||
|
<th style="width: 20%">E-Mail</th>
|
||||||
|
<th style="width: 20%">Parent</th>
|
||||||
|
<th style="width: auto"> </th>
|
||||||
|
<th style="width: auto"> </th>
|
||||||
|
</MatTableHeader>
|
||||||
|
<MatTableRow>
|
||||||
|
<td>@context.CommonName</td>
|
||||||
|
<td>@context.Description</td>
|
||||||
|
<td>@context.EMail</td>
|
||||||
|
<td>@context.Parent</td>
|
||||||
|
<td><a href="securitygroups" @onclick="@(e => EditSecurityGroup(context))">edit</a></td>
|
||||||
|
<td><a href="securitygroups" @onclick="@(e => DeleteSecurityGroup(context))">delete</a></td>
|
||||||
|
|
||||||
|
</MatTableRow>
|
||||||
|
</MatTable>
|
||||||
|
<MatButton @onclick="@(e => EditSecurityGroup(new SecurityGroup()))">Create new group</MatButton>
|
||||||
|
}
|
||||||
|
|
||||||
|
<MatDialog @bind-IsOpen="@_dialogIsOpen">
|
||||||
|
@if (_securityGroupToEdit != null)
|
||||||
|
{
|
||||||
|
<MatDialogTitle>@(_securityGroupToEdit.Id == 0 ? "New" : "Edit") @_securityGroupToEdit.CommonName (@_securityGroupToEdit.Id)</MatDialogTitle>
|
||||||
|
<MatDialogContent>
|
||||||
|
<MatTextField Label="Common name" @bind-Value="@_securityGroupToEdit.CommonName" ReadOnly="@(_securityGroupToEdit.Id != 0)"></MatTextField>
|
||||||
|
<p />
|
||||||
|
<MatTextField Label="Description" @bind-Value="@_securityGroupToEdit.Description"></MatTextField>
|
||||||
|
<MatTextField Label="E-Mail" @bind-Value="@_securityGroupToEdit.EMail"></MatTextField>
|
||||||
|
<p />
|
||||||
|
<MatAutocompleteList Items="@_organizationUnits" TItem="Node" Label="Parent" CustomStringSelector="@(i => i.CommonName)" @bind-Value="@_securityGroupToEdit.Parent"></MatAutocompleteList>
|
||||||
|
</MatDialogContent>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<MatDialogTitle>No securityGroup selected</MatDialogTitle>
|
||||||
|
}
|
||||||
|
<MatDialogActions>
|
||||||
|
<MatButton OnClick="@(e => { _dialogIsOpen = false; })">No Thanks</MatButton>
|
||||||
|
<MatButton OnClick="@OkClick">OK</MatButton>
|
||||||
|
</MatDialogActions>
|
||||||
|
</MatDialog>
|
||||||
|
|
||||||
|
|
||||||
|
@code {
|
||||||
|
bool _dialogIsOpen;
|
||||||
|
SecurityGroup _securityGroupToEdit;
|
||||||
|
|
||||||
|
private IReadOnlyList<SecurityGroup> _securityGroups;
|
||||||
|
private IReadOnlyList<OrganizationUnit> _organizationUnits;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
_securityGroups = await SecurityGroupsRepository.GetAllAsync();
|
||||||
|
_organizationUnits = await OrganizationUnits.GetAllAsync().ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void EditSecurityGroup(SecurityGroup securityGroup)
|
||||||
|
{
|
||||||
|
_dialogIsOpen = true;
|
||||||
|
_securityGroupToEdit = (SecurityGroup)securityGroup.Clone();
|
||||||
|
}
|
||||||
|
|
||||||
|
async Task OkClick()
|
||||||
|
{
|
||||||
|
await SecurityGroupsRepository.UpdateAsync(_securityGroupToEdit).ConfigureAwait(false);
|
||||||
|
await OnInitializedAsync().ConfigureAwait(false);
|
||||||
|
_dialogIsOpen = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task DeleteSecurityGroup(SecurityGroup securityGroup)
|
||||||
|
{
|
||||||
|
await SecurityGroupsRepository.DeleteAsync(securityGroup).ConfigureAwait(false);
|
||||||
|
await OnInitializedAsync().ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
}
|
66
UserService/Pages/Users.razor
Normal file
66
UserService/Pages/Users.razor
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
@page "/users"
|
||||||
|
@using UserService.DatabaseLayer.DataModels
|
||||||
|
@inherits UsersBase
|
||||||
|
|
||||||
|
<h1>List of all users</h1>
|
||||||
|
|
||||||
|
@if (Users == null)
|
||||||
|
{
|
||||||
|
<p>
|
||||||
|
<em>Loading...</em>
|
||||||
|
</p>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<MatTable Items="@Users" class="mat-elevation-z5">
|
||||||
|
<MatTableHeader>
|
||||||
|
<th style="width: 20%">Common Name</th>
|
||||||
|
<th style="width: 30%">Full name</th>
|
||||||
|
<th style="width: 20%">Description</th>
|
||||||
|
<th style="width: 20%">E-Mail</th>
|
||||||
|
<th style="width: 20%">Parent</th>
|
||||||
|
<th style="width: auto">Is active</th>
|
||||||
|
<th style="width: auto"> </th>
|
||||||
|
<th style="width: auto"> </th>
|
||||||
|
</MatTableHeader>
|
||||||
|
<MatTableRow>
|
||||||
|
<td>@context.CommonName</td>
|
||||||
|
<td>@context.FullName</td>
|
||||||
|
<td>@context.Description</td>
|
||||||
|
<td>@context.EMail</td>
|
||||||
|
<td>@context.Parent</td>
|
||||||
|
<td>@context.IsActive</td>
|
||||||
|
<td><a href="users" @onclick="@(e => EditUser(context))">edit</a></td>
|
||||||
|
<td><a href="users" @onclick="@(e => DeleteUser(context))">delete</a></td>
|
||||||
|
</MatTableRow>
|
||||||
|
</MatTable>
|
||||||
|
|
||||||
|
<MatButton @onclick="@(e => EditUser(new User()))">Create user</MatButton>
|
||||||
|
}
|
||||||
|
|
||||||
|
<MatDialog @bind-IsOpen="@DialogIsOpen">
|
||||||
|
@if (UserToEdit != null)
|
||||||
|
{
|
||||||
|
<MatDialogTitle>@(UserToEdit.Id == 0 ? "New" : "Edit") @UserToEdit.CommonName (@UserToEdit.Id)</MatDialogTitle>
|
||||||
|
<MatDialogContent>
|
||||||
|
<MatTextField Label="Common name" @bind-Value="@UserToEdit.CommonName" ReadOnly="@(UserToEdit.Id != 0)"></MatTextField>
|
||||||
|
<MatSlideToggle Label="Is active" @bind-Value="@UserToEdit.IsActive"></MatSlideToggle>
|
||||||
|
<p />
|
||||||
|
<MatTextField Label="First name" @bind-Value="@UserToEdit.FirstName"></MatTextField>
|
||||||
|
<MatTextField Label="Last name" @bind-Value="@UserToEdit.LastName"></MatTextField>
|
||||||
|
<p />
|
||||||
|
<MatTextField Label="Description" @bind-Value="@UserToEdit.Description"></MatTextField>
|
||||||
|
<MatTextField Label="E-Mail" @bind-Value="@UserToEdit.EMail"></MatTextField>
|
||||||
|
<p />
|
||||||
|
<MatAutocompleteList Items="@OrganizationUnits" TItem="Node" Label="Parent" CustomStringSelector="@(i => i.CommonName)" @bind-Value="@UserToEdit.Parent"></MatAutocompleteList>
|
||||||
|
</MatDialogContent>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<MatDialogTitle>No securityGroup selected</MatDialogTitle>
|
||||||
|
}
|
||||||
|
<MatDialogActions>
|
||||||
|
<MatButton OnClick="@(e => { DialogIsOpen = false; })">No Thanks</MatButton>
|
||||||
|
<MatButton OnClick="@OkClick">OK</MatButton>
|
||||||
|
</MatDialogActions>
|
||||||
|
</MatDialog>
|
46
UserService/Pages/Users.razor.cs
Normal file
46
UserService/Pages/Users.razor.cs
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Components;
|
||||||
|
using UserService.DatabaseLayer.DataModels;
|
||||||
|
using UserService.DatabaseLayer.Repository;
|
||||||
|
|
||||||
|
namespace UserService.Pages
|
||||||
|
{
|
||||||
|
public class UsersBase : ComponentBase
|
||||||
|
{
|
||||||
|
[Inject] private IUsersRepository UsersRepository { get; set; } = null!;
|
||||||
|
[Inject] private IOrganizationUnitsRepository OrganizationUnitsRepository { get; set; } = null!;
|
||||||
|
|
||||||
|
protected bool DialogIsOpen { get; set; }
|
||||||
|
protected User? UserToEdit { get; private set; }
|
||||||
|
|
||||||
|
protected IReadOnlyList<User>? Users { get; private set; }
|
||||||
|
protected IReadOnlyList<OrganizationUnit>? OrganizationUnits { get; private set; }
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
Users = await UsersRepository.GetAllAsync();
|
||||||
|
OrganizationUnits = await OrganizationUnitsRepository.GetAllAsync().ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void EditUser(User user)
|
||||||
|
{
|
||||||
|
DialogIsOpen = true;
|
||||||
|
UserToEdit = user;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async Task OkClick()
|
||||||
|
{
|
||||||
|
if (UserToEdit is null) return;
|
||||||
|
await UsersRepository.UpdateAsync(UserToEdit).ConfigureAwait(false);
|
||||||
|
await OnInitializedAsync().ConfigureAwait(false);
|
||||||
|
DialogIsOpen = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async Task DeleteUser(User user)
|
||||||
|
{
|
||||||
|
await UsersRepository.DeleteAsync(user).ConfigureAwait(false);
|
||||||
|
await OnInitializedAsync().ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -16,7 +16,6 @@
|
|||||||
<link href="css/site.css" rel="stylesheet"/>
|
<link href="css/site.css" rel="stylesheet"/>
|
||||||
<script src="_content/MatBlazor/dist/matBlazor.js"></script>
|
<script src="_content/MatBlazor/dist/matBlazor.js"></script>
|
||||||
<link href="_content/MatBlazor/dist/matBlazor.css" rel="stylesheet"/>
|
<link href="_content/MatBlazor/dist/matBlazor.css" rel="stylesheet"/>
|
||||||
<link href="_content/DevExpress.Blazor/dx-blazor.css" rel="stylesheet"/>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<app>
|
<app>
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="@NavMenuCssClass" @onclick="ToggleNavMenu">
|
<div class="@NavMenuCssClass" @onclick="ToggleNavMenu">
|
||||||
<ul class="nav flex-column">
|
<ul class="nav flex-column">
|
||||||
<li class="nav-item px-3">
|
<li class="nav-item px-3">
|
||||||
@ -13,20 +14,30 @@
|
|||||||
</NavLink>
|
</NavLink>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item px-3">
|
<li class="nav-item px-3">
|
||||||
<NavLink class="nav-link" href="counter">
|
<NavLink class="nav-link" href="users">
|
||||||
<span class="oi oi-plus" aria-hidden="true"></span> Counter
|
<span class="oi oi-plus" aria-hidden="true"></span> Users
|
||||||
|
</NavLink>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item px-3">
|
||||||
|
<NavLink class="nav-link" href="securitygroups">
|
||||||
|
<span class="oi oi-plus" aria-hidden="true"></span> Security groups
|
||||||
|
</NavLink>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item px-3">
|
||||||
|
<NavLink class="nav-link" href="directory">
|
||||||
|
<span class="oi oi-plus" aria-hidden="true"></span> Directory
|
||||||
</NavLink>
|
</NavLink>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private bool collapseNavMenu = true;
|
private bool _collapseNavMenu = true;
|
||||||
|
|
||||||
private string NavMenuCssClass => collapseNavMenu ? "collapse" : null;
|
private string NavMenuCssClass => _collapseNavMenu ? "collapse" : null;
|
||||||
|
|
||||||
private void ToggleNavMenu()
|
private void ToggleNavMenu()
|
||||||
{
|
{
|
||||||
collapseNavMenu = !collapseNavMenu;
|
_collapseNavMenu = !_collapseNavMenu;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
@using UserService.DatabaseLayer.DataModels
|
|
||||||
<MatNavSubMenu>
|
|
||||||
<MatNavSubMenuHeader>
|
|
||||||
<MatNavItem AllowSelection="false"><MatIcon Icon="folder"></MatIcon> @OrganizationUnit.CommonName</MatNavItem>
|
|
||||||
</MatNavSubMenuHeader>
|
|
||||||
<MatNavSubMenuList>
|
|
||||||
<MatNavItem Disabled="true" Href="#">Item 6.A</MatNavItem>
|
|
||||||
<MatNavItem>Item 6.B</MatNavItem>
|
|
||||||
<MatNavItem>Item 6.C</MatNavItem>
|
|
||||||
</MatNavSubMenuList>
|
|
||||||
</MatNavSubMenu>
|
|
||||||
@code {
|
|
||||||
[Parameter]
|
|
||||||
public OrganizationUnit OrganizationUnit { get; set; }
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
// Generated by the DevExpress.Blazor package.
|
|
||||||
// To prevent this operation, add the DxExtendStartupHost property to the project and set this property to False.
|
|
||||||
//
|
|
||||||
// UserService.csproj:
|
|
||||||
//
|
|
||||||
// <Project Sdk="Microsoft.NET.Sdk.Web">
|
|
||||||
// <PropertyGroup>
|
|
||||||
// <TargetFramework>netcoreapp3.1</TargetFramework>
|
|
||||||
// <DxExtendStartupHost>False</DxExtendStartupHost>
|
|
||||||
// </PropertyGroup>
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
using System;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.AspNetCore.Hosting;
|
|
||||||
|
|
||||||
[assembly: HostingStartup(typeof(UserService.DevExpressHostingStartup))]
|
|
||||||
|
|
||||||
namespace UserService {
|
|
||||||
public partial class DevExpressHostingStartup : IHostingStartup {
|
|
||||||
void IHostingStartup.Configure(IWebHostBuilder builder) {
|
|
||||||
builder.ConfigureServices((serviceCollection) => {
|
|
||||||
serviceCollection.AddDevExpressBlazor();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,3 +1,4 @@
|
|||||||
|
using System.Net.Http;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
@ -25,7 +26,7 @@ namespace UserService
|
|||||||
services.AddSingleton<IUsersRepository, UsersRepository>();
|
services.AddSingleton<IUsersRepository, UsersRepository>();
|
||||||
services.AddSingleton<ISecurityGroupsRepository, SecurityGroupsRepository>();
|
services.AddSingleton<ISecurityGroupsRepository, SecurityGroupsRepository>();
|
||||||
services.AddSingleton<IOrganizationUnitsRepository, OrganizationUnitsRepository>();
|
services.AddSingleton<IOrganizationUnitsRepository, OrganizationUnitsRepository>();
|
||||||
//services.AddSingleton<INodesRepository, NodesRepository>();
|
services.AddScoped<HttpClient>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="DevExpress.Blazor" Version="20.1.5" />
|
|
||||||
<PackageReference Include="MatBlazor" Version="2.6.2" />
|
<PackageReference Include="MatBlazor" Version="2.6.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
@ -7,5 +7,4 @@
|
|||||||
@using Microsoft.JSInterop
|
@using Microsoft.JSInterop
|
||||||
@using UserService
|
@using UserService
|
||||||
@using UserService.Shared
|
@using UserService.Shared
|
||||||
@using MatBlazor
|
@using MatBlazor
|
||||||
@using DevExpress.Blazor
|
|
Loading…
x
Reference in New Issue
Block a user