Skip to content

Commit

Permalink
#255 Add root namespace declaration and local storage clearing func…
Browse files Browse the repository at this point in the history
…tionality

- Added `@namespace Pds.Web` declaration in `App.razor` for better code organization.
- Injected `Blazored.LocalStorage.ILocalStorageService` and `IJSRuntime` into `List.razor` to manage local storage.
- Implemented a new button in `List.razor` to clear local storage, along with associated confirmation dialog and page reload for user feedback.
- Updated the project file `Pds.Web.csproj` to include `RootNamespace` set to `Pds.Web`.
⭐⭐⭐⭐⭐⭐⭐⭐⭐💩
  • Loading branch information
itbeard committed Oct 1, 2024
1 parent 4bb9ffa commit c3dbc8b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Pds/Pds.Web/App.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<Router AppAssembly="@typeof(App).Assembly">
@namespace Pds.Web

<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
<Authorizing>
Expand Down
13 changes: 13 additions & 0 deletions Pds/Pds.Web/Pages/Settings/Brands/List.razor
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

@inject IApiClient ApiClient
@inject IAccessTokenProvider TokenProvider
@inject Blazored.LocalStorage.ILocalStorageService localStorage
@inject IJSRuntime JsRuntime

<Title>@WithSuffix("Бренды")</Title>

Expand Down Expand Up @@ -101,6 +103,7 @@ else
</tbody>
</table>
<div class="form-group d-grid gap-2 d-md-flex justify-content-md-end">
<button @onclick="OnClearLocalStorageAsync" class="btn btn-warning">Очистить localStore</button>
<button @onclick='() => GoBack("/settings")' class="btn btn-primary right">Назад</button>
</div>
}
Expand All @@ -122,4 +125,14 @@ else
{
return await ApiClient.Get<GetBrandsResponse>(TokenProvider, "brands");
}

private async Task OnClearLocalStorageAsync()
{
var confirmed = await JsRuntime.InvokeAsync<bool>("confirm", "Вы уверены, что хотите очистить localStorage?");
if (confirmed)
{
await localStorage.ClearAsync();
await JsRuntime.InvokeVoidAsync("location.reload");
}
}
}
1 change: 1 addition & 0 deletions Pds/Pds.Web/Pds.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<Nullable>disable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<RootNamespace>Pds.Web</RootNamespace>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit c3dbc8b

Please sign in to comment.