Activities of "safi"

hi

The MainHeaderToolbarUserMenu class

using System; 
using System.Text; 
using System.Threading.Tasks; 
using Localization.Resources.AbpUi; 
using Microsoft.AspNetCore.Components; 
using Microsoft.AspNetCore.Components.Authorization; 
using Microsoft.AspNetCore.Components.Routing; 
using Microsoft.AspNetCore.Components.WebAssembly.Authentication; 
using Microsoft.Extensions.Localization; 
using Microsoft.Extensions.Options; 
using Microsoft.JSInterop; 
using Volo.Abp.Http.Client; 
using Volo.Abp.MultiTenancy; 
using Volo.Abp.UI.Navigation; 
using Volo.Abp.Users; 
 
namespace Volo.Abp.AspNetCore.Components.WebAssembly.LeptonTheme.Components.ApplicationLayout.MainHeader; 
 
public partial class MainHeaderToolbarUserMenu : IDisposable 
{ 
    [Inject] 
    protected IMenuManager MenuManager { get; set; } 
 
    [Inject] 
    protected ICurrentUser CurrentUser { get; set; } 
 
    [Inject] 
    protected ICurrentTenant CurrentTenant { get; set; } 
 
    [Inject] 
    protected SignOutSessionStateManager SignOutManager { get; set; } 
 
    [Inject] 
    protected NavigationManager Navigation { get; set; } 
 
    [Inject] 
    protected AuthenticationStateProvider AuthenticationStateProvider { get; set; } 
 
    [Inject] 
    protected IStringLocalizer<AbpUiResource> UiLocalizer { get; set; } 
 
    [Inject] 
    protected IOptions<AbpRemoteServiceOptions> RemoteServiceOptions { get; set; } 
 
    [Inject] 
    protected IJSRuntime JsRuntime { get; set; } 
 
    protected ApplicationMenu UserMenu { get; set; } 
 
    protected Guid? UserId { get; set; } 
 
    protected string UserName { get; set; } 
 
    protected string TenantName { get; set; } 
 
    protected string ProfileImageUrl { get; set; } 
 
    protected string UserFullName { get; set; } 
 
    protected override async Task OnInitializedAsync() 
    { 
        await SetUserMenuAndProfileAsync(); 
 
        Navigation.LocationChanged += OnLocationChanged; 
        AuthenticationStateProvider.AuthenticationStateChanged += AuthenticationStateProviderOnAuthenticationStateChanged; 
    } 
 
    private async Task SetUserMenuAndProfileAsync() 
    { 
        UserMenu = await MenuManager.GetAsync(StandardMenus.User); 
 
        UserId = CurrentUser.Id; 
        UserName = CurrentUser.UserName; 
        UserFullName = CalculateUserFullName(); 
        TenantName = CurrentTenant.Name; 
 
        if (UserId != null) 
        { 
            ProfileImageUrl = RemoteServiceOptions.Value.RemoteServices.Default?.BaseUrl?.TrimEnd('/') + 
                              $"/api/account/profile-picture-file/{UserId}"; 
        } 
    } 
 
    protected virtual void OnLocationChanged(object sender, LocationChangedEventArgs e) 
    { 
        InvokeAsync(StateHasChanged); 
    } 
 
    private async void AuthenticationStateProviderOnAuthenticationStateChanged(Task<AuthenticationState> task) 
    { 
        await SetUserMenuAndProfileAsync(); 
        await InvokeAsync(StateHasChanged); 
    } 
 
    protected virtual async Task BeginSignOut() 
    { 
        await SignOutManager.SetSignOutState(); 
        await NavigateToAsync("authentication/logout"); 
    } 
 
    protected virtual async Task NavigateToAsync(string uri, string target = null) 
    { 
        if (target == "_blank") 
        { 
            await JsRuntime.InvokeVoidAsync("open", uri, target); 
        } 
        else 
        { 
            Navigation.NavigateTo(uri); 
        } 
 
    } 
 
    protected virtual string CalculateUserFullName() 
    { 
        //TODO: Should we move this logic to some extension method for the ICurrentUser? 
 
        var fullName = new StringBuilder(); 
 
        if (!CurrentUser.Name.IsNullOrEmpty()) 
        { 
            fullName.Append(CurrentUser.Name); 
        } 
 
        if (!CurrentUser.SurName.IsNullOrEmpty()) 
        { 
            if (fullName.Length > 0) 
            { 
                fullName.Append(" "); 
            } 
 
            fullName.Append(CurrentUser.SurName); 
        } 
 
        if (fullName.Length == 0) 
        { 
            fullName.Append(CurrentUser.UserName); 
        } 
 
        return fullName.ToString(); 
    } 
 
