Testing devexpress
This commit is contained in:
parent
110663456d
commit
7a8cd13c2d
@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
@ -33,15 +32,8 @@ namespace UserService.DatabaseLayer.Repository
|
||||
|
||||
public class NodesRepository : INodesRepository
|
||||
{
|
||||
private readonly IUsersRepository _users;
|
||||
private readonly ISecurityGroupsRepository _securityGroups;
|
||||
private readonly IOrganizationUnitsRepository _organizationUnits;
|
||||
|
||||
public NodesRepository(IUsersRepository users, ISecurityGroupsRepository securityGroups, IOrganizationUnitsRepository organizationUnits)
|
||||
public NodesRepository()
|
||||
{
|
||||
_users = users;
|
||||
_securityGroups = securityGroups;
|
||||
_organizationUnits = organizationUnits;
|
||||
}
|
||||
|
||||
public static async IAsyncEnumerable<Node> GetNodesAsync([EnumeratorCancellation] CancellationToken token = default)
|
||||
|
27
UserService.Test/Startup.DevExpress.cs
Normal file
27
UserService.Test/Startup.DevExpress.cs
Normal file
@ -0,0 +1,27 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Generated by the DevExpress.Blazor package.
|
||||
// To prevent this operation, add the DxExtendStartupHost property to the project and set this property to False.
|
||||
//
|
||||
// UserService.Test.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.Test.DevExpressHostingStartup))]
|
||||
|
||||
namespace UserService.Test {
|
||||
public partial class DevExpressHostingStartup : IHostingStartup {
|
||||
void IHostingStartup.Configure(IWebHostBuilder builder) {
|
||||
builder.ConfigureServices((serviceCollection) => {
|
||||
serviceCollection.AddDevExpressBlazor();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
BIN
UserService.db
BIN
UserService.db
Binary file not shown.
@ -1,6 +1,7 @@
|
||||
@page "/counter"
|
||||
@using UserService.DatabaseLayer.DataModels
|
||||
@using UserService.DatabaseLayer.Repository
|
||||
@using System.Collections
|
||||
@inject IOrganizationUnitsRepository OuRepository
|
||||
|
||||
<h1>Tree</h1>
|
||||
@ -13,18 +14,52 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
<MatNavMenu>
|
||||
@foreach (var unit in _organizationUnits)
|
||||
{
|
||||
<OrgUnitItem OrganizationUnit="@unit"/>
|
||||
}
|
||||
</MatNavMenu>
|
||||
<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);
|
||||
_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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -8,31 +8,34 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<title>UserService</title>
|
||||
<base href="~/" />
|
||||
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" />
|
||||
<link href="css/site.css" rel="stylesheet" />
|
||||
<base href="~/"/>
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
|
||||
<link href="css/site.css" rel="stylesheet"/>
|
||||
<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>
|
||||
<body>
|
||||
<app>
|
||||
<component type="typeof(App)" render-mode="ServerPrerendered" />
|
||||
</app>
|
||||
<app>
|
||||
<component type="typeof(App)" render-mode="ServerPrerendered"/>
|
||||
</app>
|
||||
|
||||
<div id="blazor-error-ui">
|
||||
<environment include="Staging,Production">
|
||||
An error has occurred. This application may no longer respond until reloaded.
|
||||
</environment>
|
||||
<environment include="Development">
|
||||
An unhandled exception has occurred. See browser dev tools for details.
|
||||
</environment>
|
||||
<a href="" class="reload">Reload</a>
|
||||
<a class="dismiss">🗙</a>
|
||||
</div>
|
||||
|
||||
<script src="_framework/blazor.server.js"></script>
|
||||
<div id="blazor-error-ui">
|
||||
<environment include="Staging,Production">
|
||||
An error has occurred. This application may no longer respond until reloaded.
|
||||
</environment>
|
||||
<environment include="Development">
|
||||
An unhandled exception has occurred. See browser dev tools for details.
|
||||
</environment>
|
||||
<a href="" class="reload">Reload</a>
|
||||
<a class="dismiss">🗙</a>
|
||||
</div>
|
||||
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
|
||||
<script src="_framework/blazor.server.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
@ -1,13 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace UserService
|
||||
{
|
||||
|
27
UserService/Startup.DevExpress.cs
Normal file
27
UserService/Startup.DevExpress.cs
Normal file
@ -0,0 +1,27 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 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,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
@ -6,6 +6,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DevExpress.Blazor" Version="20.1.5" />
|
||||
<PackageReference Include="MatBlazor" Version="2.6.2" />
|
||||
</ItemGroup>
|
||||
|
||||
|
@ -7,4 +7,5 @@
|
||||
@using Microsoft.JSInterop
|
||||
@using UserService
|
||||
@using UserService.Shared
|
||||
@using MatBlazor
|
||||
@using MatBlazor
|
||||
@using DevExpress.Blazor
|
Loading…
x
Reference in New Issue
Block a user