From ece29956b26a13f8acd18198ba1ae93378c912e4 Mon Sep 17 00:00:00 2001 From: masoodafar-web Date: Sat, 27 Dec 2025 02:45:47 +0330 Subject: [PATCH] feat(app-versions): Add functionality to create new app versions and update UI components --- .../Pages/Settings/AppVersions.razor | 82 +++++++++++++++---- .../Components/AppVersionEditDialog.razor | 27 ++++-- src/BackOffice/Shared/NavMenu.razor | 11 +++ src/BackOffice/wwwroot/appsettings.json | 3 +- 4 files changed, 103 insertions(+), 20 deletions(-) diff --git a/src/BackOffice/Pages/Settings/AppVersions.razor b/src/BackOffice/Pages/Settings/AppVersions.razor index 3e815f0..e12d2ed 100644 --- a/src/BackOffice/Pages/Settings/AppVersions.razor +++ b/src/BackOffice/Pages/Settings/AppVersions.razor @@ -26,12 +26,20 @@ T="bool" ValueChanged="@(async (bool val) => { _includeInactive = val; await LoadVersions(); })" /> - - بارگذاری مجدد - + + + افزودن نسخه جدید + + + بارگذاری مجدد + + @if (_loading) @@ -61,7 +69,7 @@ - v@context.Item.CurrentVersion + @context.Item.CurrentVersion @@ -71,7 +79,7 @@ @if (!string.IsNullOrEmpty(context.Item.MinRequiredVersion)) { - v@context.Item.MinRequiredVersion + @context.Item.MinRequiredVersion } else @@ -151,14 +159,14 @@ نسخه فعلی: - v@version.CurrentVersion + @version.CurrentVersion حداقل نسخه: @if (!string.IsNullOrEmpty(version.MinRequiredVersion)) { - v@version.MinRequiredVersion + @version.MinRequiredVersion } else { @@ -215,6 +223,52 @@ } } + private async Task OpenCreateDialog() + { + var parameters = new DialogParameters + { + { x => x.Model, new UpdateAppVersionDto + { + AppName = "", + CurrentVersion = "1.0.0", + MinRequiredVersion = null, + RequiresFullCacheClear = false, + UpdateMessage = null, + ReleaseNotes = null + } + }, + { x => x.IsNew, true } + }; + + var options = new DialogOptions + { + CloseButton = true, + MaxWidth = MaxWidth.Medium, + FullWidth = true + }; + + var dialog = await DialogService.ShowAsync( + "افزودن نسخه جدید", + parameters, + options); + + var result = await dialog.Result; + + if (result is { Canceled: false, Data: UpdateAppVersionDto dto }) + { + try + { + await AppVersionService.UpdateAsync(dto); + Snackbar.Add("نسخه جدید با موفقیت ایجاد شد", Severity.Success); + await LoadVersions(); + } + catch (Exception ex) + { + Snackbar.Add($"خطا در ایجاد: {ex.Message}", Severity.Error); + } + } + } + private async Task OpenEditDialog(AppVersionDto version) { var parameters = new DialogParameters @@ -296,15 +350,15 @@ private string GetAppIcon(string appName) => appName switch { - "FoursatMarketApp" => Icons.Material.Filled.ShoppingCart, - "FoursatClubApp" => Icons.Material.Filled.Groups, + "KaraBazarApp" => Icons.Material.Filled.ShoppingCart, + "KaraBazarAdminApp" => Icons.Material.Filled.AdminPanelSettings, _ => Icons.Material.Filled.PhoneAndroid }; private Color GetAppColor(string appName) => appName switch { - "FoursatMarketApp" => Color.Primary, - "FoursatClubApp" => Color.Secondary, + "KaraBazarApp" => Color.Primary, + "KaraBazarAdminApp" => Color.Secondary, _ => Color.Default }; } diff --git a/src/BackOffice/Pages/Settings/Components/AppVersionEditDialog.razor b/src/BackOffice/Pages/Settings/Components/AppVersionEditDialog.razor index e3231b9..dc3163b 100644 --- a/src/BackOffice/Pages/Settings/Components/AppVersionEditDialog.razor +++ b/src/BackOffice/Pages/Settings/Components/AppVersionEditDialog.razor @@ -5,11 +5,25 @@ - + @if (IsNew) + { + + کارابازار + ادمین کارابازار + + } + else + { + + } } + + @if (CanViewSettings) + { + + نسخه اپلیکیشن‌ها + + } @@ -295,6 +304,7 @@ private bool CanViewSystemAlerts; private bool CanViewSystemHealth; private bool CanManageSystemConfiguration; + private bool CanViewSettings; protected override async Task OnInitializedAsync() { @@ -323,6 +333,7 @@ CanViewSystemAlerts = await AuthorizationService.HasPermissionAsync("system.alerts.view"); CanViewSystemHealth = await AuthorizationService.HasPermissionAsync("system.health.view"); CanManageSystemConfiguration = await AuthorizationService.HasPermissionAsync("settings.manage_configuration"); + CanViewSettings = await AuthorizationService.HasPermissionAsync("settings.view"); _initialized = true; StateHasChanged(); diff --git a/src/BackOffice/wwwroot/appsettings.json b/src/BackOffice/wwwroot/appsettings.json index 85b46cc..50cda35 100644 --- a/src/BackOffice/wwwroot/appsettings.json +++ b/src/BackOffice/wwwroot/appsettings.json @@ -1,5 +1,6 @@ { - "GwUrl": "https://bogw.kbs2.ir", +// "GwUrl": "https://localhost:6468", + "GwUrl": "https://backoffice-bff.foursat.afrino.co", "Authentication": { "Authority": "https://ids.afrino.co/", "ClientId": "client_backoffice_spa"