Skip to content

Commit

Permalink
Improve code
Browse files Browse the repository at this point in the history
  • Loading branch information
franklupo committed Jul 19, 2023
1 parent e7f711d commit 688f51a
Show file tree
Hide file tree
Showing 24 changed files with 53 additions and 49 deletions.
2 changes: 1 addition & 1 deletion src/Corsinvest.AppHero.AppBss/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
options.Transports = HttpTransportType.WebSockets | HttpTransportType.LongPolling;
});

app.MapFallbackToPage("/_Index");
app.MapFallbackToPage("/_Host");

await app.OnPostApplicationInitializationAsync();

Expand Down
2 changes: 1 addition & 1 deletion src/Corsinvest.AppHero.Auditing/Module.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public Module()
Description = "Auditing";
Slug = "Auditing";

Link = new ModuleLink(this, Description)
Link = new(this, Description)
{
Icon = UIIcon.PersonSearch.GetName(),
};
Expand Down
1 change: 0 additions & 1 deletion src/Corsinvest.AppHero.Authentication/OptionsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.OAuth.Claims;
using System.ComponentModel.DataAnnotations;
using System.Xml.Linq;

namespace Corsinvest.AppHero.Authentication;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Fast.Components.FluentUI" Version="2.4.0" />
<PackageReference Include="Microsoft.Fast.Components.FluentUI" Version="2.4.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CodeBeam.MudBlazor.Extensions" Version="6.5.4" />
<PackageReference Include="CodeBeam.MudBlazor.Extensions" Version="6.5.5" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.9" />
<PackageReference Include="MudBlazor" Version="6.7.0" />
<PackageReference Include="BlazorDownloadFile" Version="2.4.0.2" />
<PackageReference Include="MudBlazor.Extensions" Version="1.7.62" />
<PackageReference Include="MudBlazor.Extensions" Version="1.7.63" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.0.1" />
<PackageReference Include="Toolbelt.Blazor.LoadingBar" Version="13.2.0" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Corsinvest.AppHero.Core.MudBlazorUI.Extensions;

public static class ModularityExtensions
{
public static string ToMBIcon(this IModularityService modularityService, string category)
public static string ToMBIcon(this IModularityService modularityService, string category)
=> MudBlazorHelper.ToMBIcon(modularityService.GetCategoryIcon(category));

public static string ToMBIcon(this IGroupableService groupableService) => MudBlazorHelper.ToMBIcon(groupableService.GetGroupIcon());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,7 @@ public static void InitializeIcons()
_ => string.Empty,
};

if (!string.IsNullOrEmpty(value))
{
IconConvert.Add($"{nameof(UIIcon)}.{item}", value);
}
if (!string.IsNullOrEmpty(value)) { IconConvert.Add($"{nameof(UIIcon)}.{item}", value); }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
using Humanizer;
using Microsoft.AspNetCore.Components.Rendering;
using MudBlazor.Extensions;
using MudBlazor.Extensions.Components.ObjectEdit;
using MudBlazor.Extensions.Components.ObjectEdit.Options;
Expand All @@ -16,6 +17,15 @@ namespace Corsinvest.AppHero.Core.MudBlazorUI.Helpers;

public static class MudExObjectEditFormHelper
{
class CustomRenderer : ICustomRenderer
{
public void Render(RenderTreeBuilder builder, IHandleEvent eventTarget, ObjectEditPropertyMeta propertyMeta)
{
// FixPropertyItem(propertyMeta);
}
}


public static void FixPropertyItem(ObjectEditPropertyMeta item)
{
if (!string.IsNullOrEmpty(item.GroupInfo.Name)) { item.GroupInfo.Name = item.GroupInfo.Name.Humanize(LetterCasing.Title); }
Expand Down Expand Up @@ -51,6 +61,13 @@ public static void FixPropertyItem(ObjectEditPropertyMeta item)
DisablePositionMargin = true
});

//item.Value
//RenderDataDefaults.RegisterDefault<ICollection<string>, MudExCollectionEditor<string>>(f => f.Items);

// item.RenderWith(new CustomRenderer());

