Browse Source

implemented theme detail pages for MudBlazor themes

feat/mudblazor-mix
İsmail ÇAĞDAŞ 7 months ago
parent
commit
ed7b6ee72d
  1. 5
      modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Server.MudBlazorBasicTheme/AbpAspNetCoreComponentsServerMudBlazorBasicThemeModule.cs
  2. 3
      modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Server.MudBlazorBasicTheme/Bundling/BlazorServerMudBlazorBasicThemeStyleContributor.cs
  3. 3
      modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Server.MudBlazorBasicTheme/MudBlazorBasicThemeToolbarContributor.cs
  4. 28
      modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Web.MudBlazorBasicTheme/Themes/Basic/App.razor
  5. 15
      modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Web.MudBlazorBasicTheme/Themes/Basic/AppWithoutAuth.razor
  6. 1
      modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Web.MudBlazorBasicTheme/Themes/Basic/Branding.razor
  7. 77
      modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Web.MudBlazorBasicTheme/Themes/Basic/FirstLevelNavMenuItem.razor
  8. 7
      modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Web.MudBlazorBasicTheme/Themes/Basic/LoginDisplay.razor
  9. 3
      modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Web.MudBlazorBasicTheme/Themes/Basic/MainLayout.razor
  10. 36
      modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Web.MudBlazorBasicTheme/Themes/Basic/NavMenu.razor
  11. 1
      modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Web.MudBlazorBasicTheme/Themes/Basic/NavToolbar.razor
  12. 1
      modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Web.MudBlazorBasicTheme/Themes/Basic/NullLayout.razor
  13. 9
      modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Web.MudBlazorBasicTheme/Themes/Basic/RedirectToLogin.razor
  14. 70
      modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Web.MudBlazorBasicTheme/Themes/Basic/SecondLevelNavMenuItem.razor
  15. 22
      modules/basic-theme/src/Volo.Abp.AspNetCore.Components.WebAssembly.MudBlazorBasicTheme.Bundling/AbpAspNetCoreComponentsWebAssemblyMudBlazorBasicThemeBundlingModule.cs
  16. 14
      modules/basic-theme/src/Volo.Abp.AspNetCore.Components.WebAssembly.MudBlazorBasicTheme.Bundling/Volo.Abp.AspNetCore.Components.WebAssembly.MudBlazorBasicTheme.Bundling.csproj
  17. 12
      modules/basic-theme/src/Volo.Abp.AspNetCore.Components.WebAssembly.MudBlazorBasicTheme.Bundling/WebAssemblyMudBlazorBasicThemeBundleStyleContributor.cs
  18. 2
      modules/basic-theme/src/Volo.Abp.AspNetCore.Components.WebAssembly.MudBlazorBasicTheme/AbpAspNetCoreComponentsWebAssemblyMudBlazorBasicThemeModule.cs
  19. 17
      modules/basic-theme/src/Volo.Abp.AspNetCore.Components.WebAssembly.MudBlazorBasicTheme/MudBlazorBasicThemeToolbarContributor.cs
  20. 18
      modules/basic-theme/src/Volo.Abp.AspNetCore.Components.WebAssembly.MudBlazorBasicTheme/Pages/Authentication.razor
  21. 3
      modules/basic-theme/src/Volo.Abp.AspNetCore.Components.WebAssembly.MudBlazorBasicTheme/Themes/Basic/LoginDisplay.razor
  22. 25
      modules/basic-theme/src/Volo.Abp.AspNetCore.Components.WebAssembly.MudBlazorBasicTheme/Themes/Basic/WebAssemblyRedirectToLogin.razor
  23. 1
      modules/basic-theme/src/Volo.Abp.AspNetCore.Components.WebAssembly.MudBlazorBasicTheme/Volo.Abp.AspNetCore.Components.WebAssembly.MudBlazorBasicTheme.csproj

5
modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Server.MudBlazorBasicTheme/AbpAspNetCoreComponentsServerMudBlazorBasicThemeModule.cs

