diff --git a/Client/Biskilog Accounting.Client.csproj b/Client/Biskilog Accounting.Client.csproj index 7b814f8..54f710b 100644 --- a/Client/Biskilog Accounting.Client.csproj +++ b/Client/Biskilog Accounting.Client.csproj @@ -20,6 +20,7 @@ + diff --git a/Client/Pages/Dashboard/Dashboard.razor b/Client/Pages/Dashboard/Dashboard.razor index 56240e1..de635ad 100644 --- a/Client/Pages/Dashboard/Dashboard.razor +++ b/Client/Pages/Dashboard/Dashboard.razor @@ -7,35 +7,35 @@
- +
- +
- +
- +
- +
- +
- +
@@ -43,7 +43,7 @@
- +
@@ -54,7 +54,7 @@
- +
diff --git a/Client/Pages/Dashboard/Dashboard.razor.cs b/Client/Pages/Dashboard/Dashboard.razor.cs index 913556d..a1306bb 100644 --- a/Client/Pages/Dashboard/Dashboard.razor.cs +++ b/Client/Pages/Dashboard/Dashboard.razor.cs @@ -6,6 +6,7 @@ namespace Biskilog_Accounting.Client.Pages.Dashboard { public partial class Dashboard { + #region Declarations private TradeSummary m_tradeSummary { get; set; } = new TradeSummary(); private List m_weeklySaleItems { get; set; } = new List { }; private List m_weeklyCancelledSales { get; set; } = new List { }; @@ -17,10 +18,18 @@ namespace Biskilog_Accounting.Client.Pages.Dashboard private double m_cancelledPercentage { get; set; } = 0; private double m_totalDebt { get; set; } = 0; private string m_username { get; set; } = string.Empty; - private bool loadWeeklySales = true; - private bool loadingPriceHistory = true; + #region Loading Variables + private bool m_loadingWeeklySales = true; + private bool m_loadingPriceHistory = true; private bool m_loadingMostPurchased { get; set; } = true; - + private bool m_loadingTradeSummary { get; set; } = true; + private bool m_loadingDebtSummary { get; set; } = true; + private bool m_loadingLowStockSummary { get; set; } = true; + private bool m_loadingRecentTransactionsSummary { get; set; } = true; + private bool m_loadingCancelledSummary { get; set; } = true; + private bool m_loadingCreditSummary { get; set; } = true; + #endregion + #endregion protected override async Task OnInitializedAsync() { m_username = m_tokenService.GetUserNameFromToken(await m_tokenService.GetToken())!; @@ -48,9 +57,6 @@ namespace Biskilog_Accounting.Client.Pages.Dashboard productPriceChangeHistoryTask ); }); - - // Rest of the code... - return; } @@ -62,6 +68,8 @@ namespace Biskilog_Accounting.Client.Pages.Dashboard { try { + m_loadingTradeSummary = true; + StateHasChanged(); var response = await m_http.GetAsync("api/analytics/tradesummary"); if (response.IsSuccessStatusCode) { @@ -69,6 +77,7 @@ namespace Biskilog_Accounting.Client.Pages.Dashboard var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true }; var tradeSummary = JsonSerializer.Deserialize(jsonContent, options); m_tradeSummary = tradeSummary; + m_loadingTradeSummary = false; StateHasChanged(); } } @@ -85,6 +94,8 @@ namespace Biskilog_Accounting.Client.Pages.Dashboard { try { + m_loadingDebtSummary = true; + StateHasChanged(); var response = await m_http.GetAsync("api/analytics/debtors"); if (response.IsSuccessStatusCode) { @@ -92,6 +103,7 @@ namespace Biskilog_Accounting.Client.Pages.Dashboard var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true }; var debt = JsonSerializer.Deserialize>(jsonContent, options); m_totalDebt = (double)debt.Sum(c => c.Debt); + m_loadingDebtSummary = false; StateHasChanged(); } } @@ -108,6 +120,8 @@ namespace Biskilog_Accounting.Client.Pages.Dashboard { try { + m_loadingWeeklySales = true; + StateHasChanged(); var response = await m_http.GetAsync("api/analytics/sales/weekly"); if (response.IsSuccessStatusCode) { @@ -115,7 +129,7 @@ namespace Biskilog_Accounting.Client.Pages.Dashboard var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true }; var sales = JsonSerializer.Deserialize>(jsonContent, options); m_weeklySaleItems = sales; - loadWeeklySales = false; + m_loadingWeeklySales = false; StateHasChanged(); } } @@ -132,8 +146,10 @@ namespace Biskilog_Accounting.Client.Pages.Dashboard { try { - DateTime start = DateTime.Now.AddDays(-7).Date; - DateTime end = DateTime.Now.Date; + m_loadingCancelledSummary = true; + StateHasChanged(); + string start = m_tradeSummary.CurrentTradeDate.Date.AddDays(-7).ToString("yyyy-MM-dd"); + string end = m_tradeSummary.CurrentTradeDate.ToString("yyyy-MM-dd"); var response = await m_http.GetAsync($"api/analytics/cancelledsales/{start}/{end}"); if (response.IsSuccessStatusCode) { @@ -143,24 +159,21 @@ namespace Biskilog_Accounting.Client.Pages.Dashboard m_weeklyCancelledSales = weekly; var loadCancelledSales = m_weeklyCancelledSales.OrderByDescending(t => t.CancelledTransaction.DateCancelled); - if (loadCancelledSales.Count() > 1) + if (loadCancelledSales.Count() >= 1) { m_cancelledWeeklySale = (double)loadCancelledSales.ToList()[0].Value; m_cancelledPercentage = (((double)loadCancelledSales.ToList()[0].Value - (double)loadCancelledSales.ToList()[1].Value) / (double)loadCancelledSales.ToList()[0].Value) * 100; } else { - m_cancelledWeeklySale = (double)loadCancelledSales.FirstOrDefault().Value; + m_cancelledWeeklySale = 0; m_cancelledPercentage = 0; } - + m_loadingCancelledSummary = false; StateHasChanged(); } } - catch (Exception ex) - { - Console.WriteLine(ex.Message); - } + catch { } } /// /// Gets the recent transaction @@ -170,6 +183,8 @@ namespace Biskilog_Accounting.Client.Pages.Dashboard { try { + m_loadingRecentTransactionsSummary = true; + StateHasChanged(); var response = await m_http.GetAsync($"api/analytics/sales/recent/{50}"); if (response.IsSuccessStatusCode) { @@ -177,6 +192,7 @@ namespace Biskilog_Accounting.Client.Pages.Dashboard var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true }; var recent = JsonSerializer.Deserialize>(jsonContent, options); m_recentTransaction = recent; + m_loadingRecentTransactionsSummary = false; StateHasChanged(); } } @@ -191,6 +207,7 @@ namespace Biskilog_Accounting.Client.Pages.Dashboard try { m_loadingMostPurchased = true; + StateHasChanged(); string start = m_tradeSummary.LastTradeDate.ToString("yyyy-MM-dd"); string end = m_tradeSummary.CurrentTradeDate.ToString("yyyy-MM-dd"); var response = await m_http.GetAsync($"api/analytics/mostpurchaseditem/" + start + "/" + end); @@ -214,6 +231,8 @@ namespace Biskilog_Accounting.Client.Pages.Dashboard { try { + m_loadingLowStockSummary = true; + StateHasChanged(); var response = await m_http.GetAsync($"api/analytics/lowonstock"); if (response.IsSuccessStatusCode) { @@ -221,12 +240,11 @@ namespace Biskilog_Accounting.Client.Pages.Dashboard var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true }; var recent = JsonSerializer.Deserialize>(jsonContent, options); m_lowstock = recent; + m_loadingLowStockSummary = false; StateHasChanged(); } } - catch (Exception ex) - { - } + catch { } } /// /// Gets a collection of items that are low on stock @@ -236,6 +254,8 @@ namespace Biskilog_Accounting.Client.Pages.Dashboard { try { + m_loadingPriceHistory = true; + StateHasChanged(); var response = await m_http.GetAsync($"api/analytics/pricechanges/product/history/{5}"); if (response.IsSuccessStatusCode) { @@ -243,13 +263,11 @@ namespace Biskilog_Accounting.Client.Pages.Dashboard var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true }; var recent = JsonSerializer.Deserialize>(jsonContent, options); m_ProductPriceChanges = recent; - loadingPriceHistory = false; + m_loadingPriceHistory = false; StateHasChanged(); } } - catch (Exception ex) - { - } + catch { } } } } diff --git a/Client/Pages/Dashboard/Elements/AnalyticsItemSmall.razor b/Client/Pages/Dashboard/Elements/AnalyticsItemSmall.razor index 361d842..ef15d33 100644 --- a/Client/Pages/Dashboard/Elements/AnalyticsItemSmall.razor +++ b/Client/Pages/Dashboard/Elements/AnalyticsItemSmall.razor @@ -1,17 +1,39 @@ @using Biskilog_Accounting.Shared.Interfaces +@using Microsoft.Fast.Components.FluentUI @inject ICalculator m_calculator -
-
-
-
- chart success +@if (!IsLoading) +{ +
+
+
+
+ chart success +
+ @Title +
@(m_calculator.FormatMoneyWithCurrency(Value))
+ @(Percentage.ToString("0.00")) %
- @Title -
@(m_calculator.FormatMoneyWithCurrency(Value))
- @(Percentage.ToString("0.00")) %
-
\ No newline at end of file +} +else +{ + + + + + + + +} \ No newline at end of file diff --git a/Client/Pages/Dashboard/Elements/AnalyticsItemSmall.razor.cs b/Client/Pages/Dashboard/Elements/AnalyticsItemSmall.razor.cs index 1e6651c..924fe75 100644 --- a/Client/Pages/Dashboard/Elements/AnalyticsItemSmall.razor.cs +++ b/Client/Pages/Dashboard/Elements/AnalyticsItemSmall.razor.cs @@ -7,10 +7,12 @@ namespace Biskilog_Accounting.Client.Pages.Dashboard.Elements [Parameter] public string Icon { get; set; } = string.Empty; [Parameter] - public string Title { get; set; }= string.Empty; + public string Title { get; set; } = string.Empty; [Parameter] - public double Value{ get; set; } + public double Value { get; set; } [Parameter] - public double Percentage { get;set; } + public double Percentage { get; set; } + [Parameter] + public bool IsLoading { get; set; } = true; } } diff --git a/Client/Pages/Dashboard/Elements/ChartElement.razor b/Client/Pages/Dashboard/Elements/ChartElement.razor index 8f94414..a6abdea 100644 --- a/Client/Pages/Dashboard/Elements/ChartElement.razor +++ b/Client/Pages/Dashboard/Elements/ChartElement.razor @@ -1,10 +1,11 @@ @using Biskilog_Accounting.Shared.CustomModels; @using Biskilog_Accounting.Shared.Interfaces; +@using Microsoft.Fast.Components.FluentUI @inject ICalculator m_calculator @if (!IsLoading) { -
+
@Title
@@ -49,6 +50,22 @@
-}else{ - +} +else +{ + + + + + + + } \ No newline at end of file diff --git a/Client/Pages/Dashboard/Elements/LowStockItems.razor b/Client/Pages/Dashboard/Elements/LowStockItems.razor index 4124868..0ef7238 100644 --- a/Client/Pages/Dashboard/Elements/LowStockItems.razor +++ b/Client/Pages/Dashboard/Elements/LowStockItems.razor @@ -1,7 +1,9 @@ @using Biskilog_Accounting.Shared.CustomModels; @using Biskilog_Accounting.Shared.Interfaces; +@using Microsoft.Fast.Components.FluentUI @inject ICalculator m_calculator +@if(!IsLoading){
@@ -28,3 +30,25 @@
+}else{ + + + + + + + +} + \ No newline at end of file diff --git a/Client/Pages/Dashboard/Elements/LowStockItems.razor.cs b/Client/Pages/Dashboard/Elements/LowStockItems.razor.cs index e0734d4..3348bfd 100644 --- a/Client/Pages/Dashboard/Elements/LowStockItems.razor.cs +++ b/Client/Pages/Dashboard/Elements/LowStockItems.razor.cs @@ -6,6 +6,8 @@ namespace Biskilog_Accounting.Client.Pages.Dashboard.Elements public partial class LowStockItems { [Parameter] - public IEnumerable LowStockProducts { get;set; } = new List(); + public IEnumerable LowStockProducts { get; set; } = new List(); + [Parameter] + public bool IsLoading { get; set; } = true; } } diff --git a/Client/Pages/Dashboard/Elements/MostPurchasedElement.razor b/Client/Pages/Dashboard/Elements/MostPurchasedElement.razor index 56f4a08..6e1a325 100644 --- a/Client/Pages/Dashboard/Elements/MostPurchasedElement.razor +++ b/Client/Pages/Dashboard/Elements/MostPurchasedElement.razor @@ -1,5 +1,6 @@ @using Biskilog_Accounting.Shared.CustomModels; @using Biskilog_Accounting.Shared.Interfaces; +@using Microsoft.Fast.Components.FluentUI @inject ICalculator m_calculator @if (!IsLoading) @@ -34,10 +35,21 @@ } else { -
-
-
-
+ + + + + + + } diff --git a/Client/Pages/Dashboard/Elements/ProductPriceHistory.razor b/Client/Pages/Dashboard/Elements/ProductPriceHistory.razor index eb03db0..7adccb3 100644 --- a/Client/Pages/Dashboard/Elements/ProductPriceHistory.razor +++ b/Client/Pages/Dashboard/Elements/ProductPriceHistory.razor @@ -1,5 +1,6 @@ @using Biskilog_Accounting.Shared.CustomModels; @using Biskilog_Accounting.Shared.Interfaces; +@using Microsoft.Fast.Components.FluentUI @inject ICalculator m_calculator @if (!IsLoading) { @@ -14,5 +15,20 @@ } else { + + + + + + + } \ No newline at end of file diff --git a/Client/Pages/Dashboard/Elements/ProductPriceHistory.razor.cs b/Client/Pages/Dashboard/Elements/ProductPriceHistory.razor.cs index 7a83d41..eb36634 100644 --- a/Client/Pages/Dashboard/Elements/ProductPriceHistory.razor.cs +++ b/Client/Pages/Dashboard/Elements/ProductPriceHistory.razor.cs @@ -16,12 +16,12 @@ namespace Biskilog_Accounting.Client.Pages.Dashboard.Elements private bool m_increase { get; set; } = false; private double m_currentPrice { get; set; } = 0; private ApexChartOptions options = new ApexChartOptions(); - private string m_productName { get; set; }= string.Empty; - private string m_subtitle { get;set; } = string.Empty; - private string m_title { get;set; } = string.Empty; + private string m_productName { get; set; } = string.Empty; + private string m_subtitle { get; set; } = string.Empty; + private string m_title { get; set; } = string.Empty; protected override void OnInitialized() { - + base.OnInitialized(); } protected override void OnParametersSet() @@ -52,11 +52,10 @@ namespace Biskilog_Accounting.Client.Pages.Dashboard.Elements } } }; - Random random = new Random(); int randomNumber = random.Next(ProductHistory.Count); m_currentProduct = ProductHistory[randomNumber].Pcode; - m_productHistory = ProductHistory.Where(t => t.Pcode == m_currentProduct).ToList(); + m_productHistory = ValidateList(ProductHistory.Where(t => t.Pcode == m_currentProduct).ToList()); if (m_productHistory.Count > 0) { @@ -71,5 +70,23 @@ namespace Biskilog_Accounting.Client.Pages.Dashboard.Elements } base.OnParametersSet(); } + /// + /// Validates list to remove duplicate dates + /// + /// + /// + private List ValidateList(List a_list) + { + List validated = new List(); + + foreach (ProductPriceChange change in a_list) + { + if (!validated.Select(d => d.ChangeDate).Contains(change.ChangeDate)) + { + validated.Add(change); + } + } + return validated; + } } } diff --git a/Client/Pages/Dashboard/Elements/TransactionCard.razor b/Client/Pages/Dashboard/Elements/TransactionCard.razor index dc0c1c6..bba253f 100644 --- a/Client/Pages/Dashboard/Elements/TransactionCard.razor +++ b/Client/Pages/Dashboard/Elements/TransactionCard.razor @@ -1,31 +1,58 @@ @using Biskilog_Accounting.Shared.CustomModels; @using Biskilog_Accounting.Shared.Interfaces; +@using Microsoft.Fast.Components.FluentUI @inject ICalculator m_calculator -
-
-
Last 50 Transactions
-
-
- - - - - - - +@if (!IsLoading) +{ +
+
+
Last 50 Transactions
+
+
+ + + + + + + - - + + +
-
- +} +else +{ + + + + + + + +} \ No newline at end of file diff --git a/Client/Pages/Dashboard/Elements/WelcomeCard.razor b/Client/Pages/Dashboard/Elements/WelcomeCard.razor index 969e02b..e3efb96 100644 --- a/Client/Pages/Dashboard/Elements/WelcomeCard.razor +++ b/Client/Pages/Dashboard/Elements/WelcomeCard.razor @@ -1,25 +1,47 @@ @using Biskilog_Accounting.Shared.Interfaces; +@using Microsoft.Fast.Components.FluentUI @inject ICalculator m_calculator; -
-
-
-
-
@(TradeSummary.CurrentTradeSales > TradeSummary.LastTradeSales ? "Congratulations 🎉" : TradeSummary.LastTradeSales > TradeSummary.CurrentTradeSales ? "Tough shift there" : "Well Done") @Username!
-

