Browse Source
* Added Blazor Client Configured PublicAPI CORS to allow traffic from client * Make admin page home page; remove extra pages Add CatalogType list endpoint * Wired up Types and Brands in the API and the admin list page * Adding a custom HttpClient to talk securely to API * Ardalis/blazor (#419) * Login added * AuthService will handel http request secure and not secure. * Logout added * CatalogBrandService in it is own service * Get token from localstorage when refresh. * used GetAsync * Fixed Login and Logout switch. * CatalogItemService added * CatalogTypeService added & Auth for CatalogType. using not used removed. * Made BlazorComponent and BlazorLayoutComponent for refresh. Index now small enough to be in one file. * Removed the service from program main and use lazy singleton. * used OnInitialized * Refactoring and detecting login status in login.razor * Refactoring login to redirect if user is already logged in * Blazor login with MVC (#420) * Blazor login with MVC * return back the PasswordSignInAsync in Login page * CRUD added (#422) * CRUD added * Unit Test changed to meet new redirect /admin * CreateCatalogItemRequest added. * Action caption added. * Validation added for name and price. * Updated port of api Redirect to returnUrl from login * Add username to /admin; link to my profile * Working on authorization of /admin * Working on custom auth locking down /admin page * Microsoft authorize working.Login.razor removed.Login from SignInMana… (#425) * Microsoft authorize working.Login.razor removed.Login from SignInManager and create token from it.unit test fixed. * GetTokenFromController function used in CustomAuthStateProvider * Cleaned up button styles Refactored to use codebehind for List component Updated Not Authorized view Co-authored-by: Shady Nagy <shadynagi@gmail.com>main
committed by
GitHub
86 changed files with 3266 additions and 80 deletions
@ -0,0 +1,30 @@ |
|||
<CascadingAuthenticationState> |
|||
<Router AppAssembly="@typeof(Program).Assembly"> |
|||
<Found Context="routeData"> |
|||
<AuthorizeRouteView RouteData="@routeData" |
|||
DefaultLayout="@typeof(MainLayout)"> |
|||
<NotAuthorized> |
|||
@if (!context.User.Identity.IsAuthenticated) |
|||
{ |
|||
<RedirectToLogin /> |
|||
} |
|||
else |
|||
{ |
|||
<h2>Not Authorized</h2> |
|||
<p> |
|||
You are not authorized to access |
|||
this resource. |
|||
|
|||
<a href="/">Return to eShop</a> |
|||
</p> |
|||
} |
|||
</NotAuthorized> |
|||
</AuthorizeRouteView> |
|||
</Found> |
|||
<NotFound> |
|||
<LayoutView Layout="@typeof(MainLayout)"> |
|||
<p>Sorry, there's nothing at this address.</p> |
|||
</LayoutView> |
|||
</NotFound> |
|||
</Router> |
|||
</CascadingAuthenticationState> |
|||
@ -0,0 +1,37 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk.Web"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netstandard2.1</TargetFramework> |
|||
<RazorLangVersion>3.0</RazorLangVersion> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Blazored.LocalStorage" Version="2.1.6" /> |
|||
<PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="3.1.5" /> |
|||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="3.2.0" /> |
|||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="3.2.0" /> |
|||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Build" Version="3.2.0" PrivateAssets="all" /> |
|||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="3.2.0" PrivateAssets="all" /> |
|||
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="3.1.5" /> |
|||
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" /> |
|||
<PackageReference Include="System.Net.Http.Json" Version="3.2.0" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\ApplicationCore\ApplicationCore.csproj" /> |
|||
<ProjectReference Include="..\Shared\Shared.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<Compile Update="Services\CatalogItem\Delete.EditCatalogItemResult.cs"> |
|||
<DependentUpon>Delete.cs</DependentUpon> |
|||
</Compile> |
|||
<Compile Update="Services\CatalogItem\GetById.EditCatalogItemResult.cs"> |
|||
<DependentUpon>GetById.cs</DependentUpon> |
|||
</Compile> |
|||
<Compile Update="Services\CatalogItem\Edit.CreateCatalogItemResult.cs"> |
|||
<DependentUpon>Edit.cs</DependentUpon> |
|||
</Compile> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,7 @@ |
|||
namespace BlazorAdmin |
|||
{ |
|||
public class Constants |
|||
{ |
|||
public const string API_URL = "https://localhost:5099/api/"; |
|||
} |
|||
} |
|||
@ -0,0 +1,83 @@ |
|||
using System; |
|||
using System.Net.Http; |
|||
using System.Net.Http.Json; |
|||
using BlazorAdmin.Services; |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using Microsoft.AspNetCore.Components.Authorization; |
|||
using System.Security.Claims; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Components; |
|||
using Microsoft.eShopWeb; |
|||
using Microsoft.Extensions.Logging; |
|||
using Shared.Authorization; |
|||
|
|||
namespace BlazorAdmin |
|||
{ |
|||
public class CustomAuthStateProvider : AuthenticationStateProvider |
|||
{ |
|||
private static readonly TimeSpan UserCacheRefreshInterval = TimeSpan.FromSeconds(60); |
|||
|
|||
private readonly AuthService _authService; |
|||
private readonly ILogger<CustomAuthStateProvider> _logger; |
|||
|
|||
private DateTimeOffset _userLastCheck = DateTimeOffset.FromUnixTimeSeconds(0); |
|||
private ClaimsPrincipal _cachedUser = new ClaimsPrincipal(new ClaimsIdentity()); |
|||
|
|||
public CustomAuthStateProvider(AuthService authService, ILogger<CustomAuthStateProvider> logger) |
|||
{ |
|||
_authService = authService; |
|||
_logger = logger; |
|||
} |
|||
|
|||
public override async Task<AuthenticationState> GetAuthenticationStateAsync() => |
|||
new AuthenticationState(await GetUser(useCache: true)); |
|||
|
|||
private async ValueTask<ClaimsPrincipal> GetUser(bool useCache = false) |
|||
{ |
|||
var now = DateTimeOffset.Now; |
|||
if (useCache && now < _userLastCheck + UserCacheRefreshInterval) |
|||
{ |
|||
return _cachedUser; |
|||
} |
|||
|
|||
_cachedUser = await FetchUser(); |
|||
_userLastCheck = now; |
|||
|
|||
return _cachedUser; |
|||
} |
|||
|
|||
private async Task<ClaimsPrincipal> FetchUser() |
|||
{ |
|||
UserInfo user = null; |
|||
|
|||
try |
|||
{ |
|||
user = await _authService.GetTokenFromController(); |
|||
} |
|||
catch (Exception exc) |
|||
{ |
|||
_logger.LogWarning(exc, "Fetching user failed."); |
|||
} |
|||
|
|||
if (user == null || !user.IsAuthenticated) |
|||
{ |
|||
return new ClaimsPrincipal(new ClaimsIdentity()); |
|||
} |
|||
|
|||
var identity = new ClaimsIdentity( |
|||
nameof(CustomAuthStateProvider), |
|||
user.NameClaimType, |
|||
user.RoleClaimType); |
|||
|
|||
if (user.Claims != null) |
|||
{ |
|||
foreach (var claim in user.Claims) |
|||
{ |
|||
identity.AddClaim(new Claim(claim.Type, claim.Value)); |
|||
} |
|||
} |
|||
|
|||
return new ClaimsPrincipal(identity); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,26 @@ |
|||
using Microsoft.AspNetCore.Components; |
|||
|
|||
namespace BlazorAdmin.Helpers |
|||
{ |
|||
public class BlazorComponent : ComponentBase |
|||
{ |
|||
private readonly RefreshBroadcast _refresh = RefreshBroadcast.Instance; |
|||
|
|||
protected override void OnInitialized() |
|||
{ |
|||
_refresh.RefreshRequested += DoRefresh; |
|||
base.OnInitialized(); |
|||
} |
|||
|
|||
public void CallRequestRefresh() |
|||
{ |
|||
_refresh.CallRequestRefresh(); |
|||
} |
|||
|
|||
private void DoRefresh() |
|||
{ |
|||
StateHasChanged(); |
|||
} |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
using System.Threading.Tasks; |
|||
using BlazorAdmin.Services; |
|||
using Microsoft.AspNetCore.Components; |
|||
|
|||
namespace BlazorAdmin.Helpers |
|||
{ |
|||
public class BlazorLayoutComponent : LayoutComponentBase |
|||
{ |
|||
private readonly RefreshBroadcast _refresh = RefreshBroadcast.Instance; |
|||
|
|||
protected override void OnInitialized() |
|||
{ |
|||
_refresh.RefreshRequested += DoRefresh; |
|||
base.OnInitialized(); |
|||
} |
|||
|
|||
public void CallRequestRefresh() |
|||
{ |
|||
_refresh.CallRequestRefresh(); |
|||
} |
|||
|
|||
private void DoRefresh() |
|||
{ |
|||
StateHasChanged(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
using System; |
|||
|
|||
namespace BlazorAdmin.Helpers |
|||
{ |
|||
internal sealed class RefreshBroadcast |
|||
{ |
|||
private static readonly Lazy<RefreshBroadcast> |
|||
Lazy = |
|||
new Lazy<RefreshBroadcast> |
|||
(() => new RefreshBroadcast()); |
|||
|
|||
public static RefreshBroadcast Instance => Lazy.Value; |
|||
|
|||
private RefreshBroadcast() |
|||
{ |
|||
} |
|||
|
|||
public event Action RefreshRequested; |
|||
public void CallRequestRefresh() |
|||
{ |
|||
RefreshRequested?.Invoke(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Components; |
|||
using Microsoft.JSInterop; |
|||
|
|||
namespace BlazorAdmin.JavaScript |
|||
{ |
|||
public class Cookies |
|||
{ |
|||
private readonly IJSRuntime _jsRuntime; |
|||
|
|||
public Cookies(IJSRuntime jsRuntime) |
|||
{ |
|||
_jsRuntime = jsRuntime; |
|||
} |
|||
|
|||
public async Task DeleteCookie(string name) |
|||
{ |
|||
await _jsRuntime.InvokeAsync<string>("deleteCookie", name); |
|||
} |
|||
|
|||
public async Task<string> GetCookie(string name) |
|||
{ |
|||
return await _jsRuntime.InvokeAsync<string>("getCookie", name); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Components; |
|||
using Microsoft.JSInterop; |
|||
|
|||
namespace BlazorAdmin.JavaScript |
|||
{ |
|||
public class Route |
|||
{ |
|||
private readonly IJSRuntime _jsRuntime; |
|||
|
|||
public Route(IJSRuntime jsRuntime) |
|||
{ |
|||
_jsRuntime = jsRuntime; |
|||
} |
|||
|
|||
public async Task RouteOutside(string path) |
|||
{ |
|||
await _jsRuntime.InvokeAsync<string>("routeOutside", path); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,37 @@ |
|||
using Microsoft.AspNetCore.Components.WebAssembly.Authentication; |
|||
using System.Collections.Generic; |
|||
using System.Net.Http; |
|||
using System.Net.Http.Json; |
|||
using System.Threading.Tasks; |
|||
using BlazorAdmin.Services.CatalogBrandService; |
|||
|
|||
namespace BlazorAdmin.Network |
|||
{ |
|||
public class SecureHttpClient |
|||
{ |
|||
private readonly HttpClient client; |
|||
|
|||
public SecureHttpClient(HttpClient client) |
|||
{ |
|||
this.client = client; |
|||
|
|||
this.client.DefaultRequestHeaders.Add("Authorization", $"Bearer "); |
|||
} |
|||
|
|||
public async Task<List<CatalogBrand>> GetCatalogBrandsAsync() |
|||
{ |
|||
var brands = new List<CatalogBrand>(); |
|||
|
|||
try |
|||
{ |
|||
brands = (await client.GetFromJsonAsync<CatalogBrandResult>($"{Constants.API_URL}catalog-brands")).CatalogBrands; |
|||
} |
|||
catch (AccessTokenNotAvailableException exception) |
|||
{ |
|||
exception.Redirect(); |
|||
} |
|||
|
|||
return brands; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,111 @@ |
|||
@inject ILogger<Create> Logger |
|||
@inject AuthService Auth |
|||
|
|||
@inherits BlazorAdmin.Helpers.BlazorComponent |
|||
|
|||
@namespace BlazorAdmin.Pages.CatalogItemPage |
|||
|
|||
<h2 class="esh-body-title">Create</h2> |
|||
|
|||
<div> |
|||
<EditForm Model="_item" OnValidSubmit="@CreateClick"> |
|||
<DataAnnotationsValidator /> |
|||
|
|||
<div class="form-group"> |
|||
<label class="control-label col-md-2">Name</label> |
|||
<div class="col-md-3"> |
|||
<InputText class="form-control" @bind-Value="_item.Name" /> |
|||
<ValidationMessage For="(() => _item.Name)" /> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="form-group"> |
|||
<label class="control-label col-md-2">Description</label> |
|||
<div class="col-md-3"> |
|||
<InputText class="form-control" @bind-Value="_item.Description" /> |
|||
<ValidationMessage For="(() => _item.Description)" /> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="form-group"> |
|||
<label class="control-label col-md-2">Brand</label> |
|||
<div class="col-md-3"> |
|||
<InputSelect @bind-Value="_item.CatalogBrandId" class="form-control"> |
|||
@foreach (var brand in Brands) |
|||
{ |
|||
<option value="@brand.Id">@brand.Name</option> |
|||
} |
|||
</InputSelect> |
|||
<ValidationMessage For="(() => _item.CatalogBrandId)" /> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="form-group"> |
|||
<label class="control-label col-md-2">Type</label> |
|||
<div class="col-md-3"> |
|||
<InputSelect @bind-Value="_item.CatalogTypeId" class="form-control"> |
|||
@foreach (var type in Types) |
|||
{ |
|||
<option value="@type.Id">@type.Name</option> |
|||
} |
|||
</InputSelect> |
|||
<ValidationMessage For="(() => _item.CatalogTypeId)" /> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="form-group"> |
|||
<label class="control-label col-md-2">Price</label> |
|||
<div class="col-md-3"> |
|||
<InputNumber @bind-Value="_item.Price" class="form-control" /> |
|||
<ValidationMessage For="(() => _item.Price)" /> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="form-group"> |
|||
<label class="control-label col-md-2">Picture name</label> |
|||
<div class="col-md-4 esh-form-information"> |
|||
Uploading images not allowed for this version. |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="form-group"> |
|||
<div class="col-md-offset-2 col-md-3 text-right esh-button-actions"> |
|||
<a href="" @onclick="@(() => OnCloseClick.InvokeAsync(null))" @onclick:preventDefault class="btn btn-secondary"> |
|||
Cancel |
|||
</a> |
|||
<button type="submit" class="btn esh-button btn-primary"> |
|||
Create |
|||
</button> |
|||
</div> |
|||
</div> |
|||
</EditForm> |
|||
</div> |
|||
|
|||
@code { |
|||
|
|||
[Parameter] |
|||
public IEnumerable<CatalogBrand> Brands { get; set; } |
|||
[Parameter] |
|||
public IEnumerable<CatalogType> Types { get; set; } |
|||
|
|||
[Parameter] |
|||
public EventCallback<string> OnCloseClick { get; set; } |
|||
|
|||
private readonly CreateCatalogItemRequest _item = new CreateCatalogItemRequest(); |
|||
|
|||
protected override async Task OnAfterRenderAsync(bool firstRender) |
|||
{ |
|||
Logger.LogInformation("Now loading... /Catalog/Create"); |
|||
|
|||
_item.CatalogTypeId = Types.First().Id; |
|||
_item.CatalogBrandId = Brands.First().Id; |
|||
|
|||
await base.OnAfterRenderAsync(firstRender); |
|||
} |
|||
|
|||
private async Task CreateClick() |
|||
{ |
|||
await new BlazorAdmin.Services.CatalogItemService.Create(Auth).HandleAsync(_item); |
|||
await OnCloseClick.InvokeAsync(null); |
|||
} |
|||
} |
|||
@ -0,0 +1,95 @@ |
|||
@inject ILogger<Delete> Logger |
|||
@inject AuthService Auth |
|||
|
|||
@inherits BlazorAdmin.Helpers.BlazorComponent |
|||
|
|||
@namespace BlazorAdmin.Pages.CatalogItemPage |
|||
|
|||
<div class="container"> |
|||
<div class="row"> |
|||
<img class="col-md-6 esh-picture" src="@($"https://localhost:44315/{_item.PictureUri}")"> |
|||
|
|||
<dl class="col-md-6 dl-horizontal"> |
|||
<dt> |
|||
Name |
|||
</dt> |
|||
|
|||
<dd> |
|||
@_item.Name |
|||
</dd> |
|||
|
|||
<dt> |
|||
Description |
|||
</dt> |
|||
|
|||
<dd> |
|||
@_item.Description |
|||
</dd> |
|||
|
|||
<dt> |
|||
Brand |
|||
</dt> |
|||
|
|||
<dd> |
|||
@Services.CatalogBrandService.List.GetBrandName(Brands, _item.CatalogBrandId) |
|||
</dd> |
|||
|
|||
<dt> |
|||
Type |
|||
</dt> |
|||
|
|||
<dd> |
|||
@Services.CatalogTypeService.List.GetTypeName(Types, _item.CatalogTypeId) |
|||
</dd> |
|||
<dt> |
|||
Price |
|||
</dt> |
|||
|
|||
<dd> |
|||
@_item.Price |
|||
</dd> |
|||
</dl> |
|||
</div> |
|||
|
|||
<div class="form-actions no-color"> |
|||
<a href="" @onclick="@(() => OnCloseClick.InvokeAsync(null))" @onclick:preventDefault class="btn btn-secondary"> |
|||
Cancel |
|||
</a> |
|||
<button class="btn btn-danger" @onclick="DeleteClick"> |
|||
Delete |
|||
</button> |
|||
</div> |
|||
|
|||
</div> |
|||
|
|||
@code { |
|||
[Parameter] |
|||
public int Id { get; set; } |
|||
[Parameter] |
|||
public IEnumerable<CatalogBrand> Brands { get; set; } |
|||
[Parameter] |
|||
public IEnumerable<CatalogType> Types { get; set; } |
|||
|
|||
[Parameter] |
|||
public EventCallback<string> OnCloseClick { get; set; } |
|||
|
|||
private CatalogItem _item = new CatalogItem(); |
|||
|
|||
protected override async Task OnInitializedAsync() |
|||
{ |
|||
Logger.LogInformation("Now loading... /Catalog/Delete/{Id}", Id); |
|||
|
|||
_item = await new GetById(Auth).HandleAsync(Id); |
|||
|
|||
await base.OnInitializedAsync(); |
|||
} |
|||
|
|||
private async Task DeleteClick() |
|||
{ |
|||
// TODO: Add some kind of "are you sure" check before this |
|||
|
|||
await new BlazorAdmin.Services.CatalogItemService.Delete(Auth).HandleAsync(Id); |
|||
|
|||
await OnCloseClick.InvokeAsync(null); |
|||
} |
|||
} |
|||
@ -0,0 +1,99 @@ |
|||
@inject ILogger<Details> Logger |
|||
@inject AuthService Auth |
|||
|
|||
@inherits BlazorAdmin.Helpers.BlazorComponent |
|||
|
|||
@namespace BlazorAdmin.Pages.CatalogItemPage |
|||
|
|||
@if (_item == null) |
|||
{ |
|||
<p><em>Loading...</em></p> |
|||
} |
|||
else |
|||
{ |
|||
<h2 class="esh-body-title">Details</h2> |
|||
|
|||
<div class="container"> |
|||
<div class="row"> |
|||
<img class="col-md-6 esh-picture" src="@($"https://localhost:44315/{_item.PictureUri}")"> |
|||
|
|||
<dl class="col-md-6 dl-horizontal"> |
|||
<dt> |
|||
Name |
|||
</dt> |
|||
|
|||
<dd> |
|||
@_item.Name |
|||
</dd> |
|||
|
|||
<dt> |
|||
Description |
|||
</dt> |
|||
|
|||
<dd> |
|||
@_item.Description |
|||
</dd> |
|||
|
|||
<dt> |
|||
Brand |
|||
</dt> |
|||
|
|||
<dd> |
|||
@Services.CatalogBrandService.List.GetBrandName(Brands, _item.CatalogBrandId) |
|||
</dd> |
|||
|
|||
<dt> |
|||
Type |
|||
</dt> |
|||
|
|||
<dd> |
|||
@Services.CatalogTypeService.List.GetTypeName(Types, _item.CatalogTypeId) |
|||
</dd> |
|||
<dt> |
|||
Price |
|||
</dt> |
|||
|
|||
<dd> |
|||
@_item.Price |
|||
</dd> |
|||
|
|||
</dl> |
|||
</div> |
|||
|
|||
<div class="form-actions no-color"> |
|||
<a href="" @onclick="@(() => OnCloseClick.InvokeAsync(null))" @onclick:preventDefault class="btn btn-secondary"> |
|||
Cancel |
|||
</a> |
|||
<a href="" @onclick="@(() => OnEditClick.InvokeAsync(_item.Id))" @onclick:preventDefault class="btn btn-secondary"> |
|||
Edit |
|||
</a> |
|||
</div> |
|||
|
|||
</div> |
|||
} |
|||
@code { |
|||
[Parameter] |
|||
public int Id { get; set; } |
|||
[Parameter] |
|||
public IEnumerable<CatalogBrand> Brands { get; set; } |
|||
[Parameter] |
|||
public IEnumerable<CatalogType> Types { get; set; } |
|||
|
|||
[Parameter] |
|||
public EventCallback<string> OnCloseClick { get; set; } |
|||
[Parameter] |
|||
public EventCallback<int> OnEditClick { get; set; } |
|||
|
|||
private CatalogItem _item = new CatalogItem(); |
|||
|
|||
protected override async Task OnInitializedAsync() |
|||
{ |
|||
Logger.LogInformation("Now loading... /Catalog/Details/{Id}", Id); |
|||
|
|||
_item = await new GetById(Auth).HandleAsync(Id); |
|||
StateHasChanged(); |
|||
|
|||
await base.OnInitializedAsync(); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,110 @@ |
|||
@inject ILogger<Edit> Logger |
|||
@inject AuthService Auth |
|||
|
|||
@inherits BlazorAdmin.Helpers.BlazorComponent |
|||
|
|||
@namespace BlazorAdmin.Pages.CatalogItemPage |
|||
|
|||
<h2 class="esh-body-title">Edit</h2> |
|||
|
|||
<div> |
|||
<EditForm Model="_item" OnValidSubmit="@SaveClick"> |
|||
<DataAnnotationsValidator /> |
|||
|
|||
<div class="form-group"> |
|||
<label class="control-label col-md-2">Name</label> |
|||
<div class="col-md-3"> |
|||
<InputText class="form-control" @bind-Value="_item.Name" /> |
|||
<ValidationMessage For="(() => _item.Name)" /> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="form-group"> |
|||
<label class="control-label col-md-2">Description</label> |
|||
<div class="col-md-3"> |
|||
<InputText class="form-control" @bind-Value="_item.Description" /> |
|||
<ValidationMessage For="(() => _item.Description)" /> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="form-group"> |
|||
<label class="control-label col-md-2">Brand</label> |
|||
<div class="col-md-3"> |
|||
<InputSelect @bind-Value="_item.CatalogBrandId" class="form-control"> |
|||
@foreach (var brand in Brands) |
|||
{ |
|||
<option value="@brand.Id">@brand.Name</option> |
|||
} |
|||
</InputSelect> |
|||
<ValidationMessage For="(() => _item.CatalogBrandId)" /> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="form-group"> |
|||
<label class="control-label col-md-2">Type</label> |
|||
<div class="col-md-3"> |
|||
<InputSelect @bind-Value="_item.CatalogTypeId" class="form-control"> |
|||
@foreach (var type in Types) |
|||
{ |
|||
<option value="@type.Id">@type.Name</option> |
|||
} |
|||
</InputSelect> |
|||
<ValidationMessage For="(() => _item.CatalogTypeId)" /> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="form-group"> |
|||
<label class="control-label col-md-2">Price</label> |
|||
<div class="col-md-3"> |
|||
<InputNumber @bind-Value="_item.Price" class="form-control" /> |
|||
<ValidationMessage For="(() => _item.Price)" /> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="form-group"> |
|||
<label class="control-label col-md-2">Picture name</label> |
|||
<div class="col-md-4 esh-form-information"> |
|||
Uploading images not allowed for this version. |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="form-group"> |
|||
<div class="col-md-offset-2 col-md-3 text-right esh-button-actions"> |
|||
<a href="" @onclick="@(() => OnCloseClick.InvokeAsync(null))" @onclick:preventDefault class="btn btn-secondary"> |
|||
Cancel |
|||
</a> |
|||
<button type="submit" class="btn btn-primary"> |
|||
Save |
|||
</button> |
|||
</div> |
|||
</div> |
|||
</EditForm> |
|||
</div> |
|||
|
|||
@code { |
|||
[Parameter] |
|||
public int Id { get; set; } |
|||
[Parameter] |
|||
public IEnumerable<CatalogBrand> Brands { get; set; } |
|||
[Parameter] |
|||
public IEnumerable<CatalogType> Types { get; set; } |
|||
|
|||
[Parameter] |
|||
public EventCallback<string> OnCloseClick { get; set; } |
|||
|
|||
private CatalogItem _item = new CatalogItem(); |
|||
|
|||
protected override async Task OnInitializedAsync() |
|||
{ |
|||
Logger.LogInformation("Now loading... /Catalog/Edit/{Id}", Id); |
|||
|
|||
_item = await new GetById(Auth).HandleAsync(Id); |
|||
|
|||
await base.OnInitializedAsync(); |
|||
} |
|||
|
|||
private async Task SaveClick() |
|||
{ |
|||
await new BlazorAdmin.Services.CatalogItemService.Edit(Auth).HandleAsync(_item); |
|||
} |
|||
} |
|||
@ -0,0 +1,82 @@ |
|||
@page "/admin" |
|||
@attribute [Authorize(Roles = Microsoft.eShopWeb.ApplicationCore.Constants.AuthorizationConstants.Roles.ADMINISTRATORS)] |
|||
@inject AuthService Auth |
|||
@inherits BlazorAdmin.Helpers.BlazorComponent |
|||
@namespace BlazorAdmin.Pages.CatalogItemPage |
|||
|
|||
<h1>Manage Product Catalog</h1> |
|||
|
|||
@if (catalogItems == null) |
|||
{ |
|||
<p><em>Loading...</em></p> |
|||
} |
|||
else |
|||
{ |
|||
@if (!showCreate && !showDetails && !showEdit && !showDelete) |
|||
{ |
|||
<p class="esh-link-wrapper"> |
|||
<button class="btn btn-primary" @onclick="@(() => CreateClick())"> |
|||
Create New |
|||
</button> |
|||
</p> |
|||
|
|||
<table class="table table-striped table-hover"> |
|||
<thead> |
|||
<tr> |
|||
<th></th> |
|||
<th>Item Type</th> |
|||
<th>Brand</th> |
|||
<th>Id</th> |
|||
<th>Name</th> |
|||
<th>@nameof(CatalogItem.Description)</th> |
|||
<th>@nameof(CatalogItem.Price)</th> |
|||
<th>Actions</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody class="cursor-pointer"> |
|||
@foreach (var item in catalogItems) |
|||
{ |
|||
<tr @onclick="@(() => DetailsClick(item.Id))"> |
|||
<td> |
|||
<img class="img-thumbnail" src="@($"https://localhost:44315/{item.PictureUri}")"> |
|||
</td> |
|||
<td>@Services.CatalogTypeService.List.GetTypeName(catalogTypes, item.CatalogTypeId)</td> |
|||
<td>@Services.CatalogBrandService.List.GetBrandName(catalogBrands, item.CatalogBrandId)</td> |
|||
<td>@item.Id</td> |
|||
<td>@item.Name</td> |
|||
<td>@item.Description</td> |
|||
<td>@item.Price</td> |
|||
<td> |
|||
<a href="" @onclick="@(() => EditClick(item.Id))" @onclick:preventDefault class="btn btn-primary"> |
|||
Edit |
|||
</a> |
|||
|
|||
<a href="" @onclick="@(() => DeleteClick(item.Id))" @onclick:preventDefault class="btn btn-primary"> |
|||
Delete |
|||
</a> |
|||
</td> |
|||
</tr> |
|||
} |
|||
</tbody> |
|||
</table> |
|||
} |
|||
@if (showDetails) |
|||
{ |
|||
<Details Id="@selectedId" Brands="@catalogBrands" Types="@catalogTypes" OnCloseClick="CloseDetailsHandler" OnEditClick="EditDetailsHandler"></Details> |
|||
} |
|||
|
|||
@if (showEdit) |
|||
{ |
|||
<Edit Id="@selectedId" Brands="@catalogBrands" Types="@catalogTypes" OnCloseClick="CloseEditHandler"></Edit> |
|||
} |
|||
|
|||
@if (showCreate) |
|||
{ |
|||
<Create Brands="@catalogBrands" Types="@catalogTypes" OnCloseClick="CloseCreateHandler"></Create> |
|||
} |
|||
|
|||
@if (showDelete) |
|||
{ |
|||
<Delete Id="@selectedId" Brands="@catalogBrands" Types="@catalogTypes" OnCloseClick="CloseDeleteHandler"></Delete> |
|||
} |
|||
} |
|||
@ -0,0 +1,95 @@ |
|||
using BlazorAdmin.Helpers; |
|||
using BlazorAdmin.Services.CatalogBrandService; |
|||
using BlazorAdmin.Services.CatalogItemService; |
|||
using BlazorAdmin.Services.CatalogTypeService; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace BlazorAdmin.Pages.CatalogItemPage |
|||
{ |
|||
public partial class List : BlazorComponent |
|||
{ |
|||
private List<CatalogItem> catalogItems = new List<CatalogItem>(); |
|||
private List<CatalogType> catalogTypes = new List<CatalogType>(); |
|||
private List<CatalogBrand> catalogBrands = new List<CatalogBrand>(); |
|||
private bool showCreate = false; |
|||
private bool showDetails = false; |
|||
private bool showEdit = false; |
|||
private bool showDelete = false; |
|||
private int selectedId = 0; |
|||
|
|||
protected override async Task OnAfterRenderAsync(bool firstRender) |
|||
{ |
|||
if (firstRender) |
|||
{ |
|||
catalogItems = await new BlazorAdmin.Services.CatalogItemService.ListPaged(Auth).HandleAsync(50); |
|||
catalogTypes = await new BlazorAdmin.Services.CatalogTypeService.List(Auth).HandleAsync(); |
|||
catalogBrands = await new BlazorAdmin.Services.CatalogBrandService.List(Auth).HandleAsync(); |
|||
|
|||
CallRequestRefresh(); |
|||
} |
|||
|
|||
await base.OnAfterRenderAsync(firstRender); |
|||
} |
|||
|
|||
private void DetailsClick(int id) |
|||
{ |
|||
selectedId = id; |
|||
showDetails = true; |
|||
} |
|||
|
|||
private void CreateClick() |
|||
{ |
|||
showCreate = true; |
|||
} |
|||
|
|||
private void EditClick(int id) |
|||
{ |
|||
selectedId = id; |
|||
showEdit = true; |
|||
} |
|||
|
|||
private void DeleteClick(int id) |
|||
{ |
|||
selectedId = id; |
|||
showDelete = true; |
|||
} |
|||
|
|||
private async Task CloseDetailsHandler(string action) |
|||
{ |
|||
showDetails = false; |
|||
await ReloadCatalogItems(); |
|||
} |
|||
|
|||
private void EditDetailsHandler(int id) |
|||
{ |
|||
showDetails = false; |
|||
selectedId = id; |
|||
showEdit = true; |
|||
} |
|||
|
|||
private async Task CloseEditHandler(string action) |
|||
{ |
|||
showEdit = false; |
|||
await ReloadCatalogItems(); |
|||
} |
|||
|
|||
private async Task CloseDeleteHandler(string action) |
|||
{ |
|||
showDelete = false; |
|||
await ReloadCatalogItems(); |
|||
} |
|||
|
|||
private async Task CloseCreateHandler(string action) |
|||
{ |
|||
showCreate = false; |
|||
await ReloadCatalogItems(); |
|||
} |
|||
|
|||
private async Task ReloadCatalogItems() |
|||
{ |
|||
catalogItems = await new BlazorAdmin.Services.CatalogItemService.ListPaged(Auth).HandleAsync(50); |
|||
StateHasChanged(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
@page "/logout" |
|||
@inject AuthService AuthService |
|||
@inject NavigationManager NavigationManager |
|||
@inject IJSRuntime JSRuntime |
|||
@inherits BlazorAdmin.Helpers.BlazorComponent |
|||
|
|||
|
|||
@code { |
|||
|
|||
|
|||
protected override async Task OnInitializedAsync() |
|||
{ |
|||
await AuthService.Logout(); |
|||
await DeleteCookies(); |
|||
|
|||
CallRequestRefresh(); |
|||
await new Route(JSRuntime).RouteOutside("/Identity/Account/Login"); |
|||
} |
|||
|
|||
private async Task DeleteCookies() |
|||
{ |
|||
await new Cookies(JSRuntime).DeleteCookie("token"); |
|||
await new Cookies(JSRuntime).DeleteCookie("username"); |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,34 @@ |
|||
using System; |
|||
using System.Net.Http; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Components.WebAssembly.Hosting; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using BlazorAdmin.Network; |
|||
using BlazorAdmin.Services; |
|||
using Blazored.LocalStorage; |
|||
using Microsoft.AspNetCore.Components.Authorization; |
|||
using Microsoft.AspNetCore.Authorization; |
|||
|
|||
namespace BlazorAdmin |
|||
{ |
|||
public class Program |
|||
{ |
|||
public static async Task Main(string[] args) |
|||
{ |
|||
var builder = WebAssemblyHostBuilder.CreateDefault(args); |
|||
builder.RootComponents.Add<App>("admin"); |
|||
|
|||
builder.Services.AddTransient(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); |
|||
builder.Services.AddTransient(sp => new SecureHttpClient(sp.GetRequiredService<HttpClient>())); |
|||
|
|||
builder.Services.AddSingleton<ILocalStorageService, LocalStorageService>(); |
|||
builder.Services.AddSingleton<AuthService>(); |
|||
|
|||
builder.Services.AddAuthorizationCore(); |
|||
builder.Services.AddSingleton<AuthenticationStateProvider, CustomAuthStateProvider>(); |
|||
builder.Services.AddSingleton(sp => (CustomAuthStateProvider)sp.GetRequiredService<AuthenticationStateProvider>()); |
|||
|
|||
await builder.Build().RunAsync(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
{ |
|||
"iisSettings": { |
|||
"windowsAuthentication": false, |
|||
"anonymousAuthentication": true, |
|||
"iisExpress": { |
|||
"applicationUrl": "http://localhost:58126", |
|||
"sslPort": 44315 |
|||
} |
|||
}, |
|||
"profiles": { |
|||
"IIS Express": { |
|||
"commandName": "IISExpress", |
|||
"launchBrowser": true, |
|||
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", |
|||
"environmentVariables": { |
|||
"ASPNETCORE_ENVIRONMENT": "Development" |
|||
} |
|||
}, |
|||
"BlazorAdmin": { |
|||
"commandName": "Project", |
|||
"launchBrowser": true, |
|||
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", |
|||
"applicationUrl": "https://localhost:5001;http://localhost:5000", |
|||
"environmentVariables": { |
|||
"ASPNETCORE_ENVIRONMENT": "Development" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,8 @@ |
|||
namespace BlazorAdmin.Services |
|||
{ |
|||
public class AuthRequest |
|||
{ |
|||
public string Username { get; set; } |
|||
public string Password { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
namespace BlazorAdmin.Services |
|||
{ |
|||
public class AuthResponse |
|||
{ |
|||
public AuthResponse() |
|||
{ |
|||
} |
|||
|
|||
public bool Result { get; set; } = false; |
|||
public string Token { get; set; } = string.Empty; |
|||
public string Username { get; set; } = string.Empty; |
|||
public bool IsLockedOut { get; set; } = false; |
|||
public bool IsNotAllowed { get; set; } = false; |
|||
public bool RequiresTwoFactor { get; set; } = false; |
|||
} |
|||
} |
|||
@ -0,0 +1,220 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Net.Http; |
|||
using System.Net.Http.Headers; |
|||
using System.Net.Http.Json; |
|||
using System.Security.Claims; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using BlazorAdmin.JavaScript; |
|||
using Blazored.LocalStorage; |
|||
using Microsoft.AspNetCore.Identity; |
|||
using Microsoft.JSInterop; |
|||
using Newtonsoft.Json; |
|||
using Shared.Authorization; |
|||
|
|||
namespace BlazorAdmin.Services |
|||
{ |
|||
public class AuthService |
|||
{ |
|||
private readonly HttpClient _httpClient; |
|||
private readonly ILocalStorageService _localStorage; |
|||
public bool IsLoggedIn { get; set; } |
|||
public string UserName { get; set; } |
|||
|
|||
public AuthService(HttpClient httpClient, ILocalStorageService localStorage) |
|||
{ |
|||
_httpClient = httpClient; |
|||
_localStorage = localStorage; |
|||
} |
|||
|
|||
public HttpClient GetHttpClient() |
|||
{ |
|||
return _httpClient; |
|||
} |
|||
|
|||
public async Task<AuthResponse> LoginWithoutSaveToLocalStorage(AuthRequest user) |
|||
{ |
|||
var jsonContent = new StringContent(JsonConvert.SerializeObject(user), Encoding.UTF8, "application/json"); |
|||
var response = await _httpClient.PostAsync($"{Constants.API_URL}authenticate", jsonContent); |
|||
var authResponse = new AuthResponse(); |
|||
|
|||
if (response.IsSuccessStatusCode) |
|||
{ |
|||
authResponse = await DeserializeToAuthResponse(response); |
|||
|
|||
IsLoggedIn = true; |
|||
} |
|||
|
|||
return authResponse; |
|||
} |
|||
|
|||
public async Task<AuthResponse> Login(AuthRequest user) |
|||
{ |
|||
var jsonContent = new StringContent(JsonConvert.SerializeObject(user), Encoding.UTF8, "application/json"); |
|||
var response = await _httpClient.PostAsync($"{Constants.API_URL}authenticate", jsonContent); |
|||
var authResponse = new AuthResponse(); |
|||
|
|||
if (response.IsSuccessStatusCode) |
|||
{ |
|||
authResponse = await DeserializeToAuthResponse(response); |
|||
await SaveTokenInLocalStorage(authResponse); |
|||
await SaveUsernameInLocalStorage(authResponse); |
|||
await SetAuthorizationHeader(); |
|||
|
|||
UserName = await GetUsername(); |
|||
IsLoggedIn = true; |
|||
} |
|||
|
|||
return authResponse; |
|||
} |
|||
|
|||
public async Task Logout() |
|||
{ |
|||
await _localStorage.RemoveItemAsync("authToken"); |
|||
await _localStorage.RemoveItemAsync("username"); |
|||
|
|||
RemoveAuthorizationHeader(); |
|||
UserName = null; |
|||
IsLoggedIn = false; |
|||
} |
|||
|
|||
public async Task RefreshLoginInfo() |
|||
{ |
|||
await SetLoginData(); |
|||
} |
|||
|
|||
public async Task RefreshLoginInfoFromCookie(IJSRuntime jSRuntime) |
|||
{ |
|||
var token = await new Cookies(jSRuntime).GetCookie("token"); |
|||
await SaveTokenInLocalStorage(token); |
|||
|
|||
var username = await new Cookies(jSRuntime).GetCookie("username"); |
|||
await SaveUsernameInLocalStorage(username); |
|||
|
|||
await RefreshLoginInfo(); |
|||
} |
|||
|
|||
private async Task SetLoginData() |
|||
{ |
|||
IsLoggedIn = !string.IsNullOrEmpty(await GetToken()); |
|||
UserName = await GetUsername(); |
|||
await SetAuthorizationHeader(); |
|||
} |
|||
|
|||
private async Task<AuthResponse> DeserializeToAuthResponse(HttpResponseMessage response) |
|||
{ |
|||
var responseContent = await response.Content.ReadAsStringAsync(); |
|||
return JsonConvert.DeserializeObject<AuthResponse>(responseContent); |
|||
} |
|||
|
|||
private async Task SaveTokenInLocalStorage(AuthResponse authResponse) |
|||
{ |
|||
await _localStorage.SetItemAsync("authToken", SaveTokenInLocalStorage(authResponse.Token)); |
|||
} |
|||
|
|||
private async Task SaveTokenInLocalStorage(string token) |
|||
{ |
|||
if (string.IsNullOrEmpty(token)) |
|||
{ |
|||
return; |
|||
} |
|||
await _localStorage.SetItemAsync("authToken", token); |
|||
} |
|||
|
|||
private void RemoveAuthorizationHeader() |
|||
{ |
|||
if (_httpClient.DefaultRequestHeaders.Contains("Authorization")) |
|||
{ |
|||
_httpClient.DefaultRequestHeaders.Remove("Authorization"); |
|||
} |
|||
} |
|||
|
|||
private async Task SaveUsernameInLocalStorage(AuthResponse authResponse) |
|||
{ |
|||
await _localStorage.SetItemAsync("username", SaveUsernameInLocalStorage(authResponse.Username)); |
|||
} |
|||
|
|||
private async Task SaveUsernameInLocalStorage(string username) |
|||
{ |
|||
if (string.IsNullOrEmpty(username)) |
|||
{ |
|||
return; |
|||
} |
|||
await _localStorage.SetItemAsync("username", username); |
|||
} |
|||
|
|||
public async Task<string> GetToken() |
|||
{ |
|||
|
|||
var token = await _localStorage.GetItemAsync<string>("authToken"); |
|||
return token; |
|||
} |
|||
|
|||
public async Task<UserInfo> GetTokenFromController() |
|||
{ |
|||
return await _httpClient.GetFromJsonAsync<UserInfo>("User"); |
|||
} |
|||
|
|||
public async Task<string> GetUsername() |
|||
{ |
|||
var username = await _localStorage.GetItemAsync<string>("username"); |
|||
return username; |
|||
} |
|||
|
|||
private async Task SetAuthorizationHeader() |
|||
{ |
|||
var token = await GetToken(); |
|||
_httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); |
|||
} |
|||
|
|||
public IEnumerable<Claim> ParseClaimsFromJwt(string jwt) |
|||
{ |
|||
var claims = new List<Claim>(); |
|||
if (string.IsNullOrEmpty(jwt)) |
|||
{ |
|||
return claims; |
|||
} |
|||
|
|||
var payload = jwt.Split('.')[1]; |
|||
var jsonBytes = ParseBase64WithoutPadding(payload); |
|||
var keyValuePairs = JsonConvert.DeserializeObject<Dictionary<string, object>>(Encoding.UTF8.GetString(jsonBytes)); |
|||
|
|||
keyValuePairs.TryGetValue(ClaimTypes.Role, out object roles); |
|||
|
|||
if (roles != null) |
|||
{ |
|||
if (roles.ToString().Trim().StartsWith("[")) |
|||
{ |
|||
var parsedRoles = JsonConvert.DeserializeObject<string[]>(roles.ToString()); |
|||
|
|||
foreach (var parsedRole in parsedRoles) |
|||
{ |
|||
claims.Add(new Claim(ClaimTypes.Role, parsedRole)); |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
claims.Add(new Claim(ClaimTypes.Role, roles.ToString())); |
|||
} |
|||
|
|||
keyValuePairs.Remove(ClaimTypes.Role); |
|||
} |
|||
|
|||
claims.AddRange(keyValuePairs.Select(kvp => new Claim(kvp.Key, kvp.Value.ToString()))); |
|||
|
|||
return claims; |
|||
} |
|||
|
|||
private byte[] ParseBase64WithoutPadding(string base64) |
|||
{ |
|||
switch (base64.Length % 4) |
|||
{ |
|||
case 2: base64 += "=="; break; |
|||
case 3: base64 += "="; break; |
|||
} |
|||
return Convert.FromBase64String(base64); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,8 @@ |
|||
namespace BlazorAdmin.Services.CatalogBrandService |
|||
{ |
|||
public class CatalogBrand |
|||
{ |
|||
public int Id { get; set; } |
|||
public string Name { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
using System.Collections.Generic; |
|||
|
|||
namespace BlazorAdmin.Services.CatalogBrandService |
|||
{ |
|||
public class CatalogBrandResult |
|||
{ |
|||
public List<CatalogBrand> CatalogBrands { get; set; } = new List<CatalogBrand>(); |
|||
} |
|||
} |
|||
@ -0,0 +1,53 @@ |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Net; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Components.WebAssembly.Authentication; |
|||
using Newtonsoft.Json; |
|||
|
|||
namespace BlazorAdmin.Services.CatalogBrandService |
|||
{ |
|||
public class List |
|||
{ |
|||
private readonly AuthService _authService; |
|||
|
|||
public List(AuthService authService) |
|||
{ |
|||
_authService = authService; |
|||
} |
|||
|
|||
public async Task<List<CatalogBrand>> HandleAsync() |
|||
{ |
|||
var brands = new List<CatalogBrand>(); |
|||
if (!_authService.IsLoggedIn) |
|||
{ |
|||
return brands; |
|||
} |
|||
|
|||
try |
|||
{ |
|||
var result = (await _authService.GetHttpClient().GetAsync($"{Constants.API_URL}catalog-brands")); |
|||
if (result.StatusCode != HttpStatusCode.OK) |
|||
{ |
|||
return brands; |
|||
} |
|||
|
|||
brands = JsonConvert.DeserializeObject<CatalogBrandResult>(await result.Content.ReadAsStringAsync()).CatalogBrands; |
|||
} |
|||
catch (AccessTokenNotAvailableException) |
|||
{ |
|||
return brands; |
|||
} |
|||
|
|||
return brands; |
|||
} |
|||
|
|||
public static string GetBrandName(IEnumerable<CatalogBrand> brands, int brandId) |
|||
{ |
|||
var type = brands.FirstOrDefault(t => t.Id == brandId); |
|||
|
|||
return type == null ? "None" : type.Name; |
|||
} |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,26 @@ |
|||
using System.ComponentModel.DataAnnotations; |
|||
|
|||
namespace BlazorAdmin.Services.CatalogItemService |
|||
{ |
|||
public class CatalogItem |
|||
{ |
|||
public int Id { get; set; } |
|||
|
|||
public int CatalogTypeId { get; set; } |
|||
|
|||
public int CatalogBrandId { get; set; } |
|||
|
|||
[Required(ErrorMessage = "The Name field is required")] |
|||
public string Name { get; set; } |
|||
|
|||
public string Description { get; set; } |
|||
|
|||
// decimal(18,2)
|
|||
[RegularExpression(@"^\d+(\.\d{0,2})*$", ErrorMessage = "The field Price must be a positive number with maximum two decimals.")] |
|||
[Range(0, 9999999999999999.99)] |
|||
[DataType(DataType.Currency)] |
|||
public decimal Price { get; set; } |
|||
|
|||
public string PictureUri { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
using System.ComponentModel.DataAnnotations; |
|||
|
|||
namespace BlazorAdmin.Services.CatalogItemService |
|||
{ |
|||
public class CreateCatalogItemRequest |
|||
{ |
|||
public int CatalogTypeId { get; set; } |
|||
|
|||
public int CatalogBrandId { get; set; } |
|||
|
|||
[Required(ErrorMessage = "The Name field is required")] |
|||
public string Name { get; set; } = string.Empty; |
|||
|
|||
public string Description { get; set; } = string.Empty; |
|||
|
|||
// decimal(18,2)
|
|||
[RegularExpression(@"^\d+(\.\d{0,2})*$", ErrorMessage = "The field Price must be a positive number with maximum two decimals.")] |
|||
[Range(0, 9999999999999999.99)] |
|||
[DataType(DataType.Currency)] |
|||
public decimal Price { get; set; } = 0; |
|||
|
|||
public string PictureUri { get; set; } = string.Empty; |
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace BlazorAdmin.Services.CatalogItemService |
|||
{ |
|||
public class CreateCatalogItemResult |
|||
{ |
|||
public CatalogItem CatalogItem { get; set; } = new CatalogItem(); |
|||
} |
|||
} |
|||
@ -0,0 +1,38 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Net; |
|||
using System.Net.Http; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Newtonsoft.Json; |
|||
|
|||
namespace BlazorAdmin.Services.CatalogItemService |
|||
{ |
|||
public class Create |
|||
{ |
|||
private readonly AuthService _authService; |
|||
|
|||
public Create(AuthService authService) |
|||
{ |
|||
_authService = authService; |
|||
} |
|||
|
|||
public async Task<CatalogItem> HandleAsync(CreateCatalogItemRequest catalogItem) |
|||
{ |
|||
var catalogItemResult = new CatalogItem(); |
|||
|
|||
var content = new StringContent(JsonConvert.SerializeObject(catalogItem), Encoding.UTF8, "application/json"); |
|||
|
|||
var result = await _authService.GetHttpClient().PostAsync($"{Constants.API_URL}catalog-items", content); |
|||
if (result.StatusCode != HttpStatusCode.OK) |
|||
{ |
|||
return catalogItemResult; |
|||
} |
|||
|
|||
catalogItemResult = JsonConvert.DeserializeObject<CreateCatalogItemResult>(await result.Content.ReadAsStringAsync()).CatalogItem; |
|||
|
|||
return catalogItemResult; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace BlazorAdmin.Services.CatalogItemService |
|||
{ |
|||
public class DeleteCatalogItemResult |
|||
{ |
|||
public string Status { get; set; } = "Deleted"; |
|||
} |
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Net; |
|||
using System.Net.Http; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Newtonsoft.Json; |
|||
|
|||
namespace BlazorAdmin.Services.CatalogItemService |
|||
{ |
|||
public class Delete |
|||
{ |
|||
private readonly AuthService _authService; |
|||
|
|||
public Delete(AuthService authService) |
|||
{ |
|||
_authService = authService; |
|||
} |
|||
|
|||
public async Task<string> HandleAsync(int catalogItemId) |
|||
{ |
|||
var catalogItemResult = string.Empty; |
|||
|
|||
var result = await _authService.GetHttpClient().DeleteAsync($"{Constants.API_URL}catalog-items/{catalogItemId}"); |
|||
if (result.StatusCode != HttpStatusCode.OK) |
|||
{ |
|||
return catalogItemResult; |
|||
} |
|||
|
|||
catalogItemResult = JsonConvert.DeserializeObject<DeleteCatalogItemResult>(await result.Content.ReadAsStringAsync()).Status; |
|||
|
|||
return catalogItemResult; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace BlazorAdmin.Services.CatalogItemService |
|||
{ |
|||
public class EditCatalogItemResult |
|||
{ |
|||
public CatalogItem CatalogItem { get; set; } = new CatalogItem(); |
|||
} |
|||
} |
|||
@ -0,0 +1,38 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Net; |
|||
using System.Net.Http; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Newtonsoft.Json; |
|||
|
|||
namespace BlazorAdmin.Services.CatalogItemService |
|||
{ |
|||
public class Edit |
|||
{ |
|||
private readonly AuthService _authService; |
|||
|
|||
public Edit(AuthService authService) |
|||
{ |
|||
_authService = authService; |
|||
} |
|||
|
|||
public async Task<CatalogItem> HandleAsync(CatalogItem catalogItem) |
|||
{ |
|||
var catalogItemResult = new CatalogItem(); |
|||
|
|||
var content = new StringContent(JsonConvert.SerializeObject(catalogItem), Encoding.UTF8, "application/json"); |
|||
|
|||
var result = await _authService.GetHttpClient().PutAsync($"{Constants.API_URL}catalog-items", content); |
|||
if (result.StatusCode != HttpStatusCode.OK) |
|||
{ |
|||
return catalogItemResult; |
|||
} |
|||
|
|||
catalogItemResult = JsonConvert.DeserializeObject<EditCatalogItemResult>(await result.Content.ReadAsStringAsync()).CatalogItem; |
|||
|
|||
return catalogItemResult; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace BlazorAdmin.Services.CatalogItemService |
|||
{ |
|||
public class GetByIdCatalogItemResult |
|||
{ |
|||
public CatalogItem CatalogItem { get; set; } = new CatalogItem(); |
|||
} |
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Net; |
|||
using System.Net.Http; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Newtonsoft.Json; |
|||
|
|||
namespace BlazorAdmin.Services.CatalogItemService |
|||
{ |
|||
public class GetById |
|||
{ |
|||
private readonly AuthService _authService; |
|||
|
|||
public GetById(AuthService authService) |
|||
{ |
|||
_authService = authService; |
|||
} |
|||
|
|||
public async Task<CatalogItem> HandleAsync(int catalogItemId) |
|||
{ |
|||
var catalogItemResult = new CatalogItem(); |
|||
|
|||
var result = await _authService.GetHttpClient().GetAsync($"{Constants.API_URL}catalog-items/{catalogItemId}"); |
|||
if (result.StatusCode != HttpStatusCode.OK) |
|||
{ |
|||
return catalogItemResult; |
|||
} |
|||
|
|||
catalogItemResult = JsonConvert.DeserializeObject<EditCatalogItemResult>(await result.Content.ReadAsStringAsync()).CatalogItem; |
|||
|
|||
return catalogItemResult; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,10 @@ |
|||
using System.Collections.Generic; |
|||
|
|||
namespace BlazorAdmin.Services.CatalogItemService |
|||
{ |
|||
public class PagedCatalogItemResult |
|||
{ |
|||
public List<CatalogItem> CatalogItems { get; set; } = new List<CatalogItem>(); |
|||
public int PageCount { get; set; } = 0; |
|||
} |
|||
} |
|||
@ -0,0 +1,33 @@ |
|||
using System.Collections.Generic; |
|||
using System.Net; |
|||
using System.Threading.Tasks; |
|||
using Newtonsoft.Json; |
|||
|
|||
namespace BlazorAdmin.Services.CatalogItemService |
|||
{ |
|||
public class ListPaged |
|||
{ |
|||
private readonly AuthService _authService; |
|||
|
|||
public ListPaged(AuthService authService) |
|||
{ |
|||
_authService = authService; |
|||
} |
|||
|
|||
public async Task<List<CatalogItem>> HandleAsync(int pageSize) |
|||
{ |
|||
var catalogItems = new List<CatalogItem>(); |
|||
|
|||
var result = (await _authService.GetHttpClient().GetAsync($"{Constants.API_URL}catalog-items?PageSize={pageSize}")); |
|||
if (result.StatusCode != HttpStatusCode.OK) |
|||
{ |
|||
return catalogItems; |
|||
} |
|||
|
|||
catalogItems = JsonConvert.DeserializeObject<PagedCatalogItemResult>(await result.Content.ReadAsStringAsync()).CatalogItems; |
|||
|
|||
return catalogItems; |
|||
} |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,8 @@ |
|||
namespace BlazorAdmin.Services.CatalogTypeService |
|||
{ |
|||
public class CatalogType |
|||
{ |
|||
public int Id { get; set; } |
|||
public string Name { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
using System.Collections.Generic; |
|||
|
|||
namespace BlazorAdmin.Services.CatalogTypeService |
|||
{ |
|||
public class CatalogTypeResult |
|||
{ |
|||
public List<CatalogType> CatalogTypes { get; set; } = new List<CatalogType>(); |
|||
} |
|||
} |
|||
@ -0,0 +1,54 @@ |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Net; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Components.WebAssembly.Authentication; |
|||
using Newtonsoft.Json; |
|||
|
|||
namespace BlazorAdmin.Services.CatalogTypeService |
|||
{ |
|||
public class List |
|||
{ |
|||
private readonly AuthService _authService; |
|||
|
|||
public List(AuthService authService) |
|||
{ |
|||
_authService = authService; |
|||
} |
|||
|
|||
public async Task<List<CatalogType>> HandleAsync() |
|||
{ |
|||
var types = new List<CatalogType>(); |
|||
|
|||
if (!_authService.IsLoggedIn) |
|||
{ |
|||
return types; |
|||
} |
|||
|
|||
try |
|||
{ |
|||
var result = (await _authService.GetHttpClient().GetAsync($"{Constants.API_URL}catalog-types")); |
|||
if (result.StatusCode != HttpStatusCode.OK) |
|||
{ |
|||
return types; |
|||
} |
|||
|
|||
types = JsonConvert.DeserializeObject<CatalogTypeResult>(await result.Content.ReadAsStringAsync()).CatalogTypes; |
|||
} |
|||
catch (AccessTokenNotAvailableException) |
|||
{ |
|||
return types; |
|||
} |
|||
|
|||
return types; |
|||
} |
|||
|
|||
public static string GetTypeName(IEnumerable<CatalogType> types, int typeId) |
|||
{ |
|||
var type = types.FirstOrDefault(t => t.Id == typeId); |
|||
|
|||
return type == null ? "None" : type.Name; |
|||
} |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,42 @@ |
|||
@using BlazorAdmin.Services |
|||
@using BlazorAdmin.JavaScript |
|||
|
|||
@inject AuthService Auth |
|||
@inject IJSRuntime JSRuntime |
|||
|
|||
@inherits BlazorAdmin.Helpers.BlazorLayoutComponent |
|||
|
|||
<AuthorizeView Roles=@Microsoft.eShopWeb.ApplicationCore.Constants.AuthorizationConstants.Roles.ADMINISTRATORS> |
|||
<div class="sidebar"> |
|||
<NavMenu /> |
|||
</div> |
|||
</AuthorizeView> |
|||
|
|||
<div class="main"> |
|||
<div class="top-row px-4"> |
|||
<a href="https://github.com/dotnet-architecture/eShopOnWeb" target="_blank" class="ml-md-auto">About eShopOnWeb</a> |
|||
</div> |
|||
|
|||
<div class="content px-4"> |
|||
@Body |
|||
</div> |
|||
</div> |
|||
|
|||
@code |
|||
{ |
|||
protected override async Task OnAfterRenderAsync(bool firstRender) |
|||
{ |
|||
if (firstRender) |
|||
{ |
|||
await Auth.RefreshLoginInfoFromCookie(JSRuntime); |
|||
if (!Auth.IsLoggedIn) |
|||
{ |
|||
await new Route(JSRuntime).RouteOutside("/Identity/Account/Login"); |
|||
} |
|||
CallRequestRefresh(); |
|||
} |
|||
|
|||
await base.OnAfterRenderAsync(firstRender); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,54 @@ |
|||
@inject AuthService Auth |
|||
@inherits BlazorAdmin.Helpers.BlazorComponent |
|||
|
|||
@using BlazorAdmin.Services |
|||
<div class="top-row pl-4 navbar navbar-dark"> |
|||
<a class="navbar-brand" href="">eShopOnWeb Admin</a> |
|||
<button class="navbar-toggler" @onclick="ToggleNavMenu"> |
|||
<span class="navbar-toggler-icon"></span> |
|||
</button> |
|||
</div> |
|||
|
|||
<div class="@NavMenuCssClass" @onclick="ToggleNavMenu"> |
|||
<ul class="nav flex-column"> |
|||
<li class="nav-item px-3"> |
|||
<NavLink class="nav-link" href="admin" Match="NavLinkMatch.All"> |
|||
<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> |
|||
|
|||
<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> |
|||
} |
|||
else |
|||
{ |
|||
<NavLink class="nav-link" href="login"> |
|||
<span class="oi oi-account-login" aria-hidden="true"></span> Login |
|||
</NavLink> |
|||
} |
|||
|
|||
</li> |
|||
</ul> |
|||
</div> |
|||
|
|||
@code { |
|||
|
|||
private bool collapseNavMenu = true; |
|||
public string UserName { get; set; } |
|||
|
|||
private string NavMenuCssClass => collapseNavMenu ? "collapse" : null; |
|||
|
|||
private void ToggleNavMenu() |
|||
{ |
|||
collapseNavMenu = !collapseNavMenu; |
|||
} |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
@inject NavigationManager Navigation |
|||
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication |
|||
@code { |
|||
protected override void OnInitialized() |
|||
{ |
|||
Navigation.NavigateTo($"authentication/login?returnUrl=" + |
|||
Uri.EscapeDataString(Navigation.Uri)); |
|||
} |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
@using System.Net.Http |
|||
@using System.Net.Http.Json |
|||
@using Microsoft.AspNetCore.Authorization; |
|||
@using Microsoft.AspNetCore.Components.Authorization |
|||
@using Microsoft.AspNetCore.Components.Forms |
|||
@using Microsoft.AspNetCore.Components.Routing |
|||
@using Microsoft.AspNetCore.Components.Web |
|||
@using Microsoft.AspNetCore.Components.WebAssembly.Http |
|||
@using Microsoft.JSInterop |
|||
@using BlazorAdmin |
|||
@using BlazorAdmin.Shared |
|||
@using BlazorAdmin.Network |
|||
@using BlazorAdmin.Services |
|||
@using BlazorAdmin.Services.CatalogBrandService |
|||
@using BlazorAdmin.Services.CatalogItemService |
|||
@using BlazorAdmin.Services.CatalogTypeService |
|||
@using Microsoft.Extensions.Logging |
|||
@using BlazorAdmin.JavaScript |
|||
@ -0,0 +1,192 @@ |
|||
@import url('open-iconic/font/css/open-iconic-bootstrap.min.css'); |
|||
|
|||
html, body { |
|||
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; |
|||
} |
|||
|
|||
a, .btn-link { |
|||
color: #0366d6; |
|||
} |
|||
|
|||
.btn-primary { |
|||
color: #fff; |
|||
background-color: #1b6ec2; |
|||
border-color: #1861ac; |
|||
} |
|||
|
|||
admin { |
|||
position: relative; |
|||
display: flex; |
|||
flex-direction: column; |
|||
} |
|||
|
|||
.top-row { |
|||
height: 3.5rem; |
|||
display: flex; |
|||
align-items: center; |
|||
} |
|||
|
|||
.main { |
|||
flex: 1; |
|||
} |
|||
|
|||
.main .top-row { |
|||
background-color: #f7f7f7; |
|||
border-bottom: 1px solid #d6d5d5; |
|||
justify-content: flex-end; |
|||
} |
|||
|
|||
.main .top-row > a, .main .top-row .btn-link { |
|||
white-space: nowrap; |
|||
margin-left: 1.5rem; |
|||
} |
|||
|
|||
.main .top-row a:first-child { |
|||
overflow: hidden; |
|||
text-overflow: ellipsis; |
|||
} |
|||
|
|||
.sidebar { |
|||
background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%); |
|||
} |
|||
|
|||
.sidebar .top-row { |
|||
background-color: rgba(0,0,0,0.4); |
|||
} |
|||
|
|||
.sidebar .navbar-brand { |
|||
font-size: 1.1rem; |
|||
} |
|||
|
|||
.sidebar .oi { |
|||
width: 2rem; |
|||
font-size: 1.1rem; |
|||
vertical-align: text-top; |
|||
top: -2px; |
|||
} |
|||
|
|||
.sidebar .nav-item { |
|||
font-size: 0.9rem; |
|||
padding-bottom: 0.5rem; |
|||
} |
|||
|
|||
.sidebar .nav-item:first-of-type { |
|||
padding-top: 1rem; |
|||
} |
|||
|
|||
.sidebar .nav-item:last-of-type { |
|||
padding-bottom: 1rem; |
|||
} |
|||
|
|||
.sidebar .nav-item a { |
|||
color: #d7d7d7; |
|||
border-radius: 4px; |
|||
height: 3rem; |
|||
display: flex; |
|||
align-items: center; |
|||
line-height: 3rem; |
|||
} |
|||
|
|||
.sidebar .nav-item a.active { |
|||
background-color: rgba(255,255,255,0.25); |
|||
color: white; |
|||
} |
|||
|
|||
.sidebar .nav-item a:hover { |
|||
background-color: rgba(255,255,255,0.1); |
|||
color: white; |
|||
} |
|||
|
|||
.content { |
|||
padding-top: 1.1rem; |
|||
} |
|||
|
|||
.navbar-toggler { |
|||
background-color: rgba(255, 255, 255, 0.1); |
|||
} |
|||
|
|||
.valid.modified:not([type=checkbox]) { |
|||
outline: 1px solid #26b050; |
|||
} |
|||
|
|||
.invalid { |
|||
outline: 1px solid red; |
|||
} |
|||
|
|||
.validation-message { |
|||
color: red; |
|||
} |
|||
|
|||
#blazor-error-ui { |
|||
background: lightyellow; |
|||
bottom: 0; |
|||
box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); |
|||
display: none; |
|||
left: 0; |
|||
padding: 0.6rem 1.25rem 0.7rem 1.25rem; |
|||
position: fixed; |
|||
width: 100%; |
|||
z-index: 1000; |
|||
} |
|||
|
|||
#blazor-error-ui .dismiss { |
|||
cursor: pointer; |
|||
position: absolute; |
|||
right: 0.75rem; |
|||
top: 0.5rem; |
|||
} |
|||
|
|||
.cursor-pointer { |
|||
cursor: pointer; |
|||
} |
|||
|
|||
.img-thumbnail { |
|||
max-width: 120px; |
|||
height: auto; |
|||
} |
|||
|
|||
@media (max-width: 767.98px) { |
|||
.main .top-row:not(.auth) { |
|||
display: none; |
|||
} |
|||
|
|||
.main .top-row.auth { |
|||
justify-content: space-between; |
|||
} |
|||
|
|||
.main .top-row a, .main .top-row .btn-link { |
|||
margin-left: 0; |
|||
} |
|||
} |
|||
|
|||
@media (min-width: 768px) { |
|||
admin { |
|||
flex-direction: row; |
|||
} |
|||
|
|||
.sidebar { |
|||
width: 250px; |
|||
height: 100vh; |
|||
position: sticky; |
|||
top: 0; |
|||
} |
|||
|
|||
.main .top-row { |
|||
position: sticky; |
|||
top: 0; |
|||
} |
|||
|
|||
.main > div { |
|||
padding-left: 2rem !important; |
|||
padding-right: 1.5rem !important; |
|||
} |
|||
|
|||
.navbar-toggler { |
|||
display: none; |
|||
} |
|||
|
|||
.sidebar .collapse { |
|||
/* Never collapse the sidebar for wide screens */ |
|||
display: block; |
|||
} |
|||
} |
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,86 @@ |
|||
SIL OPEN FONT LICENSE Version 1.1 |
|||
|
|||
Copyright (c) 2014 Waybury |
|||
|
|||
PREAMBLE |
|||
The goals of the Open Font License (OFL) are to stimulate worldwide |
|||
development of collaborative font projects, to support the font creation |
|||
efforts of academic and linguistic communities, and to provide a free and |
|||
open framework in which fonts may be shared and improved in partnership |
|||
with others. |
|||
|
|||
The OFL allows the licensed fonts to be used, studied, modified and |
|||
redistributed freely as long as they are not sold by themselves. The |
|||
fonts, including any derivative works, can be bundled, embedded, |
|||
redistributed and/or sold with any software provided that any reserved |
|||
names are not used by derivative works. The fonts and derivatives, |
|||
however, cannot be released under any other type of license. The |
|||
requirement for fonts to remain under this license does not apply |
|||
to any document created using the fonts or their derivatives. |
|||
|
|||
DEFINITIONS |
|||
"Font Software" refers to the set of files released by the Copyright |
|||
Holder(s) under this license and clearly marked as such. This may |
|||
include source files, build scripts and documentation. |
|||
|
|||
"Reserved Font Name" refers to any names specified as such after the |
|||
copyright statement(s). |
|||
|
|||
"Original Version" refers to the collection of Font Software components as |
|||
distributed by the Copyright Holder(s). |
|||
|
|||
"Modified Version" refers to any derivative made by adding to, deleting, |
|||
or substituting -- in part or in whole -- any of the components of the |
|||
Original Version, by changing formats or by porting the Font Software to a |
|||
new environment. |
|||
|
|||
"Author" refers to any designer, engineer, programmer, technical |
|||
writer or other person who contributed to the Font Software. |
|||
|
|||
PERMISSION & CONDITIONS |
|||
Permission is hereby granted, free of charge, to any person obtaining |
|||
a copy of the Font Software, to use, study, copy, merge, embed, modify, |
|||
redistribute, and sell modified and unmodified copies of the Font |
|||
Software, subject to the following conditions: |
|||
|
|||
1) Neither the Font Software nor any of its individual components, |
|||
in Original or Modified Versions, may be sold by itself. |
|||
|
|||
2) Original or Modified Versions of the Font Software may be bundled, |
|||
redistributed and/or sold with any software, provided that each copy |
|||
contains the above copyright notice and this license. These can be |
|||
included either as stand-alone text files, human-readable headers or |
|||
in the appropriate machine-readable metadata fields within text or |
|||
binary files as long as those fields can be easily viewed by the user. |
|||
|
|||
3) No Modified Version of the Font Software may use the Reserved Font |
|||
Name(s) unless explicit written permission is granted by the corresponding |
|||
Copyright Holder. This restriction only applies to the primary font name as |
|||
presented to the users. |
|||
|
|||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font |
|||
Software shall not be used to promote, endorse or advertise any |
|||
Modified Version, except to acknowledge the contribution(s) of the |
|||
Copyright Holder(s) and the Author(s) or with their explicit written |
|||
permission. |
|||
|
|||
5) The Font Software, modified or unmodified, in part or in whole, |
|||
must be distributed entirely under this license, and must not be |
|||
distributed under any other license. The requirement for fonts to |
|||
remain under this license does not apply to any document created |
|||
using the Font Software. |
|||
|
|||
TERMINATION |
|||
This license becomes null and void if any of the above conditions are |
|||
not met. |
|||
|
|||
DISCLAIMER |
|||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
|||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF |
|||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT |
|||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE |
|||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL |
|||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM |
|||
OTHER DEALINGS IN THE FONT SOFTWARE. |
|||
@ -0,0 +1,21 @@ |
|||
The MIT License (MIT) |
|||
|
|||
Copyright (c) 2014 Waybury |
|||
|
|||
Permission is hereby granted, free of charge, to any person obtaining a copy |
|||
of this software and associated documentation files (the "Software"), to deal |
|||
in the Software without restriction, including without limitation the rights |
|||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|||
copies of the Software, and to permit persons to whom the Software is |
|||
furnished to do so, subject to the following conditions: |
|||
|
|||
The above copyright notice and this permission notice shall be included in |
|||
all copies or substantial portions of the Software. |
|||
|
|||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|||
THE SOFTWARE. |
|||
@ -0,0 +1,114 @@ |
|||
[Open Iconic v1.1.1](http://useiconic.com/open) |
|||
=========== |
|||
|
|||
### Open Iconic is the open source sibling of [Iconic](http://useiconic.com). It is a hyper-legible collection of 223 icons with a tiny footprint—ready to use with Bootstrap and Foundation. [View the collection](http://useiconic.com/open#icons) |
|||
|
|||
|
|||
|
|||
## What's in Open Iconic? |
|||
|
|||
* 223 icons designed to be legible down to 8 pixels |
|||
* Super-light SVG files - 61.8 for the entire set |
|||
* SVG sprite—the modern replacement for icon fonts |
|||
* Webfont (EOT, OTF, SVG, TTF, WOFF), PNG and WebP formats |
|||
* Webfont stylesheets (including versions for Bootstrap and Foundation) in CSS, LESS, SCSS and Stylus formats |
|||
* PNG and WebP raster images in 8px, 16px, 24px, 32px, 48px and 64px. |
|||
|
|||
|
|||
## Getting Started |
|||
|
|||
#### For code samples and everything else you need to get started with Open Iconic, check out our [Icons](http://useiconic.com/open#icons) and [Reference](http://useiconic.com/open#reference) sections. |
|||
|
|||
### General Usage |
|||
|
|||
#### Using Open Iconic's SVGs |
|||
|
|||
We like SVGs and we think they're the way to display icons on the web. Since Open Iconic are just basic SVGs, we suggest you display them like you would any other image (don't forget the `alt` attribute). |
|||
|
|||
``` |
|||
<img src="/open-iconic/svg/icon-name.svg" alt="icon name"> |
|||
``` |
|||
|
|||
#### Using Open Iconic's SVG Sprite |
|||
|
|||
Open Iconic also comes in a SVG sprite which allows you to display all the icons in the set with a single request. It's like an icon font, without being a hack. |
|||
|
|||
Adding an icon from an SVG sprite is a little different than what you're used to, but it's still a piece of cake. *Tip: To make your icons easily style able, we suggest adding a general class to the* `<svg>` *tag and a unique class name for each different icon in the* `<use>` *tag.* |
|||
|
|||
``` |
|||
<svg class="icon"> |
|||
<use xlink:href="open-iconic.svg#account-login" class="icon-account-login"></use> |
|||
</svg> |
|||
``` |
|||
|
|||
Sizing icons only needs basic CSS. All the icons are in a square format, so just set the `<svg>` tag with equal width and height dimensions. |
|||
|
|||
``` |
|||
.icon { |
|||
width: 16px; |
|||
height: 16px; |
|||
} |
|||
``` |
|||
|
|||
Coloring icons is even easier. All you need to do is set the `fill` rule on the `<use>` tag. |
|||
|
|||
``` |
|||
.icon-account-login { |
|||
fill: #f00; |
|||
} |
|||
``` |
|||
|
|||
To learn more about SVG Sprites, read [Chris Coyier's guide](http://css-tricks.com/svg-sprites-use-better-icon-fonts/). |
|||
|
|||
#### Using Open Iconic's Icon Font... |
|||
|
|||
|
|||
##### …with Bootstrap |
|||
|
|||
You can find our Bootstrap stylesheets in `font/css/open-iconic-bootstrap.{css, less, scss, styl}` |
|||
|
|||
|
|||
``` |
|||
<link href="/open-iconic/font/css/open-iconic-bootstrap.css" rel="stylesheet"> |
|||
``` |
|||
|
|||
|
|||
``` |
|||
<span class="oi oi-icon-name" title="icon name" aria-hidden="true"></span> |
|||
``` |
|||
|
|||
##### …with Foundation |
|||
|
|||
You can find our Foundation stylesheets in `font/css/open-iconic-foundation.{css, less, scss, styl}` |
|||
|
|||
``` |
|||
<link href="/open-iconic/font/css/open-iconic-foundation.css" rel="stylesheet"> |
|||
``` |
|||
|
|||
|
|||
``` |
|||
<span class="fi-icon-name" title="icon name" aria-hidden="true"></span> |
|||
``` |
|||
|
|||
##### …on its own |
|||
|
|||
You can find our default stylesheets in `font/css/open-iconic.{css, less, scss, styl}` |
|||
|
|||
``` |
|||
<link href="/open-iconic/font/css/open-iconic.css" rel="stylesheet"> |
|||
``` |
|||
|
|||
``` |
|||
<span class="oi" data-glyph="icon-name" title="icon name" aria-hidden="true"></span> |
|||
``` |
|||
|
|||
|
|||
## License |
|||
|
|||
### Icons |
|||
|
|||
All code (including SVG markup) is under the [MIT License](http://opensource.org/licenses/MIT). |
|||
|
|||
### Fonts |
|||
|
|||
All fonts are under the [SIL Licensed](http://scripts.sil.org/cms/scripts/page.php?item_id=OFL_web). |
|||
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 54 KiB |
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 31 KiB |
@ -0,0 +1,27 @@ |
|||
[ |
|||
{ |
|||
"date": "2018-05-06", |
|||
"temperatureC": 1, |
|||
"summary": "Freezing" |
|||
}, |
|||
{ |
|||
"date": "2018-05-07", |
|||
"temperatureC": 14, |
|||
"summary": "Bracing" |
|||
}, |
|||
{ |
|||
"date": "2018-05-08", |
|||
"temperatureC": -13, |
|||
"summary": "Freezing" |
|||
}, |
|||
{ |
|||
"date": "2018-05-09", |
|||
"temperatureC": -16, |
|||
"summary": "Balmy" |
|||
}, |
|||
{ |
|||
"date": "2018-05-10", |
|||
"temperatureC": -2, |
|||
"summary": "Chilly" |
|||
} |
|||
] |
|||
@ -0,0 +1,23 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Microsoft.eShopWeb.PublicApi.AuthEndpoints |
|||
{ |
|||
public class ClaimValue |
|||
{ |
|||
public ClaimValue() |
|||
{ |
|||
} |
|||
|
|||
public ClaimValue(string type, string value) |
|||
{ |
|||
Type = type; |
|||
Value = value; |
|||
} |
|||
|
|||
public string Type { get; set; } |
|||
public string Value { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Microsoft.eShopWeb.PublicApi.AuthEndpoints |
|||
{ |
|||
public class UserInfo |
|||
{ |
|||
public static readonly UserInfo Anonymous = new UserInfo(); |
|||
public bool IsAuthenticated { get; set; } |
|||
public string NameClaimType { get; set; } |
|||
public string RoleClaimType { get; set; } |
|||
public IEnumerable<ClaimValue> Claims { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,8 @@ |
|||
namespace Microsoft.eShopWeb.PublicApi.CatalogBrandEndpoints |
|||
{ |
|||
public class CatalogBrandDto |
|||
{ |
|||
public int Id { get; set; } |
|||
public string Name { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
|
|||
namespace Microsoft.eShopWeb.PublicApi.CatalogBrandEndpoints |
|||
{ |
|||
public class ListCatalogBrandsResponse : BaseResponse |
|||
{ |
|||
public ListCatalogBrandsResponse(Guid correlationId) : base(correlationId) |
|||
{ |
|||
} |
|||
|
|||
public ListCatalogBrandsResponse() |
|||
{ |
|||
} |
|||
|
|||
public List<CatalogBrandDto> CatalogBrands { get; set; } = new List<CatalogBrandDto>(); |
|||
} |
|||
} |
|||
@ -0,0 +1,42 @@ |
|||
using Ardalis.ApiEndpoints; |
|||
using AutoMapper; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Microsoft.eShopWeb.ApplicationCore.Entities; |
|||
using Microsoft.eShopWeb.ApplicationCore.Interfaces; |
|||
using Swashbuckle.AspNetCore.Annotations; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Microsoft.eShopWeb.PublicApi.CatalogBrandEndpoints |
|||
{ |
|||
public class List : BaseAsyncEndpoint<ListCatalogBrandsResponse> |
|||
{ |
|||
private readonly IAsyncRepository<CatalogBrand> _catalogBrandRepository; |
|||
private readonly IMapper _mapper; |
|||
|
|||
public List(IAsyncRepository<CatalogBrand> catalogBrandRepository, |
|||
IMapper mapper) |
|||
{ |
|||
_catalogBrandRepository = catalogBrandRepository; |
|||
_mapper = mapper; |
|||
} |
|||
|
|||
[HttpGet("api/catalog-brands")] |
|||
[SwaggerOperation( |
|||
Summary = "List Catalog Brands", |
|||
Description = "List Catalog Brands", |
|||
OperationId = "catalog-brands.List", |
|||
Tags = new[] { "CatalogBrandEndpoints" }) |
|||
] |
|||
public override async Task<ActionResult<ListCatalogBrandsResponse>> HandleAsync() |
|||
{ |
|||
var response = new ListCatalogBrandsResponse(); |
|||
|
|||
var items = await _catalogBrandRepository.ListAllAsync(); |
|||
|
|||
response.CatalogBrands.AddRange(items.Select(_mapper.Map<CatalogBrandDto>)); |
|||
|
|||
return Ok(response); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,8 @@ |
|||
namespace Microsoft.eShopWeb.PublicApi.CatalogTypeEndpoints |
|||
{ |
|||
public class CatalogTypeDto |
|||
{ |
|||
public int Id { get; set; } |
|||
public string Name { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
|
|||
namespace Microsoft.eShopWeb.PublicApi.CatalogTypeEndpoints |
|||
{ |
|||
public class ListCatalogTypesResponse : BaseResponse |
|||
{ |
|||
public ListCatalogTypesResponse(Guid correlationId) : base(correlationId) |
|||
{ |
|||
} |
|||
|
|||
public ListCatalogTypesResponse() |
|||
{ |
|||
} |
|||
|
|||
public List<CatalogTypeDto> CatalogTypes { get; set; } = new List<CatalogTypeDto>(); |
|||
} |
|||
} |
|||
@ -0,0 +1,42 @@ |
|||
using Ardalis.ApiEndpoints; |
|||
using AutoMapper; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Microsoft.eShopWeb.ApplicationCore.Entities; |
|||
using Microsoft.eShopWeb.ApplicationCore.Interfaces; |
|||
using Swashbuckle.AspNetCore.Annotations; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Microsoft.eShopWeb.PublicApi.CatalogTypeEndpoints |
|||
{ |
|||
public class List : BaseAsyncEndpoint<ListCatalogTypesResponse> |
|||
{ |
|||
private readonly IAsyncRepository<CatalogType> _catalogTypeRepository; |
|||
private readonly IMapper _mapper; |
|||
|
|||
public List(IAsyncRepository<CatalogType> catalogTypeRepository, |
|||
IMapper mapper) |
|||
{ |
|||
_catalogTypeRepository = catalogTypeRepository; |
|||
_mapper = mapper; |
|||
} |
|||
|
|||
[HttpGet("api/catalog-types")] |
|||
[SwaggerOperation( |
|||
Summary = "List Catalog Types", |
|||
Description = "List Catalog Types", |
|||
OperationId = "catalog-types.List", |
|||
Tags = new[] { "CatalogTypeEndpoints" }) |
|||
] |
|||
public override async Task<ActionResult<ListCatalogTypesResponse>> HandleAsync() |
|||
{ |
|||
var response = new ListCatalogTypesResponse(); |
|||
|
|||
var items = await _catalogTypeRepository.ListAllAsync(); |
|||
|
|||
response.CatalogTypes.AddRange(items.Select(_mapper.Map<CatalogTypeDto>)); |
|||
|
|||
return Ok(response); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
|
|||
namespace Shared.Authorization |
|||
{ |
|||
public class ClaimValue |
|||
{ |
|||
public ClaimValue() |
|||
{ |
|||
} |
|||
|
|||
public ClaimValue(string type, string value) |
|||
{ |
|||
Type = type; |
|||
Value = value; |
|||
} |
|||
|
|||
public string Type { get; set; } |
|||
public string Value { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Security.Claims; |
|||
using System.Text; |
|||
|
|||
namespace Shared.Authorization |
|||
{ |
|||
public class UserInfo |
|||
{ |
|||
public static readonly UserInfo Anonymous = new UserInfo(); |
|||
public bool IsAuthenticated { get; set; } |
|||
public string NameClaimType { get; set; } |
|||
public string RoleClaimType { get; set; } |
|||
public IEnumerable<ClaimValue> Claims { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netstandard2.0</TargetFramework> |
|||
</PropertyGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,63 @@ |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Security.Claims; |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Shared.Authorization; |
|||
|
|||
namespace Microsoft.eShopWeb.Web.Controllers |
|||
{ |
|||
[Route("[controller]")]
|
|||
[ApiController] |
|||
public class UserController : ControllerBase |
|||
{ |
|||
[HttpGet] |
|||
[Authorize] |
|||
[AllowAnonymous] |
|||
public IActionResult GetCurrentUser() => |
|||
Ok(User.Identity.IsAuthenticated ? CreateUserInfo(User) : UserInfo.Anonymous); |
|||
|
|||
private UserInfo CreateUserInfo(ClaimsPrincipal claimsPrincipal) |
|||
{ |
|||
if (!claimsPrincipal.Identity.IsAuthenticated) |
|||
{ |
|||
return UserInfo.Anonymous; |
|||
} |
|||
|
|||
var userInfo = new UserInfo |
|||
{ |
|||
IsAuthenticated = true |
|||
}; |
|||
|
|||
if (claimsPrincipal.Identity is ClaimsIdentity claimsIdentity) |
|||
{ |
|||
userInfo.NameClaimType = claimsIdentity.NameClaimType; |
|||
userInfo.RoleClaimType = claimsIdentity.RoleClaimType; |
|||
} |
|||
else |
|||
{ |
|||
userInfo.NameClaimType = "name"; |
|||
userInfo.RoleClaimType = "role"; |
|||
} |
|||
|
|||
if (claimsPrincipal.Claims.Any()) |
|||
{ |
|||
var claims = new List<ClaimValue>(); |
|||
var nameClaims = claimsPrincipal.FindAll(userInfo.NameClaimType); |
|||
foreach (var claim in nameClaims) |
|||
{ |
|||
claims.Add(new ClaimValue(userInfo.NameClaimType, claim.Value)); |
|||
} |
|||
|
|||
foreach (var claim in claimsPrincipal.Claims.Except(nameClaims)) |
|||
{ |
|||
claims.Add(new ClaimValue(claim.Type, claim.Value)); |
|||
} |
|||
|
|||
userInfo.Claims = claims; |
|||
} |
|||
|
|||
return userInfo; |
|||
} |
|||
} |
|||
} |
|||
@ -1,45 +1,67 @@ |
|||
@page |
|||
@using BlazorAdmin |
|||
|
|||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers |
|||
|
|||
@{ |
|||
Layout = null; |
|||
ViewData["Title"] = "Admin - Catalog"; |
|||
@model IndexModel |
|||
} |
|||
<section class="esh-catalog-hero"> |
|||
<div class="container"> |
|||
<img class="esh-catalog-title" src="~/images/main_banner_text.png" /> |
|||
</div> |
|||
</section> |
|||
<section class="esh-catalog-filters"> |
|||
<div class="container"> |
|||
<form method="get"> |
|||
<label class="esh-catalog-label" data-title="brand"> |
|||
<select asp-for="@Model.CatalogModel.BrandFilterApplied" asp-items="@Model.CatalogModel.Brands" class="esh-catalog-filter"></select> |
|||
</label> |
|||
<label class="esh-catalog-label" data-title="type"> |
|||
<select asp-for="@Model.CatalogModel.TypesFilterApplied" asp-items="@Model.CatalogModel.Types" class="esh-catalog-filter"></select> |
|||
</label> |
|||
<input class="esh-catalog-send" type="image" src="images/arrow-right.svg" /> |
|||
</form> |
|||
</div> |
|||
</section> |
|||
<div class="container"> |
|||
@if (Model.CatalogModel.CatalogItems.Any()) |
|||
{ |
|||
<partial name="_pagination" for="CatalogModel.PaginationInfo" /> |
|||
|
|||
<div class="esh-catalog-items row"> |
|||
@foreach (var catalogItem in Model.CatalogModel.CatalogItems) |
|||
{ |
|||
<div class="esh-catalog-item col-md-4"> |
|||
<partial name="_editCatalog" for="@catalogItem" /> |
|||
</div> |
|||
|
|||
|
|||
<!DOCTYPE html> |
|||
<html> |
|||
<head> |
|||
<meta charset="utf-8" /> |
|||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> |
|||
<title>@ViewData["Title"] - Microsoft.eShopOnWeb</title> |
|||
<base href="~/" /> |
|||
<environment include="Development"> |
|||
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" /> |
|||
</environment> |
|||
<environment exclude="Development"> |
|||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" |
|||
asp-fallback-href="css/bootstrap/bootstrap.min.css" |
|||
asp-fallback-test-class="sr-only" asp-fallback-test-property="position" asp-fallback-test-value="absolute" |
|||
crossorigin="anonymous" |
|||
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" /> |
|||
</environment> |
|||
<link href="css/admin.css" rel="stylesheet" /> |
|||
|
|||
<script> |
|||
|
|||
window.getCookie = (cname) => { |
|||
var name = cname + "="; |
|||
var decodedCookie = decodeURIComponent(document.cookie); |
|||
var ca = decodedCookie.split(';'); |
|||
for (var i = 0; i < ca.length; i++) { |
|||
var c = ca[i]; |
|||
while (c.charAt(0) == ' ') { |
|||
c = c.substring(1); |
|||
} |
|||
if (c.indexOf(name) == 0) { |
|||
return c.substring(name.length, c.length); |
|||
} |
|||
} |
|||
</div> |
|||
<partial name="_pagination" for="CatalogModel.PaginationInfo" /> |
|||
} |
|||
else |
|||
{ |
|||
<div class="esh-catalog-items row"> |
|||
THERE ARE NO RESULTS THAT MATCH YOUR SEARCH |
|||
</div> |
|||
} |
|||
</div> |
|||
|
|||
return ""; |
|||
}; |
|||
|
|||
window.deleteCookie = (cname) => { |
|||
document.cookie = cname + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"; |
|||
}; |
|||
|
|||
window.routeOutside = (path) => { |
|||
window.location = path; |
|||
}; |
|||
|
|||
</script> |
|||
</head> |
|||
<body> |
|||
<admin>@(await Html.RenderComponentAsync<App>(RenderMode.ServerPrerendered))</admin> |
|||
<script src="_content/Microsoft.AspNetCore.Components.WebAssembly.Authentication/AuthenticationService.js"></script> |
|||
<script src="_framework/blazor.webassembly.js"></script> |
|||
|
|||
</body> |
|||
</html> |
|||
|
|||
|
|||
Loading…
Reference in new issue