Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blazor UI extensions #6647

Merged
merged 85 commits into from
Mar 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
98c1746
UI extensions initial implementation.
ilkayilknur Dec 10, 2020
3a77152
abp datagrid implementation.
ilkayilknur Dec 10, 2020
f760b48
AbpDataGrid implementation.
ilkayilknur Dec 11, 2020
e63080a
implement entity action and table column extensibility in identity mo…
ilkayilknur Dec 11, 2020
77381e8
page toolbar implementation
ilkayilknur Dec 11, 2020
06bfd14
implement page toolbar in identity module
ilkayilknur Dec 11, 2020
b57ccff
remove setters
ilkayilknur Dec 11, 2020
4699927
bundling improvements.
ilkayilknur Dec 14, 2020
5f2a238
add mising file.
ilkayilknur Dec 14, 2020
2801e1b
add abp cli options to the appsettings file.
ilkayilknur Dec 14, 2020
b797527
add comments
ilkayilknur Dec 14, 2020
efd2e05
handle json comments and exception improvement.
ilkayilknur Dec 14, 2020
6386fe4
Merge branch 'dev' into ui-extensions-blazor
ilkayilknur Dec 15, 2020
89541d0
Merge branch 'dev' into ui-extensions-blazor
ilkayilknur Dec 22, 2020
2b58e3a
remove unnecessary item group.
ilkayilknur Dec 22, 2020
1936389
make constructor private to enforce using the Instance
ilkayilknur Dec 22, 2020
b704cac
rename AbpDataGrid to AbpExtensibleDataGrid
ilkayilknur Dec 22, 2020
9591c23
refactor usages.
ilkayilknur Dec 24, 2020
7725e62
Merge branch 'dev' into ui-extensions-blazor
hikalkan Jan 11, 2021
a407012
Update RoleManagement.razor.cs
hikalkan Jan 11, 2021
c8ebda3
custom component support for table columns
ilkayilknur Jan 12, 2021
a32304f
remove semicolon
ilkayilknur Jan 13, 2021
1969364
make data field name const
ilkayilknur Jan 13, 2021
fbafe73
remove render usage inside table column
ilkayilknur Jan 13, 2021
400cbd5
Merge branch 'dev' into blazor-module-extensions
ilkayilknur Jan 15, 2021
89c69dc
blazor module extensions initial implementation.
ilkayilknur Jan 19, 2021
82aef9d
remove IEquatable implementation.
ilkayilknur Jan 22, 2021
9b01d7a
refactoring
ilkayilknur Jan 22, 2021
f2669db
add extension property support to the data grid.
ilkayilknur Jan 22, 2021
a06fb47
show icon when displaying boolean properties.
ilkayilknur Jan 26, 2021
d4c5640
remove unused code
ilkayilknur Jan 26, 2021
17b4bac
introduce new components for other data types
ilkayilknur Jan 26, 2021
e9a4f12
remove unnecessary code
ilkayilknur Jan 27, 2021
b79d88e
lookup property HttpClient implementation
ilkayilknur Jan 29, 2021
3fecd0c
Merge branch 'dev' into ui-extensions-blazor
ilkayilknur Feb 2, 2021
d11e253
Merge branch 'ui-extensions-blazor' of https://github.com/abpframewor…
ilkayilknur Feb 2, 2021
ebd97f6
add missing reference and update bundles.
ilkayilknur Feb 2, 2021
fe203bb
fix item loading issue.
ilkayilknur Feb 3, 2021
03fe7c0
initial value problem fixed.
ilkayilknur Feb 4, 2021
f21ba0a
add datetime-local support and fix listing.
ilkayilknur Feb 4, 2021
a031937
add custom converter support to the table column and use it to displa…
ilkayilknur Feb 9, 2021
2607053
initial value setting fix.
ilkayilknur Feb 10, 2021
1da3b65
canbenull attribute has been added.
ilkayilknur Feb 10, 2021
04d6fa9
remove unused code
ilkayilknur Feb 10, 2021
8f90168
Merge pull request #7686 from abpframework/blazor-module-extensions
hikalkan Feb 15, 2021
a3cfde8
Merge branch 'dev' into ui-extensions-blazor
hikalkan Feb 15, 2021
758db7f
Fix URL: Module-Entity-Extensions
hikalkan Feb 15, 2021
c91c35b
Implement blazor UI extensions for UserManagement
hikalkan Feb 15, 2021
b2038c6
Do not validate extra props on blazor UI
hikalkan Feb 15, 2021
bccc474
do not validate lookup property on client side
ilkayilknur Feb 15, 2021
cc58ee9
Merge branch 'ui-extensions-blazor' of https://github.com/abpframewor…
ilkayilknur Feb 15, 2021
c586442
Added default values to summaries.
hikalkan Feb 15, 2021
599dccd
Merge branch 'ui-extensions-blazor' of https://github.com/abpframewor…
ilkayilknur Mar 2, 2021
e8bb417
Merge branch 'dev' into ui-extensions-blazor
ilkayilknur Mar 2, 2021
1cc9f2c
Remove BlazoriseUI.PageHeader
ilkayilknur Mar 2, 2021
160533f
UI extension code updates.
ilkayilknur Mar 2, 2021
f022cfb
Implement Blazor UI and Module Extensions
ilkayilknur Mar 2, 2021
c520807
add icon and color options for entity actions
ilkayilknur Mar 4, 2021
7076689
current page parameter has been added.
ilkayilknur Mar 8, 2021
71f0759
use current page parameter on AbpExtensibleDataGrids.
ilkayilknur Mar 8, 2021
175bb06
breadcrumbitem removed.
ilkayilknur Mar 9, 2021
2ceeeff
visible parameter has been added.
ilkayilknur Mar 9, 2021
0e7c6e0
Merge branch 'dev' into ui-extensions-blazor
ilkayilknur Mar 9, 2021
ccd8b9b
Merge branch 'dev' into ui-extensions-blazor
ilkayilknur Mar 9, 2021
7ea10a2
Merge branch 'dev' into ui-extensions-blazor
ilkayilknur Mar 10, 2021
fb5e94b
put bundle parameters inside bundle context.
ilkayilknur Dec 16, 2020
150e285
Update MyProjectNameBundleContributor.
maliming Dec 17, 2020
419a642
Merge branch 'dev' into ui-extensions-blazor
ilkayilknur Mar 11, 2021
fe1558a
place each toolbar item in a new column
ilkayilknur Mar 11, 2021
68eecc7
Improve visible usage to avoid NRE
ilkayilknur Mar 11, 2021
5e60fa5
visibility fix.
ilkayilknur Mar 15, 2021
e33afe8
display dropdown toggle as block
ilkayilknur Mar 15, 2021
014c4ae
Merge branch 'dev' into ui-extensions-blazor
ilkayilknur Mar 15, 2021
1be0836
set currentpage default value to match with blazorise datagrid
ilkayilknur Mar 16, 2021
6445629
Merge branch 'dev' into ui-extensions-blazor
ilkayilknur Mar 17, 2021
66448fd
Move entity actions and table columns to the Volo.Abp.AspNetCore.Comp…
ilkayilknur Mar 18, 2021
b769d84
move page toolbars and header to the Volo.Abp.AspNetCore.Components.W…
ilkayilknur Mar 18, 2021
13099f7
Remove RequiredPolicy from entity actions and use Visible property.
ilkayilknur Mar 19, 2021
7660c8b
Merge branch 'dev' into ui-extensions-blazor
ilkayilknur Mar 19, 2021
b4c4d75
Merge branch 'dev' into ui-extensions-blazor
ilkayilknur Mar 22, 2021
51c74c4
add Http.Client and Components.Web dependencies.
ilkayilknur Mar 23, 2021
6598c37
lookup api request service implementation
ilkayilknur Mar 23, 2021
6c3baed
add lookup implementation when blazor server is not tiered
ilkayilknur Mar 23, 2021
4f1d53f
Merge branch 'dev' into ui-extensions-blazor
ilkayilknur Mar 23, 2021
d76b7a6
change page toolbar call order.
ilkayilknur Mar 23, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Volo.Abp.AspNetCore.Components.Web\Volo.Abp.AspNetCore.Components.Web.csproj" />
<ProjectReference Include="..\Volo.Abp.Http.Client\Volo.Abp.Http.Client.csproj" />
<ProjectReference Include="..\Volo.Abp.AspNetCore.SignalR\Volo.Abp.AspNetCore.SignalR.csproj" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders;
using Volo.Abp.AspNetCore.Auditing;
using Volo.Abp.AspNetCore.Components.Web;
using Volo.Abp.AspNetCore.SignalR;
using Volo.Abp.AspNetCore.Uow;
using Volo.Abp.Http.Client;
using Volo.Abp.Modularity;