@ -5,6 +5,7 @@ using Volo.Abp.AspNetCore.Components.Web.MudBlazorBasicTheme;
using Volo.Abp.AspNetCore.Components.Web.Theming.MudBlazor.Toolbars;
using Volo.Abp.AspNetCore.Mvc.UI.Bundling;
using Volo.Abp.Modularity;
using BlazorStandardBundles = Volo.Abp.AspNetCore.Components.Server.Theming.MudBlazor.Bundling.BlazorStandardBundles;
namespace Volo.Abp.AspNetCore.Components.Server.MudBlazorBasicTheme;
@ -28,7 +29,7 @@ public class AbpAspNetCoreComponentsServerMudBlazorBasicThemeModule : AbpModule
.Add(BlazorMudBlazorBasicThemeBundles.Styles.Global, bundle =>
{
bundle
.AddBaseBundles(BlazorServerStandardBundles.Styles.Global)
.AddBaseBundles(BlazorStandardBundles.Styles.Global)
.AddContributors(typeof(BlazorServerMudBlazorBasicThemeStyleContributor));
});
@ -37,7 +38,7 @@ public class AbpAspNetCoreComponentsServerMudBlazorBasicThemeModule : AbpModule
.Add(BlazorMudBlazorBasicThemeBundles.Scripts.Global, bundle =>
{
bundle
.AddBaseBundles(BlazorServerStandardBundles.Scripts.Global)
.AddBaseBundles(BlazorStandardBundles.Scripts.Global)
.AddContributors(typeof(BlazorServerMudBlazorBasicThemeScriptContributor));
});
});

3
modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Server.MudBlazorBasicTheme/Bundling/BlazorServerMudBlazorBasicThemeStyleContributor.cs

@ -1,3 +1,4 @@
using System.Collections.Generic;
using Volo.Abp.AspNetCore.Mvc.UI.Bundling;
namespace Volo.Abp.AspNetCore.Components.Server.MudBlazorBasicTheme.Bundling;
@ -6,6 +7,6 @@ public class BlazorServerMudBlazorBasicThemeStyleContributor : BundleContributor
{
public override void ConfigureBundle(BundleConfigurationContext context)
{
context.Files.AddIfNotContains("/themes/basic/main.css");
context.Files.AddIfNotContains("/_content/Volo.Abp.AspNetCore.Components.Web.MudBlazorBasicTheme/themes/basic/main.css");
}
}

3
modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Server.MudBlazorBasicTheme/MudBlazorBasicThemeToolbarContributor.cs

@ -1,7 +1,7 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components;
using Volo.Abp.AspNetCore.Components.Server.MudBlazorBasicTheme.Themes.Basic;
using Volo.Abp.AspNetCore.Components.Web.Theming.MudBlazor.Toolbars;
using Volo.Abp.AspNetCore.Components.Web.MudBlazorBasicTheme.Themes.Basic;
namespace Volo.Abp.AspNetCore.Components.Server.MudBlazorBasicTheme;
@ -12,6 +12,7 @@ public class MudBlazorBasicThemeToolbarContributor : IToolbarContributor
if (context.Toolbar.Name == StandardToolbars.Main)
{
context.Toolbar.Items.Add(new ToolbarItem(typeof(LoginDisplay)));
context.Toolbar.Items.Add(new ToolbarItem(typeof(LanguageSwitch)));
}
return Task.CompletedTask;

28
modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Web.MudBlazorBasicTheme/Themes/Basic/App.razor

