-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Blazor UI extensions #6647
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 3a77152
abp datagrid implementation.
ilkayilknur f760b48
AbpDataGrid implementation.
ilkayilknur e63080a
implement entity action and table column extensibility in identity mo…
ilkayilknur 77381e8
page toolbar implementation
ilkayilknur 06bfd14
implement page toolbar in identity module
ilkayilknur b57ccff
remove setters
ilkayilknur 4699927
bundling improvements.
ilkayilknur 5f2a238
add mising file.
ilkayilknur 2801e1b
add abp cli options to the appsettings file.
ilkayilknur b797527
add comments
ilkayilknur efd2e05
handle json comments and exception improvement.
ilkayilknur 6386fe4
Merge branch 'dev' into ui-extensions-blazor
ilkayilknur 89541d0
Merge branch 'dev' into ui-extensions-blazor
ilkayilknur 2b58e3a
remove unnecessary item group.
ilkayilknur 1936389
make constructor private to enforce using the Instance
ilkayilknur b704cac
rename AbpDataGrid to AbpExtensibleDataGrid
ilkayilknur 9591c23
refactor usages.
ilkayilknur 7725e62
Merge branch 'dev' into ui-extensions-blazor
hikalkan a407012
Update RoleManagement.razor.cs
hikalkan c8ebda3
custom component support for table columns
ilkayilknur a32304f
remove semicolon
ilkayilknur 1969364
make data field name const
ilkayilknur fbafe73
remove render usage inside table column
ilkayilknur 400cbd5
Merge branch 'dev' into blazor-module-extensions
ilkayilknur 89c69dc
blazor module extensions initial implementation.
ilkayilknur 82aef9d
remove IEquatable implementation.
ilkayilknur 9b01d7a
refactoring
ilkayilknur f2669db
add extension property support to the data grid.
ilkayilknur a06fb47
show icon when displaying boolean properties.
ilkayilknur d4c5640
remove unused code
ilkayilknur 17b4bac
introduce new components for other data types
ilkayilknur e9a4f12
remove unnecessary code
ilkayilknur b79d88e
lookup property HttpClient implementation
ilkayilknur 3fecd0c
Merge branch 'dev' into ui-extensions-blazor
ilkayilknur d11e253
Merge branch 'ui-extensions-blazor' of https://github.com/abpframewor…
ilkayilknur ebd97f6
add missing reference and update bundles.
ilkayilknur fe203bb
fix item loading issue.
ilkayilknur 03fe7c0
initial value problem fixed.
ilkayilknur f21ba0a
add datetime-local support and fix listing.
ilkayilknur a031937
add custom converter support to the table column and use it to displa…
ilkayilknur 2607053
initial value setting fix.
ilkayilknur 1da3b65
canbenull attribute has been added.
ilkayilknur 04d6fa9
remove unused code
ilkayilknur 8f90168
Merge pull request #7686 from abpframework/blazor-module-extensions
hikalkan a3cfde8
Merge branch 'dev' into ui-extensions-blazor
hikalkan 758db7f
Fix URL: Module-Entity-Extensions
hikalkan c91c35b
Implement blazor UI extensions for UserManagement
hikalkan b2038c6
Do not validate extra props on blazor UI
hikalkan bccc474
do not validate lookup property on client side
ilkayilknur cc58ee9
Merge branch 'ui-extensions-blazor' of https://github.com/abpframewor…
ilkayilknur c586442
Added default values to summaries.
hikalkan 599dccd
Merge branch 'ui-extensions-blazor' of https://github.com/abpframewor…
ilkayilknur e8bb417
Merge branch 'dev' into ui-extensions-blazor
ilkayilknur 1cc9f2c
Remove BlazoriseUI.PageHeader
ilkayilknur 160533f
UI extension code updates.
ilkayilknur f022cfb
Implement Blazor UI and Module Extensions
ilkayilknur c520807
add icon and color options for entity actions
ilkayilknur 7076689
current page parameter has been added.
ilkayilknur 71f0759
use current page parameter on AbpExtensibleDataGrids.
ilkayilknur 175bb06
breadcrumbitem removed.
ilkayilknur 2ceeeff
visible parameter has been added.
ilkayilknur 0e7c6e0
Merge branch 'dev' into ui-extensions-blazor
ilkayilknur ccd8b9b
Merge branch 'dev' into ui-extensions-blazor
ilkayilknur 7ea10a2
Merge branch 'dev' into ui-extensions-blazor
ilkayilknur fb5e94b
put bundle parameters inside bundle context.
ilkayilknur 150e285
Update MyProjectNameBundleContributor.
maliming 419a642
Merge branch 'dev' into ui-extensions-blazor
ilkayilknur fe1558a
place each toolbar item in a new column
ilkayilknur 68eecc7
Improve visible usage to avoid NRE
ilkayilknur 5e60fa5
visibility fix.
ilkayilknur e33afe8
display dropdown toggle as block
ilkayilknur 014c4ae
Merge branch 'dev' into ui-extensions-blazor
ilkayilknur 1be0836
set currentpage default value to match with blazorise datagrid
ilkayilknur 6445629
Merge branch 'dev' into ui-extensions-blazor
ilkayilknur 66448fd
Move entity actions and table columns to the Volo.Abp.AspNetCore.Comp…
ilkayilknur b769d84
move page toolbars and header to the Volo.Abp.AspNetCore.Components.W…
ilkayilknur 13099f7
Remove RequiredPolicy from entity actions and use Visible property.
ilkayilknur 7660c8b
Merge branch 'dev' into ui-extensions-blazor
ilkayilknur b4c4d75
Merge branch 'dev' into ui-extensions-blazor
ilkayilknur 51c74c4
add Http.Client and Components.Web dependencies.
ilkayilknur 6598c37
lookup api request service implementation
ilkayilknur 6c3baed
add lookup implementation when blazor server is not tiered
ilkayilknur 4f1d53f
Merge branch 'dev' into ui-extensions-blazor
ilkayilknur d76b7a6
change page toolbar call order.
ilkayilknur File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
...olo/Abp/AspNetCore/Components/Server/Extensibility/BlazorServerLookupApiRequestService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Layout/PageHeader.razor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
var toolbarItems = await PageToolbarManager.GetItemsAsync(Toolbar); | ||
Console.WriteLine($"Toolbar item count:{toolbarItems.Length}"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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(); | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...rk/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/IPageToolbarContributor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/IPageToolbarManager.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbar.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbarContributionContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...ork/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbarContributor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbarContributorList.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
{ | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...work/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbarDictionary.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
{ | ||
|
||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
...work/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbarExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove Console.WriteLine