From 4e886183ce9e6a6fe5f2ff1e44ecab7a8f6f9d70 Mon Sep 17 00:00:00 2001 From: Shady Nagy Date: Sat, 25 Jul 2020 22:39:21 +0200 Subject: [PATCH] Shady nagy/blazor enhance (#429) * - Using cdnjs not nuget on bootstrap and signalr. - Bootstrap modal used for add, edit details and delete. * EditForm inside modal-content * Top close button action added * Removed unused using. * DeleteCookies moved inside AuthService * ApplicationCore removed from BlazorAdmin dependencies * SecureHttpClient removed * Logout from identity manager added * last thing to do in logout from admin is LogoutIdentityManager. * JSRuntime used in AuthService without pass to the functions * Link fixed when logout from MVC --- src/BlazorAdmin/BlazorAdmin.csproj | 1 - src/BlazorAdmin/Constants.cs | 5 + src/BlazorAdmin/CustomAuthStateProvider.cs | 5 - src/BlazorAdmin/Network/SecureHttpClient.cs | 37 ---- .../Pages/CatalogItemPage/Create.razor | 174 ++++++++++------- .../Pages/CatalogItemPage/Delete.razor | 163 ++++++++++------ .../Pages/CatalogItemPage/Details.razor | 172 ++++++++++------- .../Pages/CatalogItemPage/Edit.razor | 179 +++++++++++------- .../Pages/CatalogItemPage/List.razor | 115 +++++------ .../Pages/CatalogItemPage/List.razor.cs | 58 ++---- src/BlazorAdmin/Pages/Logout.razor | 12 -- src/BlazorAdmin/Program.cs | 3 - src/BlazorAdmin/Services/AuthService.cs | 24 ++- .../Services/CatalogItemService/Create.cs | 5 +- .../Delete.DeleteCatalogItemResult.cs | 7 +- .../Services/CatalogItemService/Delete.cs | 7 +- .../Edit.EditCatalogItemResult.cs | 7 +- .../Services/CatalogItemService/Edit.cs | 5 +- .../GetById.GetByIdCatalogItemResult.cs | 7 +- .../Services/CatalogItemService/GetById.cs | 7 +- src/BlazorAdmin/Shared/MainLayout.razor | 9 +- src/BlazorAdmin/Shared/NavMenu.razor | 2 - src/BlazorAdmin/Shared/RedirectToLogin.razor | 4 +- src/BlazorAdmin/Shared/Spinner.razor | 9 + src/BlazorAdmin/_Imports.razor | 1 - src/Web/libman.json | 28 ++- 26 files changed, 531 insertions(+), 515 deletions(-) delete mode 100644 src/BlazorAdmin/Network/SecureHttpClient.cs create mode 100644 src/BlazorAdmin/Shared/Spinner.razor diff --git a/src/BlazorAdmin/BlazorAdmin.csproj b/src/BlazorAdmin/BlazorAdmin.csproj index 7300c65..84a9a38 100644 --- a/src/BlazorAdmin/BlazorAdmin.csproj +++ b/src/BlazorAdmin/BlazorAdmin.csproj @@ -18,7 +18,6 @@ - diff --git a/src/BlazorAdmin/Constants.cs b/src/BlazorAdmin/Constants.cs index 0ff40f7..ae930e5 100644 --- a/src/BlazorAdmin/Constants.cs +++ b/src/BlazorAdmin/Constants.cs @@ -3,5 +3,10 @@ public class Constants { public const string API_URL = "https://localhost:5099/api/"; + + public static class Roles + { + public const string ADMINISTRATORS = "Administrators"; + } } } diff --git a/src/BlazorAdmin/CustomAuthStateProvider.cs b/src/BlazorAdmin/CustomAuthStateProvider.cs index 6e68d69..bdf4dd5 100644 --- a/src/BlazorAdmin/CustomAuthStateProvider.cs +++ b/src/BlazorAdmin/CustomAuthStateProvider.cs @@ -1,13 +1,8 @@ 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; diff --git a/src/BlazorAdmin/Network/SecureHttpClient.cs b/src/BlazorAdmin/Network/SecureHttpClient.cs deleted file mode 100644 index bd01fdb..0000000 --- a/src/BlazorAdmin/Network/SecureHttpClient.cs +++ /dev/null @@ -1,37 +0,0 @@ -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> GetCatalogBrandsAsync() - { - var brands = new List(); - - try - { - brands = (await client.GetFromJsonAsync($"{Constants.API_URL}catalog-brands")).CatalogBrands; - } - catch (AccessTokenNotAvailableException exception) - { - exception.Redirect(); - } - - return brands; - } - } -} diff --git a/src/BlazorAdmin/Pages/CatalogItemPage/Create.razor b/src/BlazorAdmin/Pages/CatalogItemPage/Create.razor index de09858..7c86680 100644 --- a/src/BlazorAdmin/Pages/CatalogItemPage/Create.razor +++ b/src/BlazorAdmin/Pages/CatalogItemPage/Create.razor @@ -5,81 +5,101 @@ @namespace BlazorAdmin.Pages.CatalogItemPage -

Create

- -
- - - -
- -
- - -
-
-
- -
- - -
-
-
- -
- - @foreach (var brand in Brands) + +
-
- -
- - -
-
-
- -
- Uploading images not allowed for this version. -
-
-
-
- - Cancel - - -
-
- -
+@if (_showCreateModal) +{ + +} @code { @@ -91,21 +111,35 @@ [Parameter] public EventCallback OnCloseClick { get; set; } + private string _modalDisplay = "none;"; + private string _modalClass = ""; + private bool _showCreateModal = false; private readonly CreateCatalogItemRequest _item = new CreateCatalogItemRequest(); - protected override async Task OnAfterRenderAsync(bool firstRender) + private async Task CreateClick() + { + await new BlazorAdmin.Services.CatalogItemService.Create(Auth).HandleAsync(_item); + await OnCloseClick.InvokeAsync(null); + Close(); + } + + public void Open() { Logger.LogInformation("Now loading... /Catalog/Create"); _item.CatalogTypeId = Types.First().Id; _item.CatalogBrandId = Brands.First().Id; - await base.OnAfterRenderAsync(firstRender); + _modalDisplay = "block;"; + _modalClass = "Show"; + _showCreateModal = true; } - private async Task CreateClick() + public void Close() { - await new BlazorAdmin.Services.CatalogItemService.Create(Auth).HandleAsync(_item); - await OnCloseClick.InvokeAsync(null); + _modalDisplay = "none"; + _modalClass = ""; + _showCreateModal = false; + OnCloseClick.InvokeAsync(null); } } diff --git a/src/BlazorAdmin/Pages/CatalogItemPage/Delete.razor b/src/BlazorAdmin/Pages/CatalogItemPage/Delete.razor index 8637d03..82bb464 100644 --- a/src/BlazorAdmin/Pages/CatalogItemPage/Delete.razor +++ b/src/BlazorAdmin/Pages/CatalogItemPage/Delete.razor @@ -5,66 +5,89 @@ @namespace BlazorAdmin.Pages.CatalogItemPage -
-
- - -
-
- Name -
- -
- @_item.Name -
- -
- Description -
- -
- @_item.Description -
- -
- Brand -
- -
- @Services.CatalogBrandService.List.GetBrandName(Brands, _item.CatalogBrandId) -
- -
- Type -
- -
- @Services.CatalogTypeService.List.GetTypeName(Types, _item.CatalogTypeId) -
-
- Price -
- -
- @_item.Price -
-
+ -
- - Cancel - - -
+@if (_showDeleteModal) +{ + +} -
@code { - [Parameter] - public int Id { get; set; } [Parameter] public IEnumerable Brands { get; set; } [Parameter] @@ -73,23 +96,37 @@ [Parameter] public EventCallback OnCloseClick { get; set; } + private string _modalDisplay = "none;"; + private string _modalClass = ""; + private bool _showDeleteModal = false; private CatalogItem _item = new CatalogItem(); - protected override async Task OnInitializedAsync() + private async Task DeleteClick(int id) { - Logger.LogInformation("Now loading... /Catalog/Delete/{Id}", Id); + // TODO: Add some kind of "are you sure" check before this - _item = await new GetById(Auth).HandleAsync(Id); + await new BlazorAdmin.Services.CatalogItemService.Delete(Auth).HandleAsync(id); - await base.OnInitializedAsync(); + await OnCloseClick.InvokeAsync(null); + Close(); } - private async Task DeleteClick() + public async Task Open(int id) { - // TODO: Add some kind of "are you sure" check before this + Logger.LogInformation("Now loading... /Catalog/Delete/{Id}", id); - await new BlazorAdmin.Services.CatalogItemService.Delete(Auth).HandleAsync(Id); + _item = await new GetById(Auth).HandleAsync(id); - await OnCloseClick.InvokeAsync(null); + _modalDisplay = "block;"; + _modalClass = "Show"; + _showDeleteModal = true; + } + + public void Close() + { + _modalDisplay = "none"; + _modalClass = ""; + _showDeleteModal = false; + OnCloseClick.InvokeAsync(null); } } diff --git a/src/BlazorAdmin/Pages/CatalogItemPage/Details.razor b/src/BlazorAdmin/Pages/CatalogItemPage/Details.razor index 673494f..12c8956 100644 --- a/src/BlazorAdmin/Pages/CatalogItemPage/Details.razor +++ b/src/BlazorAdmin/Pages/CatalogItemPage/Details.razor @@ -5,95 +5,127 @@ @namespace BlazorAdmin.Pages.CatalogItemPage -@if (_item == null) -{ -

Loading...

-} -else -{ -

Details

- -
-
- - -
-
- Name -
- -
- @_item.Name -
- -
- Description -
- -
- @_item.Description -
- -
- Brand -
- -
- @Services.CatalogBrandService.List.GetBrandName(Brands, _item.CatalogBrandId) -
- -
- Type -
- -
- @Services.CatalogTypeService.List.GetTypeName(Types, _item.CatalogTypeId) -
-
- Price -
- -
- @_item.Price -
-
-
-
- - Cancel - - - Edit - + + +@if (_showDetailsModal) +{ + } + @code { - [Parameter] - public int Id { get; set; } [Parameter] public IEnumerable Brands { get; set; } [Parameter] public IEnumerable Types { get; set; } - [Parameter] - public EventCallback OnCloseClick { get; set; } [Parameter] public EventCallback OnEditClick { get; set; } + private string _modalDisplay = "none;"; + private string _modalClass = ""; + private bool _showDetailsModal = false; private CatalogItem _item = new CatalogItem(); - protected override async Task OnInitializedAsync() + public void EditClick() { - Logger.LogInformation("Now loading... /Catalog/Details/{Id}", Id); + OnEditClick.InvokeAsync(_item.Id); + Close(); + } + + public async Task Open(int id) + { + Logger.LogInformation("Now loading... /Catalog/Details/{Id}", id); - _item = await new GetById(Auth).HandleAsync(Id); - StateHasChanged(); + _item = await new GetById(Auth).HandleAsync(id); - await base.OnInitializedAsync(); + _modalDisplay = "block;"; + _modalClass = "Show"; + _showDetailsModal = true; + } + + public void Close() + { + _modalDisplay = "none"; + _modalClass = ""; + _showDetailsModal = false; } } diff --git a/src/BlazorAdmin/Pages/CatalogItemPage/Edit.razor b/src/BlazorAdmin/Pages/CatalogItemPage/Edit.razor index 77f5ca0..4a193ee 100644 --- a/src/BlazorAdmin/Pages/CatalogItemPage/Edit.razor +++ b/src/BlazorAdmin/Pages/CatalogItemPage/Edit.razor @@ -5,85 +5,104 @@ @namespace BlazorAdmin.Pages.CatalogItemPage -

Edit

- -
- - - -
- -
- - -
-
-
- -
- - -
-
-
- -
- - @foreach (var brand in Brands) + +
-
- -
- - -
-
-
- -
- Uploading images not allowed for this version. -
-
-
-
- - Cancel - - -
-
- -
+@if (_showEditModal) +{ + +} @code { - [Parameter] - public int Id { get; set; } [Parameter] public IEnumerable Brands { get; set; } [Parameter] @@ -92,19 +111,33 @@ [Parameter] public EventCallback OnCloseClick { get; set; } + private string _modalDisplay = "none;"; + private string _modalClass = ""; + private bool _showEditModal = false; private CatalogItem _item = new CatalogItem(); - protected override async Task OnInitializedAsync() + private async Task SaveClick() { - Logger.LogInformation("Now loading... /Catalog/Edit/{Id}", Id); + await new BlazorAdmin.Services.CatalogItemService.Edit(Auth).HandleAsync(_item); + Close(); + } - _item = await new GetById(Auth).HandleAsync(Id); + public async Task Open(int id) + { + Logger.LogInformation("Now loading... /Catalog/Edit/{Id}", id); + + _item = await new GetById(Auth).HandleAsync(id); - await base.OnInitializedAsync(); + _modalDisplay = "block;"; + _modalClass = "Show"; + _showEditModal = true; } - private async Task SaveClick() + public void Close() { - await new BlazorAdmin.Services.CatalogItemService.Edit(Auth).HandleAsync(_item); + _modalDisplay = "none"; + _modalClass = ""; + _showEditModal = false; + OnCloseClick.InvokeAsync(null); } } diff --git a/src/BlazorAdmin/Pages/CatalogItemPage/List.razor b/src/BlazorAdmin/Pages/CatalogItemPage/List.razor index e5f5e10..90125a0 100644 --- a/src/BlazorAdmin/Pages/CatalogItemPage/List.razor +++ b/src/BlazorAdmin/Pages/CatalogItemPage/List.razor @@ -1,6 +1,7 @@ @page "/admin" -@attribute [Authorize(Roles = Microsoft.eShopWeb.ApplicationCore.Constants.AuthorizationConstants.Roles.ADMINISTRATORS)] +@attribute [Authorize(Roles = Constants.Roles.ADMINISTRATORS)] @inject AuthService Auth +@using global::Shared.Authorization @inherits BlazorAdmin.Helpers.BlazorComponent @namespace BlazorAdmin.Pages.CatalogItemPage @@ -8,75 +9,59 @@ @if (catalogItems == null) { -

Loading...

+ } else { - @if (!showCreate && !showDetails && !showEdit && !showDelete) - { - - - - - - - - - - - - - - - - @foreach (var item in catalogItems) - { - - - - - - - - - - - } - -
Item TypeBrandIdName@nameof(CatalogItem.Description)@nameof(CatalogItem.Price)Actions
- - @Services.CatalogTypeService.List.GetTypeName(catalogTypes, item.CatalogTypeId)@Services.CatalogBrandService.List.GetBrandName(catalogBrands, item.CatalogBrandId)@item.Id@item.Name@item.Description@item.Price - - Edit - - - - Delete - -
- } - @if (showDetails) - { -
- } + - @if (showEdit) - { - - } + + + + + + + + + + + + + + + @foreach (var item in catalogItems) + { + + + + + + + + + + + } + +
Item TypeBrandIdName@nameof(CatalogItem.Description)@nameof(CatalogItem.Price)Actions
+ + @Services.CatalogTypeService.List.GetTypeName(catalogTypes, item.CatalogTypeId)@Services.CatalogBrandService.List.GetBrandName(catalogBrands, item.CatalogBrandId)@item.Id@item.Name@item.Description@item.Price + - @if (showCreate) - { - - } + +
- @if (showDelete) - { - - } +
+ + + } diff --git a/src/BlazorAdmin/Pages/CatalogItemPage/List.razor.cs b/src/BlazorAdmin/Pages/CatalogItemPage/List.razor.cs index ad606e0..a37fa02 100644 --- a/src/BlazorAdmin/Pages/CatalogItemPage/List.razor.cs +++ b/src/BlazorAdmin/Pages/CatalogItemPage/List.razor.cs @@ -12,11 +12,11 @@ namespace BlazorAdmin.Pages.CatalogItemPage private List catalogItems = new List(); private List catalogTypes = new List(); private List catalogBrands = new List(); - private bool showCreate = false; - private bool showDetails = false; - private bool showEdit = false; - private bool showDelete = false; - private int selectedId = 0; + + private Edit EditComponent { get; set; } + private Delete DeleteComponent { get; set; } + private Details DetailsComponent { get; set; } + private Create CreateComponent { get; set; } protected override async Task OnAfterRenderAsync(bool firstRender) { @@ -32,58 +32,24 @@ namespace BlazorAdmin.Pages.CatalogItemPage await base.OnAfterRenderAsync(firstRender); } - private void DetailsClick(int id) + private async void DetailsClick(int id) { - selectedId = id; - showDetails = true; + await DetailsComponent.Open(id); } 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(); + CreateComponent.Open(); } - private async Task CloseDeleteHandler(string action) + private async Task EditClick(int id) { - showDelete = false; - await ReloadCatalogItems(); + await EditComponent.Open(id); } - private async Task CloseCreateHandler(string action) + private async Task DeleteClick(int id) { - showCreate = false; - await ReloadCatalogItems(); + await DeleteComponent.Open(id); } private async Task ReloadCatalogItems() diff --git a/src/BlazorAdmin/Pages/Logout.razor b/src/BlazorAdmin/Pages/Logout.razor index bec3f67..bceb4ce 100644 --- a/src/BlazorAdmin/Pages/Logout.razor +++ b/src/BlazorAdmin/Pages/Logout.razor @@ -1,27 +1,15 @@ @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"); - } - - } diff --git a/src/BlazorAdmin/Program.cs b/src/BlazorAdmin/Program.cs index 4d07f88..eace497 100644 --- a/src/BlazorAdmin/Program.cs +++ b/src/BlazorAdmin/Program.cs @@ -3,11 +3,9 @@ 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 { @@ -19,7 +17,6 @@ namespace BlazorAdmin builder.RootComponents.Add("admin"); builder.Services.AddTransient(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); - builder.Services.AddTransient(sp => new SecureHttpClient(sp.GetRequiredService())); builder.Services.AddSingleton(); builder.Services.AddSingleton(); diff --git a/src/BlazorAdmin/Services/AuthService.cs b/src/BlazorAdmin/Services/AuthService.cs index 11bc2d3..12bda0a 100644 --- a/src/BlazorAdmin/Services/AuthService.cs +++ b/src/BlazorAdmin/Services/AuthService.cs @@ -9,7 +9,6 @@ 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; @@ -20,13 +19,15 @@ namespace BlazorAdmin.Services { private readonly HttpClient _httpClient; private readonly ILocalStorageService _localStorage; + private readonly IJSRuntime _jSRuntime; public bool IsLoggedIn { get; set; } public string UserName { get; set; } - public AuthService(HttpClient httpClient, ILocalStorageService localStorage) + public AuthService(HttpClient httpClient, ILocalStorageService localStorage, IJSRuntime jSRuntime) { _httpClient = httpClient; _localStorage = localStorage; + _jSRuntime = jSRuntime; } public HttpClient GetHttpClient() @@ -74,10 +75,11 @@ namespace BlazorAdmin.Services { await _localStorage.RemoveItemAsync("authToken"); await _localStorage.RemoveItemAsync("username"); - + await DeleteCookies(); RemoveAuthorizationHeader(); UserName = null; IsLoggedIn = false; + await LogoutIdentityManager(); } public async Task RefreshLoginInfo() @@ -85,16 +87,26 @@ namespace BlazorAdmin.Services await SetLoginData(); } - public async Task RefreshLoginInfoFromCookie(IJSRuntime jSRuntime) + public async Task RefreshLoginInfoFromCookie() { - var token = await new Cookies(jSRuntime).GetCookie("token"); + var token = await new Cookies(_jSRuntime).GetCookie("token"); await SaveTokenInLocalStorage(token); - var username = await new Cookies(jSRuntime).GetCookie("username"); + var username = await new Cookies(_jSRuntime).GetCookie("username"); await SaveUsernameInLocalStorage(username); await RefreshLoginInfo(); } + private async Task LogoutIdentityManager() + { + await _httpClient.PostAsync("Identity/Account/Logout", null); + } + + private async Task DeleteCookies() + { + await new Cookies(_jSRuntime).DeleteCookie("token"); + await new Cookies(_jSRuntime).DeleteCookie("username"); + } private async Task SetLoginData() { diff --git a/src/BlazorAdmin/Services/CatalogItemService/Create.cs b/src/BlazorAdmin/Services/CatalogItemService/Create.cs index 56a0dcb..ac37d82 100644 --- a/src/BlazorAdmin/Services/CatalogItemService/Create.cs +++ b/src/BlazorAdmin/Services/CatalogItemService/Create.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net; +using System.Net; using System.Net.Http; using System.Text; using System.Threading.Tasks; diff --git a/src/BlazorAdmin/Services/CatalogItemService/Delete.DeleteCatalogItemResult.cs b/src/BlazorAdmin/Services/CatalogItemService/Delete.DeleteCatalogItemResult.cs index 2a22337..4b66e4e 100644 --- a/src/BlazorAdmin/Services/CatalogItemService/Delete.DeleteCatalogItemResult.cs +++ b/src/BlazorAdmin/Services/CatalogItemService/Delete.DeleteCatalogItemResult.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace BlazorAdmin.Services.CatalogItemService +namespace BlazorAdmin.Services.CatalogItemService { public class DeleteCatalogItemResult { diff --git a/src/BlazorAdmin/Services/CatalogItemService/Delete.cs b/src/BlazorAdmin/Services/CatalogItemService/Delete.cs index 0adc7e8..ce74c67 100644 --- a/src/BlazorAdmin/Services/CatalogItemService/Delete.cs +++ b/src/BlazorAdmin/Services/CatalogItemService/Delete.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net; -using System.Net.Http; -using System.Text; +using System.Net; using System.Threading.Tasks; using Newtonsoft.Json; diff --git a/src/BlazorAdmin/Services/CatalogItemService/Edit.EditCatalogItemResult.cs b/src/BlazorAdmin/Services/CatalogItemService/Edit.EditCatalogItemResult.cs index ccf1039..fb17b93 100644 --- a/src/BlazorAdmin/Services/CatalogItemService/Edit.EditCatalogItemResult.cs +++ b/src/BlazorAdmin/Services/CatalogItemService/Edit.EditCatalogItemResult.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace BlazorAdmin.Services.CatalogItemService +namespace BlazorAdmin.Services.CatalogItemService { public class EditCatalogItemResult { diff --git a/src/BlazorAdmin/Services/CatalogItemService/Edit.cs b/src/BlazorAdmin/Services/CatalogItemService/Edit.cs index 71c04bd..d80f19c 100644 --- a/src/BlazorAdmin/Services/CatalogItemService/Edit.cs +++ b/src/BlazorAdmin/Services/CatalogItemService/Edit.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net; +using System.Net; using System.Net.Http; using System.Text; using System.Threading.Tasks; diff --git a/src/BlazorAdmin/Services/CatalogItemService/GetById.GetByIdCatalogItemResult.cs b/src/BlazorAdmin/Services/CatalogItemService/GetById.GetByIdCatalogItemResult.cs index 89d3aed..5c9b7a8 100644 --- a/src/BlazorAdmin/Services/CatalogItemService/GetById.GetByIdCatalogItemResult.cs +++ b/src/BlazorAdmin/Services/CatalogItemService/GetById.GetByIdCatalogItemResult.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace BlazorAdmin.Services.CatalogItemService +namespace BlazorAdmin.Services.CatalogItemService { public class GetByIdCatalogItemResult { diff --git a/src/BlazorAdmin/Services/CatalogItemService/GetById.cs b/src/BlazorAdmin/Services/CatalogItemService/GetById.cs index 992738e..9539fb7 100644 --- a/src/BlazorAdmin/Services/CatalogItemService/GetById.cs +++ b/src/BlazorAdmin/Services/CatalogItemService/GetById.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net; -using System.Net.Http; -using System.Text; +using System.Net; using System.Threading.Tasks; using Newtonsoft.Json; diff --git a/src/BlazorAdmin/Shared/MainLayout.razor b/src/BlazorAdmin/Shared/MainLayout.razor index c6413df..aa39334 100644 --- a/src/BlazorAdmin/Shared/MainLayout.razor +++ b/src/BlazorAdmin/Shared/MainLayout.razor @@ -1,12 +1,9 @@ -@using BlazorAdmin.Services -@using BlazorAdmin.JavaScript - -@inject AuthService Auth +@inject AuthService Auth @inject IJSRuntime JSRuntime @inherits BlazorAdmin.Helpers.BlazorLayoutComponent - + @@ -28,7 +25,7 @@ { if (firstRender) { - await Auth.RefreshLoginInfoFromCookie(JSRuntime); + await Auth.RefreshLoginInfoFromCookie(); if (!Auth.IsLoggedIn) { await new Route(JSRuntime).RouteOutside("/Identity/Account/Login"); diff --git a/src/BlazorAdmin/Shared/NavMenu.razor b/src/BlazorAdmin/Shared/NavMenu.razor index 477f9e3..0688581 100644 --- a/src/BlazorAdmin/Shared/NavMenu.razor +++ b/src/BlazorAdmin/Shared/NavMenu.razor @@ -1,7 +1,5 @@ @inject AuthService Auth @inherits BlazorAdmin.Helpers.BlazorComponent - -@using BlazorAdmin.Services