@ -0,0 +1,28 @@
@using Microsoft.Extensions.Options
@using Volo.Abp.AspNetCore.Components.Web.Theming.MudBlazor.Routing
@using MudBlazor
@inject IOptions<AbpRouterOptions> RouterOptions
<CascadingAuthenticationState>
<Router AppAssembly="RouterOptions.Value.AppAssembly"
AdditionalAssemblies="RouterOptions.Value.AdditionalAssemblies">
<Found Context="routeData">
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
<NotAuthorized>
@if (!context.User.Identity.IsAuthenticated)
{
<RedirectToLogin />
}
else
{
<MudText>You are not authorized to access this resource.</MudText>
}
</NotAuthorized>
</AuthorizeRouteView>
</Found>
<NotFound>
<LayoutView Layout="@typeof(MainLayout)">
<MudText>Sorry, there's nothing at this address.</MudText>
</LayoutView>
</NotFound>
</Router>
</CascadingAuthenticationState>

15
modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Web.MudBlazorBasicTheme/Themes/Basic/AppWithoutAuth.razor

@ -0,0 +1,15 @@
@using Microsoft.Extensions.Options
@using Volo.Abp.AspNetCore.Components.Web.Theming.MudBlazor.Routing
@using MudBlazor
@inject IOptions<AbpRouterOptions> RouterOptions
<Router AppAssembly="RouterOptions.Value.AppAssembly"
AdditionalAssemblies="RouterOptions.Value.AdditionalAssemblies">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
</Found>
<NotFound>
<LayoutView Layout="@typeof(MainLayout)">
<MudText>Sorry, there's nothing at this address.</MudText>
</LayoutView>
</NotFound>
</Router>

1
modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Web.MudBlazorBasicTheme/Themes/Basic/Branding.razor

@ -1,4 +1,5 @@
@using Volo.Abp.Ui.Branding
@using MudBlazor
@inject IBrandingProvider BrandingProvider
<MudText Typo="Typo.h6" Class="ma-0">@BrandingProvider.AppName</MudText>

77
modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Web.MudBlazorBasicTheme/Themes/Basic/FirstLevelNavMenuItem.razor

@ -0,0 +1,77 @@
@using Volo.Abp.UI.Navigation
@using MudBlazor
@using Microsoft.AspNetCore.Components
@using Microsoft.AspNetCore.Components.Routing
@using System
@{
var customComponentType = MenuItem.GetComponentTypeOrDefault();
}
@if (customComponentType != null && typeof(ComponentBase).IsAssignableFrom(customComponentType))
{
<DynamicComponent Type="@customComponentType" />
}
else
{
<MudNavGroup Title="@MenuItem.DisplayName" Icon="@GetIcon(MenuItem.Icon)">
@foreach (var item in MenuItem.Items)
{
@if (item.Items.Any())
{
<SecondLevelNavMenuItem MenuItem="item" />
}
else
{
<MudNavLink Href="@(item.Url?.TrimStart('/', '~') ?? "#")" Match="@(item.Url != null ? NavLinkMatch.All : NavLinkMatch.Prefix)">
@if (!string.IsNullOrEmpty(item.Icon))
{
<MudIcon Icon="@GetIcon(item.Icon)" Class="me-2" />
}
@item.DisplayName
</MudNavLink>
}
}
</MudNavGroup>
}
@code {
[Parameter]
public ApplicationMenuItem MenuItem { get; set; } = default!;
[Inject]
private NavigationManager NavigationManager { get; set; } = default!;
protected override void OnInitialized()
{
NavigationManager.LocationChanged += OnLocationChanged;
}
protected virtual void OnLocationChanged(object? sender, LocationChangedEventArgs e)
{
// Menu will close automatically on navigation
}
public void Dispose()
{
NavigationManager.LocationChanged -= OnLocationChanged;
}
private string? GetIcon(string? icon)
{
if (string.IsNullOrEmpty(icon))
{
return null;
}
// Convert FontAwesome icons to Material icons if needed
if (icon.StartsWith("fa"))
{
// Map common FontAwesome icons to Material icons
return icon.Replace("fa-", "").Replace("-", "_");
}
return icon;
}
}
@implements IDisposable

7
modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Web.MudBlazorBasicTheme/Themes/Basic/LoginDisplay.razor