//item.RenderData
//var cc =
//foreach (var item1 in item.MainEditMeta.Properties())
//{
// FixPropertyItem(item1, stringLocalizer);
Expand Down
6 changes: 3 additions & 3 deletions src/Corsinvest.AppHero.Core.MudBlazorUI/Module.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ public override async Task OnApplicationInitializationAsync(IHost host)
{
await Task.CompletedTask;
var modularityService = host.Services.GetRequiredService<IModularityService>();
modularityService.SetRenderIndex<Modularity.Module, MudBlazorUI.Pages.Modularity.Index>();
modularityService.SetRenderIndex<Options.Module, MudBlazorUI.Pages.Options.Index>();
modularityService.SetRenderIndex<Modularity.Module, Pages.Modularity.Index>();
modularityService.SetRenderIndex<Options.Module, Pages.Options.Index>();
//modularityService.SetRenderOptions<Notification.Email.Module, MudBlazorUI.Shared.Notification.Email.RenderOptions>();
modularityService.SetRenderIndex<Session.Module, MudBlazorUI.Pages.Session.Index>();
modularityService.SetRenderIndex<Session.Module, Pages.Session.Index>();

//security
modularityService.SetRenderOptions<Security.Module, Pages.Security.RenderOptions>();
Expand Down
30 changes: 11 additions & 19 deletions src/Corsinvest.AppHero.Core.MudBlazorUI/Shared/MainLayout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -70,28 +70,20 @@

<MudDivider Class="mt-auto"></MudDivider>

<MudNavMenu Class="d-flex justify-space-between pa-4">
<MudLink Href="@AppOptions.Url" Target="_blank"
Style="font-size:0.625rem; line-height:1.125rem; color: var(--mud-palette-text-primary) !important">
<b>@AppOptions.Author</b>
</MudLink>

@if (ReleaseInfo == null)
{
<MudBadge Content="@L["New version: {0}",ReleaseInfo?.Version].ToString()" Color="Color.Primary" OnClick="OpenRelease"
Origin="Origin.TopCenter" Style="cursor:pointer" Visible="@(ReleaseInfo != null)">

<div class="d-flex justify-space-between pa-4">
<MudLink Href="@AppOptions.Url" Target="_blank"
Style="font-size:0.625rem; line-height:1.125rem; color: var(--mud-palette-text-primary) !important">
<b>@AppOptions.Author</b>
</MudLink>

<MudText Style="font-size:0.625rem; line-height:1.125rem;color: var(--mud-palette-text-primary) !important">
@L["version"] @ApplicationHelper.ProductVersion
</MudText>
}
else
{
<MudBadge Content="@ReleaseInfo.Version" Color="Color.Primary" Origin="Origin.TopCenter" OnClick="OpenRelease"
Style="cursor:pointer">
<MudText Style="font-size:0.625rem; line-height:1.125rem;color: var(--mud-palette-text-primary) !important">
@L["version"] @ApplicationHelper.ProductVersion
</MudText>
</MudBadge>
}
</MudNavMenu>
</div>
</MudBadge>
</MudDrawer>

<MudMainContent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
Icon="@link.ToMBIcon()"
IconColor="@link.IconColor.ToMBColor()"
Match="NavLinkMatch.All"
Target="@(link.IsExternal ? "_blank" : null)"
Target="@(link.IsExternal ? "_blank" : null)"
Disabled="@(!link.Enabled)">
@link.Text
</MudNavLink>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ private async Task SubmitAsync()

InSaving = false;

Logger.LogInformation(L["Save options {Module}", Module.FullInfo]);
Logger.LogInformation(L["Save options {0}", Module.FullInfo]);
MudDialog.Close(DialogResult.Ok(true));
//force refresh
//NavigationManager.NavigateTo(NavigationManager.Uri, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
ShowCancelButton="false"
ShowSaveButton="false"
Localizer="L"
AutoHideDisabledFields
AutoHideDisabledFields="true"
GroupingStyle="GroupingStyle.DefaultExpansionPanel"
GroupElevation="1"
DefaultGroupName="@DefaultGroupName"
AutoSkeletonOnLoad
AutoSkeletonOnLoad="true"
AddScrollToTop="false"
ConfigureMetaInformationAlways
ConfigureMetaInformationAlways="true"
MetaConfiguration="@Configure" />
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* SPDX-FileCopyrightText: Copyright Corsinvest Srl
* SPDX-License-Identifier: AGPL-3.0-only
*/

namespace Corsinvest.AppHero.Core.MudBlazorUI.Style;

public class LayoutService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Radzen.Blazor" Version="4.13.5" />
<PackageReference Include="Radzen.Blazor" Version="4.13.6" />
</ItemGroup>

<ItemGroup>
Expand Down
1 change: 0 additions & 1 deletion src/Corsinvest.AppHero.Core/Helpers/ApplicationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* SPDX-FileCopyrightText: Copyright Corsinvest Srl
* SPDX-License-Identifier: AGPL-3.0-only
*/
using Microsoft.AspNetCore.Components;
using System.Reflection;
using System.Security.Cryptography;
using System.Text;
Expand Down
1 change: 0 additions & 1 deletion src/Corsinvest.AppHero.Core/Modularity/ModuleBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ public virtual void ConfigureServices(IServiceCollection services, IConfiguratio
//public virtual async Task ShutdownAsync() => await Task.CompletedTask;
public virtual async Task RefreshOptionsAsync(IServiceScope scope) => await Task.CompletedTask;


protected IServiceCollection AddOptions<TType>(IServiceCollection services, IConfiguration config, string? section = null) where TType : class, new()
{
Options = new()
Expand Down
1 change: 0 additions & 1 deletion src/Corsinvest.AppHero.Core/Modularity/ModuleCategory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* SPDX-FileCopyrightText: Copyright Corsinvest Srl
* SPDX-License-Identifier: AGPL-3.0-only
*/

namespace Corsinvest.AppHero.Core.Modularity;

public class ModuleCategory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* SPDX-FileCopyrightText: Copyright Corsinvest Srl
* SPDX-License-Identifier: AGPL-3.0-only
*/

namespace Corsinvest.AppHero.Core.Notification.WebHook;

public enum BodyType
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
using Corsinvest.AppHero.Core.Security.Identity;
/*
* SPDX-FileCopyrightText: Copyright Corsinvest Srl
* SPDX-License-Identifier: AGPL-3.0-only
*/
using Corsinvest.AppHero.Core.Security.Identity;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage;
using System.Security.Claims;
using System.Security.Cryptography;

namespace Corsinvest.AppHero.Core.Security.Auth;

public class AccessTokenProvider
public class AccessTokenProvider
{
private readonly string _tokenKey = nameof(_tokenKey);
private readonly ProtectedLocalStorage _localStorage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public override async Task<AuthenticationState> GetAuthenticationStateAsync()
public async Task<bool> LoginAsync(LoginRequest loginRequest)
{
var userManager = _serviceProvider.GetRequiredService<UserManager<ApplicationUser>>();

var user = await userManager.FindByNameAsync(loginRequest.Username);
var valid = user != null
&& user.IsActive
Expand Down Expand Up @@ -85,7 +86,7 @@ public async Task LogoutAsync()
}
else
{
_navigationManager.NavigateTo("/logout" ,true);
_navigationManager.NavigateTo("/logout", true);
}
//NotifyAuthenticationStateChanged(Task.FromResult(new AuthenticationState(_httpContextAccessor.HttpContext!.User)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* SPDX-FileCopyrightText: Copyright Corsinvest Srl
* SPDX-License-Identifier: AGPL-3.0-only
*/

namespace Corsinvest.AppHero.Core.SoftwareUpdater;

public class UpdaterOptions
Expand Down
2 changes: 1 addition & 1 deletion src/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ImplicitUsings>enable</ImplicitUsings>

<LangVersion>latest</LangVersion>
<Version>0.0.108</Version>
<Version>0.0.110</Version>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<!--<NoWarn>$(NoWarn);CS1591;CS0436</NoWarn>-->

Expand Down

0 comments on commit 688f51a

Please sign in to comment.