- @m_remarks -

- View Trade Summary +@if (!IsLoading) +{ +
+
+
+
+
@(TradeSummary.CurrentTradeSales > TradeSummary.LastTradeSales ? "Congratulations 🎉" : TradeSummary.LastTradeSales > TradeSummary.CurrentTradeSales ? "Tough shift there" : "Well Done") @Username!
+

+ @m_remarks +

+ View Trade Summary +
-
-
-
- View Badge User +
+
+ View Badge User +
-
\ No newline at end of file +} +else +{ + + + + + + + +} \ No newline at end of file diff --git a/Client/Pages/Dashboard/Elements/WelcomeCard.razor.cs b/Client/Pages/Dashboard/Elements/WelcomeCard.razor.cs index 4982050..277f19b 100644 --- a/Client/Pages/Dashboard/Elements/WelcomeCard.razor.cs +++ b/Client/Pages/Dashboard/Elements/WelcomeCard.razor.cs @@ -10,7 +10,8 @@ namespace Biskilog_Accounting.Client.Pages.Dashboard.Elements [Parameter] public TradeSummary TradeSummary { get; set; } = new TradeSummary(); - + [Parameter] + public bool IsLoading { get; set; } = true; private string m_remarks { get; set; } = ""; private string m_currentTrade { get; set; } = string.Empty; private string m_previousTrade { get; set; } = string.Empty; @@ -21,7 +22,7 @@ namespace Biskilog_Accounting.Client.Pages.Dashboard.Elements } private void CalculateStatistic() { - if(TradeSummary.CurrentTradeDate != DateTime.Today) + if (TradeSummary.CurrentTradeDate != DateTime.Today) { m_currentTrade = $"most recent trade date ({TradeSummary.CurrentTradeDate.ToString("dd MMM,yyy")})"; } diff --git a/Client/Program.cs b/Client/Program.cs index 2f1b925..5109c32 100644 --- a/Client/Program.cs +++ b/Client/Program.cs @@ -6,6 +6,7 @@ using Blazored.LocalStorage; using Blazored.SessionStorage; using Microsoft.AspNetCore.Components.Web; using Microsoft.AspNetCore.Components.WebAssembly.Hosting; +using Microsoft.Fast.Components.FluentUI; var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.RootComponents.Add("#app"); @@ -20,5 +21,11 @@ builder.Services.AddBlazoredSessionStorageAsSingleton(); builder.Services.AddScoped(); builder.Services.AddScoped(); +builder.Services.AddFluentUIComponents(options => +{ + options.HostingModel = BlazorHostingModel.WebAssembly; + options.IconConfiguration = ConfigurationGenerator.GetIconConfiguration(); + options.EmojiConfiguration = ConfigurationGenerator.GetEmojiConfiguration(); +}); await builder.Build().RunAsync();