@ -1,6 +1,10 @@
@using Volo.Abp.AspNetCore.Components.Web.Theming.MudBlazor.Components
@using Volo.Abp.Users
@using MudBlazor
@using Microsoft.Extensions.Localization
@using global::Localization.Resources.AbpUi
@inject ICurrentUser CurrentUser
@inject IStringLocalizer<AbpUiResource> L
@if (CurrentUser.IsAuthenticated)
{
@ -19,9 +23,8 @@ else
[Inject] protected NavigationManager NavigationManager { get; set; } = default!;
[Inject] protected IAbpLazyServiceProvider LazyServiceProvider { get; set; } = default!;
protected async Task Logout()
protected void Logout()
{
// TODO: Implement logout logic
NavigationManager.NavigateTo("/Account/Logout", forceLoad: true);
}
}

3
modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Web.MudBlazorBasicTheme/Themes/Basic/MainLayout.razor

@ -2,6 +2,7 @@
@using Volo.Abp.AspNetCore.Components.Web.Theming.MudBlazor.Components.LayoutHooks
@using Volo.Abp.AspNetCore.Components.Web.Theming.MudBlazor.Components
@using Volo.Abp.AspNetCore.Components.Web.Theming.Layout
@using MudBlazor
@inherits LayoutComponentBase
<MudThemeProvider />
@ -48,5 +49,3 @@
_drawerOpen = !_drawerOpen;
}
}
@implements IDisposable

36
modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Web.MudBlazorBasicTheme/Themes/Basic/NavMenu.razor

@ -1,4 +1,6 @@
@using Volo.Abp.UI.Navigation
@using MudBlazor
@using Microsoft.AspNetCore.Components.Routing
@inject IMenuManager MenuManager
<MudNavMenu>
@ -9,25 +11,33 @@
<MudNavLink Href="@menuItem.Url" Match="@(menuItem.Url != null ? NavLinkMatch.All : NavLinkMatch.Prefix)">
@if (!string.IsNullOrEmpty(menuItem.Icon))
{
<MudIcon Icon="@menuItem.Icon" Class="me-2" />
<MudIcon Icon="@GetIcon(menuItem.Icon)" Class="me-2" />
}
@menuItem.DisplayName
</MudNavLink>
}
else
{
<MudNavGroup Title="@menuItem.DisplayName" Icon="@menuItem.Icon">
@foreach (var childItem in menuItem.Items)
{
<MudNavLink Href="@childItem.Url" Match="@(childItem.Url != null ? NavLinkMatch.All : NavLinkMatch.Prefix)">
@if (!string.IsNullOrEmpty(childItem.Icon))
{
<MudIcon Icon="@childItem.Icon" Class="me-2" />
}
@childItem.DisplayName
</MudNavLink>
}
</MudNavGroup>
<FirstLevelNavMenuItem MenuItem="menuItem" />
}
}
</MudNavMenu>
@code {
private string? GetIcon(string? icon)
{
if (string.IsNullOrEmpty(icon))
{
return null;
}
// Convert FontAwesome icons to Material icons if needed
if (icon.StartsWith("fa"))
{
// Map common FontAwesome icons to Material icons
return icon.Replace("fa-", "").Replace("-", "_");
}
return icon;
}
}

1
modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Web.MudBlazorBasicTheme/Themes/Basic/NavToolbar.razor

@ -3,6 +3,7 @@
@using System.Collections.Generic
@using System
@using Microsoft.AspNetCore.Components
@using MudBlazor
@implements IDisposable

1
modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Web.MudBlazorBasicTheme/Themes/Basic/NullLayout.razor

@ -1,6 +1,7 @@
@using Volo.Abp.Ui.LayoutHooks
@using Volo.Abp.AspNetCore.Components.Web.Theming.MudBlazor.Components.LayoutHooks
@using Volo.Abp.AspNetCore.Components.Web.Theming.Layout
@using MudBlazor
@inherits LayoutComponentBase
<MudThemeProvider />

