Added very nice DataGrid control
This commit is contained in:
@ -1,5 +1,4 @@
|
||||
|
||||
<CascadingAuthenticationState>
|
||||
<CascadingAuthenticationState>
|
||||
<Router AppAssembly="@typeof(Program).Assembly">
|
||||
<Found Context="routeData">
|
||||
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
|
||||
@ -10,4 +9,4 @@
|
||||
</LayoutView>
|
||||
</NotFound>
|
||||
</Router>
|
||||
</CascadingAuthenticationState>
|
||||
</CascadingAuthenticationState>
|
@ -1,14 +1,6 @@
|
||||
@page "/directory"
|
||||
@using UserService.DatabaseLayer.Repository
|
||||
@inject IOrganizationUnitsRepository OuRepository
|
||||
@inherits DirectoryBase
|
||||
|
||||
@functions {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
<Row>
|
||||
<Column ColumnSize="ColumnSize.Is12">
|
||||
<h1>TODO</h1>
|
||||
@ -29,12 +21,12 @@ else
|
||||
HasChildNodes="@(item => item?.Children?.Any() == true)"
|
||||
@bind-SelectedNode="@SelectedNode">
|
||||
<NodeContent>
|
||||
<Icon Name="IconName.Folder"/>
|
||||
<Icon Name="IconName.Folder" />
|
||||
@context?.CommonName
|
||||
</NodeContent> </TreeView>
|
||||
</NodeContent>
|
||||
</TreeView>
|
||||
</Column>
|
||||
<Column ColumnSize="ColumnSize.Is4">
|
||||
|
||||
</Column>
|
||||
</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"
|
||||
@using UserService.DatabaseLayer.DataModels
|
||||
@using UserService.DatabaseLayer.Repository
|
||||
@inherits SecurityGroupsBase
|
||||
|
||||
<h1>Table of all security groups</h1>
|
||||
|
||||
@if (SecurityGroups is null)
|
||||
{
|
||||
<p>
|
||||
<em>Loading...</em>
|
||||
</p>
|
||||
<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 />
|
||||
<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>*@
|
||||
<DataGrid TItem="SecurityGroup" Data="@SecurityGroups">
|
||||
<DataGridCommandColumn TItem="User" />
|
||||
<DataGridColumn TItem="SecurityGroup" Field="@nameof(SecurityGroup.Id)" Caption="#" Sortable="false" />
|
||||
<DataGridColumn TItem="SecurityGroup" Field="@nameof(SecurityGroup.CommonName)" Caption="CN" Editable="true" />
|
||||
<DataGridColumn TItem="SecurityGroup" Field="@nameof(SecurityGroup.EMail)" Caption="EMail" Editable="true" />
|
||||
</DataGrid>
|
||||
}
|
@ -12,55 +12,24 @@
|
||||
}
|
||||
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)" />
|
||||
<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>*@
|
||||
<DataGrid TItem="User" Editable="true" EditMode="DataGridEditMode.Inline" Data="@Users" RowInserted="@RowInsertedCallback">
|
||||
<DataGridCommandColumn TItem="User">
|
||||
<NewCommandTemplate>
|
||||
<Button Color="Color.Success" Clicked="@context.Clicked">New</Button>
|
||||
</NewCommandTemplate>
|
||||
<EditCommandTemplate>
|
||||
<Button Color="Color.Primary" Clicked="@context.Clicked">Edit</Button>
|
||||
</EditCommandTemplate>
|
||||
<DeleteCommandTemplate>
|
||||
<Button Color="Color.Danger" Clicked="@context.Clicked">Delete</Button>
|
||||
</DeleteCommandTemplate>
|
||||
</DataGridCommandColumn>
|
||||
<DataGridColumn TItem="User" Field="@nameof(User.Id)" Caption="#" Sortable="false"/>
|
||||
<DataGridColumn TItem="User" Field="@nameof(User.CommonName)" Caption="CN" CellsEditableOnEditCommand="false" Editable="true"/>
|
||||
<DataGridColumn TItem="User" Field="@nameof(User.FirstName)" Caption="First Name" Editable="true"/>
|
||||
<DataGridColumn TItem="User" Field="@nameof(User.LastName)" Caption="Last Name" Editable="true"/>
|
||||
<DataGridColumn TItem="User" Field="@nameof(User.EMail)" Caption="EMail" Editable="true"/>
|
||||
<DataGridColumn TItem="User" Field="@nameof(User.Parent)" Caption="Parent" Editable="false"/>
|
||||
<DataGridCheckColumn TItem="User" Field="@nameof(User.IsActive)" Caption="Active" Editable="true"/>
|
||||
</DataGrid>
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Blazorise.DataGrid;
|
||||
using UserService.DatabaseLayer.DataModels;
|
||||
using UserService.DatabaseLayer.Repository;
|
||||
|
||||
@ -40,5 +41,12 @@ namespace UserService.Pages
|
||||
{
|
||||
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
|
||||
{
|
||||
Text = "SidebarBrand",
|
||||
Text = "User service",
|
||||
To = "/"
|
||||
}, Items = new List<SidebarItemInfo>
|
||||
},
|
||||
Items = new List<SidebarItemInfo>
|
||||
{
|
||||
new SidebarItemInfo
|
||||
{
|
||||
Text = "Directory",
|
||||
Icon = IconName.Folder,
|
||||
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.Bootstrap;
|
||||
using Blazorise.Icons.FontAwesome;
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<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.Sidebar" Version="0.9.1.2" />
|
||||
<PackageReference Include="Blazorise.TreeView" Version="0.9.1.2" />
|
||||
|
@ -10,4 +10,4 @@
|
||||
@using Blazorise
|
||||
@using Blazorise.Sidebar
|
||||
@using Blazorise.TreeView
|
||||
|
||||
@using Blazorise.DataGrid
|
||||
|
Reference in New Issue
Block a user