    public void Dispose() 
    { 
        Navigation.LocationChanged -= OnLocationChanged; 
        AuthenticationStateProvider.AuthenticationStateChanged -= AuthenticationStateProviderOnAuthenticationStateChanged; 
    } 
} 
 

Hi

Thanks for this. I create a class in blazer project and put this class in root level while building the project getting errors like no suitable method.

https://github.com/abpframework/abp/blob/dev/docs/en/UI/Blazor/Customization-Overriding-Components.md

<AuthorizeView> 
    <Authorized> 
        @if ( UserMenu != null ) 
        { 
            <BarItem> 
                <BarDropdown> 
                    <BarDropdownToggle Class="btn"> 
                        <img src="@ProfileImageUrl" width="21" class="user-avatar me-1" alt="@UserName" /> 
                        @if ( TenantName != null ) 
                        { 
                            <span><i>@TenantName</i>\@UserName</span> 
                        } 
                        else 
                        { 
                            <span>@UserName</span> 
                        } 
                    </BarDropdownToggle> 
                    <BarDropdownMenu RightAligned="true"> 
                        <BarDropdownItem> 
                            <Row Padding="Padding.Is2"> 
                                <Column ColumnSize="ColumnSize.IsAuto" Padding="Padding.Is0.FromEnd"> 
                                    <img src="@ProfileImageUrl" class="user-avatar-big" width="48" alt="@UserName" /> 
                                </Column> 
                                <Column Padding="Padding.Is2.FromStart"> 
                                    <span>@UiLocalizer["Welcome"]</span><br /> 
                                    <Strong>@UserFullName</Strong> 
                                </Column> 
                            </Row> 
                        </BarDropdownItem> 
                        <DropdownDivider /> 
                        @foreach ( var item in UserMenu.Items ) 
                        { 
                            <BarDropdownItem id="@item.ElementId" Class="@item.CssClass" Clicked="() => NavigateToAsync(item.Url, item.Target)">@item.DisplayName</BarDropdownItem> 
                        } 
                        <BarDropdownItem Clicked="BeginSignOut">@UiLocalizer["Logout"]</BarDropdownItem> 
                    </BarDropdownMenu> 
                </BarDropdown> 
            </BarItem> 
        } 
    </Authorized> 
    <NotAuthorized> 
        <a class="nav-link btn" href="authentication/login">@UiLocalizer["Login"]</a> 
    </NotAuthorized> 
</AuthorizeView> 
 

I referred that link and created a razor page and pasted this code as well but while building project I am getting 20 errors which is related to above code only like Username is not defined etc.

Can you please guide me for the same.

Thanks,

hi

Can you try to get latest source code of Lepton and override the MainHeaderToolbarUserMenu?

How can I do this?

hi

Can you check the HTML structure via the chrome elements tool?

Hi

Any update?

Hi

I am facing a UI issue while changing the language from English to german. Please find the below screenshot for the same and please let me know how can I resolve this. Thanks,

  • ABP Framework version: v4.4.3
  • UI type: Blazor
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no

AccountResource

Hi

Yes, the account resource is working but it's not taking keys from my resource file. I added a localization folder under the host project and added a test folder into it in which I have added a de-DE.json file and calling like this only.

Can we connect on zoom to check this? I already spent enough time on this and it's very urgent for me.

AbpAccountResource

Yes, still the same error.Can we connect on zoom?

What does the error say?

Adding this code into hostmodule.cs and getting this error also I have added the above-mentioned namespace and references too.

Namespace for AbpAccountResource is Volo.Abp.Account.Localization, and Volo.Abp.UI.Navigation.Localization.Resource for AbpUiNavigationResource.

using Volo.Abp.Account.Localization;

using Volo.Abp.UI.Navigation.Localization.Resource;

However, make sure that you are overriding these resources in a project/layer that references Volo.Abp.Account.Pro.Shared.Application.Contracts package. I suggest you to make these changes in the top layer (i guess HttpApi.Host for blazor) of your solution.

Ok thanks, yekalkan. Let me try this solution.

I added these folders into host project and trying like this but still getting error while using AbpAccountResource

Showing 241 to 250 of 347 entries
Made with ❤️ on ABP v9.0.0-preview Updated on September 20, 2024, 08:30