9
modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Web.MudBlazorBasicTheme/Themes/Basic/RedirectToLogin.razor

@ -0,0 +1,9 @@
@inject NavigationManager Navigation
@using System
@code {
protected override void OnInitialized()
{
Navigation.NavigateTo($"account/login?returnUrl={Uri.EscapeDataString(Navigation.Uri)}", true);
}
}

70
modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Web.MudBlazorBasicTheme/Themes/Basic/SecondLevelNavMenuItem.razor

@ -0,0 +1,70 @@
@using Volo.Abp.UI.Navigation
@using MudBlazor
@using Microsoft.AspNetCore.Components
@using Microsoft.AspNetCore.Components.Routing
@using System
@{
var customComponentType = MenuItem.GetComponentTypeOrDefault();
}
@if (customComponentType != null && typeof(ComponentBase).IsAssignableFrom(customComponentType))
{
<DynamicComponent Type="@customComponentType" />
}
else
{
<MudNavGroup Title="@MenuItem.DisplayName" Icon="@GetIcon(MenuItem.Icon)">
@foreach (var item in MenuItem.Items)
{
<MudNavLink Href="@(item.Url?.TrimStart('/', '~') ?? "#")" Match="@(item.Url != null ? NavLinkMatch.All : NavLinkMatch.Prefix)">
@if (!string.IsNullOrEmpty(item.Icon))
{
<MudIcon Icon="@GetIcon(item.Icon)" Class="me-2" />
}
@item.DisplayName
</MudNavLink>
}
</MudNavGroup>
}
@code {
[Parameter]
public ApplicationMenuItem MenuItem { get; set; } = default!;
[Inject]
private NavigationManager NavigationManager { get; set; } = default!;
protected override void OnInitialized()
{
NavigationManager.LocationChanged += OnLocationChanged;
}
protected virtual void OnLocationChanged(object? sender, LocationChangedEventArgs e)
{
// Menu will close automatically on navigation
}
public void Dispose()
{
NavigationManager.LocationChanged -= OnLocationChanged;
}
private string? GetIcon(string? icon)
{
if (string.IsNullOrEmpty(icon))
{
return null;
}
// Convert FontAwesome icons to Material icons if needed
if (icon.StartsWith("fa"))
{
// Map common FontAwesome icons to Material icons
return icon.Replace("fa-", "").Replace("-", "_");
}
return icon;
}
}
@implements IDisposable

22
modules/basic-theme/src/Volo.Abp.AspNetCore.Components.WebAssembly.MudBlazorBasicTheme.Bundling/AbpAspNetCoreComponentsWebAssemblyMudBlazorBasicThemeBundlingModule.cs

@ -0,0 +1,22 @@
using Volo.Abp.AspNetCore.Components.WebAssembly.Theming.Bundling;
using Volo.Abp.AspNetCore.Components.WebAssembly.Theming.MudBlazor;
using Volo.Abp.AspNetCore.Mvc.UI.Bundling;
using Volo.Abp.Modularity;
using BlazorWebAssemblyStandardBundles = Volo.Abp.AspNetCore.Components.WebAssembly.Theming.Bundling.BlazorWebAssemblyStandardBundles;
namespace Volo.Abp.AspNetCore.Components.WebAssembly.MudBlazorBasicTheme.Bundling;
[DependsOn(
typeof(AbpAspNetCoreComponentsWebAssemblyThemingMudBlazorModule)
)]
public class AbpAspNetCoreComponentsWebAssemblyMudBlazorBasicThemeBundlingModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpBundlingOptions>(options =>
{
var globalStyles = options.StyleBundles.Get(BlazorWebAssemblyStandardBundles.Styles.Global);
globalStyles.AddContributors(typeof(WebAssemblyMudBlazorBasicThemeBundleStyleContributor));
});
}
}

