mirror of https://github.com/abpframework/abp.git
24 changed files with 1149 additions and 0 deletions
@ -0,0 +1,10 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace Volo.Abp.SettingManagement.Blazor.MudBlazor; |
||||
|
|
||||
|
public interface ISettingComponentContributor |
||||
|
{ |
||||
|
Task ConfigureAsync(SettingComponentCreationContext context); |
||||
|
|
||||
|
Task<bool> CheckPermissionsAsync(SettingComponentCreationContext context); |
||||
|
} |
||||
@ -0,0 +1,63 @@ |
|||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.Extensions.Options; |
||||
|
using Volo.Abp.Features; |
||||
|
using Volo.Abp.SettingManagement.Localization; |
||||
|
using Volo.Abp.UI.Navigation; |
||||
|
|
||||
|
namespace Volo.Abp.SettingManagement.Blazor.MudBlazor.Menus; |
||||
|
|
||||
|
public class SettingManagementMenuContributor : IMenuContributor |
||||
|
{ |
||||
|
public async Task ConfigureMenuAsync(MenuConfigurationContext context) |
||||
|
{ |
||||
|
if (context.Menu.Name == StandardMenus.Main) |
||||
|
{ |
||||
|
await ConfigureMainMenuAsync(context); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private async Task ConfigureMainMenuAsync(MenuConfigurationContext context) |
||||
|
{ |
||||
|
var settingManagementPageOptions = context.ServiceProvider.GetRequiredService<IOptions<SettingManagementComponentOptions>>().Value; |
||||
|
var settingPageCreationContext = new SettingComponentCreationContext(context.ServiceProvider); |
||||
|
if (!settingManagementPageOptions.Contributors.Any() || |
||||
|
!(await CheckAnyOfPagePermissionsGranted(settingManagementPageOptions, settingPageCreationContext)) |
||||
|
) |
||||
|
{ |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
var l = context.GetLocalizer<AbpSettingManagementResource>(); |
||||
|
|
||||
|
/* This may happen if MVC UI is being used in the same application. |
||||
|
* In this case, we are removing the MVC setting management UI. */ |
||||
|
context.Menu.GetAdministration().TryRemoveMenuItem(SettingManagementMenus.GroupName); |
||||
|
|
||||
|
context.Menu |
||||
|
.GetAdministration() |
||||
|
.AddItem( |
||||
|
new ApplicationMenuItem( |
||||
|
SettingManagementMenus.GroupName, |
||||
|
l["Settings"], |
||||
|
"~/setting-management", |
||||
|
icon: "fa fa-cog" |
||||
|
).RequireFeatures(SettingManagementFeatures.Enable) |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
protected virtual async Task<bool> CheckAnyOfPagePermissionsGranted( |
||||
|
SettingManagementComponentOptions settingManagementComponentOptions, |
||||
|
SettingComponentCreationContext settingComponentCreationContext) |
||||
|
{ |
||||
|
foreach (var contributor in settingManagementComponentOptions.Contributors) |
||||
|
{ |
||||
|
if (await contributor.CheckPermissionsAsync(settingComponentCreationContext)) |
||||
|
{ |
||||
|
return true; |
||||
|
} |
||||
|
} |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,6 @@ |
|||||
|
namespace Volo.Abp.SettingManagement.Blazor.MudBlazor.Menus; |
||||
|
|
||||
|
public class SettingManagementMenus |
||||
|
{ |
||||
|
public const string GroupName = "SettingManagement"; |
||||
|
} |
||||
@ -0,0 +1,121 @@ |
|||||
|
@using Volo.Abp.SettingManagement.Localization |
||||
|
@using MudBlazor |
||||
|
@inherits Volo.Abp.AspNetCore.Components.AbpComponentBase |
||||
|
|
||||
|
@if (EmailSettings != null) |
||||
|
{ |
||||
|
<MudForm> |
||||
|
<MudForm @ref="@_emailFormRef" Model="@EmailSettings"> |
||||
|
<MudGrid> |
||||
|
<MudItem xs="12"> |
||||
|
<MudTextField @bind-Value="@EmailSettings.DefaultFromDisplayName" |
||||
|
Label="@L["DefaultFromDisplayName"]" |
||||
|
Required="true" |
||||
|
RequiredError="@L["ThisFieldIsRequired"]" |
||||
|
Variant="Variant.Outlined" /> |
||||
|
</MudItem> |
||||
|
<MudItem xs="12"> |
||||
|
<MudTextField @bind-Value="@EmailSettings.DefaultFromAddress" |
||||
|
Label="@L["DefaultFromAddress"]" |
||||
|
Required="true" |
||||
|
RequiredError="@L["ThisFieldIsRequired"]" |
||||
|
Variant="Variant.Outlined" /> |
||||
|
</MudItem> |
||||
|
<MudItem xs="12"> |
||||
|
<MudTextField @bind-Value="@EmailSettings.SmtpHost" |
||||
|
Label="@L["SmtpHost"]" |
||||
|
Variant="Variant.Outlined" /> |
||||
|
</MudItem> |
||||
|
<MudItem xs="12"> |
||||
|
<MudNumericField<int> @bind-Value="@EmailSettings.SmtpPort" |
||||
|
Label="@L["SmtpPort"]" |
||||
|
Variant="Variant.Outlined" /> |
||||
|
</MudItem> |
||||
|
<MudItem xs="12"> |
||||
|
<MudCheckBox @bind-Checked="@EmailSettings.SmtpEnableSsl" |
||||
|
Label="@L["SmtpEnableSsl"]" /> |
||||
|
</MudItem> |
||||
|
<MudItem xs="12"> |
||||
|
<MudCheckBox @bind-Checked="@EmailSettings.SmtpUseDefaultCredentials" |
||||
|
Label="@L["SmtpUseDefaultCredentials"]" /> |
||||
|
</MudItem> |
||||
|
@if (!EmailSettings.SmtpUseDefaultCredentials) |
||||
|
{ |
||||
|
<MudItem xs="12"> |
||||
|
<MudTextField @bind-Value="@EmailSettings.SmtpDomain" |
||||
|
Label="@L["SmtpDomain"]" |
||||
|
Variant="Variant.Outlined" /> |
||||
|
</MudItem> |
||||
|
<MudItem xs="12"> |
||||
|
<MudTextField @bind-Value="@EmailSettings.SmtpUserName" |
||||
|
Label="@L["SmtpUserName"]" |
||||
|
Variant="Variant.Outlined" /> |
||||
|
</MudItem> |
||||
|
<MudItem xs="12"> |
||||
|
<MudTextField @bind-Value="@EmailSettings.SmtpPassword" |
||||
|
Label="@L["SmtpPassword"]" |
||||
|
InputType="InputType.Password" |
||||
|
Placeholder="@L["SmtpPasswordPlaceholder"]" |
||||
|
Variant="Variant.Outlined" /> |
||||
|
</MudItem> |
||||
|
} |
||||
|
</MudGrid> |
||||
|
</MudForm> |
||||
|
<MudDivider Class="my-3" /> |
||||
|
<MudGrid> |
||||
|
<MudItem xs="12"> |
||||
|
@if (HasSendTestEmailPermission) |
||||
|
{ |
||||
|
<MudButton Color="Color.Primary" |
||||
|
Variant="Variant.Outlined" |
||||
|
OnClick="@OpenSendTestEmailDialogAsync" |
||||
|
Class="me-2"> |
||||
|
@L["SendTestEmail"] |
||||
|
</MudButton> |
||||
|
} |
||||
|
<MudButton Color="Color.Primary" |
||||
|
Variant="Variant.Filled" |
||||
|
OnClick="@UpdateSettingsAsync"> |
||||
|
@L["Save"] |
||||
|
</MudButton> |
||||
|
</MudItem> |
||||
|
</MudGrid> |
||||
|
</MudForm> |
||||
|
|
||||
|
@if (HasSendTestEmailPermission) |
||||
|
{ |
||||
|
<MudDialog @bind-IsVisible="@_sendTestEmailDialogVisible" Options="@(new DialogOptions { MaxWidth = MaxWidth.Medium, FullWidth = true })" CloseOnEscapeKey="true"> |
||||
|
<TitleContent> |
||||
|
<MudText Typo="Typo.h6">@L["SendTestEmail"]</MudText> |
||||
|
</TitleContent> |
||||
|
<DialogContent> |
||||
|
<MudForm @ref="@_testEmailFormRef" Model="@SendTestEmailInput"> |
||||
|
<MudTextField @bind-Value="@SendTestEmailInput.SenderEmailAddress" |
||||
|
Label="@L["SenderEmailAddress"]" |
||||
|
Required="true" |
||||
|
RequiredError="@L["ThisFieldIsRequired"]" |
||||
|
Variant="Variant.Outlined" |
||||
|
AutoFocus="true" /> |
||||
|
<MudTextField @bind-Value="@SendTestEmailInput.TargetEmailAddress" |
||||
|
Label="@L["TargetEmailAddress"]" |
||||
|
Required="true" |
||||
|
RequiredError="@L["ThisFieldIsRequired"]" |
||||
|
Variant="Variant.Outlined" /> |
||||
|
<MudTextField @bind-Value="@SendTestEmailInput.Subject" |
||||
|
Label="@L["Subject"]" |
||||
|
Required="true" |
||||
|
RequiredError="@L["ThisFieldIsRequired"]" |
||||
|
Variant="Variant.Outlined" /> |
||||
|
<MudTextField @bind-Value="@SendTestEmailInput.Body" |
||||
|
Label="@L["Body"]" |
||||
|
Lines="5" |
||||
|
Variant="Variant.Outlined" /> |
||||
|
</MudForm> |
||||
|
</DialogContent> |
||||
|
<DialogActions> |
||||
|
<MudButton OnClick="@CloseSendTestEmailDialogAsync">@L["Cancel"]</MudButton> |
||||
|
<MudButton Color="Color.Primary" Variant="Variant.Filled" OnClick="@SendTestEmailAsync">@L["Send"]</MudButton> |
||||
|
</DialogActions> |
||||
|
</MudDialog> |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,195 @@ |
|||||
|
using System; |
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Components; |
||||
|
using MudBlazor; |
||||
|
using Volo.Abp.AspNetCore.Components.Messages; |
||||
|
using Volo.Abp.AspNetCore.Components.Web.Configuration; |
||||
|
using Volo.Abp.Auditing; |
||||
|
using Volo.Abp.Authorization.Permissions; |
||||
|
using Volo.Abp.SettingManagement.Localization; |
||||
|
|
||||
|
namespace Volo.Abp.SettingManagement.Blazor.MudBlazor.Pages.SettingManagement.EmailSettingGroup; |
||||
|
|
||||
|
public partial class EmailSettingGroupViewComponent |
||||
|
{ |
||||
|
[Inject] |
||||
|
protected IEmailSettingsAppService EmailSettingsAppService { get; set; } = default!; |
||||
|
|
||||
|
[Inject] |
||||
|
protected IPermissionChecker PermissionChecker { get; set; } = default!; |
||||
|
|
||||
|
[Inject] |
||||
|
private ICurrentApplicationConfigurationCacheResetService CurrentApplicationConfigurationCacheResetService { get; set; } = default!; |
||||
|
|
||||
|
[Inject] |
||||
|
protected IUiMessageService UiMessageService { get; set; } = default!; |
||||
|
|
||||
|
[Inject] |
||||
|
protected ISnackbar Snackbar { get; set; } = default!; |
||||
|
|
||||
|
protected UpdateEmailSettingsViewModel? EmailSettings; |
||||
|
|
||||
|
protected SendTestEmailViewModel SendTestEmailInput = new(); |
||||
|
|
||||
|
protected MudForm? _emailFormRef; |
||||
|
protected MudForm? _testEmailFormRef; |
||||
|
|
||||
|
protected bool _sendTestEmailDialogVisible; |
||||
|
|
||||
|
protected bool HasSendTestEmailPermission { get; set; } |
||||
|
|
||||
|
public EmailSettingGroupViewComponent() |
||||
|
{ |
||||
|
ObjectMapperContext = typeof(AbpSettingManagementBlazorMudBlazorModule); |
||||
|
LocalizationResource = typeof(AbpSettingManagementResource); |
||||
|
} |
||||
|
|
||||
|
protected async override Task OnInitializedAsync() |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
EmailSettings = ObjectMapper.Map<EmailSettingsDto, UpdateEmailSettingsViewModel>(await EmailSettingsAppService.GetAsync()); |
||||
|
HasSendTestEmailPermission = await PermissionChecker.IsGrantedAsync(SettingManagementPermissions.EmailingTest); |
||||
|
SendTestEmailInput = new SendTestEmailViewModel(); |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
await HandleErrorAsync(ex); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
protected virtual async Task UpdateSettingsAsync() |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
if (_emailFormRef != null && !await _emailFormRef.Validate()) |
||||
|
{ |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
if (EmailSettings == null) |
||||
|
{ |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
await EmailSettingsAppService.UpdateAsync(ObjectMapper.Map<UpdateEmailSettingsViewModel, UpdateEmailSettingsDto>(EmailSettings)); |
||||
|
|
||||
|
await CurrentApplicationConfigurationCacheResetService.ResetAsync(); |
||||
|
|
||||
|
Snackbar.Add(L["SavedSuccessfully"], Severity.Success); |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
await HandleErrorAsync(ex); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
protected virtual async Task OpenSendTestEmailDialogAsync() |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
if (_testEmailFormRef != null) |
||||
|
{ |
||||
|
await _testEmailFormRef.ResetAsync(); |
||||
|
} |
||||
|
var emailSettings = await EmailSettingsAppService.GetAsync(); |
||||
|
SendTestEmailInput = new SendTestEmailViewModel |
||||
|
{ |
||||
|
SenderEmailAddress = emailSettings.DefaultFromAddress, |
||||
|
TargetEmailAddress = CurrentUser.Email, |
||||
|
Subject = L["TestEmailSubject", new Random().Next(1000, 9999)], |
||||
|
Body = L["TestEmailBody"] |
||||
|
}; |
||||
|
|
||||
|
_sendTestEmailDialogVisible = true; |
||||
|
await InvokeAsync(StateHasChanged); |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
await HandleErrorAsync(ex); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
protected virtual Task CloseSendTestEmailDialogAsync() |
||||
|
{ |
||||
|
_sendTestEmailDialogVisible = false; |
||||
|
return InvokeAsync(StateHasChanged); |
||||
|
} |
||||
|
|
||||
|
protected virtual async Task SendTestEmailAsync() |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
if (_testEmailFormRef != null && !await _testEmailFormRef.Validate()) |
||||
|
{ |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
await EmailSettingsAppService.SendTestEmailAsync(ObjectMapper.Map<SendTestEmailViewModel, SendTestEmailInput>(SendTestEmailInput)); |
||||
|
|
||||
|
Snackbar.Add(L["SentSuccessfully"], Severity.Success); |
||||
|
|
||||
|
await CloseSendTestEmailDialogAsync(); |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
await HandleErrorAsync(ex); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public class UpdateEmailSettingsViewModel |
||||
|
{ |
||||
|
[MaxLength(256)] |
||||
|
[Display(Name = "SmtpHost")] |
||||
|
public string? SmtpHost { get; set; } |
||||
|
|
||||
|
[Range(1, 65535)] |
||||
|
[Display(Name = "SmtpPort")] |
||||
|
public int SmtpPort { get; set; } |
||||
|
|
||||
|
[MaxLength(1024)] |
||||
|
[Display(Name = "SmtpUserName")] |
||||
|
public string? SmtpUserName { get; set; } |
||||
|
|
||||
|
[MaxLength(1024)] |
||||
|
[DataType(DataType.Password)] |
||||
|
[DisableAuditing] |
||||
|
[Display(Name = "SmtpPassword")] |
||||
|
public string? SmtpPassword { get; set; } |
||||
|
|
||||
|
[MaxLength(1024)] |
||||
|
[Display(Name = "SmtpDomain")] |
||||
|
public string? SmtpDomain { get; set; } |
||||
|
|
||||
|
[Display(Name = "SmtpEnableSsl")] |
||||
|
public bool SmtpEnableSsl { get; set; } |
||||
|
|
||||
|
[Display(Name = "SmtpUseDefaultCredentials")] |
||||
|
public bool SmtpUseDefaultCredentials { get; set; } |
||||
|
|
||||
|
[MaxLength(1024)] |
||||
|
[Required] |
||||
|
[Display(Name = "DefaultFromAddress")] |
||||
|
public string? DefaultFromAddress { get; set; } |
||||
|
|
||||
|
[MaxLength(1024)] |
||||
|
[Required] |
||||
|
[Display(Name = "DefaultFromDisplayName")] |
||||
|
public string? DefaultFromDisplayName { get; set; } |
||||
|
} |
||||
|
|
||||
|
public class SendTestEmailViewModel |
||||
|
{ |
||||
|
[Required] |
||||
|
public string? SenderEmailAddress { get; set; } |
||||
|
|
||||
|
[Required] |
||||
|
public string? TargetEmailAddress { get; set; } |
||||
|
|
||||
|
[Required] |
||||
|
public string? Subject { get; set; } |
||||
|
|
||||
|
public string? Body { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,41 @@ |
|||||
|
@page "/setting-management" |
||||
|
@using Microsoft.AspNetCore.Authorization |
||||
|
@using Volo.Abp.AspNetCore.Components.Web.Theming.MudBlazor.Components |
||||
|
@using Volo.Abp.Features |
||||
|
@attribute [Authorize] |
||||
|
@attribute [RequiresFeature(SettingManagementFeatures.Enable)] |
||||
|
@using Microsoft.Extensions.Localization |
||||
|
@using Volo.Abp.UI.Navigation.Localization.Resource |
||||
|
@inject IStringLocalizer<AbpUiNavigationResource> LUiNavigation |
||||
|
|
||||
|
@* ************************* PAGE HEADER ************************* *@ |
||||
|
<PageHeader Title="@L["Settings"]" BreadcrumbItems="@BreadcrumbItems" /> |
||||
|
|
||||
|
<MudCard> |
||||
|
<MudCardContent Class="pt-3"> |
||||
|
@if (!string.IsNullOrEmpty(SelectedGroup)) |
||||
|
{ |
||||
|
<MudTabs @bind-ActivePanelIndex="@_activeTabIndex" |
||||
|
Variant="Variant.Pills" |
||||
|
Position="Position.Left" |
||||
|
PanelClass="pa-4"> |
||||
|
@foreach (var group in SettingComponentCreationContext.Groups) |
||||
|
{ |
||||
|
<MudTabPanel Text="@group.DisplayName"> |
||||
|
<div class="abp-md-form"> |
||||
|
@{ |
||||
|
SettingItemRenders.Add(builder => |
||||
|
{ |
||||
|
builder.OpenComponent(0, group.ComponentType); |
||||
|
builder.CloseComponent(); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
@SettingItemRenders.Last() |
||||
|
</div> |
||||
|
</MudTabPanel> |
||||
|
} |
||||
|
</MudTabs> |
||||
|
} |
||||
|
</MudCardContent> |
||||
|
</MudCard> |
||||
@ -0,0 +1,60 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Components; |
||||
|
using Microsoft.Extensions.Localization; |
||||
|
using Microsoft.Extensions.Options; |
||||
|
using Volo.Abp.BlazoriseUI; |
||||
|
using Volo.Abp.SettingManagement.Localization; |
||||
|
|
||||
|
namespace Volo.Abp.SettingManagement.Blazor.MudBlazor.Pages.SettingManagement; |
||||
|
|
||||
|
public partial class SettingManagement |
||||
|
{ |
||||
|
[Inject] |
||||
|
protected IServiceProvider ServiceProvider { get; set; } = default!; |
||||
|
|
||||
|
protected SettingComponentCreationContext SettingComponentCreationContext { get; set; } = default!; |
||||
|
|
||||
|
[Inject] |
||||
|
protected IOptions<SettingManagementComponentOptions> _options { get; set; } = default!; |
||||
|
|
||||
|
[Inject] |
||||
|
protected IStringLocalizer<AbpSettingManagementResource> L { get; set; } = default!; |
||||
|
|
||||
|
protected SettingManagementComponentOptions Options => _options.Value; |
||||
|
|
||||
|
protected List<RenderFragment> SettingItemRenders { get; set; } = new List<RenderFragment>(); |
||||
|
|
||||
|
protected string? SelectedGroup; |
||||
|
protected List<BreadcrumbItem> BreadcrumbItems = new List<BreadcrumbItem>(); |
||||
|
|
||||
|
protected int _activeTabIndex = 0; |
||||
|
|
||||
|
protected async override Task OnInitializedAsync() |
||||
|
{ |
||||
|
BreadcrumbItems.Add(new BreadcrumbItem(LUiNavigation["Menu:Administration"].Value)); |
||||
|
BreadcrumbItems.Add(new BreadcrumbItem(L["Menu:Settings"].Value)); |
||||
|
|
||||
|
SettingComponentCreationContext = new SettingComponentCreationContext(ServiceProvider); |
||||
|
|
||||
|
foreach (var contributor in Options.Contributors) |
||||
|
{ |
||||
|
await contributor.ConfigureAsync(SettingComponentCreationContext); |
||||
|
} |
||||
|
SettingComponentCreationContext.Normalize(); |
||||
|
SettingItemRenders.Clear(); |
||||
|
|
||||
|
if (SelectedGroup.IsNullOrEmpty() && SettingComponentCreationContext.Groups.Any()) |
||||
|
{ |
||||
|
SelectedGroup = GetNormalizedString(SettingComponentCreationContext.Groups.First().Id); |
||||
|
_activeTabIndex = 0; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
protected virtual string GetNormalizedString(string value) |
||||
|
{ |
||||
|
return value.Replace('.', '_'); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,35 @@ |
|||||
|
@using Volo.Abp.SettingManagement.Localization |
||||
|
@using MudBlazor |
||||
|
@inherits Volo.Abp.AspNetCore.Components.AbpComponentBase |
||||
|
|
||||
|
@if (TimezoneSettings != null) |
||||
|
{ |
||||
|
<MudForm> |
||||
|
<MudGrid> |
||||
|
<MudItem xs="12"> |
||||
|
<MudSelect T="string" |
||||
|
Label="@L["DisplayName:Timezone"]" |
||||
|
Required="true" |
||||
|
RequiredError="@L["ThisFieldIsRequired"]" |
||||
|
Value="@TimezoneSettings.Timezone" |
||||
|
ValueChanged="@OnSelectedValueChangedAsync" |
||||
|
Variant="Variant.Outlined"> |
||||
|
@foreach (var item in TimezoneSettings.TimeZoneItems) |
||||
|
{ |
||||
|
<MudSelectItem Value="@item.Value">@item.Name</MudSelectItem> |
||||
|
} |
||||
|
</MudSelect> |
||||
|
<MudText Typo="Typo.caption" Class="mt-1">@L["TimezoneHelpText"]</MudText> |
||||
|
</MudItem> |
||||
|
</MudGrid> |
||||
|
<MudGrid> |
||||
|
<MudItem xs="12"> |
||||
|
<MudButton Color="Color.Primary" |
||||
|
Variant="Variant.Filled" |
||||
|
OnClick="@UpdateSettingsAsync"> |
||||
|
@L["Save"] |
||||
|
</MudButton> |
||||
|
</MudItem> |
||||
|
</MudGrid> |
||||
|
</MudForm> |
||||
|
} |
||||
@ -0,0 +1,77 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Components; |
||||
|
using MudBlazor; |
||||
|
using Volo.Abp.AspNetCore.Components.Messages; |
||||
|
using Volo.Abp.AspNetCore.Components.Web.Configuration; |
||||
|
using Volo.Abp.SettingManagement.Localization; |
||||
|
|
||||
|
namespace Volo.Abp.SettingManagement.Blazor.MudBlazor.Pages.SettingManagement.TimeZoneSettingGroup; |
||||
|
|
||||
|
public partial class TimeZoneSettingGroupViewComponent |
||||
|
{ |
||||
|
[Inject] |
||||
|
protected ITimeZoneSettingsAppService TimeZoneSettingsAppService { get; set; } = default!; |
||||
|
|
||||
|
[Inject] |
||||
|
private ICurrentApplicationConfigurationCacheResetService CurrentApplicationConfigurationCacheResetService { get; set; } = default!; |
||||
|
|
||||
|
[Inject] |
||||
|
protected IUiMessageService UiMessageService { get; set; } = default!; |
||||
|
|
||||
|
[Inject] |
||||
|
protected ISnackbar Snackbar { get; set; } = default!; |
||||
|
|
||||
|
protected UpdateTimezoneSettingsViewModel? TimezoneSettings; |
||||
|
|
||||
|
public TimeZoneSettingGroupViewComponent() |
||||
|
{ |
||||
|
ObjectMapperContext = typeof(AbpSettingManagementBlazorMudBlazorModule); |
||||
|
LocalizationResource = typeof(AbpSettingManagementResource); |
||||
|
} |
||||
|
|
||||
|
protected async override Task OnInitializedAsync() |
||||
|
{ |
||||
|
TimezoneSettings = new UpdateTimezoneSettingsViewModel() |
||||
|
{ |
||||
|
Timezone = await TimeZoneSettingsAppService.GetAsync(), |
||||
|
TimeZoneItems = await TimeZoneSettingsAppService.GetTimezonesAsync() |
||||
|
}; |
||||
|
} |
||||
|
|
||||
|
protected virtual async Task OnSelectedValueChangedAsync(string? timezone) |
||||
|
{ |
||||
|
if (TimezoneSettings != null) |
||||
|
{ |
||||
|
TimezoneSettings.Timezone = timezone; |
||||
|
} |
||||
|
await InvokeAsync(StateHasChanged); |
||||
|
} |
||||
|
|
||||
|
protected virtual async Task UpdateSettingsAsync() |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
if (TimezoneSettings == null) |
||||
|
{ |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
await TimeZoneSettingsAppService.UpdateAsync(TimezoneSettings.Timezone); |
||||
|
await CurrentApplicationConfigurationCacheResetService.ResetAsync(); |
||||
|
Snackbar.Add(L["SavedSuccessfully"], Severity.Success); |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
await HandleErrorAsync(ex); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public class UpdateTimezoneSettingsViewModel |
||||
|
{ |
||||
|
public string? Timezone { get; set; } |
||||
|
|
||||
|
public List<NameValue>? TimeZoneItems { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,30 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
|
||||
|
namespace Volo.Abp.SettingManagement.Blazor.MudBlazor; |
||||
|
|
||||
|
public class SettingComponentCreationContext : IServiceProviderAccessor |
||||
|
{ |
||||
|
public IServiceProvider ServiceProvider { get; } |
||||
|
|
||||
|
public List<SettingComponentGroup> Groups { get; private set; } |
||||
|
|
||||
|
public SettingComponentCreationContext(IServiceProvider serviceProvider) |
||||
|
{ |
||||
|
ServiceProvider = serviceProvider; |
||||
|
|
||||
|
Groups = new List<SettingComponentGroup>(); |
||||
|
} |
||||
|
|
||||
|
public void Normalize() |
||||
|
{ |
||||
|
Order(); |
||||
|
} |
||||
|
|
||||
|
private void Order() |
||||
|
{ |
||||
|
Groups = Groups.OrderBy(item => item.Order).ThenBy(item => item.DisplayName).ToList(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,40 @@ |
|||||
|
using System; |
||||
|
using JetBrains.Annotations; |
||||
|
|
||||
|
namespace Volo.Abp.SettingManagement.Blazor.MudBlazor; |
||||
|
|
||||
|
public class SettingComponentGroup |
||||
|
{ |
||||
|
public const int DefaultOrder = 1000; |
||||
|
|
||||
|
public string Id { |
||||
|
get => _id; |
||||
|
set => _id = Check.NotNullOrWhiteSpace(value, nameof(Id)); |
||||
|
} |
||||
|
private string _id = string.Empty; |
||||
|
|
||||
|
public string DisplayName { |
||||
|
get => _displayName; |
||||
|
set => _displayName = Check.NotNullOrWhiteSpace(value, nameof(DisplayName)); |
||||
|
} |
||||
|
private string _displayName = string.Empty; |
||||
|
|
||||
|
public Type ComponentType { |
||||
|
get => _componentType; |
||||
|
set => _componentType = Check.NotNull(value, nameof(ComponentType)); |
||||
|
} |
||||
|
private Type _componentType = null!; |
||||
|
|
||||
|
public object? Parameter { get; set; } |
||||
|
|
||||
|
public int Order { get; set; } |
||||
|
|
||||
|
public SettingComponentGroup([NotNull] string id, [NotNull] string displayName, [NotNull] Type componentType, object? parameter = null, int order = DefaultOrder) |
||||
|
{ |
||||
|
Id = id; |
||||
|
DisplayName = displayName; |
||||
|
ComponentType = componentType; |
||||
|
Parameter = parameter; |
||||
|
Order = order; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,30 @@ |
|||||
|
using Riok.Mapperly.Abstractions; |
||||
|
using Volo.Abp.Mapperly; |
||||
|
using static Volo.Abp.SettingManagement.Blazor.MudBlazor.Pages.SettingManagement.EmailSettingGroup.EmailSettingGroupViewComponent; |
||||
|
|
||||
|
namespace Volo.Abp.SettingManagement.Blazor.MudBlazor; |
||||
|
|
||||
|
[Mapper] |
||||
|
public partial class UpdateEmailSettingsViewModelToUpdateEmailSettingsDtoMapper : MapperBase<UpdateEmailSettingsViewModel, UpdateEmailSettingsDto> |
||||
|
{ |
||||
|
public override partial UpdateEmailSettingsDto Map(UpdateEmailSettingsViewModel source); |
||||
|
|
||||
|
public override partial void Map(UpdateEmailSettingsViewModel source, UpdateEmailSettingsDto destination); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
[Mapper] |
||||
|
public partial class EmailSettingsDtoToUpdateEmailSettingsViewModelMapper : MapperBase<EmailSettingsDto, UpdateEmailSettingsViewModel> |
||||
|
{ |
||||
|
public override partial UpdateEmailSettingsViewModel Map(EmailSettingsDto source); |
||||
|
|
||||
|
public override partial void Map(EmailSettingsDto source, UpdateEmailSettingsViewModel destination); |
||||
|
} |
||||
|
|
||||
|
[Mapper] |
||||
|
public partial class SendTestEmailViewModelToSendTestEmailInputMapper : MapperBase<SendTestEmailViewModel, SendTestEmailInput> |
||||
|
{ |
||||
|
public override partial SendTestEmailInput Map(SendTestEmailViewModel source); |
||||
|
|
||||
|
public override partial void Map(SendTestEmailViewModel source, SendTestEmailInput destination); |
||||
|
} |
||||
@ -0,0 +1,13 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
|
||||
|
namespace Volo.Abp.SettingManagement.Blazor.MudBlazor; |
||||
|
|
||||
|
public class SettingManagementComponentOptions |
||||
|
{ |
||||
|
public List<ISettingComponentContributor> Contributors { get; } |
||||
|
|
||||
|
public SettingManagementComponentOptions() |
||||
|
{ |
||||
|
Contributors = new List<ISettingComponentContributor>(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,62 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Authorization; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.Extensions.Localization; |
||||
|
using Volo.Abp.Features; |
||||
|
using Volo.Abp.MultiTenancy; |
||||
|
using Volo.Abp.SettingManagement.Blazor.MudBlazor.Pages.SettingManagement.EmailSettingGroup; |
||||
|
using Volo.Abp.SettingManagement.Localization; |
||||
|
|
||||
|
namespace Volo.Abp.SettingManagement.Blazor.MudBlazor.Settings; |
||||
|
|
||||
|
public class EmailingPageContributor : ISettingComponentContributor |
||||
|
{ |
||||
|
public async Task ConfigureAsync(SettingComponentCreationContext context) |
||||
|
{ |
||||
|
if (!await CheckPermissionsInternalAsync(context)) |
||||
|
{ |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
var l = context.ServiceProvider.GetRequiredService<IStringLocalizer<AbpSettingManagementResource>>(); |
||||
|
context.Groups.Add( |
||||
|
new SettingComponentGroup( |
||||
|
"Volo.Abp.SettingManagement", |
||||
|
l["Menu:Emailing"], |
||||
|
typeof(EmailSettingGroupViewComponent) |
||||
|
) |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
public async Task<bool> CheckPermissionsAsync(SettingComponentCreationContext context) |
||||
|
{ |
||||
|
return await CheckPermissionsInternalAsync(context); |
||||
|
} |
||||
|
|
||||
|
private async Task<bool> CheckPermissionsInternalAsync(SettingComponentCreationContext context) |
||||
|
{ |
||||
|
if (!await CheckFeatureAsync(context)) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
var authorizationService = context.ServiceProvider.GetRequiredService<IAuthorizationService>(); |
||||
|
|
||||
|
return await authorizationService.IsGrantedAsync(SettingManagementPermissions.Emailing); |
||||
|
} |
||||
|
|
||||
|
private async Task<bool> CheckFeatureAsync(SettingComponentCreationContext context) |
||||
|
{ |
||||
|
var currentTenant = context.ServiceProvider.GetRequiredService<ICurrentTenant>(); |
||||
|
|
||||
|
if (!currentTenant.IsAvailable) |
||||
|
{ |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
var featureCheck = context.ServiceProvider.GetRequiredService<IFeatureChecker>(); |
||||
|
|
||||
|
return await featureCheck.IsEnabledAsync(SettingManagementFeatures.AllowChangingEmailSettings); |
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,36 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Authorization; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.Extensions.Localization; |
||||
|
using Volo.Abp.Features; |
||||
|
using Volo.Abp.SettingManagement.Blazor.MudBlazor.Pages.SettingManagement.TimeZoneSettingGroup; |
||||
|
using Volo.Abp.SettingManagement.Localization; |
||||
|
using Volo.Abp.Timing; |
||||
|
|
||||
|
namespace Volo.Abp.SettingManagement.Blazor.MudBlazor.Settings; |
||||
|
|
||||
|
public class TimeZonePageContributor : ISettingComponentContributor |
||||
|
{ |
||||
|
public async Task ConfigureAsync(SettingComponentCreationContext context) |
||||
|
{ |
||||
|
var l = context.ServiceProvider.GetRequiredService<IStringLocalizer<AbpSettingManagementResource>>(); |
||||
|
if (await CheckPermissionsAsync(context)) |
||||
|
{ |
||||
|
context.Groups.Add( |
||||
|
new SettingComponentGroup( |
||||
|
"Volo.Abp.TimeZone", |
||||
|
l["Menu:TimeZone"], |
||||
|
typeof(TimeZoneSettingGroupViewComponent) |
||||
|
) |
||||
|
); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public async Task<bool> CheckPermissionsAsync(SettingComponentCreationContext context) |
||||
|
{ |
||||
|
var authorizationService = context.ServiceProvider.GetRequiredService<IAuthorizationService>(); |
||||
|
|
||||
|
return context.ServiceProvider.GetRequiredService<IClock>().SupportsMultipleTimezone |
||||
|
&& await authorizationService.IsGrantedAsync(SettingManagementPermissions.TimeZone); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,4 @@ |
|||||
|
@using Microsoft.AspNetCore.Components.Web |
||||
|
@using Volo.Abp.AspNetCore.Components.Web.Theming.MudBlazor |
||||
|
@using MudBlazor |
||||
|
@using Volo.Abp.MudBlazorUI |
||||
@ -0,0 +1,16 @@ |
|||||
|
using Riok.Mapperly.Abstractions; |
||||
|
using Volo.Abp.Mapperly; |
||||
|
|
||||
|
namespace Volo.Abp.TenantManagement.Blazor.MudBlazor; |
||||
|
|
||||
|
[Mapper] |
||||
|
[MapExtraProperties] |
||||
|
public partial class TenantDtoToTenantUpdateDtoMapper |
||||
|
: MapperBase<TenantDto, TenantUpdateDto> |
||||
|
{ |
||||
|
[MapperIgnoreSource(nameof(TenantDto.Id))] |
||||
|
public override partial TenantUpdateDto Map(TenantDto source); |
||||
|
|
||||
|
[MapperIgnoreSource(nameof(TenantDto.Id))] |
||||
|
public override partial void Map(TenantDto source, TenantUpdateDto destination); |
||||
|
} |
||||
@ -0,0 +1,36 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.TenantManagement.Localization; |
||||
|
using Volo.Abp.UI.Navigation; |
||||
|
using Volo.Abp.Authorization.Permissions; |
||||
|
|
||||
|
namespace Volo.Abp.TenantManagement.Blazor.MudBlazor.Navigation; |
||||
|
|
||||
|
public class TenantManagementBlazorMenuContributor : IMenuContributor |
||||
|
{ |
||||
|
public virtual Task ConfigureMenuAsync(MenuConfigurationContext context) |
||||
|
{ |
||||
|
if (context.Menu.Name != StandardMenus.Main) |
||||
|
{ |
||||
|
return Task.CompletedTask; |
||||
|
} |
||||
|
|
||||
|
var administrationMenu = context.Menu.GetAdministration(); |
||||
|
|
||||
|
var l = context.GetLocalizer<AbpTenantManagementResource>(); |
||||
|
|
||||
|
var tenantManagementMenuItem = new ApplicationMenuItem( |
||||
|
TenantManagementMenuNames.GroupName, |
||||
|
l["Menu:TenantManagement"], |
||||
|
icon: "fa fa-users" |
||||
|
); |
||||
|
administrationMenu.AddItem(tenantManagementMenuItem); |
||||
|
|
||||
|
tenantManagementMenuItem.AddItem(new ApplicationMenuItem( |
||||
|
TenantManagementMenuNames.Tenants, |
||||
|
l["Tenants"], |
||||
|
url: "~/tenant-management/tenants" |
||||
|
).RequirePermissions(TenantManagementPermissions.Tenants.Default)); |
||||
|
|
||||
|
return Task.CompletedTask; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,8 @@ |
|||||
|
namespace Volo.Abp.TenantManagement.Blazor.MudBlazor.Navigation; |
||||
|
|
||||
|
public class TenantManagementMenuNames |
||||
|
{ |
||||
|
public const string GroupName = "TenantManagement"; |
||||
|
|
||||
|
public const string Tenants = GroupName + ".Tenants"; |
||||
|
} |
||||
@ -0,0 +1,99 @@ |
|||||
|
@page "/tenant-management/tenants" |
||||
|
@attribute [Authorize(TenantManagementPermissions.Tenants.Default)] |
||||
|
@using Microsoft.AspNetCore.Authorization |
||||
|
@using Volo.Abp.FeatureManagement.Blazor.MudBlazor.Components |
||||
|
@using Microsoft.AspNetCore.Components.Forms |
||||
|
@using Volo.Abp.TenantManagement.Localization |
||||
|
@using Volo.Abp.AspNetCore.Components.Web.Theming.MudBlazor.Components |
||||
|
@using Volo.Abp.MudBlazorUI.Components.ObjectExtending |
||||
|
@using Volo.Abp.AspNetCore.Components.Web |
||||
|
@using Microsoft.Extensions.Localization |
||||
|
@using Volo.Abp.UI.Navigation.Localization.Resource |
||||
|
@inject IStringLocalizer<AbpUiNavigationResource> LUiNavigation |
||||
|
@inherits AbpMudCrudPageBase<ITenantAppService, TenantDto, Guid, GetTenantsInput, TenantCreateDto, TenantUpdateDto> |
||||
|
|
||||
|
<PageHeader Title="@L["Tenants"]" |
||||
|
BreadcrumbItems="@BreadcrumbItems" |
||||
|
Toolbar="@Toolbar" /> |
||||
|
|
||||
|
<MudCard> |
||||
|
<MudCardContent> |
||||
|
<AbpMudExtensibleDataGrid TItem="TenantDto" |
||||
|
Items="@Entities" |
||||
|
ReadData="@OnDataGridReadAsync" |
||||
|
TotalItems="@TotalCount" |
||||
|
PageSize="@PageSize" |
||||
|
CurrentPage="@CurrentPage" |
||||
|
Columns="@TenantManagementTableColumns" /> |
||||
|
</MudCardContent> |
||||
|
</MudCard> |
||||
|
|
||||
|
@* ************************* CREATE MODAL ************************* *@ |
||||
|
@if (HasCreatePermission) |
||||
|
{ |
||||
|
<MudDialog @bind-IsVisible="@CreateDialogVisible" Options="@(new DialogOptions { MaxWidth = MaxWidth.Medium, FullWidth = true })" CloseOnEscapeKey="true"> |
||||
|
<TitleContent> |
||||
|
<MudText Typo="Typo.h6">@L["NewTenant"]</MudText> |
||||
|
</TitleContent> |
||||
|
<DialogContent> |
||||
|
<MudForm @ref="@_createFormRef" Model="@NewEntity"> |
||||
|
<MudTextField @bind-Value="@NewEntity.Name" |
||||
|
Label="@L["TenantName"]" |
||||
|
Required="true" |
||||
|
RequiredError="@L["ThisFieldIsRequired"]" |
||||
|
Variant="Variant.Outlined" |
||||
|
AutoFocus="true" /> |
||||
|
<MudTextField @bind-Value="@NewEntity.AdminEmailAddress" |
||||
|
Label="@L["DisplayName:AdminEmailAddress"]" |
||||
|
Required="true" |
||||
|
RequiredError="@L["ThisFieldIsRequired"]" |
||||
|
InputType="InputType.Email" |
||||
|
Variant="Variant.Outlined" /> |
||||
|
<MudTextField @bind-Value="@NewEntity.AdminPassword" |
||||
|
Label="@L["DisplayName:AdminPassword"]" |
||||
|
Required="true" |
||||
|
RequiredError="@L["ThisFieldIsRequired"]" |
||||
|
InputType="@(ShowPassword ? InputType.Text : InputType.Password)" |
||||
|
Variant="Variant.Outlined" |
||||
|
Adornment="Adornment.End" |
||||
|
AdornmentIcon="@(ShowPassword ? Icons.Material.Filled.Visibility : Icons.Material.Filled.VisibilityOff)" |
||||
|
OnAdornmentClick="@TogglePasswordVisibility" /> |
||||
|
<ExtensionProperties TEntityType="TenantCreateDto" TResourceType="AbpTenantManagementResource" Entity="@NewEntity" ModalType="ExtensionPropertyModalType.CreateModal" /> |
||||
|
</MudForm> |
||||
|
</DialogContent> |
||||
|
<DialogActions> |
||||
|
<MudButton OnClick="@CloseCreateDialogAsync">@L["Cancel"]</MudButton> |
||||
|
<MudButton Color="Color.Primary" Variant="Variant.Filled" OnClick="@CreateEntityAsync">@L["Save"]</MudButton> |
||||
|
</DialogActions> |
||||
|
</MudDialog> |
||||
|
} |
||||
|
|
||||
|
@* ************************* EDIT MODAL ************************* *@ |
||||
|
@if (HasUpdatePermission) |
||||
|
{ |
||||
|
<MudDialog @bind-IsVisible="@EditDialogVisible" Options="@(new DialogOptions { MaxWidth = MaxWidth.Medium, FullWidth = true })" CloseOnEscapeKey="true"> |
||||
|
<TitleContent> |
||||
|
<MudText Typo="Typo.h6">@L["Edit"]</MudText> |
||||
|
</TitleContent> |
||||
|
<DialogContent> |
||||
|
<MudForm @ref="@_editFormRef" Model="@EditingEntity"> |
||||
|
<MudTextField @bind-Value="@EditingEntity.Name" |
||||
|
Label="@L["TenantName"]" |
||||
|
Required="true" |
||||
|
RequiredError="@L["ThisFieldIsRequired"]" |
||||
|
Variant="Variant.Outlined" |
||||
|
AutoFocus="true" /> |
||||
|
<ExtensionProperties TEntityType="TenantUpdateDto" TResourceType="AbpTenantManagementResource" Entity="@EditingEntity" ModalType="ExtensionPropertyModalType.EditModal" /> |
||||
|
</MudForm> |
||||
|
</DialogContent> |
||||
|
<DialogActions> |
||||
|
<MudButton OnClick="@CloseEditDialogAsync">@L["Cancel"]</MudButton> |
||||
|
<MudButton Color="Color.Primary" Variant="Variant.Filled" OnClick="@UpdateEntityAsync">@L["Save"]</MudButton> |
||||
|
</DialogActions> |
||||
|
</MudDialog> |
||||
|
} |
||||
|
|
||||
|
@if (HasManageFeaturesPermission) |
||||
|
{ |
||||
|
<FeatureManagementModal @ref="FeatureManagementModal"/> |
||||
|
} |
||||
@ -0,0 +1,161 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Authorization; |
||||
|
using MudBlazor; |
||||
|
using Volo.Abp.AspNetCore.Components.Web.Extensibility.EntityActions; |
||||
|
using Volo.Abp.AspNetCore.Components.Web.Extensibility.TableColumns; |
||||
|
using Volo.Abp.AspNetCore.Components.Web.Theming.MudBlazor.PageToolbars; |
||||
|
using Volo.Abp.BlazoriseUI; |
||||
|
using Volo.Abp.FeatureManagement.Blazor.MudBlazor.Components; |
||||
|
using Volo.Abp.ObjectExtending; |
||||
|
using Volo.Abp.TenantManagement.Localization; |
||||
|
using Volo.Abp.MudBlazorUI; |
||||
|
|
||||
|
namespace Volo.Abp.TenantManagement.Blazor.MudBlazor.Pages.TenantManagement; |
||||
|
|
||||
|
public partial class TenantManagement |
||||
|
{ |
||||
|
protected const string FeatureProviderName = "T"; |
||||
|
|
||||
|
protected bool HasManageFeaturesPermission; |
||||
|
protected string? ManageFeaturesPolicyName; |
||||
|
|
||||
|
protected FeatureManagementModal? FeatureManagementModal; |
||||
|
|
||||
|
protected bool ShowPassword { get; set; } |
||||
|
|
||||
|
protected PageToolbar Toolbar { get; } = new(); |
||||
|
|
||||
|
protected List<TableColumn> TenantManagementTableColumns => TableColumns.Get<TenantManagement>(); |
||||
|
|
||||
|
private MudForm? _createFormRef; |
||||
|
private MudForm? _editFormRef; |
||||
|
|
||||
|
public TenantManagement() |
||||
|
{ |
||||
|
LocalizationResource = typeof(AbpTenantManagementResource); |
||||
|
ObjectMapperContext = typeof(AbpTenantManagementBlazorMudBlazorModule); |
||||
|
|
||||
|
CreatePolicyName = TenantManagementPermissions.Tenants.Create; |
||||
|
UpdatePolicyName = TenantManagementPermissions.Tenants.Update; |
||||
|
DeletePolicyName = TenantManagementPermissions.Tenants.Delete; |
||||
|
|
||||
|
ManageFeaturesPolicyName = TenantManagementPermissions.Tenants.ManageFeatures; |
||||
|
} |
||||
|
|
||||
|
protected override ValueTask SetBreadcrumbItemsAsync() |
||||
|
{ |
||||
|
BreadcrumbItems.Add(new BreadcrumbItem(LUiNavigation["Menu:Administration"].Value)); |
||||
|
BreadcrumbItems.Add(new BreadcrumbItem(L["Menu:TenantManagement"].Value)); |
||||
|
BreadcrumbItems.Add(new BreadcrumbItem(L["Tenants"].Value)); |
||||
|
return base.SetBreadcrumbItemsAsync(); |
||||
|
} |
||||
|
|
||||
|
protected override async Task SetPermissionsAsync() |
||||
|
{ |
||||
|
await base.SetPermissionsAsync(); |
||||
|
|
||||
|
HasManageFeaturesPermission = await AuthorizationService.IsGrantedAsync(ManageFeaturesPolicyName!); |
||||
|
} |
||||
|
|
||||
|
protected override string GetDeleteConfirmationMessage(TenantDto entity) |
||||
|
{ |
||||
|
return string.Format(L["TenantDeletionConfirmationMessage"], entity.Name); |
||||
|
} |
||||
|
|
||||
|
protected override ValueTask SetToolbarItemsAsync() |
||||
|
{ |
||||
|
Toolbar.AddMudButton(L["NewTenant"], |
||||
|
OpenCreateDialogAsync, |
||||
|
icon: Icons.Material.Filled.Add.ToString(), |
||||
|
requiredPolicyName: CreatePolicyName); |
||||
|
|
||||
|
return base.SetToolbarItemsAsync(); |
||||
|
} |
||||
|
|
||||
|
protected override ValueTask SetEntityActionsAsync() |
||||
|
{ |
||||
|
EntityActions |
||||
|
.Get<TenantManagement>() |
||||
|
.AddRange(new EntityAction[] |
||||
|
{ |
||||
|
new EntityAction |
||||
|
{ |
||||
|
Text = L["Edit"], |
||||
|
Visible = (data) => HasUpdatePermission, |
||||
|
Clicked = async (data) => { await OpenEditDialogAsync(data.As<TenantDto>()); } |
||||
|
}, |
||||
|
new EntityAction |
||||
|
{ |
||||
|
Text = L["Features"], |
||||
|
Visible = (data) => HasManageFeaturesPermission, |
||||
|
Clicked = async (data) => |
||||
|
{ |
||||
|
var tenant = data.As<TenantDto>(); |
||||
|
if (FeatureManagementModal != null) |
||||
|
{ |
||||
|
await FeatureManagementModal.OpenAsync(FeatureProviderName, tenant.Id.ToString(), tenant.Name); |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
new EntityAction |
||||
|
{ |
||||
|
Text = L["Delete"], |
||||
|
Visible = (data) => HasDeletePermission, |
||||
|
Clicked = async (data) => await DeleteEntityAsync(data.As<TenantDto>()), |
||||
|
ConfirmationMessage = (data) => GetDeleteConfirmationMessage(data.As<TenantDto>()) |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
return base.SetEntityActionsAsync(); |
||||
|
} |
||||
|
|
||||
|
protected override async ValueTask SetTableColumnsAsync() |
||||
|
{ |
||||
|
TenantManagementTableColumns |
||||
|
.AddRange(new TableColumn[] |
||||
|
{ |
||||
|
new TableColumn |
||||
|
{ |
||||
|
Title = L["Actions"], |
||||
|
Actions = EntityActions.Get<TenantManagement>(), |
||||
|
}, |
||||
|
new TableColumn |
||||
|
{ |
||||
|
Title = L["TenantName"], |
||||
|
Sortable = true, |
||||
|
Data = nameof(TenantDto.Name), |
||||
|
}, |
||||
|
}); |
||||
|
|
||||
|
TenantManagementTableColumns.AddRange(await GetExtensionTableColumnsAsync( |
||||
|
TenantManagementModuleExtensionConsts.ModuleName, |
||||
|
TenantManagementModuleExtensionConsts.EntityNames.Tenant)); |
||||
|
|
||||
|
await base.SetTableColumnsAsync(); |
||||
|
} |
||||
|
|
||||
|
protected virtual void TogglePasswordVisibility() |
||||
|
{ |
||||
|
ShowPassword = !ShowPassword; |
||||
|
} |
||||
|
|
||||
|
protected override async Task CreateEntityAsync() |
||||
|
{ |
||||
|
if (_createFormRef != null && !await _createFormRef.Validate()) |
||||
|
{ |
||||
|
return; |
||||
|
} |
||||
|
await base.CreateEntityAsync(); |
||||
|
} |
||||
|
|
||||
|
protected override async Task UpdateEntityAsync() |
||||
|
{ |
||||
|
if (_editFormRef != null && !await _editFormRef.Validate()) |
||||
|
{ |
||||
|
return; |
||||
|
} |
||||
|
await base.UpdateEntityAsync(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,4 @@ |
|||||
|
@using Microsoft.AspNetCore.Components.Web |
||||
|
@using Volo.Abp.AspNetCore.Components.Web.Theming.MudBlazor |
||||
|
@using MudBlazor |
||||
|
@using Volo.Abp.MudBlazorUI |
||||
Loading…
Reference in new issue