Browse Source

Some enhancements for Blazor UI

pull/12157/head
liangshiwei 5 years ago
parent
commit
ce45aea0b2
  1. 35
      modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor
  2. 17
      modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor.cs
  3. 9
      modules/permission-management/src/Volo.Abp.PermissionManagement.Blazor/Components/PermissionManagementModal.razor.cs
  4. 6
      modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/Pages/SettingManagement/EmailSettingGroup/EmailSettingGroupViewComponent.razor
  5. 56
      modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/Pages/SettingManagement/EmailSettingGroup/EmailSettingGroupViewComponent.razor.cs
  6. 4
      modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/SettingManagementBlazorAutoMapperProfile.cs

35
modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor

@ -89,11 +89,18 @@
<Validation MessageLocalizer="@LH.Localize"> <Validation MessageLocalizer="@LH.Localize">
<Field> <Field>
<FieldLabel>@L["DisplayName:Password"]</FieldLabel> <FieldLabel>@L["DisplayName:Password"]</FieldLabel>
<TextEdit Role="TextRole.Password" @bind-Text="NewEntity.Password"> <Addons>
<Feedback> <Addon AddonType="AddonType.Body">
<ValidationError/> <TextEdit Role="@_passwordTextRole" @bind-Text="NewEntity.Password">
</Feedback> <Feedback>
</TextEdit> <ValidationError/>
</Feedback>
</TextEdit>
</Addon>
<Addon AddonType="AddonType.End">
<Button Color="Color.Secondary" Clicked="@(() => ChangePasswordTextRole(null))"><Icon Name="IconName.EyeSlash"/></Button>
</Addon>
</Addons>
</Field> </Field>
</Validation> </Validation>
<Validation MessageLocalizer="@LH.Localize"> <Validation MessageLocalizer="@LH.Localize">
@ -203,11 +210,19 @@
<Validation MessageLocalizer="@LH.Localize"> <Validation MessageLocalizer="@LH.Localize">
<Field> <Field>
<FieldLabel>@L["DisplayName:Password"]</FieldLabel> <FieldLabel>@L["DisplayName:Password"]</FieldLabel>
<TextEdit Role="TextRole.Password" @bind-Text="EditingEntity.Password"> <Addons>
<Feedback> <Addon AddonType="AddonType.Body">
<ValidationError/> <TextEdit Role="@_passwordTextRole" @bind-Text="EditingEntity.Password">
</Feedback> <Feedback>
</TextEdit> <ValidationError/>
</Feedback>
</TextEdit>
</Addon>
<Addon AddonType="AddonType.End">
<Button Color="Color.Secondary" Clicked="@(() => ChangePasswordTextRole(null))"><Icon Name="IconName.EyeSlash"/></Button>
</Addon>
</Addons>
</Field> </Field>
</Validation> </Validation>
<Validation MessageLocalizer="@LH.Localize"> <Validation MessageLocalizer="@LH.Localize">

17
modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor.cs

@ -39,7 +39,8 @@ public partial class UserManagement
protected PageToolbar Toolbar { get; } = new(); protected PageToolbar Toolbar { get; } = new();
private List<TableColumn> UserManagementTableColumns => TableColumns.Get<UserManagement>(); private List<TableColumn> UserManagementTableColumns => TableColumns.Get<UserManagement>();
private TextRole _passwordTextRole = TextRole.Password;
public UserManagement() public UserManagement()
{ {
ObjectMapperContext = typeof(AbpIdentityBlazorModule); ObjectMapperContext = typeof(AbpIdentityBlazorModule);
@ -90,6 +91,7 @@ public partial class UserManagement
IsAssigned = x.IsDefault IsAssigned = x.IsDefault
}).ToArray(); }).ToArray();
ChangePasswordTextRole(TextRole.Password);
return base.OpenCreateModalAsync(); return base.OpenCreateModalAsync();
} }
@ -115,6 +117,7 @@ public partial class UserManagement
IsAssigned = userRoleNames.Contains(x.Name) IsAssigned = userRoleNames.Contains(x.Name)
}).ToArray(); }).ToArray();
ChangePasswordTextRole(TextRole.Password);
await base.OpenEditModalAsync(entity); await base.OpenEditModalAsync(entity);
} }
catch (Exception ex) catch (Exception ex)
@ -211,6 +214,18 @@ public partial class UserManagement
return base.SetToolbarItemsAsync(); return base.SetToolbarItemsAsync();
} }
protected virtual void ChangePasswordTextRole(TextRole? textRole)
{
if (textRole == null)
{
ChangePasswordTextRole(_passwordTextRole == TextRole.Password ? TextRole.Text: TextRole.Password);
}
else
{
_passwordTextRole = textRole.Value;
}
}
} }
public class AssignedRoleViewModel public class AssignedRoleViewModel

9
modules/permission-management/src/Volo.Abp.PermissionManagement.Blazor/Components/PermissionManagementModal.razor.cs

