Blazorise #4
@ -1,7 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace UserService.DatabaseLayer.DataModels
|
namespace UserService.DatabaseLayer.DataModels
|
||||||
@ -9,22 +8,6 @@ namespace UserService.DatabaseLayer.DataModels
|
|||||||
public class OrganizationUnit : Node
|
public class OrganizationUnit : Node
|
||||||
{
|
{
|
||||||
public Member? Manager { get; set; }
|
public Member? Manager { get; set; }
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public override string ToString()
|
|
||||||
{
|
|
||||||
var sb = new StringBuilder();
|
|
||||||
if (Level != 0)
|
|
||||||
{
|
|
||||||
sb.Append("|");
|
|
||||||
}
|
|
||||||
|
|
||||||
sb.Append('-', Level * 4);
|
|
||||||
|
|
||||||
return sb + CommonName;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SecurityGroup : Member
|
public class SecurityGroup : Member
|
||||||
|
17
UserService.DatabaseLayer/Queryable.cs
Normal file
17
UserService.DatabaseLayer/Queryable.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using System.Linq.Expressions;
|
||||||
|
|
||||||
|
// ReSharper disable once CheckNamespace
|
||||||
|
namespace System.Linq
|
||||||
|
{
|
||||||
|
public static class Queryable
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Makes a where filtering, if it is not null.
|
||||||
|
/// </summary>
|
||||||
|
public static IQueryable<TSource> WhereOrDefault<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>>? predicate)
|
||||||
|
{
|
||||||
|
if (source == null) throw new ArgumentNullException(nameof(source));
|
||||||
|
return predicate is null ? source : source.Where(predicate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -22,10 +22,7 @@ namespace UserService.DatabaseLayer.Repository
|
|||||||
public virtual async Task<IReadOnlyList<T>> GetAllAsync(Expression<Func<T, bool>>? predicate = null, CancellationToken token = default)
|
public virtual async Task<IReadOnlyList<T>> GetAllAsync(Expression<Func<T, bool>>? predicate = null, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
await using var db = new UserServiceDbContext();
|
await using var db = new UserServiceDbContext();
|
||||||
|
return await Context(db).Include(x => x.Parent).WhereOrDefault(predicate).ToListAsync(token);
|
||||||
IQueryable<T> queryable = Context(db).Include(x => x.Parent);
|
|
||||||
if(predicate != null) queryable = queryable.Where(predicate);
|
|
||||||
return await queryable.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)
|
||||||
|
@ -0,0 +1,50 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using UserService.DatabaseLayer.DataModels;
|
||||||
|
|
||||||
|
namespace UserService.DatabaseLayer.Repository
|
||||||
|
{
|
||||||
|
public class OrganizationUnitsRepository : BaseRepository<OrganizationUnit>, IOrganizationUnitsRepository
|
||||||
|
{
|
||||||
|
public OrganizationUnitsRepository() : base(x => x.OrganizationUnits)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="GetAllAsync" />
|
||||||
|
public override async Task<IReadOnlyList<OrganizationUnit>> GetAllAsync(
|
||||||
|
Expression<Func<OrganizationUnit, bool>>? predicate = null, CancellationToken token = default)
|
||||||
|
{
|
||||||
|
await using var db = new UserServiceDbContext();
|
||||||
|
var result = new List<OrganizationUnit>();
|
||||||
|
var rootOus = await Context(db)
|
||||||
|
.Include(x => x.Parent)
|
||||||
|
.WhereOrDefault(predicate)
|
||||||
|
.ToListAsync(cancellationToken: token);
|
||||||
|
|
||||||
|
IEnumerable<OrganizationUnit> Rec(Node node)
|
||||||
|
{
|
||||||
|
if (!(node is OrganizationUnit organizationUnit)) yield break;
|
||||||
|
yield return organizationUnit;
|
||||||
|
foreach (var ouChild in rootOus.Where(x => x.ParentId != null && x.ParentId == organizationUnit.Id))
|
||||||
|
{
|
||||||
|
foreach (var unit in Rec(ouChild))
|
||||||
|
{
|
||||||
|
yield return unit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var ou in rootOus.Where(x => x.ParentId is null))
|
||||||
|
{
|
||||||
|
result.AddRange(Rec(ou));
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,121 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Linq.Expressions;
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using UserService.DatabaseLayer.DataModels;
|
|
||||||
|
|
||||||
namespace UserService.DatabaseLayer.Repository
|
|
||||||
{
|
|
||||||
public class OrganizationUnitsRepository : BaseRepository<OrganizationUnit>, IOrganizationUnitsRepository
|
|
||||||
{
|
|
||||||
public OrganizationUnitsRepository() : base(x => x.OrganizationUnits)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public override async Task<IReadOnlyList<OrganizationUnit>> GetAllAsync(CancellationToken token = default)
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
await using var db = new UserServiceDbContext();
|
|
||||||
var result = new List<OrganizationUnit>();
|
|
||||||
var rootOus = await Context(db)
|
|
||||||
.Include(x => x.Parent)
|
|
||||||
.ToListAsync(token);
|
|
||||||
|
|
||||||
IEnumerable<OrganizationUnit> Rec(Node node)
|
|
||||||
{
|
|
||||||
if (!(node is OrganizationUnit organizationUnit)) yield break;
|
|
||||||
yield return organizationUnit;
|
|
||||||
foreach (var ouChild in rootOus.Where(x=>x.ParentId != null && x.ParentId == organizationUnit.Id))
|
|
||||||
{
|
|
||||||
foreach (var unit in Rec(ouChild))
|
|
||||||
{
|
|
||||||
yield return unit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foreach (var ou in rootOus.Where(x=> x.ParentId is null))
|
|
||||||
{
|
|
||||||
result.AddRange(Rec(ou));
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class SecurityGroupsRepository : BaseRepository<SecurityGroup>, ISecurityGroupsRepository
|
|
||||||
{
|
|
||||||
public SecurityGroupsRepository() : base(x=> x.SecurityGroups)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public class UsersRepository : BaseRepository<User>, IUsersRepository
|
|
||||||
{
|
|
||||||
public UsersRepository() : base(x => x.Users)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class NodesRepository : INodesRepository
|
|
||||||
{
|
|
||||||
public NodesRepository()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public static async IAsyncEnumerable<Node> GetNodesAsync([EnumeratorCancellation] CancellationToken token = default)
|
|
||||||
{
|
|
||||||
await using var db = new UserServiceDbContext();
|
|
||||||
await foreach (var note in db.OrganizationUnits.AsAsyncEnumerable().WithCancellation(token))
|
|
||||||
{
|
|
||||||
yield return note;
|
|
||||||
}
|
|
||||||
await foreach (var node in db.SecurityGroups.AsAsyncEnumerable().WithCancellation(token))
|
|
||||||
{
|
|
||||||
yield return node;
|
|
||||||
}
|
|
||||||
|
|
||||||
await foreach (var node in db.Users.AsAsyncEnumerable().WithCancellation(token))
|
|
||||||
{
|
|
||||||
yield return node;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<IReadOnlyList<Node>> GetAllAsync(CancellationToken token = default)
|
|
||||||
{
|
|
||||||
|
|
||||||
var list = new List<Node>();
|
|
||||||
await foreach (var node in GetNodesAsync(token))
|
|
||||||
{
|
|
||||||
list.Add(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task<Node?> GetAsync(Expression<Func<Node, bool>> predicate, CancellationToken token = default)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task AddAsync(Node entity, CancellationToken token = default)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task UpdateAsync(Node entity, CancellationToken token = default)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task DeleteAsync(Node entity, CancellationToken token = default)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,11 @@
|
|||||||
|
using UserService.DatabaseLayer.DataModels;
|
||||||
|
|
||||||
|
namespace UserService.DatabaseLayer.Repository
|
||||||
|
{
|
||||||
|
public class SecurityGroupsRepository : BaseRepository<SecurityGroup>, ISecurityGroupsRepository
|
||||||
|
{
|
||||||
|
public SecurityGroupsRepository() : base(x => x.SecurityGroups)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
UserService.DatabaseLayer/Repository/UsersRepository.cs
Normal file
11
UserService.DatabaseLayer/Repository/UsersRepository.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
using UserService.DatabaseLayer.DataModels;
|
||||||
|
|
||||||
|
namespace UserService.DatabaseLayer.Repository
|
||||||
|
{
|
||||||
|
public class UsersRepository : BaseRepository<User>, IUsersRepository
|
||||||
|
{
|
||||||
|
public UsersRepository() : base(x => x.Users)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,11 +1,9 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Security.Cryptography.X509Certificates;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using UserService.DatabaseLayer.DataModels;
|
using UserService.DatabaseLayer.DataModels;
|
||||||
|
|
||||||
namespace UserService.Test
|
namespace UserService.Test
|
||||||
@ -45,7 +43,6 @@ namespace UserService.Test
|
|||||||
NewMethod(ous, null, 0, ref sb);
|
NewMethod(ous, null, 0, ref sb);
|
||||||
var result = sb.ToString();
|
var result = sb.ToString();
|
||||||
Assert.Pass();
|
Assert.Pass();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void NewMethod(IEnumerable<OrganizationUnit> ous, Node parent, int level, ref StringBuilder sb)
|
private static void NewMethod(IEnumerable<OrganizationUnit> ous, Node parent, int level, ref StringBuilder sb)
|
||||||
|
BIN
UserService.db
BIN
UserService.db
Binary file not shown.
@ -1,5 +1,4 @@
|
|||||||
|
<CascadingAuthenticationState>
|
||||||
<CascadingAuthenticationState>
|
|
||||||
<Router AppAssembly="@typeof(Program).Assembly">
|
<Router AppAssembly="@typeof(Program).Assembly">
|
||||||
<Found Context="routeData">
|
<Found Context="routeData">
|
||||||
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
|
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
|
||||||
|
@ -1,14 +1,6 @@
|
|||||||
@page "/directory"
|
@page "/directory"
|
||||||
@using UserService.DatabaseLayer.Repository
|
|
||||||
@inject IOrganizationUnitsRepository OuRepository
|
|
||||||
@inherits DirectoryBase
|
@inherits DirectoryBase
|
||||||
|
|
||||||
@functions {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
<Row>
|
<Row>
|
||||||
<Column ColumnSize="ColumnSize.Is12">
|
<Column ColumnSize="ColumnSize.Is12">
|
||||||
<h1>TODO</h1>
|
<h1>TODO</h1>
|
||||||
@ -29,12 +21,12 @@ else
|
|||||||
HasChildNodes="@(item => item?.Children?.Any() == true)"
|
HasChildNodes="@(item => item?.Children?.Any() == true)"
|
||||||
@bind-SelectedNode="@SelectedNode">
|
@bind-SelectedNode="@SelectedNode">
|
||||||
<NodeContent>
|
<NodeContent>
|
||||||
<Icon Name="IconName.Folder"/>
|
<Icon Name="IconName.Folder" />
|
||||||
@context?.CommonName
|
@context?.CommonName
|
||||||
</NodeContent> </TreeView>
|
</NodeContent>
|
||||||
|
</TreeView>
|
||||||
</Column>
|
</Column>
|
||||||
<Column ColumnSize="ColumnSize.Is4">
|
<Column ColumnSize="ColumnSize.Is4">
|
||||||
|
|
||||||
</Column>
|
</Column>
|
||||||
</Row>
|
</Row>
|
||||||
|
|
||||||
|
@ -1,65 +0,0 @@
|
|||||||
@page "/organizationUnits"
|
|
||||||
@using UserService.DatabaseLayer.DataModels
|
|
||||||
@inherits OrganizationUnitsBase
|
|
||||||
|
|
||||||
<h1>List of all organization units</h1>
|
|
||||||
|
|
||||||
@if (OrganizationUnits is null)
|
|
||||||
{
|
|
||||||
<p>
|
|
||||||
<em>Loading...</em>
|
|
||||||
</p>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@*<MatTable Items="@OrganizationUnits" class="mat-elevation-z5">
|
|
||||||
<MatTableHeader>
|
|
||||||
<th style="width: 20%">Common Name</th>
|
|
||||||
<th style="width: 20%">Description</th>
|
|
||||||
<th style="width: 20%">Parent</th>
|
|
||||||
<th style="width: auto">Manager</th>
|
|
||||||
<th style="width: auto"> </th>
|
|
||||||
<th style="width: auto"> </th>
|
|
||||||
</MatTableHeader>
|
|
||||||
<MatTableRow>
|
|
||||||
<td>@context.CommonName</td>
|
|
||||||
<td>@context.Description</td>
|
|
||||||
<td>@context.Parent</td>
|
|
||||||
<td>@context.Manager</td>
|
|
||||||
<td>
|
|
||||||
<a href="organizationUnits" @onclick="@(e => Edit(context))">edit</a>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<a href="organizationUnits" @onclick="@(e => Delete(context))">delete</a>
|
|
||||||
</td>
|
|
||||||
</MatTableRow>
|
|
||||||
</MatTable>*@
|
|
||||||
|
|
||||||
<MatButton @onclick="@(e => Edit(new OrganizationUnit()))">Create organization unit</MatButton>
|
|
||||||
}
|
|
||||||
|
|
||||||
@*<MatDialog @bind-IsOpen="@DialogIsOpen">
|
|
||||||
@if (OuToEdit != null)
|
|
||||||
{
|
|
||||||
<MatDialogTitle>@(OuToEdit.Id == 0 ? "New" : "Edit") @OuToEdit.CommonName (@OuToEdit.Id)</MatDialogTitle>
|
|
||||||
<MatDialogContent>
|
|
||||||
<MatTextField Label="Common name" @bind-Value="@OuToEdit.CommonName" ReadOnly="@(OuToEdit.Id != 0)"/>
|
|
||||||
<p/>
|
|
||||||
<MatTextField Label="Description" @bind-Value="@OuToEdit.Description"/>
|
|
||||||
@*<MatTextField Label="Manager" @bind-Value="@OuToEdit.Manager"/>*@
|
|
||||||
@*<p />
|
|
||||||
<MatSelectItem Items="@OrganizationUnits" Label="Parent" @bind-Value="@OuToEdit.Parent" />
|
|
||||||
</MatDialogContent>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<MatDialogTitle>No securityGroup selected</MatDialogTitle>
|
|
||||||
}
|
|
||||||
<MatDialogActions>
|
|
||||||
<MatButton OnClick="@(e => { DialogIsOpen = false; })">No Thanks</MatButton>
|
|
||||||
<MatButton OnClick="@OkClick">OK</MatButton>
|
|
||||||
</MatDialogActions>
|
|
||||||
</MatDialog>*@
|
|
@ -1,41 +0,0 @@
|
|||||||
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 OrganizationUnitsBase : ComponentBase
|
|
||||||
{
|
|
||||||
[Inject] private IOrganizationUnitsRepository OrganizationUnitsRepository { get; set; } = null!;
|
|
||||||
|
|
||||||
protected bool DialogIsOpen { get; set; }
|
|
||||||
protected OrganizationUnit? OuToEdit { get; private set; }
|
|
||||||
|
|
||||||
protected IReadOnlyList<OrganizationUnit>? OrganizationUnits { get; private set; }
|
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
|
||||||
{
|
|
||||||
OrganizationUnits = await OrganizationUnitsRepository.GetAllAsync().ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void Edit(OrganizationUnit organizationUnit)
|
|
||||||
{
|
|
||||||
DialogIsOpen = true;
|
|
||||||
OuToEdit = organizationUnit;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected async Task OkClick()
|
|
||||||
{
|
|
||||||
if (OuToEdit is null) return;
|
|
||||||
await OrganizationUnitsRepository.UpdateAsync(OuToEdit).ConfigureAwait(false);
|
|
||||||
DialogIsOpen = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected async Task Delete(OrganizationUnit organizationUnit)
|
|
||||||
{
|
|
||||||
await OrganizationUnitsRepository.DeleteAsync(organizationUnit).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,59 +1,21 @@
|
|||||||
@page "/securitygroups"
|
@page "/securitygroups"
|
||||||
@using UserService.DatabaseLayer.DataModels
|
@using UserService.DatabaseLayer.DataModels
|
||||||
@using UserService.DatabaseLayer.Repository
|
|
||||||
@inherits SecurityGroupsBase
|
@inherits SecurityGroupsBase
|
||||||
|
|
||||||
<h1>Table of all security groups</h1>
|
<h1>Table of all security groups</h1>
|
||||||
|
|
||||||
@if (SecurityGroups is null)
|
@if (SecurityGroups is null)
|
||||||
{
|
{
|
||||||
<p>
|
<p>
|
||||||
<em>Loading...</em>
|
<em>Loading...</em>
|
||||||
</p>
|
</p>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@*<MatTable Items="@SecurityGroups" class="mat-elevation-z5">
|
<DataGrid TItem="SecurityGroup" Data="@SecurityGroups">
|
||||||
<MatTableHeader>
|
<DataGridCommandColumn TItem="User" />
|
||||||
<th style="width: 30%">Common Name</th>
|
<DataGridColumn TItem="SecurityGroup" Field="@nameof(SecurityGroup.Id)" Caption="#" Sortable="false" />
|
||||||
<th style="width: 20%">Description</th>
|
<DataGridColumn TItem="SecurityGroup" Field="@nameof(SecurityGroup.CommonName)" Caption="CN" Editable="true" />
|
||||||
<th style="width: 20%">E-Mail</th>
|
<DataGridColumn TItem="SecurityGroup" Field="@nameof(SecurityGroup.EMail)" Caption="EMail" Editable="true" />
|
||||||
<th style="width: 20%">Parent</th>
|
</DataGrid>
|
||||||
<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 />
|
|
||||||
<MatSelectItem Items="@OrganizationUnits" Label="Parent" @bind-Value="@SecurityGroupToEdit.Parent"></MatSelectItem>
|
|
||||||
</MatDialogContent>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<MatDialogTitle>No securityGroup selected</MatDialogTitle>
|
|
||||||
}
|
|
||||||
<MatDialogActions>
|
|
||||||
<MatButton OnClick="@(e => { DialogIsOpen = false; })">No Thanks</MatButton>
|
|
||||||
<MatButton OnClick="@OkClick">OK</MatButton>
|
|
||||||
</MatDialogActions>
|
|
||||||
</MatDialog>*@
|
|
@ -12,55 +12,24 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@*<MatTable Items="@Users" class="mat-elevation-z5">
|
<DataGrid TItem="User" Editable="true" EditMode="DataGridEditMode.Inline" Data="@Users" RowInserted="@RowInsertedCallback">
|
||||||
<MatTableHeader>
|
<DataGridCommandColumn TItem="User">
|
||||||
<th style="width: 20%">Common Name</th>
|
<NewCommandTemplate>
|
||||||
<th style="width: 30%">Full name</th>
|
<Button Color="Color.Success" Clicked="@context.Clicked">New</Button>
|
||||||
<th style="width: 20%">Description</th>
|
</NewCommandTemplate>
|
||||||
<th style="width: 20%">E-Mail</th>
|
<EditCommandTemplate>
|
||||||
<th style="width: 20%">Parent</th>
|
<Button Color="Color.Primary" Clicked="@context.Clicked">Edit</Button>
|
||||||
<th style="width: auto">Is active</th>
|
</EditCommandTemplate>
|
||||||
<th style="width: auto"> </th>
|
<DeleteCommandTemplate>
|
||||||
<th style="width: auto"> </th>
|
<Button Color="Color.Danger" Clicked="@context.Clicked">Delete</Button>
|
||||||
</MatTableHeader>
|
</DeleteCommandTemplate>
|
||||||
<MatTableRow>
|
</DataGridCommandColumn>
|
||||||
<td>@context.CommonName</td>
|
<DataGridColumn TItem="User" Field="@nameof(User.Id)" Caption="#" Sortable="false"/>
|
||||||
<td>@context.FullName</td>
|
<DataGridColumn TItem="User" Field="@nameof(User.CommonName)" Caption="CN" CellsEditableOnEditCommand="false" Editable="true"/>
|
||||||
<td>@context.Description</td>
|
<DataGridColumn TItem="User" Field="@nameof(User.FirstName)" Caption="First Name" Editable="true"/>
|
||||||
<td>@context.EMail</td>
|
<DataGridColumn TItem="User" Field="@nameof(User.LastName)" Caption="Last Name" Editable="true"/>
|
||||||
<td>@context.Parent</td>
|
<DataGridColumn TItem="User" Field="@nameof(User.EMail)" Caption="EMail" Editable="true"/>
|
||||||
<td>@context.IsActive</td>
|
<DataGridColumn TItem="User" Field="@nameof(User.Parent)" Caption="Parent" Editable="false"/>
|
||||||
<td><a href="users" @onclick="@(e => EditUser(context))">edit</a></td>
|
<DataGridCheckColumn TItem="User" Field="@nameof(User.IsActive)" Caption="Active" Editable="true"/>
|
||||||
<td><a href="users" @onclick="@(e => DeleteUser(context))">delete</a></td>
|
</DataGrid>
|
||||||
</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)" />
|
|
||||||
<MatSlideToggle Label="Is active" @bind-Value="@UserToEdit.IsActive" />
|
|
||||||
<p />
|
|
||||||
<MatTextField Label="First name" @bind-Value="@UserToEdit.FirstName" />
|
|
||||||
<MatTextField Label="Last name" @bind-Value="@UserToEdit.LastName" />
|
|
||||||
<p />
|
|
||||||
<MatTextField Label="Description" @bind-Value="@UserToEdit.Description" />
|
|
||||||
<MatTextField Label="E-Mail" @bind-Value="@UserToEdit.EMail" />
|
|
||||||
<p />
|
|
||||||
<MatSelectItem Items="@OrganizationUnits" TItem="Node" Label="Parent" @bind-Value="@UserToEdit.Parent" />
|
|
||||||
</MatDialogContent>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<MatDialogTitle>No securityGroup selected</MatDialogTitle>
|
|
||||||
}
|
|
||||||
<MatDialogActions>
|
|
||||||
<MatButton OnClick="@(e => { DialogIsOpen = false; })">No Thanks</MatButton>
|
|
||||||
<MatButton OnClick="@OkClick">OK</MatButton>
|
|
||||||
</MatDialogActions>
|
|
||||||
</MatDialog>*@
|
|
@ -1,6 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using Microsoft.AspNetCore.Components;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Components;
|
using Blazorise.DataGrid;
|
||||||
using UserService.DatabaseLayer.DataModels;
|
using UserService.DatabaseLayer.DataModels;
|
||||||
using UserService.DatabaseLayer.Repository;
|
using UserService.DatabaseLayer.Repository;
|
||||||
|
|
||||||
@ -40,5 +41,12 @@ namespace UserService.Pages
|
|||||||
{
|
{
|
||||||
await UsersRepository.DeleteAsync(user).ConfigureAwait(false);
|
await UsersRepository.DeleteAsync(user).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected async Task RowInsertedCallback(SavedRowItem<User, Dictionary<string, object>> obj)
|
||||||
|
{
|
||||||
|
var user = obj.Item;
|
||||||
|
user.ParentId = -2;
|
||||||
|
await UsersRepository.AddAsync(user);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,18 +9,30 @@
|
|||||||
{
|
{
|
||||||
Brand = new SidebarBrandInfo
|
Brand = new SidebarBrandInfo
|
||||||
{
|
{
|
||||||
Text = "SidebarBrand",
|
Text = "User service",
|
||||||
To = "/"
|
To = "/"
|
||||||
}, Items = new List<SidebarItemInfo>
|
},
|
||||||
|
Items = new List<SidebarItemInfo>
|
||||||
{
|
{
|
||||||
new SidebarItemInfo
|
new SidebarItemInfo
|
||||||
{
|
{
|
||||||
Text = "Directory",
|
Text = "Directory",
|
||||||
Icon = IconName.Folder,
|
Icon = IconName.Folder,
|
||||||
To = "/directory"
|
To = "/directory"
|
||||||
|
},
|
||||||
|
new SidebarItemInfo
|
||||||
|
{
|
||||||
|
Text = "Users",
|
||||||
|
Icon = IconName.Users,
|
||||||
|
To = "/users"
|
||||||
|
},
|
||||||
|
new SidebarItemInfo
|
||||||
|
{
|
||||||
|
Text = "Security groups",
|
||||||
|
Icon = IconName.Book,
|
||||||
|
To = "/securitygroups"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,4 +1,3 @@
|
|||||||
using System.Net.Http;
|
|
||||||
using Blazorise;
|
using Blazorise;
|
||||||
using Blazorise.Bootstrap;
|
using Blazorise.Bootstrap;
|
||||||
using Blazorise.Icons.FontAwesome;
|
using Blazorise.Icons.FontAwesome;
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Blazorise.Bootstrap" Version="0.9.1.2" />
|
<PackageReference Include="Blazorise.Bootstrap" Version="0.9.1.2" />
|
||||||
|
<PackageReference Include="Blazorise.DataGrid" Version="0.9.1.2" />
|
||||||
<PackageReference Include="Blazorise.Icons.FontAwesome" Version="0.9.1.2" />
|
<PackageReference Include="Blazorise.Icons.FontAwesome" Version="0.9.1.2" />
|
||||||
<PackageReference Include="Blazorise.Sidebar" Version="0.9.1.2" />
|
<PackageReference Include="Blazorise.Sidebar" Version="0.9.1.2" />
|
||||||
<PackageReference Include="Blazorise.TreeView" Version="0.9.1.2" />
|
<PackageReference Include="Blazorise.TreeView" Version="0.9.1.2" />
|
||||||
|
@ -10,4 +10,4 @@
|
|||||||
@using Blazorise
|
@using Blazorise
|
||||||
@using Blazorise.Sidebar
|
@using Blazorise.Sidebar
|
||||||
@using Blazorise.TreeView
|
@using Blazorise.TreeView
|
||||||
|
@using Blazorise.DataGrid
|
||||||
|
Loading…
x
Reference in New Issue
Block a user