From 84504413a9e27bd8418d3f9bbd37c2a956a68368 Mon Sep 17 00:00:00 2001 From: A-Guldborg Date: Tue, 23 Apr 2024 23:13:14 +0200 Subject: [PATCH 1/3] Adds loading indicator to non-query data pages --- Shifty.App/Components/MenuItems.razor | 131 ++++++------ Shifty.App/Components/ProductManager.razor | 219 +++++++++++---------- Shifty.App/Components/Voucher.razor | 50 ++--- 3 files changed, 205 insertions(+), 195 deletions(-) diff --git a/Shifty.App/Components/MenuItems.razor b/Shifty.App/Components/MenuItems.razor index f2537e4..2adf21a 100644 --- a/Shifty.App/Components/MenuItems.razor +++ b/Shifty.App/Components/MenuItems.razor @@ -10,77 +10,80 @@ @using Shifty.App.DomainModels @using LanguageExt.UnsafeValueAccess @using Shifty.App.Repositories +@using MudExtensions @inject ISnackbar Snackbar @inject IJSRuntime JSRuntime @inject IMenuItemService MenuItemService @inject IDialogService DialogService - @if (_loading) - { - - - - } - else - { - - - - - - - - - - - - @{ - if (context.Item.Active) - { - - } - else - { - - } - } - - - - - - - + + + + + + + + + + + + + + + + + + + @{ + if (context.Item.Active) + { + + } + else + { + + } + } + + + + + + + + + + + + Add Product + + + + - - - - Add Product - - } diff --git a/Shifty.App/Components/ProductManager.razor b/Shifty.App/Components/ProductManager.razor index 01a538e..98d713e 100644 --- a/Shifty.App/Components/ProductManager.razor +++ b/Shifty.App/Components/ProductManager.razor @@ -20,115 +20,118 @@ } - @if (_loading) - { - - - - } - - - - - - - - - - @{ - if (context.Item.Visible) - { - - } - else - { - - } - } - - - - - - - - - - - - Visible to: - @foreach (var group in Enum.GetValues()) - { - - @group - } - - - - - @{ - if (context.Item.IsPerk) - { - - } - else - { - - } - } - - - - - - + + + + + + + + + + + + + + + + + @{ + if (context.Item.Visible) + { + + } + else + { + + } + } + + + + + + + + + + + + Visible to: + @foreach (var group in Enum.GetValues()) + { + + @group + } + + + + + @{ + if (context.Item.IsPerk) + { + + } + else + { + + } + } + + + + + + - - - - Add Product - - + + + + Add Product + + + + @code { diff --git a/Shifty.App/Components/Voucher.razor b/Shifty.App/Components/Voucher.razor index 947e595..d177e6f 100644 --- a/Shifty.App/Components/Voucher.razor +++ b/Shifty.App/Components/Voucher.razor @@ -7,6 +7,7 @@ @using LanguageExt.UnsafeValueAccess @using Shifty.App.Repositories @using Shifty.App.DomainModels +@using MudExtensions @inject IProductService _productService @inject IVoucherService _voucherService @inject ISnackbar Snackbar @@ -71,25 +72,28 @@ - @if (_showProgressBar) - { - - - - } - @if (_vouchers is not null) - { - - } + + + + + + + + @if (_vouchers is not null) + { + + } + + @@ -100,7 +104,7 @@ public System.Security.Claims.ClaimsPrincipal User { get; set; } private VoucherForm _voucherForm = new(); private bool _isFormValid = false; - private bool _showProgressBar = false; + private bool _loading = false; private IEnumerable _products = new List(); private IEnumerable _vouchers; private string _voucherCodes; @@ -146,7 +150,7 @@ private async Task IssueVoucher() { - _showProgressBar = true; + _loading = true; _vouchers = null; _voucherCodes = null; var result = await _voucherService.IssueVouchers( @@ -158,12 +162,12 @@ result.Match( Succ: response => { - _showProgressBar = false; + _loading = false; _vouchers = response; _voucherCodes = string.Join("\n", _vouchers.Select(issueVoucherResponse => issueVoucherResponse.VoucherCode)); }, Fail: ex => { - _showProgressBar = false; + _loading = false; Snackbar.Add(ex.Message, Severity.Error); } ); From 6472390f7eabe40991f6bd3b79c3e958c12f7a81 Mon Sep 17 00:00:00 2001 From: A-Guldborg Date: Tue, 23 Apr 2024 23:13:35 +0200 Subject: [PATCH 2/3] Adds loading indicator to UnusedTickets component --- Shifty.App/Components/UnusedTickets.razor | 57 ++++++++++++----------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/Shifty.App/Components/UnusedTickets.razor b/Shifty.App/Components/UnusedTickets.razor index e2773bf..b36f04e 100644 --- a/Shifty.App/Components/UnusedTickets.razor +++ b/Shifty.App/Components/UnusedTickets.razor @@ -7,36 +7,41 @@ @using Shifty.App.Shared @using Shared @using LanguageExt.UnsafeValueAccess +@using MudExtensions @inject IUnusedTicketsService _unusedTicketsService @inject ISnackbar Snackbar - - - Unused Tickets - - @if (_loading) - { - - } - - - - - - - - - @context.Item.UnusedPurchasesValue.ToString("0.00") - - - - No records found for the given time period - + + Unused Tickets + + + + + + + + + + + + + + + + @context.Item.UnusedPurchasesValue.ToString("0.00") + + + + No records found for the given time period + + + + @code From d020cfaaaa52aeed42a239e638fd7d3decab6124 Mon Sep 17 00:00:00 2001 From: A-Guldborg Date: Tue, 23 Apr 2024 23:16:13 +0200 Subject: [PATCH 3/3] First attempt at loading indicator to UserTable component --- Shifty.App/Components/UserTable.razor | 120 ++++++++++++++------------ 1 file changed, 66 insertions(+), 54 deletions(-) diff --git a/Shifty.App/Components/UserTable.razor b/Shifty.App/Components/UserTable.razor index d757983..73be8f6 100644 --- a/Shifty.App/Components/UserTable.razor +++ b/Shifty.App/Components/UserTable.razor @@ -5,63 +5,73 @@ @using Shifty.Api.Generated.AnalogCoreV2 @using Shared @using LanguageExt.UnsafeValueAccess +@using MudExtensions @inject IUserService _userService @inject ISnackbar Snackbar - - - Users - - - - - Id - Name - Email - UserGroup - - - @context.Id - @context.Name - @context.Email - @context.UserGroup - - - @context.Id - @context.Name - @context.Email - - - @foreach (var group in Enum.GetValues()) { - @group - } - - - - No matching records found - - - - - + + Users + + + + + + + + + + + + Id + Name + Email + UserGroup + + + @context.Id + @context.Name + @context.Email + @context.UserGroup + + + @context.Id + @context.Name + @context.Email + + + @foreach (var group in Enum.GetValues()) { + @group + } + + + + No matching records found + + + + + + + + @code @@ -69,11 +79,13 @@ private MudTable _table; private string searchString = ""; UserGroup UserGroupBeforeEdit; + private bool _loading = false; private async Task> LoadUsers(TableState state) { + _loading = true; var result = await _userService.SearchUsers(searchString, state.Page, state.PageSize); - + _loading = false; return result.Match( Succ: res => { return new TableData(){ Items = res.Users.AsEnumerable(), TotalItems = res.TotalUsers};