feat(app-versions): Add functionality to create new app versions and update UI components
Build and Deploy / build (push) Successful in 2m26s

This commit is contained in:
masoodafar-web
2025-12-27 02:45:47 +03:30
parent d69b838a72
commit ece29956b2
4 changed files with 103 additions and 20 deletions
@@ -26,6 +26,13 @@
T="bool" T="bool"
ValueChanged="@(async (bool val) => { _includeInactive = val; await LoadVersions(); })" /> ValueChanged="@(async (bool val) => { _includeInactive = val; await LoadVersions(); })" />
<MudStack Row="true" Spacing="2">
<MudButton Variant="Variant.Filled"
Color="Color.Primary"
StartIcon="@Icons.Material.Filled.Add"
OnClick="@OpenCreateDialog">
افزودن نسخه جدید
</MudButton>
<MudButton Variant="Variant.Outlined" <MudButton Variant="Variant.Outlined"
Color="Color.Primary" Color="Color.Primary"
StartIcon="@Icons.Material.Filled.Refresh" StartIcon="@Icons.Material.Filled.Refresh"
@@ -33,6 +40,7 @@
بارگذاری مجدد بارگذاری مجدد
</MudButton> </MudButton>
</MudStack> </MudStack>
</MudStack>
@if (_loading) @if (_loading)
{ {
@@ -61,7 +69,7 @@
<TemplateColumn Title="نسخه فعلی"> <TemplateColumn Title="نسخه فعلی">
<CellTemplate> <CellTemplate>
<MudChip T="string" Color="Color.Primary" Size="Size.Small" Variant="Variant.Outlined"> <MudChip T="string" Color="Color.Primary" Size="Size.Small" Variant="Variant.Outlined">
v@context.Item.CurrentVersion @context.Item.CurrentVersion
</MudChip> </MudChip>
</CellTemplate> </CellTemplate>
</TemplateColumn> </TemplateColumn>
@@ -71,7 +79,7 @@
@if (!string.IsNullOrEmpty(context.Item.MinRequiredVersion)) @if (!string.IsNullOrEmpty(context.Item.MinRequiredVersion))
{ {
<MudChip T="string" Color="Color.Warning" Size="Size.Small" Variant="Variant.Outlined"> <MudChip T="string" Color="Color.Warning" Size="Size.Small" Variant="Variant.Outlined">
v@context.Item.MinRequiredVersion @context.Item.MinRequiredVersion
</MudChip> </MudChip>
} }
else else
@@ -151,14 +159,14 @@
<MudStack Spacing="2"> <MudStack Spacing="2">
<MudStack Row="true" Justify="Justify.SpaceBetween"> <MudStack Row="true" Justify="Justify.SpaceBetween">
<MudText Typo="Typo.body2">نسخه فعلی:</MudText> <MudText Typo="Typo.body2">نسخه فعلی:</MudText>
<MudChip T="string" Color="Color.Primary" Size="Size.Small">v@version.CurrentVersion</MudChip> <MudChip T="string" Color="Color.Primary" Size="Size.Small">@version.CurrentVersion</MudChip>
</MudStack> </MudStack>
<MudStack Row="true" Justify="Justify.SpaceBetween"> <MudStack Row="true" Justify="Justify.SpaceBetween">
<MudText Typo="Typo.body2">حداقل نسخه:</MudText> <MudText Typo="Typo.body2">حداقل نسخه:</MudText>
@if (!string.IsNullOrEmpty(version.MinRequiredVersion)) @if (!string.IsNullOrEmpty(version.MinRequiredVersion))
{ {
<MudChip T="string" Color="Color.Warning" Size="Size.Small">v@version.MinRequiredVersion</MudChip> <MudChip T="string" Color="Color.Warning" Size="Size.Small">@version.MinRequiredVersion</MudChip>
} }
else else
{ {
@@ -215,6 +223,52 @@
} }
} }
private async Task OpenCreateDialog()
{
var parameters = new DialogParameters<AppVersionEditDialog>
{
{ 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<AppVersionEditDialog>(
"افزودن نسخه جدید",
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) private async Task OpenEditDialog(AppVersionDto version)
{ {
var parameters = new DialogParameters<AppVersionEditDialog> var parameters = new DialogParameters<AppVersionEditDialog>
@@ -296,15 +350,15 @@
private string GetAppIcon(string appName) => appName switch private string GetAppIcon(string appName) => appName switch
{ {
"FoursatMarketApp" => Icons.Material.Filled.ShoppingCart, "KaraBazarApp" => Icons.Material.Filled.ShoppingCart,
"FoursatClubApp" => Icons.Material.Filled.Groups, "KaraBazarAdminApp" => Icons.Material.Filled.AdminPanelSettings,
_ => Icons.Material.Filled.PhoneAndroid _ => Icons.Material.Filled.PhoneAndroid
}; };
private Color GetAppColor(string appName) => appName switch private Color GetAppColor(string appName) => appName switch
{ {
"FoursatMarketApp" => Color.Primary, "KaraBazarApp" => Color.Primary,
"FoursatClubApp" => Color.Secondary, "KaraBazarAdminApp" => Color.Secondary,
_ => Color.Default _ => Color.Default
}; };
} }
@@ -5,11 +5,25 @@
<DialogContent> <DialogContent>
<MudForm @ref="_form" @bind-IsValid="_isValid"> <MudForm @ref="_form" @bind-IsValid="_isValid">
<MudStack Spacing="3"> <MudStack Spacing="3">
@if (IsNew)
{
<MudSelect @bind-Value="Model.AppName"
Label="نام اپلیکیشن"
Variant="Variant.Outlined"
Required="true"
RequiredError="انتخاب اپلیکیشن اجباری است">
<MudSelectItem Value="@("KaraBazarApp")">کارابازار</MudSelectItem>
<MudSelectItem Value="@("KaraBazarAdminApp")">ادمین کارابازار</MudSelectItem>
</MudSelect>
}
else
{
<MudTextField @bind-Value="Model.AppName" <MudTextField @bind-Value="Model.AppName"
Label="نام اپلیکیشن" Label="نام اپلیکیشن"
Variant="Variant.Outlined" Variant="Variant.Outlined"
ReadOnly="true" ReadOnly="true"
Disabled="true" /> Disabled="true" />
}
<MudTextField @bind-Value="Model.CurrentVersion" <MudTextField @bind-Value="Model.CurrentVersion"
Label="نسخه فعلی" Label="نسخه فعلی"
@@ -68,6 +82,9 @@
[Parameter] [Parameter]
public UpdateAppVersionDto Model { get; set; } = new(); public UpdateAppVersionDto Model { get; set; } = new();
[Parameter]
public bool IsNew { get; set; } = false;
private MudForm? _form; private MudForm? _form;
private bool _isValid; private bool _isValid;
+11
View File
@@ -252,6 +252,15 @@
تنظیمات سیستم تنظیمات سیستم
</MudNavLink> </MudNavLink>
} }
@if (CanViewSettings)
{
<MudNavLink Match="NavLinkMatch.Prefix"
Href="/settings/app-versions"
Icon="@Icons.Material.Filled.PhoneAndroid">
نسخه اپلیکیشن‌ها
</MudNavLink>
}
</Authorized> </Authorized>
</AuthorizeView> </AuthorizeView>
@@ -295,6 +304,7 @@
private bool CanViewSystemAlerts; private bool CanViewSystemAlerts;
private bool CanViewSystemHealth; private bool CanViewSystemHealth;
private bool CanManageSystemConfiguration; private bool CanManageSystemConfiguration;
private bool CanViewSettings;
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
@@ -323,6 +333,7 @@
CanViewSystemAlerts = await AuthorizationService.HasPermissionAsync("system.alerts.view"); CanViewSystemAlerts = await AuthorizationService.HasPermissionAsync("system.alerts.view");
CanViewSystemHealth = await AuthorizationService.HasPermissionAsync("system.health.view"); CanViewSystemHealth = await AuthorizationService.HasPermissionAsync("system.health.view");
CanManageSystemConfiguration = await AuthorizationService.HasPermissionAsync("settings.manage_configuration"); CanManageSystemConfiguration = await AuthorizationService.HasPermissionAsync("settings.manage_configuration");
CanViewSettings = await AuthorizationService.HasPermissionAsync("settings.view");
_initialized = true; _initialized = true;
StateHasChanged(); StateHasChanged();
+2 -1
View File
@@ -1,5 +1,6 @@
{ {
"GwUrl": "https://bogw.kbs2.ir", // "GwUrl": "https://localhost:6468",
"GwUrl": "https://backoffice-bff.foursat.afrino.co",
"Authentication": { "Authentication": {
"Authority": "https://ids.afrino.co/", "Authority": "https://ids.afrino.co/",
"ClientId": "client_backoffice_spa" "ClientId": "client_backoffice_spa"