Browse Source

Merge pull request #12157 from abpframework/liangshiwei/blazorui

Some enhancements for Blazor UI
pull/12172/head
Engincan VESKE 5 years ago
committed by GitHub
parent
commit
f842af01ea
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 44
      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

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

@ -19,10 +19,16 @@
</CardHeader>
<CardBody>
<Field Horizontal>
<FieldLabel ColumnSize="ColumnSize.Is1.Is9.WithOffset">@L["Search"]</FieldLabel>
<FieldBody ColumnSize="ColumnSize.Is2">
<TextEdit Text="@GetListInput.Filter" TextChanged="@OnSearchTextChanged" />
</FieldBody>
<FieldBody ColumnSize="ColumnSize.Is2.Is10.WithOffset">
<Addons>
<Addon AddonType="AddonType.Start">
<Label>@L["Search"]</Label>
</Addon>
<Addon AddonType="AddonType.Body">
<TextEdit Style="margin-left: 0.5rem" Size="Size.Small" Text="@GetListInput.Filter" TextChanged="@OnSearchTextChanged"/>
</Addon>
</Addons>
</FieldBody>
</Field>
@* ************************* DATA GRID ************************* *@
<AbpExtensibleDataGrid TItem="IdentityUserDto"
@ -89,11 +95,16 @@
<Validation MessageLocalizer="@LH.Localize">
<Field>
<FieldLabel>@L["DisplayName:Password"]</FieldLabel>
<TextEdit Role="TextRole.Password" @bind-Text="NewEntity.Password">
<Feedback>
<ValidationError/>
</Feedback>
</TextEdit>
<Addons>
<Addon AddonType="AddonType.Body">
<TextEdit Role="@_passwordTextRole" @bind-Text="NewEntity.Password">
</TextEdit>
</Addon>
<Addon AddonType="AddonType.End">
<Button Color="Color.Secondary" Clicked="@(() => ChangePasswordTextRole(null))"><Icon Name="IconName.EyeSlash"/></Button>
</Addon>
</Addons>
<ValidationError Style="display: block"/>
</Field>
</Validation>
<Validation MessageLocalizer="@LH.Localize">
@ -203,11 +214,16 @@
<Validation MessageLocalizer="@LH.Localize">
<Field>
<FieldLabel>@L["DisplayName:Password"]</FieldLabel>
<TextEdit Role="TextRole.Password" @bind-Text="EditingEntity.Password">
<Feedback>
<ValidationError/>
</Feedback>
</TextEdit>
<Addons>
<Addon AddonType="AddonType.Body">
<TextEdit Role="@_passwordTextRole" @bind-Text="EditingEntity.Password">
</TextEdit>
</Addon>
<Addon AddonType="AddonType.End">
<Button Color="Color.Secondary" Clicked="@(() => ChangePasswordTextRole(null))"><Icon Name="IconName.EyeSlash"/></Button>
</Addon>
</Addons>
<ValidationError Style="display: block"/>
</Field>
</Validation>
<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();
private List<TableColumn> UserManagementTableColumns => TableColumns.Get<UserManagement>();
private TextRole _passwordTextRole = TextRole.Password;
public UserManagement()
{
ObjectMapperContext = typeof(AbpIdentityBlazorModule);
@ -90,6 +91,7 @@ public partial class UserManagement
IsAssigned = x.IsDefault
}).ToArray();
ChangePasswordTextRole(TextRole.Password);
return base.OpenCreateModalAsync();
}
@ -115,6 +117,7 @@ public partial class UserManagement
IsAssigned = userRoleNames.Contains(x.Name)
}).ToArray();
ChangePasswordTextRole(TextRole.Password);
await base.OpenEditModalAsync(entity);
}
catch (Exception ex)
@ -211,6 +214,18 @@ public partial class UserManagement
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

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

@ -122,6 +122,7 @@ public partial class PermissionManagementModal
{
try
{
var updateDto = new UpdatePermissionsDto
{
Permissions = _groups
@ -129,6 +130,14 @@ public partial class PermissionManagementModal
.Select(p => new UpdatePermissionDto { IsGranted = p.IsGranted, Name = p.Name })
.ToArray()
};
if (!updateDto.Permissions.Any(x => x.IsGranted))
{
if (!await Message.Confirm(L["RemoveAllPermissionsWarningMessage"].Value))
{
return;
}
}
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)
{
<Form>
<Validations @ref="@IdentitySettingValidation" Model="@EmailSettings" ValidateOnLoad="false">
<Validations @ref="@EmailSettingValidation" Model="@EmailSettings" ValidateOnLoad="false">
<Row>
<Column>
<Validation MessageLocalizer="@LH.Localize">
<Field>
<FieldLabel>@L["DefaultFromDisplayName"]</FieldLabel>
<FieldLabel>@L["DefaultFromDisplayName"] *</FieldLabel>
<TextEdit @bind-Text="@EmailSettings.DefaultFromDisplayName">
<Feedback>
<ValidationError />
@ -20,7 +20,7 @@
</Validation>
<Validation MessageLocalizer="@LH.Localize">
<Field>
<FieldLabel>@L["DefaultFromAddress"]</FieldLabel>
<FieldLabel>@L["DefaultFromAddress"] *</FieldLabel>
<TextEdit @bind-Text="@EmailSettings.DefaultFromAddress">
<Feedback>
<ValidationError />

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

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

Loading…
Cancel
Save