Updating Blazor Admin (#442)

* Updating Blazor services

* Adding Settings and Refactoring Services

* WIP - Fighting with DI

* Configuring dependencies in both Web Startup and BlazorAdmin Program.cs has them working again.

* Everything works; need to optimize calls to ListBrands

* LocalStorageBrandService decorator working

* Added cache duration of 1 minute

* Refactoring to reduce token storage
Fixed issue with dropdowns binding to int

* Remove token stuff from login; moved to CustomAuthStateProvider

* Migrated CatalogTypes to separate service
Implemented cache decorator

* Ardalis/blazor refactor (#440)

* 1. Migrate CatalogItemServices -> CatalogItemService.
3. Add caching to CatalogItemService.

* change to $"Loading {key} from local storage" ?

* docker settings added. (#441)

* docker settings added.

* InDocker Removed

* InDocker removed from web startup.

* removed unused using

* no reload list if close without save

* startup patch for localhost

* file name fixed

* removed docker from launchSettings.

* Configure logging via appsettings

Co-authored-by: Shady Nagy <info@shadynagy.com>
This commit is contained in:
Steve Smith
2020-07-30 23:50:51 -04:00
committed by GitHub
parent 98fb0ee8ce
commit e9a9dc06d7
77 changed files with 865 additions and 533 deletions

View File

@@ -0,0 +1,38 @@
using Microsoft.AspNetCore.Components.Forms;
namespace BlazorAdmin.Shared
{
/// <summary>
/// This is needed until 5.0 ships with native support
/// https://www.pragimtech.com/blog/blazor/inputselect-does-not-support-system.int32/
/// </summary>
/// <typeparam name="TValue"></typeparam>
public class CustomInputSelect<TValue> : InputSelect<TValue>
{
protected override bool TryParseValueFromString(string value, out TValue result,
out string validationErrorMessage)
{
if (typeof(TValue) == typeof(int))
{
if (int.TryParse(value, out var resultInt))
{
result = (TValue)(object)resultInt;
validationErrorMessage = null;
return true;
}
else
{
result = default;
validationErrorMessage =
$"The selected value {value} is not a valid number.";
return false;
}
}
else
{
return base.TryParseValueFromString(value, out result,
out validationErrorMessage);
}
}
}
}

View File

@@ -1,4 +1,4 @@
@inject AuthService Auth
@inject AuthenticationStateProvider AuthStateProvider
@inject IJSRuntime JSRuntime
@inherits BlazorAdmin.Helpers.BlazorLayoutComponent
@@ -25,8 +25,9 @@
{
if (firstRender)
{
await Auth.RefreshLoginInfoFromCookie();
if (!Auth.IsLoggedIn)
var authState = await AuthStateProvider.GetAuthenticationStateAsync();
if(authState.User == null)
{
await new Route(JSRuntime).RouteOutside("/Identity/Account/Login");
}
@@ -35,5 +36,4 @@
await base.OnAfterRenderAsync(firstRender);
}
}

View File

@@ -1,5 +1,4 @@
@inject AuthService Auth
@inherits BlazorAdmin.Helpers.BlazorComponent
@inherits BlazorAdmin.Helpers.BlazorComponent
<div class="top-row pl-4 navbar navbar-dark">
<a class="navbar-brand" href="">eShopOnWeb Admin</a>
<button class="navbar-toggler" @onclick="ToggleNavMenu">
@@ -14,28 +13,27 @@
<span class="oi oi-home" aria-hidden="true"></span> Home
</NavLink>
</li>
<li class="nav-item px-3">
<NavLink class="nav-link" href="manage/my-account" Match="NavLinkMatch.All">
<span class="oi oi-person" aria-hidden="true"></span> @Auth.UserName
</NavLink>
</li>
<AuthorizeView>
<Authorized>
<li class="nav-item px-3">
<NavLink class="nav-link" href="manage/my-account" Match="NavLinkMatch.All">
<span class="oi oi-person" aria-hidden="true"></span> @context.User.Identity.Name
<li class="nav-item px-3">
@if (Auth.IsLoggedIn)
{
<NavLink class="nav-link" href="logout">
<span class="oi oi-account-logout" aria-hidden="true"></span> Logout
</NavLink>
}
</li>
</NavLink>
</li>
<li class="nav-item px-3">
<NavLink class="nav-link" href="logout">
<span class="oi oi-account-logout" aria-hidden="true"></span> Logout
</NavLink>
</li>
</Authorized>
</AuthorizeView>
</ul>
</div>
@code {
private bool collapseNavMenu = true;
public string UserName { get; set; }
private string NavMenuCssClass => collapseNavMenu ? "collapse" : null;