Skip to content

Commit

Permalink
Merge c0495ca into d477229
Browse files Browse the repository at this point in the history
  • Loading branch information
vyruz1986 authored Aug 18, 2022
2 parents d477229 + c0495ca commit 8001f34
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 40 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
using System.Linq.Expressions;

using AutoMapper;
using AutoMapper.QueryableExtensions;

using Domain;

using MediatR;

using Microsoft.EntityFrameworkCore;

using Persistence;
Expand Down Expand Up @@ -45,7 +42,6 @@ public async Task<Paginated<MemberSummary>> Handle(SearchMembersQuery request, C

var items = await memberSummaryQueryable.ToListAsync(cancellationToken: cancellationToken);


return new Paginated<MemberSummary>
{
Items = items,
Expand Down
3 changes: 0 additions & 3 deletions Queries/Transactions/Handlers/GetTransactionsHandler.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
using System.Linq.Expressions;

using AutoMapper;
using AutoMapper.QueryableExtensions;

using Domain;

using MediatR;

using Microsoft.EntityFrameworkCore;

using Persistence;
Expand Down
20 changes: 11 additions & 9 deletions Web/Pages/BankAccounts/BankAccounts.razor
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
Dense="true"
Hover="true"
@ref="table"
ServerData="@(new Func<TableState, Task<TableData<BankAccountDetail>>>(ServerReload))">
ServerData="@(new Func<TableState, Task<TableData<BankAccountDetail>>>(ServerReload))"
Loading="@loading">
<ToolBarContent>
<MudText Typo="Typo.h6">Bankaccounts</MudText>
<MudSpacer />
Expand All @@ -27,7 +28,8 @@
DisableElevation="true"
Link="/bankaccounts/new"
Size="Size.Small"
Variant="Variant.Filled">
Variant="Variant.Filled"
Disabled="@loading">
Add bankaccount
</MudButton>
</ToolBarContent>
Expand Down Expand Up @@ -79,15 +81,15 @@
@code {
private MudTable<BankAccountDetail>? table;
private string searchString = "";
private bool _isBusy = false;

// TODO: Keeping this local variable shouldn't be necessary
// because the MudTable ServerData feature should take care of displaying the loading bar appropriately
// However due to https://github.com/MudBlazor/MudBlazor/issues/4662 this doesn't currently work
private bool loading = true;

private async Task<TableData<BankAccountDetail>> ServerReload(TableState state)
{
// Workaround for https://github.com/Garderoben/MudBlazor/issues/2070
if (_isBusy)
return new TableData<BankAccountDetail>();

_isBusy = true;
loading = true;

BankAccountDetailOrderOption orderBy = state.SortLabel switch
{
Expand All @@ -99,7 +101,7 @@
var query = new SearchBankAccountsQuery(searchString, state.Page, state.PageSize, orderBy, sortDirection);
var data = await _mediator.Send(query);

_isBusy = false;
loading = false;
return new TableData<BankAccountDetail>()
{
TotalItems = data.Total,
Expand Down
22 changes: 11 additions & 11 deletions Web/Pages/Members/Members.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
@attribute [Authorize]

@using MediatR
@using Queries.Members
@using Queries.Members.Handlers.SearchMembers
@using Queries.Members.ViewModels

Expand All @@ -14,7 +13,8 @@
Dense="true"
Hover="true"
@ref="table"
ServerData="@(new Func<TableState, Task<TableData<MemberSummary>>>(ServerReload))">
ServerData="@(new Func<TableState, Task<TableData<MemberSummary>>>(ServerReload))"
Loading="@loading">
<ToolBarContent>
<MudText Typo="Typo.h6">Members</MudText>
<MudSpacer />
Expand All @@ -32,7 +32,8 @@
DisableElevation="true"
Link="/members/new"
Size="Size.Small"
Variant="Variant.Filled">
Variant="Variant.Filled"
Disabled="@loading">
Add member
</MudButton>
</ToolBarContent>
Expand Down Expand Up @@ -105,16 +106,15 @@
@code {
private MudTable<MemberSummary>? table;
private string searchString = "";
private bool _isBusy = false;

// TODO: Keeping this local variable shouldn't be necessary
// because the MudTable ServerData feature should take care of displaying the loading bar appropriately
// However due to https://github.com/MudBlazor/MudBlazor/issues/4662 this doesn't currently work
private bool loading = true;

private async Task<TableData<MemberSummary>> ServerReload(TableState state)
{
// Workaround for https://github.com/Garderoben/MudBlazor/issues/2070
if (_isBusy)
return new TableData<MemberSummary>();

_isBusy = true;

loading = true;
MemberSummaryOrderOption orderBy = state.SortLabel switch
{
"name" => MemberSummaryOrderOption.Name,
Expand All @@ -127,7 +127,7 @@
var query = new SearchMembersQuery(searchString, state.Page, state.PageSize, orderBy, sortDirection);
var data = await _mediator.Send(query);

_isBusy = false;
loading = false;
return new TableData<MemberSummary>()
{
TotalItems = data.Total,
Expand Down
23 changes: 12 additions & 11 deletions Web/Pages/Transactions/Transactions.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@page "/transactions"
@page "/transactions"
@attribute [Authorize]

@using MediatR
Expand All @@ -13,7 +13,8 @@
Dense="true"
Hover="true"
@ref="table"
ServerData="@(new Func<TableState, Task<TableData<TransactionSummary>>>(ServerReload))">
ServerData="@(new Func<TableState, Task<TableData<TransactionSummary>>>(ServerReload))"
Loading="@loading">
<ToolBarContent>
<MudText Typo="Typo.h6">Transactions</MudText>
<MudSpacer />
Expand All @@ -31,7 +32,8 @@
DisableElevation="true"
Link="/transactions/new"
Size="Size.Small"
Variant="Variant.Filled">
Variant="Variant.Filled"
Disabled="@loading">
Add transaction
</MudButton>
</ToolBarContent>
Expand Down Expand Up @@ -105,15 +107,15 @@
@code {
private MudTable<TransactionSummary>? table;
private string searchString = "";
private bool _isBusy = false;

// TODO: Keeping this local variable shouldn't be necessary
// because the MudTable ServerData feature should take care of displaying the loading bar appropriately
// However due to https://github.com/MudBlazor/MudBlazor/issues/4662 this doesn't currently work
private bool loading = true;

private async Task<TableData<TransactionSummary>> ServerReload(TableState state)
{
// Workaround for https://github.com/Garderoben/MudBlazor/issues/2070
if (_isBusy)
return new TableData<TransactionSummary>();

_isBusy = true;
loading = true;

TransactionSummaryOrderOption orderBy = state.SortLabel switch
{
Expand All @@ -126,7 +128,7 @@
var query = new GetTransactionQuery(searchString, state.Page, state.PageSize, orderBy, sortDirection);
var data = await _mediator.Send(query);

_isBusy = false;
loading = false;
return new TableData<TransactionSummary>()
{
TotalItems = data.Total,
Expand All @@ -139,5 +141,4 @@
searchString = text;
table?.ReloadServerData();
}

}
1 change: 1 addition & 0 deletions Web/Pages/_Host.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" rel="stylesheet" />
<link href="_content/MudBlazor/MudBlazor.min.css" rel="stylesheet" />
<link href="css/site.css" rel="stylesheet" />
<link href="Web.styles.css" rel="stylesheet">
</head>

<body>
Expand Down
24 changes: 24 additions & 0 deletions Web/Shared/GenericError.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@inject NavigationManager navigationManager

<MudContainer MaxWidth="MaxWidth.Small">
<div class="title">
<h1>
Something went wrong!
</h1>
</div>
<div class="body">
<MudButton OnClick="ForceReload"
Variant="Variant.Filled"
EndIcon="@Icons.Filled.Refresh"
Color="Color.Primary">
Reload application
</MudButton>
</div>
</MudContainer>

@code{
private void ForceReload()
{
navigationManager.NavigateTo(navigationManager.Uri, forceLoad: true);
}
}
11 changes: 11 additions & 0 deletions Web/Shared/GenericError.razor.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
div.title {
display: flex;
justify-content: center;
margin-top: 1rem;
}

div.body{
display: flex;
justify-content: center;
margin-top: 1rem;
}
9 changes: 8 additions & 1 deletion Web/Shared/MainLayout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,14 @@
</MudDrawer>
<MudMainContent>
<MudContainer MaxWidth="MaxWidth.ExtraLarge">
@Body
<ErrorBoundary>
<ChildContent>
@Body
</ChildContent>
<ErrorContent>
<GenericError></GenericError>
</ErrorContent>
</ErrorBoundary>
</MudContainer>
</MudMainContent>
</MudLayout>
Expand Down
2 changes: 1 addition & 1 deletion Web/Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="MudBlazor" Version="6.0.9" />
<PackageReference Include="MudBlazor" Version="6.0.14" />
</ItemGroup>

<PropertyGroup>
Expand Down

0 comments on commit 8001f34

Please sign in to comment.