From 0f7bfe5409b9a57288001051815109dc19b657f0 Mon Sep 17 00:00:00 2001 From: Yaser Moradi Date: Wed, 16 Oct 2024 18:01:51 +0200 Subject: [PATCH] fix(templates): resolve issues of dashboard page of Boilerplate #8927 (#8928) --- .../.template.config/template.json | 14 ++-- .../Pages/Main/Dashboard/DashboardPage.razor | 23 +++-- .../Main/Dashboard/DashboardPage.razor.cs | 4 +- .../Main/Dashboard/ProductsSalesWidget.razor | 24 ------ .../Dashboard/ProductsSalesWidget.razor.cs | 48 ----------- .../Dashboard/ProductsSalesWidget.razor.scss | 84 ------------------- .../compilerconfig.json | 6 -- .../Dashboard/DashboardController.cs | 13 --- .../Dashboard/IDashboardController.cs | 3 - .../src/Shared/Dtos/AppJsonContext.cs | 1 - .../Dashboard/ProductSaleStatResponseDto.cs | 10 --- 11 files changed, 19 insertions(+), 211 deletions(-) delete mode 100644 src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/Main/Dashboard/ProductsSalesWidget.razor delete mode 100644 src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/Main/Dashboard/ProductsSalesWidget.razor.cs delete mode 100644 src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/Main/Dashboard/ProductsSalesWidget.razor.scss delete mode 100644 src/Templates/Boilerplate/Bit.Boilerplate/src/Shared/Dtos/Dashboard/ProductSaleStatResponseDto.cs diff --git a/src/Templates/Boilerplate/Bit.Boilerplate/.template.config/template.json b/src/Templates/Boilerplate/Bit.Boilerplate/.template.config/template.json index 8b233d16db..a526d282fb 100644 --- a/src/Templates/Boilerplate/Bit.Boilerplate/.template.config/template.json +++ b/src/Templates/Boilerplate/Bit.Boilerplate/.template.config/template.json @@ -389,9 +389,9 @@ "src/Shared/Controllers/Categories/**", "src/Shared/Controllers/Products/**", "src/Shared/Controllers/Dashboard/**", - "src/Client/Boilerplate.Client.Core/Components/Pages/Categories/**", - "src/Client/Boilerplate.Client.Core/Components/Pages/Dashboard/**", - "src/Client/Boilerplate.Client.Core/Components/Pages/Products/**" + "src/Client/Boilerplate.Client.Core/Components/Pages/Main/Categories/**", + "src/Client/Boilerplate.Client.Core/Components/Pages/Main/Dashboard/**", + "src/Client/Boilerplate.Client.Core/Components/Pages/Main/Products/**" ] }, { @@ -402,14 +402,14 @@ "src/Server/Boilerplate.Server.Api/Mappers/TodoMapper.cs", "src/Server/Boilerplate.Server.Api/Models/Todo/**", "src/Shared/Controllers/Todo/**", - "src/Client/Boilerplate.Client.Core/Components/Pages/Todo/**" + "src/Client/Boilerplate.Client.Core/Components/Pages/Main/Todo/**" ] }, { "condition": "(offlineDb != true)", "exclude": [ "src/Client/Boilerplate.Client.Core/Data/**", - "src/Client/Boilerplate.Client.Core/Components/Pages/Offline/**" + "src/Client/Boilerplate.Client.Core/Components/Pages/Main/Offline/**" ] }, { @@ -488,7 +488,9 @@ "src/Tests/PageTests/**", "src/Tests/TestInitializer.cs", "src/Tests/Services/CulturedStringLocalizer.cs", - "src/Tests/Services/FakeGoogleRecaptchaHttpClient.cs" + "src/Tests/Services/FakeGoogleRecaptchaHttpClient.cs", + "src/Tests/Services/EmailReaderService.cs", + "src/Tests/Services/UserService.cs" ] }, { diff --git a/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/Main/Dashboard/DashboardPage.razor b/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/Main/Dashboard/DashboardPage.razor index 3fa1cb93b8..b08b7841e7 100644 --- a/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/Main/Dashboard/DashboardPage.razor +++ b/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/Main/Dashboard/DashboardPage.razor @@ -2,22 +2,19 @@ @attribute [Route("{culture?}" + Urls.DashboardPage)] @inherits AppPageBase -@if (isLoadingAssemblies) -{ - -} -else -{ -
- +
+ + @if (isLoadingAssemblies) + { + + } + else + {
+ } +
-
- -
-
-} diff --git a/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/Main/Dashboard/DashboardPage.razor.cs b/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/Main/Dashboard/DashboardPage.razor.cs index c1bd27ac2e..6b066f0241 100644 --- a/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/Main/Dashboard/DashboardPage.razor.cs +++ b/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/Main/Dashboard/DashboardPage.razor.cs @@ -20,12 +20,10 @@ protected async override Task OnInitAsync() if (AppPlatform.IsBrowser) { await lazyAssemblyLoader.LoadAssembliesAsync([ - //#if (sample == "Admin" && offlineDb == false) + //#if (offlineDb == false) "System.Private.Xml.wasm", "System.Data.Common.wasm", //#endif - //#if (sample == "Admin") "Newtonsoft.Json.wasm"] - //#endif ); } } diff --git a/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/Main/Dashboard/ProductsSalesWidget.razor b/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/Main/Dashboard/ProductsSalesWidget.razor deleted file mode 100644 index f9116f032c..0000000000 --- a/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/Main/Dashboard/ProductsSalesWidget.razor +++ /dev/null @@ -1,24 +0,0 @@ -@inherits AppComponentBase - -
-
-
- @Localizer[nameof(AppStrings.ProductSales)] -
-
- @Localizer[nameof(AppStrings.ProductSalesText)] -
-
-
- @if (isLoading) - { - - } - else - { - - } -
-
- - diff --git a/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/Main/Dashboard/ProductsSalesWidget.razor.cs b/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/Main/Dashboard/ProductsSalesWidget.razor.cs deleted file mode 100644 index 8f679a5c8d..0000000000 --- a/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/Main/Dashboard/ProductsSalesWidget.razor.cs +++ /dev/null @@ -1,48 +0,0 @@ -using Boilerplate.Shared.Controllers.Dashboard; - -namespace Boilerplate.Client.Core.Components.Pages.Main.Dashboard; - -public partial class ProductsSalesWidget -{ - [AutoInject] IDashboardController dashboardController = default!; - - private bool isLoading; - private BitChart? chart; - private BitChartBarConfig config = default!; - - protected override async Task OnInitAsync() - { - config = new BitChartBarConfig - { - Options = new BitChartBarOptions - { - Responsive = true, - Legend = new BitChartLegend() - { - Display = false, - }, - } - }; - - await GetData(); - } - - private async Task GetData() - { - try - { - isLoading = true; - - var data = await dashboardController.GetProductsSalesStats(CurrentCancellationToken); - - BitChartBarDataset chartDataSet = [.. data.Select(d => d.SaleAmount)]; - chartDataSet.BackgroundColor = data.Select(d => d.CategoryColor ?? string.Empty).ToArray(); - config.Data.Datasets.Add(chartDataSet); - config.Data.Labels.AddRange(data.Select(d => d.ProductName ?? string.Empty)); - } - finally - { - isLoading = false; - } - } -} diff --git a/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/Main/Dashboard/ProductsSalesWidget.razor.scss b/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/Main/Dashboard/ProductsSalesWidget.razor.scss deleted file mode 100644 index e392da3054..0000000000 --- a/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/Main/Dashboard/ProductsSalesWidget.razor.scss +++ /dev/null @@ -1,84 +0,0 @@ -@import "../../../../Styles/abstracts/_functions.scss"; -@import "../../../../Styles/abstracts/_media-queries.scss"; -@import "../../../../Styles/abstracts/_bit-css-variables.scss"; - -.card { - width: 100%; - display: flex; - min-height: rem2(376px); - align-items: flex-start; - border-radius: rem2(2px); - flex-flow: column nowrap; - margin-bottom: rem2(24px); - justify-content: flex-start; - padding: rem2(24px) rem2(16px) rem2(58px); - background-color: $bit-color-background-primary; - border: rem2(1px) solid $bit-color-border-secondary; - - @include lt-md { - margin-bottom: 0; - } -} - -.card-header { - width: 100%; - display: flex; - align-items: flex-start; - flex-flow: column nowrap; - padding-bottom: rem2(16px); - justify-content: flex-start; - border-bottom: rem2(1px) solid $bit-color-border-secondary; - - @include md { - padding-bottom: rem2(12px); - } -} - -.title { - font-weight: 600; - font-size: rem2(18px); - line-height: rem2(24px); - margin-bottom: rem2(4px); - - @include md { - font-size: rem2(16px); - line-height: rem2(22px); - } - - @include sm { - font-size: rem2(14px); - line-height: rem2(20px); - } -} - -.subtitle { - font-weight: 400; - font-size: rem2(14px); - line-height: rem2(20px); - - @include md { - font-size: rem2(12px); - line-height: rem2(16px); - } - - @include sm { - font-size: rem2(10px); - line-height: rem2(12px); - } -} - -.card-body { - width: 100%; - display: flex; - align-items: flex-start; - justify-content: flex-start; - padding: rem2(32px) rem2(16px) 0; - - @include md { - padding: rem2(32px) rem2(8px) 0; - } - - @include sm { - padding: rem2(32px) rem2(8px) 0; - } -} diff --git a/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/compilerconfig.json b/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/compilerconfig.json index 88bdd545b6..5d90f9b617 100644 --- a/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/compilerconfig.json +++ b/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/compilerconfig.json @@ -252,12 +252,6 @@ "minify": { "enabled": false }, "options": { "sourceMap": false } }, - { - "outputFile": "Components/Pages/Main/Dashboard/ProductsSalesWidget.razor.css", - "inputFile": "Components/Pages/Main/Dashboard/ProductsSalesWidget.razor.scss", - "minify": { "enabled": false }, - "options": { "sourceMap": false } - }, { "outputFile": "Components/Pages/Main/Products/AddOrEditProductModal.razor.css", "inputFile": "Components/Pages/Main/Products/AddOrEditProductModal.razor.scss", diff --git a/src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Controllers/Dashboard/DashboardController.cs b/src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Controllers/Dashboard/DashboardController.cs index ee4a28f8df..579db59b5c 100644 --- a/src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Controllers/Dashboard/DashboardController.cs +++ b/src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Controllers/Dashboard/DashboardController.cs @@ -32,19 +32,6 @@ public IQueryable GetProductsCountPerCatego }); } - [HttpGet] - public IQueryable GetProductsSalesStats() - { - Random rand = new Random(); - return DbContext.Products.Include(p => p.Category) - .Select(p => new ProductSaleStatResponseDto() - { - ProductName = p.Name, - CategoryColor = p.Category!.Color, - SaleAmount = rand.Next(1, 10) * p.Price - }); - } - [HttpGet] public async Task> GetProductsPercentagePerCategoryStats(CancellationToken cancellationToken) diff --git a/src/Templates/Boilerplate/Bit.Boilerplate/src/Shared/Controllers/Dashboard/IDashboardController.cs b/src/Templates/Boilerplate/Bit.Boilerplate/src/Shared/Controllers/Dashboard/IDashboardController.cs index bda81bd93b..a238327a30 100644 --- a/src/Templates/Boilerplate/Bit.Boilerplate/src/Shared/Controllers/Dashboard/IDashboardController.cs +++ b/src/Templates/Boilerplate/Bit.Boilerplate/src/Shared/Controllers/Dashboard/IDashboardController.cs @@ -11,9 +11,6 @@ public interface IDashboardController : IAppController [HttpGet] Task> GetProductsCountPerCategoryStats(CancellationToken cancellationToken) => default!; - [HttpGet] - Task> GetProductsSalesStats(CancellationToken cancellationToken) => default!; - [HttpGet] Task> GetProductsPercentagePerCategoryStats(CancellationToken cancellationToken); } diff --git a/src/Templates/Boilerplate/Bit.Boilerplate/src/Shared/Dtos/AppJsonContext.cs b/src/Templates/Boilerplate/Bit.Boilerplate/src/Shared/Dtos/AppJsonContext.cs index ef7b62da54..f2e07066a4 100644 --- a/src/Templates/Boilerplate/Bit.Boilerplate/src/Shared/Dtos/AppJsonContext.cs +++ b/src/Templates/Boilerplate/Bit.Boilerplate/src/Shared/Dtos/AppJsonContext.cs @@ -30,7 +30,6 @@ namespace Boilerplate.Shared.Dtos; //#elif (sample == "Admin") [JsonSerializable(typeof(List))] [JsonSerializable(typeof(OverallAnalyticsStatsDataResponseDto))] -[JsonSerializable(typeof(List))] [JsonSerializable(typeof(List))] [JsonSerializable(typeof(ProductDto))] [JsonSerializable(typeof(PagedResult))] diff --git a/src/Templates/Boilerplate/Bit.Boilerplate/src/Shared/Dtos/Dashboard/ProductSaleStatResponseDto.cs b/src/Templates/Boilerplate/Bit.Boilerplate/src/Shared/Dtos/Dashboard/ProductSaleStatResponseDto.cs deleted file mode 100644 index 9b69235541..0000000000 --- a/src/Templates/Boilerplate/Bit.Boilerplate/src/Shared/Dtos/Dashboard/ProductSaleStatResponseDto.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Boilerplate.Shared.Dtos.Dashboard; - -public partial class ProductSaleStatResponseDto -{ - public string? ProductName { get; set; } - - public string? CategoryColor { get; set; } - - public decimal SaleAmount { get; set; } -}