From acb8cfc638c753458c25c7878e2c238d1c176841 Mon Sep 17 00:00:00 2001 From: "Amir.H Khademi" Date: Sun, 25 Feb 2024 18:21:01 +0330 Subject: [PATCH] feat & fix : add version 0.17.16.23 , fix respons home page , add changelog add change log dialog , add home page view model --- .../Dialogs/ChangeLogDialogBox.razor | 80 ++++++++++++++++++ NetinaShop.AdminPanel.PWA/Models/Address.cs | 1 + .../NetinaShop.AdminPanel.PWA.csproj | 11 ++- NetinaShop.AdminPanel.PWA/Pages/Home.razor | 64 ++++++++++----- NetinaShop.AdminPanel.PWA/Pages/Home.razor.cs | 81 +++++++++++++++++++ .../RestServices/IDashboardApiRest.cs | 7 ++ .../Services/RestServices/IRestWrapper.cs | 1 + .../Services/RestServices/IUserRestApi.cs | 7 +- .../Services/RestServices/RestWrapper.cs | 2 + NetinaShop.AdminPanel.PWA/version.json | 20 +++++ NetinaShop.AdminPanel.PWA/wwwroot/css/app.css | 10 +++ .../wwwroot/css/app.min.css | 48 ++++++++++- .../wwwroot/css/app.output.css | 62 +++++++++++++- 13 files changed, 363 insertions(+), 31 deletions(-) create mode 100644 NetinaShop.AdminPanel.PWA/Dialogs/ChangeLogDialogBox.razor create mode 100644 NetinaShop.AdminPanel.PWA/Pages/Home.razor.cs create mode 100644 NetinaShop.AdminPanel.PWA/Services/RestServices/IDashboardApiRest.cs create mode 100644 NetinaShop.AdminPanel.PWA/version.json diff --git a/NetinaShop.AdminPanel.PWA/Dialogs/ChangeLogDialogBox.razor b/NetinaShop.AdminPanel.PWA/Dialogs/ChangeLogDialogBox.razor new file mode 100644 index 0000000..9abc6bc --- /dev/null +++ b/NetinaShop.AdminPanel.PWA/Dialogs/ChangeLogDialogBox.razor @@ -0,0 +1,80 @@ +@using NetinaShop.Domain.Dtos.ResponseDtos + + + + + + ورژن جدید : + @AdminChangeLog.Version + + @AdminChangeLog.Description + + + + + + + + + 1977 + + + + + ویژگی های جدید + + @foreach (var item in AdminChangeLog.Features) + { + @item + } + + + + + + + + + 1979 + + + + + مشکلات رفع شده + + @foreach (var item in AdminChangeLog.BugFixes) + { + @item + } + + + + + + + + + + + + + بستن + + + +@code { + + [CascadingParameter] + MudDialogInstance MudDialog { get; set; } + + [Parameter] + public AdminChangeLogResponseDto AdminChangeLog { get; set; } = new(); + + void Cancel() => MudDialog.Cancel(); + + protected override Task OnParametersSetAsync() + { + return base.OnParametersSetAsync(); + } + +} diff --git a/NetinaShop.AdminPanel.PWA/Models/Address.cs b/NetinaShop.AdminPanel.PWA/Models/Address.cs index f04ef2a..828f544 100644 --- a/NetinaShop.AdminPanel.PWA/Models/Address.cs +++ b/NetinaShop.AdminPanel.PWA/Models/Address.cs @@ -24,4 +24,5 @@ public static class Address public static string PageController => $"{BaseAddress}/page"; public static string ScraperController => $"{BaseAddress}/scraper"; public static string NewsletterMemberController => $"{BaseAddress}/newsletter/member"; + public static string DashboardController => $"{BaseAddress}/dashboard"; } \ No newline at end of file diff --git a/NetinaShop.AdminPanel.PWA/NetinaShop.AdminPanel.PWA.csproj b/NetinaShop.AdminPanel.PWA/NetinaShop.AdminPanel.PWA.csproj index 2ff350f..9f38236 100644 --- a/NetinaShop.AdminPanel.PWA/NetinaShop.AdminPanel.PWA.csproj +++ b/NetinaShop.AdminPanel.PWA/NetinaShop.AdminPanel.PWA.csproj @@ -5,8 +5,8 @@ enable enable service-worker-assets.js - 0.10.16.23 - 0.10.16.23 + 0.17.16.23 + 0.17.16.23 $(MSBuildProjectName) @@ -55,6 +55,7 @@ + @@ -66,4 +67,10 @@ + + + Always + + + diff --git a/NetinaShop.AdminPanel.PWA/Pages/Home.razor b/NetinaShop.AdminPanel.PWA/Pages/Home.razor index 4e7a1b4..2d4b8d9 100644 --- a/NetinaShop.AdminPanel.PWA/Pages/Home.razor +++ b/NetinaShop.AdminPanel.PWA/Pages/Home.razor @@ -2,70 +2,76 @@ @page "/home" @attribute [Microsoft.AspNetCore.Authorization.Authorize] - - +@inject IDialogService DialogService +@inject NavigationManager NavigationManager +@inject ISnackbar Snackbar +@inject IUserUtility UserUtility +@inject IRestWrapper RestWrapper + + + تعداد محصولاتــ - 1124 + @ViewModel.PageDto.ProductsCount عدد تعداد بلاگــ ها - 845 + @ViewModel.PageDto.BlogsCount عدد فروش های امروز - 125 + @ViewModel.PageDto.TodayOrdersCount عدد - فروش های تایید نشده - 10 + تایید نشده + @ViewModel.PageDto.UnSubmittedOrdersCount عدد تعداد برنـــدها - 125 + @ViewModel.PageDto.BrandsCount عدد تعداد مشترکین - 5632 - عدد + @ViewModel.PageDto.SubscribersCount + نفر - + - - تعداد محصولاتــ + + تعداد محصولاتــ 1124 عدد - - تعداد محصولاتــ + + تعداد محصولاتــ 1124 عدد - - تعداد محصولاتــ + + تعداد محصولاتــ 1124 عدد @@ -78,7 +84,8 @@ + OnClickCallback="@ViewModel.AddProductClicked" + Content="محصول جدید" /> @@ -88,7 +95,8 @@ + OnClickCallback="@ViewModel.AddBlogClicked" + Content="بلاگ جدید" /> @@ -98,7 +106,8 @@ + OnClickCallback="@ViewModel.AddBrandClicked" + Content="برند جدید" /> @@ -152,4 +161,17 @@ - \ No newline at end of file + +@code{ + + + public HomeViewModel ViewModel { get; set; } + protected override async Task OnInitializedAsync() + { + ViewModel = new HomeViewModel(Snackbar, UserUtility, RestWrapper, DialogService); + await ViewModel.InitializeAsync(); + await base.OnInitializedAsync(); + } + + +} diff --git a/NetinaShop.AdminPanel.PWA/Pages/Home.razor.cs b/NetinaShop.AdminPanel.PWA/Pages/Home.razor.cs new file mode 100644 index 0000000..0ac3850 --- /dev/null +++ b/NetinaShop.AdminPanel.PWA/Pages/Home.razor.cs @@ -0,0 +1,81 @@ +using NetinaShop.Domain.Entities.Brands; + +namespace NetinaShop.AdminPanel.PWA.Pages; + +public class HomeViewModel : BaseViewModel +{ + + private readonly ISnackbar _snackbar; + private readonly IUserUtility _userUtility; + private readonly IRestWrapper _restWrapper; + private readonly IDialogService _dialogService; + + public HomeViewModel(ISnackbar snackbar, IUserUtility userUtility, IRestWrapper restWrapper, IDialogService dialogService) + { + _snackbar = snackbar; + _userUtility = userUtility; + _restWrapper = restWrapper; + _dialogService = dialogService; + } + + public override async Task InitializeAsync() + { + try + { + IsProcessing = true; + + var token = await _userUtility.GetBearerTokenAsync(); + if (token == null) + throw new Exception("Token is null"); + + var dto = await _restWrapper.DashboardApiRest.GetHomeDashboardAsync(token); + PageDto = dto; + var changeLog = await _restWrapper.UserRestApi.GetChangeLogAsync(token); + if (changeLog.IsNewVersion) + { + DialogOptions maxWidth = new DialogOptions() { MaxWidth = MaxWidth.Medium, FullWidth = true, NoHeader = true, DisableBackdropClick = true }; + var parameters = new DialogParameters { { x => x.AdminChangeLog,changeLog } }; + await _dialogService.ShowAsync("", parameters, maxWidth); + } + + } + catch (ApiException ex) + { + var exe = await ex.GetContentAsAsync(); + _snackbar.Add(exe != null ? exe.Message : ex.Content, Severity.Error); + } + catch (Exception e) + { + _snackbar.Add(e.Message.Contains("Failed to fetch") ? "اینترنت خود را بررسی نمایید" : e.Message, Severity.Error); + } + finally + { + + IsProcessing = false; + } + await base.InitializeAsync(); + } + + + public async Task AddBlogClicked() + { + DialogOptions maxWidth = new DialogOptions() { MaxWidth = MaxWidth.Medium, FullWidth = true, DisableBackdropClick = true }; + await _dialogService.ShowAsync("افزودن بلاگ جدید", maxWidth); + } + public async Task AddProductClicked() + { + DialogOptions maxWidth = new DialogOptions() { MaxWidth = MaxWidth.Large, FullWidth = true, DisableBackdropClick = true }; + var dialogResult = await _dialogService.ShowAsync("افزودن محصول جدید", maxWidth); + var result = await dialogResult.Result; + if (!result.Canceled && result.Data is bool and true) + { + await InitializeAsync(); + } + } + + public async Task AddBrandClicked() + { + DialogOptions maxWidth = new DialogOptions() { MaxWidth = MaxWidth.Medium, FullWidth = true, DisableBackdropClick = true }; + await _dialogService.ShowAsync("افزودن برند جدید", maxWidth); + } +} \ No newline at end of file diff --git a/NetinaShop.AdminPanel.PWA/Services/RestServices/IDashboardApiRest.cs b/NetinaShop.AdminPanel.PWA/Services/RestServices/IDashboardApiRest.cs new file mode 100644 index 0000000..dd73c27 --- /dev/null +++ b/NetinaShop.AdminPanel.PWA/Services/RestServices/IDashboardApiRest.cs @@ -0,0 +1,7 @@ +namespace NetinaShop.AdminPanel.PWA.Services.RestServices; + +public interface IDashboardApiRest +{ + [Get("/home")] + public Task GetHomeDashboardAsync([Header("Authorization")] string authorization); +} \ No newline at end of file diff --git a/NetinaShop.AdminPanel.PWA/Services/RestServices/IRestWrapper.cs b/NetinaShop.AdminPanel.PWA/Services/RestServices/IRestWrapper.cs index f47e3b6..2f582e2 100644 --- a/NetinaShop.AdminPanel.PWA/Services/RestServices/IRestWrapper.cs +++ b/NetinaShop.AdminPanel.PWA/Services/RestServices/IRestWrapper.cs @@ -20,4 +20,5 @@ public interface IRestWrapper public IPaymentRestApi PaymentRestApi { get; } public IPageRestApi PageRestApi { get; } public IScraperRestApi ScraperRestApi { get; } + public IDashboardApiRest DashboardApiRest { get; } } \ No newline at end of file diff --git a/NetinaShop.AdminPanel.PWA/Services/RestServices/IUserRestApi.cs b/NetinaShop.AdminPanel.PWA/Services/RestServices/IUserRestApi.cs index ef03217..cc809a0 100644 --- a/NetinaShop.AdminPanel.PWA/Services/RestServices/IUserRestApi.cs +++ b/NetinaShop.AdminPanel.PWA/Services/RestServices/IUserRestApi.cs @@ -1,4 +1,6 @@ -namespace NetinaShop.AdminPanel.PWA.Services.RestServices; +using NetinaShop.Domain.Dtos.ResponseDtos; + +namespace NetinaShop.AdminPanel.PWA.Services.RestServices; public interface IUserRestApi { @@ -7,6 +9,9 @@ public interface IUserRestApi [Post("")] Task CreateUserAsync([Body] UserActionRequestDto request, [Header("Authorization")] string authorization); + [Get("/changelog")] + Task GetChangeLogAsync([Header("Authorization")] string authorization); + [Get("/{id}")] Task ReadOne(Guid id, [Header("Authorization")] string authorization); [Get("")] diff --git a/NetinaShop.AdminPanel.PWA/Services/RestServices/RestWrapper.cs b/NetinaShop.AdminPanel.PWA/Services/RestServices/RestWrapper.cs index b85353f..a91f697 100644 --- a/NetinaShop.AdminPanel.PWA/Services/RestServices/RestWrapper.cs +++ b/NetinaShop.AdminPanel.PWA/Services/RestServices/RestWrapper.cs @@ -32,4 +32,6 @@ public class RestWrapper : IRestWrapper public IPaymentRestApi PaymentRestApi => RestService.For(Address.PaymentController, setting); public IPageRestApi PageRestApi => RestService.For(Address.PageController, setting); public IScraperRestApi ScraperRestApi => RestService.For(Address.ScraperController, setting); + + public IDashboardApiRest DashboardApiRest => RestService.For(Address.DashboardController, setting); } \ No newline at end of file diff --git a/NetinaShop.AdminPanel.PWA/version.json b/NetinaShop.AdminPanel.PWA/version.json new file mode 100644 index 0000000..d0de1a4 --- /dev/null +++ b/NetinaShop.AdminPanel.PWA/version.json @@ -0,0 +1,20 @@ +{ + "version": "0.17.16.23", + "versionNumber": 0.101623, + "versionName": "چرتکه", + "description": "", + "features": [ + "افزودن خبرنامه", + "افزودن نام انگلیسی برند", + "افزودن دیالوگ اپدیت جدید", + "افزودن تخفیف همکاری در فروش", + "افزودن قابلیت تغییر نمایش سریع کالا" + ], + "bugFixes": [ + "حل مشکلات امنیتی", + "حل مشکل ویرایش کالا", + "حل مشکل فیلترهای کالاها", + "حل مشکل رسپانسیو صفحه اصلی", + "حل مشکل انتخاب دسته بندی در صفحه کالاها" + ] +} diff --git a/NetinaShop.AdminPanel.PWA/wwwroot/css/app.css b/NetinaShop.AdminPanel.PWA/wwwroot/css/app.css index d90bca3..e86222b 100644 --- a/NetinaShop.AdminPanel.PWA/wwwroot/css/app.css +++ b/NetinaShop.AdminPanel.PWA/wwwroot/css/app.css @@ -94,6 +94,16 @@ } } +/* Hide scrollbar for Chrome, Safari and Opera */ +.no-scrollbar::-webkit-scrollbar { + display: none; +} + +/* Hide scrollbar for IE, Edge and Firefox */ +.no-scrollbar { + -ms-overflow-style: none; /* IE and Edge */ + scrollbar-width: none; /* Firefox */ +} .mud-dialog-title { font-family: iranyekan !important; diff --git a/NetinaShop.AdminPanel.PWA/wwwroot/css/app.min.css b/NetinaShop.AdminPanel.PWA/wwwroot/css/app.min.css index b13c67e..096a869 100644 --- a/NetinaShop.AdminPanel.PWA/wwwroot/css/app.min.css +++ b/NetinaShop.AdminPanel.PWA/wwwroot/css/app.min.css @@ -1064,6 +1064,10 @@ input:checked + .toggle-bg { margin-left: 0.25rem; margin-right: 0.25rem; } +.mx-10 { + margin-left: 2.5rem; + margin-right: 2.5rem; +} .mx-3 { margin-left: 0.75rem; margin-right: 0.75rem; @@ -1132,9 +1136,15 @@ input:checked + .toggle-bg { .mb-5 { margin-bottom: 1.25rem; } +.mb-6 { + margin-bottom: 1.5rem; +} .mb-8 { margin-bottom: 2rem; } +.ml-16 { + margin-left: 4rem; +} .mr-1 { margin-right: 0.25rem; } @@ -1165,6 +1175,9 @@ input:checked + .toggle-bg { .mt-6 { margin-top: 1.5rem; } +.mt-7 { + margin-top: 1.75rem; +} .mt-8 { margin-top: 2rem; } @@ -1222,9 +1235,6 @@ input:checked + .toggle-bg { .h-6 { height: 1.5rem; } -.h-60 { - height: 15rem; -} .h-64 { height: 16rem; } @@ -1301,6 +1311,10 @@ input:checked + .toggle-bg { .w-96 { width: 24rem; } +.w-fit { + width: -moz-fit-content; + width: fit-content; +} .w-full { width: 100%; } @@ -1420,12 +1434,18 @@ input:checked + .toggle-bg { .overflow-hidden { overflow: hidden; } +.overflow-x-hidden { + overflow-x: hidden; +} .overflow-x-scroll { overflow-x: scroll; } .overflow-y-scroll { overflow-y: scroll; } +.whitespace-nowrap { + white-space: nowrap; +} .rounded-full { border-radius: 9999px; } @@ -1582,6 +1602,10 @@ input:checked + .toggle-bg { .p-8 { padding: 2rem; } +.px-0 { + padding-left: 0px; + padding-right: 0px; +} .px-1 { padding-left: 0.25rem; padding-right: 0.25rem; @@ -1862,6 +1886,16 @@ input:checked + .toggle-bg { url('../assets/fonts/ttf/iranyekanwebextrablackfanum.ttf') format('truetype'); } +/* Hide scrollbar for Chrome, Safari and Opera */ +.no-scrollbar::-webkit-scrollbar { + display: none; +} + +/* Hide scrollbar for IE, Edge and Firefox */ +.no-scrollbar { + -ms-overflow-style: none; /* IE and Edge */ + scrollbar-width: none; /* Firefox */ +} .mud-dialog-title { font-family: iranyekan !important; @@ -2073,6 +2107,10 @@ code { border-top-right-radius: 0px; } + .md\:p-5 { + padding: 1.25rem; + } + .md\:px-10 { padding-left: 2.5rem; padding-right: 2.5rem; @@ -2105,6 +2143,10 @@ code { width: 38rem; } + .lg\:p-8 { + padding: 2rem; + } + .lg\:px-20 { padding-left: 5rem; padding-right: 5rem; diff --git a/NetinaShop.AdminPanel.PWA/wwwroot/css/app.output.css b/NetinaShop.AdminPanel.PWA/wwwroot/css/app.output.css index 2dfb217..5d86be2 100644 --- a/NetinaShop.AdminPanel.PWA/wwwroot/css/app.output.css +++ b/NetinaShop.AdminPanel.PWA/wwwroot/css/app.output.css @@ -1140,6 +1140,11 @@ input:checked + .toggle-bg { margin-right: 0.25rem; } +.mx-10 { + margin-left: 2.5rem; + margin-right: 2.5rem; +} + .mx-3 { margin-left: 0.75rem; margin-right: 0.75rem; @@ -1228,10 +1233,18 @@ input:checked + .toggle-bg { margin-bottom: 1.25rem; } +.mb-6 { + margin-bottom: 1.5rem; +} + .mb-8 { margin-bottom: 2rem; } +.ml-16 { + margin-left: 4rem; +} + .mr-1 { margin-right: 0.25rem; } @@ -1272,6 +1285,10 @@ input:checked + .toggle-bg { margin-top: 1.5rem; } +.mt-7 { + margin-top: 1.75rem; +} + .mt-8 { margin-top: 2rem; } @@ -1347,10 +1364,6 @@ input:checked + .toggle-bg { height: 1.5rem; } -.h-60 { - height: 15rem; -} - .h-64 { height: 16rem; } @@ -1452,6 +1465,11 @@ input:checked + .toggle-bg { width: 24rem; } +.w-fit { + width: -moz-fit-content; + width: fit-content; +} + .w-full { width: 100%; } @@ -1606,6 +1624,10 @@ input:checked + .toggle-bg { overflow: hidden; } +.overflow-x-hidden { + overflow-x: hidden; +} + .overflow-x-scroll { overflow-x: scroll; } @@ -1614,6 +1636,10 @@ input:checked + .toggle-bg { overflow-y: scroll; } +.whitespace-nowrap { + white-space: nowrap; +} + .rounded-full { border-radius: 9999px; } @@ -1815,6 +1841,11 @@ input:checked + .toggle-bg { padding: 2rem; } +.px-0 { + padding-left: 0px; + padding-right: 0px; +} + .px-1 { padding-left: 0.25rem; padding-right: 0.25rem; @@ -2179,6 +2210,21 @@ input:checked + .toggle-bg { url('../assets/fonts/ttf/iranyekanwebextrablackfanum.ttf') format('truetype'); } +/* Hide scrollbar for Chrome, Safari and Opera */ + +.no-scrollbar::-webkit-scrollbar { + display: none; +} + +/* Hide scrollbar for IE, Edge and Firefox */ + +.no-scrollbar { + -ms-overflow-style: none; + /* IE and Edge */ + scrollbar-width: none; + /* Firefox */ +} + .mud-dialog-title { font-family: iranyekan !important; } @@ -2387,6 +2433,10 @@ code { border-top-right-radius: 0px; } + .md\:p-5 { + padding: 1.25rem; + } + .md\:px-10 { padding-left: 2.5rem; padding-right: 2.5rem; @@ -2418,6 +2468,10 @@ code { width: 38rem; } + .lg\:p-8 { + padding: 2rem; + } + .lg\:px-20 { padding-left: 5rem; padding-right: 5rem;