namespace Volo.Abp.AspNetCore.Components.Server
{
[DependsOn(
typeof(AbpHttpClientModule),
typeof(AbpAspNetCoreComponentsWebModule),
typeof(AbpAspNetCoreSignalRModule)
)]
public class AbpAspNetCoreComponentsServerModule : AbpModule
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
using System;
using System.Globalization;
using System.Linq.Dynamic.Core;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Options;
using Microsoft.Extensions.Primitives;
using Volo.Abp.AspNetCore.Components.Web.Extensibility;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Http.Client;
using Volo.Abp.Http.Client.Authentication;
using Volo.Abp.MultiTenancy;

namespace Volo.Abp.AspNetCore.Components.Server.Extensibility
{
public class BlazorServerLookupApiRequestService : ILookupApiRequestService, ITransientDependency
{
public IHttpClientFactory HttpClientFactory { get; }
public IRemoteServiceHttpClientAuthenticator HttpClientAuthenticator { get; }

public AbpRemoteServiceOptions RemoteServiceOptions { get; }

public ICurrentTenant CurrentTenant { get; }
public IHttpContextAccessor HttpContextAccessor { get; }
public NavigationManager NavigationManager { get; }

public BlazorServerLookupApiRequestService(IHttpClientFactory httpClientFactory,
IRemoteServiceHttpClientAuthenticator httpClientAuthenticator,
ICurrentTenant currentTenant,
IOptions<AbpRemoteServiceOptions> remoteServiceOptions,
IHttpContextAccessor httpContextAccessor,
NavigationManager navigationManager)
{
HttpClientFactory = httpClientFactory;
HttpClientAuthenticator = httpClientAuthenticator;
RemoteServiceOptions = remoteServiceOptions.Value;
CurrentTenant = currentTenant;
HttpContextAccessor = httpContextAccessor;
NavigationManager = navigationManager;
}

public async Task<string> SendAsync(string url)
{
var client = HttpClientFactory.CreateClient();
var requestMessage = new HttpRequestMessage(HttpMethod.Get, url);

var uri = new Uri(url, UriKind.RelativeOrAbsolute);
if (!uri.IsAbsoluteUri)
{
var baseUrl = string.Empty;
try
{
//Blazor tiered -- mode
var remoteServiceConfig = RemoteServiceOptions.RemoteServices.GetConfigurationOrDefault("Default");
baseUrl = remoteServiceConfig.BaseUrl;
client.BaseAddress = new Uri(baseUrl);
AddHeaders(requestMessage);
await HttpClientAuthenticator.Authenticate(new RemoteServiceHttpClientAuthenticateContext(client,
requestMessage, new RemoteServiceConfiguration(baseUrl), string.Empty));
}
catch (AbpException) // Blazor-Server mode.
{
baseUrl = NavigationManager.BaseUri;
client.BaseAddress = new Uri(baseUrl);
foreach (var header in HttpContextAccessor.HttpContext.Request.Headers)
{
requestMessage.Headers.Add(header.Key, header.Value.ToArray());
}
}
}

var response = await client.SendAsync(requestMessage);
return await response.Content.ReadAsStringAsync();
}

protected virtual void AddHeaders(HttpRequestMessage requestMessage)
{
if (CurrentTenant.Id.HasValue)
{
requestMessage.Headers.Add(TenantResolverConsts.DefaultTenantKey, CurrentTenant.Id.Value.ToString());
}

var currentCulture = CultureInfo.CurrentUICulture.Name ?? CultureInfo.CurrentCulture.Name;
if (!currentCulture.IsNullOrEmpty())
{
requestMessage.Headers.AcceptLanguage.Add(new(currentCulture));
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<Row Class="entry-row">
@using Blazorise
<Row Class="entry-row">
<Column ColumnSize="ColumnSize.IsAuto">
<h1 class="content-header-title">@Title</h1>
</Column>
Expand Down Expand Up @@ -31,7 +32,12 @@
}
<Column>
<Row Class="justify-content-end mx-n1">
@ChildContent
@foreach (var toolbarItemRender in ToolbarItemRenders)
{
<Column ColumnSize="ColumnSize.IsAuto" Class="px-1 pt-2">
@toolbarItemRender
</Column>
}
</Row>
</Column>
</Row>
</Row>
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
using System;
using Microsoft.AspNetCore.Components;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.AspNetCore.Components.Web.Theming.PageToolbars;
using Volo.Abp.BlazoriseUI;

namespace Volo.Abp.AspNetCore.Components.Web.Theming.Layout
{
public partial class PageHeader : ComponentBase
{
protected List<RenderFragment> ToolbarItemRenders { get; set; }

public IPageToolbarManager PageToolbarManager { get; set; }

[Parameter]
public string Title { get; set; }

[Parameter]
public bool BreadcrumbShowHome { get; set; } = true;

[Parameter]
public bool BreadcrumbShowCurrent { get; set; } = true;

[Parameter]
public RenderFragment ChildContent { get; set; }

[Parameter]
public List<BreadcrumbItem> BreadcrumbItems { get; set; }

[Parameter]
public PageToolbar Toolbar { get; set; }

[Parameter]
public string PageName { get; set; }

public PageHeader()
{
BreadcrumbItems = new List<BreadcrumbItem>();
ToolbarItemRenders = new List<RenderFragment>();
}

protected override async Task OnParametersSetAsync()
{
await base.OnParametersSetAsync();
if (Toolbar!=null)
{
Console.WriteLine("Toolbar is not null");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove Console.WriteLine

var toolbarItems = await PageToolbarManager.GetItemsAsync(Toolbar);
Console.WriteLine($"Toolbar item count:{toolbarItems.Length}");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove Console.WriteLine. If you want, you can write debug logs.

ToolbarItemRenders.Clear();

foreach (var item in toolbarItems)
{
var sequence = 0;
ToolbarItemRenders.Add(builder =>
{
builder.OpenComponent(sequence, item.ComponentType);
if (item.Arguments != null)
{
foreach (var argument in item.Arguments)
{
sequence++;
builder.AddAttribute(sequence, argument.Key, argument.Value);
}
}
builder.CloseComponent();
});
}
}
}

protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Threading.Tasks;

namespace Volo.Abp.AspNetCore.Components.Web.Theming.PageToolbars
{
public interface IPageToolbarContributor
{
Task ContributeAsync(PageToolbarContributionContext context);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Threading.Tasks;

namespace Volo.Abp.AspNetCore.Components.Web.Theming.PageToolbars
{
public interface IPageToolbarManager
{
Task<PageToolbarItem[]> GetItemsAsync(PageToolbar toolbar);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace Volo.Abp.AspNetCore.Components.Web.Theming.PageToolbars
{
public class PageToolbar
{
public PageToolbarContributorList Contributors { get; set; }

public PageToolbar()
{
Contributors = new PageToolbarContributorList();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using JetBrains.Annotations;
using System;

namespace Volo.Abp.AspNetCore.Components.Web.Theming.PageToolbars
{
public class PageToolbarContributionContext
{
[NotNull]
public IServiceProvider ServiceProvider { get; }

[NotNull]
public PageToolbarItemList Items { get; }

public PageToolbarContributionContext(
[NotNull] IServiceProvider serviceProvider)
{
ServiceProvider = Check.NotNull(serviceProvider, nameof(serviceProvider));
Items = new PageToolbarItemList();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Threading.Tasks;

namespace Volo.Abp.AspNetCore.Components.Web.Theming.PageToolbars
{
public abstract class PageToolbarContributor : IPageToolbarContributor
{
public abstract Task ContributeAsync(PageToolbarContributionContext context);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using System.Collections.Generic;

namespace Volo.Abp.AspNetCore.Components.Web.Theming.PageToolbars
{
public class PageToolbarContributorList : List<IPageToolbarContributor>
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Collections.Generic;

namespace Volo.Abp.AspNetCore.Components.Web.Theming.PageToolbars
{
public class PageToolbarDictionary : Dictionary<string, PageToolbar>
{

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
using Blazorise;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.BlazoriseUI.Components;
using Volo.Abp.Localization;

namespace Volo.Abp.AspNetCore.Components.Web.Theming.PageToolbars
{
public static class PageToolbarExtensions
{
public static PageToolbar AddComponent<TComponent>(
this PageToolbar toolbar,
Dictionary<string, object> arguments = null,
int order = 0,
string requiredPolicyName = null)
{
return toolbar.AddComponent(
typeof(TComponent),
arguments,
order,
requiredPolicyName
);
}

public static PageToolbar AddComponent(
this PageToolbar toolbar,
Type componentType,
Dictionary<string, object> arguments = null,
int order = 0,
string requiredPolicyName = null)
{
toolbar.Contributors.Add(
new SimplePageToolbarContributor(
componentType,
arguments,
order,
requiredPolicyName
)
);

return toolbar;
}

public static PageToolbar AddButton(
this PageToolbar toolbar,
string text,
Func<Task> clicked,
object icon = null,
Color color = Color.Primary,
bool disabled = false,
int order = 0,
string requiredPolicyName = null)
{
toolbar.AddComponent<ToolbarButton>(
new Dictionary<string, object>
{
{ nameof(ToolbarButton.Color), color},
{ nameof(ToolbarButton.Text), text},
{ nameof(ToolbarButton.Disabled), disabled},
{ nameof(ToolbarButton.Icon), icon},
{ nameof(ToolbarButton.Clicked),clicked},
},
order,
requiredPolicyName
);

return toolbar;
}
}
}