14
modules/basic-theme/src/Volo.Abp.AspNetCore.Components.WebAssembly.MudBlazorBasicTheme.Bundling/Volo.Abp.AspNetCore.Components.WebAssembly.MudBlazorBasicTheme.Bundling.csproj

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\..\configureawait.props" />
<Import Project="..\..\..\..\common.props" />
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Components.WebAssembly.Theming.MudBlazor\Volo.Abp.AspNetCore.Components.WebAssembly.Theming.MudBlazor.csproj" />
</ItemGroup>
</Project>

12
modules/basic-theme/src/Volo.Abp.AspNetCore.Components.WebAssembly.MudBlazorBasicTheme.Bundling/WebAssemblyMudBlazorBasicThemeBundleStyleContributor.cs

@ -0,0 +1,12 @@
using System.Collections.Generic;
using Volo.Abp.AspNetCore.Mvc.UI.Bundling;
namespace Volo.Abp.AspNetCore.Components.WebAssembly.MudBlazorBasicTheme.Bundling;
public class WebAssemblyMudBlazorBasicThemeBundleStyleContributor : BundleContributor
{
public override void ConfigureBundle(BundleConfigurationContext context)
{
context.Files.AddIfNotContains("_content/Volo.Abp.AspNetCore.Components.Web.MudBlazorBasicTheme/themes/basic/main.css");
}
}

2
modules/basic-theme/src/Volo.Abp.AspNetCore.Components.WebAssembly.MudBlazorBasicTheme/AbpAspNetCoreComponentsWebAssemblyMudBlazorBasicThemeModule.cs