@ -122,6 +122,7 @@ public partial class PermissionManagementModal
{ {
try try
{ {
var updateDto = new UpdatePermissionsDto var updateDto = new UpdatePermissionsDto
{ {
Permissions = _groups Permissions = _groups
@ -129,6 +130,14 @@ public partial class PermissionManagementModal
.Select(p => new UpdatePermissionDto { IsGranted = p.IsGranted, Name = p.Name }) .Select(p => new UpdatePermissionDto { IsGranted = p.IsGranted, Name = p.Name })
.ToArray() .ToArray()
}; };
if (!updateDto.Permissions.Any(x => x.IsGranted))
{
if (!await Message.Confirm(L["RemoveAllPermissionsWarningMessage"].Value))
{
return;
}
}
await PermissionAppService.UpdateAsync(_providerName, _providerKey, updateDto); await PermissionAppService.UpdateAsync(_providerName, _providerKey, updateDto);

6
modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/Pages/SettingManagement/EmailSettingGroup/EmailSettingGroupViewComponent.razor

@ -5,12 +5,12 @@
@if (EmailSettings != null) @if (EmailSettings != null)
{ {
<Form> <Form>
<Validations @ref="@IdentitySettingValidation" Model="@EmailSettings" ValidateOnLoad="false"> <Validations @ref="@EmailSettingValidation" Model="@EmailSettings" ValidateOnLoad="false">
<Row> <Row>
<Column> <Column>
<Validation MessageLocalizer="@LH.Localize"> <Validation MessageLocalizer="@LH.Localize">
<Field> <Field>
<FieldLabel>@L["DefaultFromDisplayName"]</FieldLabel> <FieldLabel>@L["DefaultFromDisplayName"] *</FieldLabel>
<TextEdit @bind-Text="@EmailSettings.DefaultFromDisplayName"> <TextEdit @bind-Text="@EmailSettings.DefaultFromDisplayName">
<Feedback> <Feedback>
<ValidationError /> <ValidationError />
@ -20,7 +20,7 @@
</Validation> </Validation>
<Validation MessageLocalizer="@LH.Localize"> <Validation MessageLocalizer="@LH.Localize">
<Field> <Field>
<FieldLabel>@L["DefaultFromAddress"]</FieldLabel> <FieldLabel>@L["DefaultFromAddress"] *</FieldLabel>
<TextEdit @bind-Text="@EmailSettings.DefaultFromAddress"> <TextEdit @bind-Text="@EmailSettings.DefaultFromAddress">
<Feedback> <Feedback>
<ValidationError /> <ValidationError />

56
modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/Pages/SettingManagement/EmailSettingGroup/EmailSettingGroupViewComponent.razor.cs

@ -1,9 +1,11 @@
using System; using System;
using System.ComponentModel.DataAnnotations;
using System.Threading.Tasks; using System.Threading.Tasks;
using Blazorise; using Blazorise;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using Volo.Abp.AspNetCore.Components.Messages; using Volo.Abp.AspNetCore.Components.Messages;
using Volo.Abp.AspNetCore.Components.Web.Configuration; using Volo.Abp.AspNetCore.Components.Web.Configuration;
using Volo.Abp.Auditing;
using Volo.Abp.SettingManagement.Localization; using Volo.Abp.SettingManagement.Localization;
namespace Volo.Abp.SettingManagement.Blazor.Pages.SettingManagement.EmailSettingGroup; namespace Volo.Abp.SettingManagement.Blazor.Pages.SettingManagement.EmailSettingGroup;
@ -19,9 +21,9 @@ public partial class EmailSettingGroupViewComponent
[Inject] [Inject]
protected IUiMessageService UiMessageService { get; set; } protected IUiMessageService UiMessageService { get; set; }
protected EmailSettingsDto EmailSettings; protected UpdateEmailSettingsViewModel EmailSettings;
protected Validations IdentitySettingValidation; protected Validations EmailSettingValidation;
public EmailSettingGroupViewComponent() public EmailSettingGroupViewComponent()
{ {
@ -33,7 +35,7 @@ public partial class EmailSettingGroupViewComponent
{ {
try try
{ {
EmailSettings = await EmailSettingsAppService.GetAsync(); EmailSettings = ObjectMapper.Map<EmailSettingsDto, UpdateEmailSettingsViewModel>(await EmailSettingsAppService.GetAsync());
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -45,7 +47,12 @@ public partial class EmailSettingGroupViewComponent
{ {
try try
{ {
await EmailSettingsAppService.UpdateAsync(ObjectMapper.Map<EmailSettingsDto, UpdateEmailSettingsDto>(EmailSettings)); if (!await EmailSettingValidation.ValidateAll())
{
return;
}
await EmailSettingsAppService.UpdateAsync(ObjectMapper.Map<UpdateEmailSettingsViewModel, UpdateEmailSettingsDto>(EmailSettings));
await CurrentApplicationConfigurationCacheResetService.ResetAsync(); await CurrentApplicationConfigurationCacheResetService.ResetAsync();
@ -56,4 +63,45 @@ public partial class EmailSettingGroupViewComponent
await HandleErrorAsync(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; }
}
} }

4
modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/SettingManagementBlazorAutoMapperProfile.cs

@ -1,4 +1,5 @@
using AutoMapper; using AutoMapper;
using Volo.Abp.SettingManagement.Blazor.Pages.SettingManagement.EmailSettingGroup;
namespace Volo.Abp.SettingManagement.Blazor; namespace Volo.Abp.SettingManagement.Blazor;
@ -6,6 +7,7 @@ public class SettingManagementBlazorAutoMapperProfile : Profile
{ {
public SettingManagementBlazorAutoMapperProfile() public SettingManagementBlazorAutoMapperProfile()
{ {
CreateMap<EmailSettingsDto, UpdateEmailSettingsDto>(); CreateMap<EmailSettingGroupViewComponent.UpdateEmailSettingsViewModel, UpdateEmailSettingsDto>();
CreateMap<EmailSettingsDto, EmailSettingGroupViewComponent.UpdateEmailSettingsViewModel>();
} }
} }

Loading…
Cancel
Save