@ -3,6 +3,7 @@ using Volo.Abp.AspNetCore.Components.Web;
using Volo.Abp.AspNetCore.Components.Web.MudBlazorBasicTheme;
using Volo.Abp.AspNetCore.Components.Web.Theming.MudBlazor.Routing;
using Volo.Abp.AspNetCore.Components.Web.Theming.MudBlazor.Toolbars;
using Volo.Abp.AspNetCore.Components.WebAssembly.MudBlazorBasicTheme.Bundling;
using Volo.Abp.AspNetCore.Components.WebAssembly.Theming.MudBlazor;
using Volo.Abp.Http.Client.IdentityModel.WebAssembly;
using Volo.Abp.Modularity;
@ -10,6 +11,7 @@ using Volo.Abp.Modularity;
namespace Volo.Abp.AspNetCore.Components.WebAssembly.MudBlazorBasicTheme;
[DependsOn(
typeof(AbpAspNetCoreComponentsWebAssemblyMudBlazorBasicThemeBundlingModule),
typeof(AbpAspNetCoreComponentsWebMudBlazorBasicThemeModule),
typeof(AbpAspNetCoreComponentsWebAssemblyThemingMudBlazorModule),
typeof(AbpHttpClientIdentityModelWebAssemblyModule)

17
modules/basic-theme/src/Volo.Abp.AspNetCore.Components.WebAssembly.MudBlazorBasicTheme/MudBlazorBasicThemeToolbarContributor.cs

@ -1,7 +1,11 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components;
using Volo.Abp.AspNetCore.Components.Web.Theming.MudBlazor.Toolbars;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.AspNetCore.Components.Web.MudBlazorBasicTheme.Themes.Basic;
using Volo.Abp.AspNetCore.Components.Web.Theming.MudBlazor.Toolbars;
using Volo.Abp.AspNetCore.Components.WebAssembly.MudBlazorBasicTheme.Themes.Basic;
using Volo.Abp.DependencyInjection;
namespace Volo.Abp.AspNetCore.Components.WebAssembly.MudBlazorBasicTheme;
@ -11,7 +15,16 @@ public class MudBlazorBasicThemeToolbarContributor : IToolbarContributor
{
if (context.Toolbar.Name == StandardToolbars.Main)
{
context.Toolbar.Items.Add(new ToolbarItem(typeof(LoginDisplay)));
context.Toolbar.Items.Add(new ToolbarItem(typeof(LanguageSwitch)));
//TODO: Can we find a different way to understand if authentication was configured or not?
var authenticationStateProvider = context.ServiceProvider
.GetService<AuthenticationStateProvider>();
if (authenticationStateProvider != null)
{
context.Toolbar.Items.Add(new ToolbarItem(typeof(LoginDisplay)));
}
}
return Task.CompletedTask;

18
modules/basic-theme/src/Volo.Abp.AspNetCore.Components.WebAssembly.MudBlazorBasicTheme/Pages/Authentication.razor

@ -0,0 +1,18 @@
@page "/authentication/{action}"
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication
@using Volo.Abp.AspNetCore.Components.Web.Security
<RemoteAuthenticatorView Action="@Action" OnLogInSucceeded="OnLogInSucceeded" OnLogOutSucceeded="OnLogOutSucceeded" />
@inject WebAssemblyCachedApplicationConfigurationClient WebAssemblyCachedApplicationConfigurationClient
@code{
[Parameter] public string? Action { get; set; }
private async Task OnLogInSucceeded(RemoteAuthenticationState state)
{
await WebAssemblyCachedApplicationConfigurationClient.InitializeAsync();
}
private async Task OnLogOutSucceeded(RemoteAuthenticationState state)
{
await WebAssemblyCachedApplicationConfigurationClient.InitializeAsync();
}
}

3
modules/basic-theme/src/Volo.Abp.AspNetCore.Components.WebAssembly.MudBlazorBasicTheme/Themes/Basic/LoginDisplay.razor

@ -52,6 +52,9 @@
{
ApplicationConfigurationChangedService.Changed -= ApplicationConfigurationChanged;
}
}
@implements IDisposable
private async Task NavigateToAsync(string? uri, string? target = null)
{

25
modules/basic-theme/src/Volo.Abp.AspNetCore.Components.WebAssembly.MudBlazorBasicTheme/Themes/Basic/WebAssemblyRedirectToLogin.razor

@ -0,0 +1,25 @@
@inject NavigationManager Navigation
@using Volo.Abp.DependencyInjection
@using Volo.Abp.AspNetCore.Components.Web.MudBlazorBasicTheme.Themes.Basic
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication
@using Microsoft.Extensions.Options
@using Volo.Abp.AspNetCore.Components.Web
@inherits RedirectToLogin
@attribute [ExposeServices(typeof(RedirectToLogin))]
@attribute [Dependency(ReplaceServices = true)]
@inject IOptions<AuthenticationOptions> AuthenticationOptions
@inject IOptions<AbpAspNetCoreComponentsWebOptions> AbpAspNetCoreComponentsWebOptions
@code {
protected override void OnInitialized()
{
if (AbpAspNetCoreComponentsWebOptions.Value.IsBlazorWebApp)
{
Navigation.NavigateTo(AuthenticationOptions.Value.LoginUrl, forceLoad: true);
}
else
{
Navigation.NavigateToLogin(AuthenticationOptions.Value.LoginUrl);
}
}
}

1
modules/basic-theme/src/Volo.Abp.AspNetCore.Components.WebAssembly.MudBlazorBasicTheme/Volo.Abp.AspNetCore.Components.WebAssembly.MudBlazorBasicTheme.csproj

@ -12,6 +12,7 @@
<ProjectReference Include="..\Volo.Abp.AspNetCore.Components.Web.MudBlazorBasicTheme\Volo.Abp.AspNetCore.Components.Web.MudBlazorBasicTheme.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Components.WebAssembly.Theming.MudBlazor\Volo.Abp.AspNetCore.Components.WebAssembly.Theming.MudBlazor.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.Http.Client.IdentityModel.WebAssembly\Volo.Abp.Http.Client.IdentityModel.WebAssembly.csproj" />
<ProjectReference Include="..\Volo.Abp.AspNetCore.Components.WebAssembly.MudBlazorBasicTheme.Bundling\Volo.Abp.AspNetCore.Components.WebAssembly.MudBlazorBasicTheme.Bundling.csproj" />
</ItemGroup>
</Project>

Loading…
Cancel
Save