Browse Source

Merge pull request #12145 from abpframework/EngincanV/setting-management

Improve EmailSettingGroupViewComponent
pull/12153/head
Engincan VESKE 5 years ago
committed by GitHub
parent
commit
23970523e2
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/AbpSettingManagementDomainSharedModule.cs
  2. 8
      modules/setting-management/src/Volo.Abp.SettingManagement.Web/AbpSettingManagementWebModule.cs
  3. 28
      modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/Components/EmailSettingGroup/Default.cshtml
  4. 47
      modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/Components/EmailSettingGroup/EmailSettingGroupViewComponent.cs
  5. 3
      modules/setting-management/src/Volo.Abp.SettingManagement.Web/SettingManagementWebAutoMapperProfile.cs

5
modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/AbpSettingManagementDomainSharedModule.cs

@ -3,6 +3,7 @@ using Volo.Abp.Modularity;
using Volo.Abp.Localization; using Volo.Abp.Localization;
using Volo.Abp.SettingManagement.Localization; using Volo.Abp.SettingManagement.Localization;
using Volo.Abp.Validation; using Volo.Abp.Validation;
using Volo.Abp.Validation.Localization;
using Volo.Abp.VirtualFileSystem; using Volo.Abp.VirtualFileSystem;
namespace Volo.Abp.SettingManagement; namespace Volo.Abp.SettingManagement;
@ -23,7 +24,9 @@ public class AbpSettingManagementDomainSharedModule : AbpModule
{ {
options.Resources options.Resources
.Add<AbpSettingManagementResource>("en") .Add<AbpSettingManagementResource>("en")
.AddVirtualJson("/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement"); .AddBaseTypes(
typeof(AbpValidationResource)
).AddVirtualJson("/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement");
}); });
} }
} }

8
modules/setting-management/src/Volo.Abp.SettingManagement.Web/AbpSettingManagementWebModule.cs

@ -1,10 +1,12 @@
using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.AspNetCore.Mvc.Localization;
using Volo.Abp.AspNetCore.Mvc.UI.Bundling; using Volo.Abp.AspNetCore.Mvc.UI.Bundling;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared;
using Volo.Abp.AutoMapper; using Volo.Abp.AutoMapper;
using Volo.Abp.Http.ProxyScripting.Generators.JQuery; using Volo.Abp.Http.ProxyScripting.Generators.JQuery;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
using Volo.Abp.SettingManagement.Localization;
using Volo.Abp.SettingManagement.Web.Navigation; using Volo.Abp.SettingManagement.Web.Navigation;
using Volo.Abp.SettingManagement.Web.Pages.SettingManagement; using Volo.Abp.SettingManagement.Web.Pages.SettingManagement;
using Volo.Abp.SettingManagement.Web.Settings; using Volo.Abp.SettingManagement.Web.Settings;
@ -23,6 +25,11 @@ public class AbpSettingManagementWebModule : AbpModule
{ {
public override void PreConfigureServices(ServiceConfigurationContext context) public override void PreConfigureServices(ServiceConfigurationContext context)
{ {
context.Services.PreConfigure<AbpMvcDataAnnotationsLocalizationOptions>(options =>
{
options.AddAssemblyResource(typeof(AbpSettingManagementResource), typeof(AbpSettingManagementWebModule).Assembly);
});
PreConfigure<IMvcBuilder>(mvcBuilder => PreConfigure<IMvcBuilder>(mvcBuilder =>
{ {
mvcBuilder.AddApplicationPartIfNotExists(typeof(AbpSettingManagementWebModule).Assembly); mvcBuilder.AddApplicationPartIfNotExists(typeof(AbpSettingManagementWebModule).Assembly);
@ -31,6 +38,7 @@ public class AbpSettingManagementWebModule : AbpModule
public override void ConfigureServices(ServiceConfigurationContext context) public override void ConfigureServices(ServiceConfigurationContext context)
{ {
Configure<AbpNavigationOptions>(options => Configure<AbpNavigationOptions>(options =>
{ {
options.MenuContributors.Add(new SettingManagementMainMenuContributor()); options.MenuContributors.Add(new SettingManagementMainMenuContributor());

28
modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/Components/EmailSettingGroup/Default.cshtml

@ -1,28 +1,30 @@
@using Microsoft.AspNetCore.Mvc.Localization @using Microsoft.AspNetCore.Mvc.Localization
@using Volo.Abp.SettingManagement.Localization @using Volo.Abp.SettingManagement.Localization
@inject IHtmlLocalizer<AbpSettingManagementResource> L @inject IHtmlLocalizer<AbpSettingManagementResource> L
@model Volo.Abp.SettingManagement.UpdateEmailSettingsDto @model Volo.Abp.SettingManagement.Web.Pages.SettingManagement.Components.EmailSettingGroup.EmailSettingGroupViewComponent.UpdateEmailSettingsViewModel
<form id="EmailSettingsForm" method="post"> <form id="EmailSettingsForm" method="post">
<abp-row> <abp-row>
<abp-column size-md="_12"> <abp-column size-md="_12">
<div> <div>
<abp-input asp-for="DefaultFromDisplayName" label="@(L["DefaultFromDisplayName"].Value + " * ")" /> <abp-input asp-for="DefaultFromDisplayName"/>
<abp-input asp-for="DefaultFromAddress" label="@(L["DefaultFromAddress"].Value + " * ")" /> <abp-input asp-for="DefaultFromAddress"/>
<abp-input asp-for="SmtpHost" label="@L["SmtpHost"].Value" /> <abp-input asp-for="SmtpHost"/>
<abp-input asp-for="SmtpPort" label="@L["SmtpPort"].Value" /> <abp-input asp-for="SmtpPort"/>
<abp-input asp-for="SmtpEnableSsl" label="@L["SmtpEnableSsl"].Value" /> <abp-input asp-for="SmtpEnableSsl"/>
<abp-input asp-for="SmtpUseDefaultCredentials" label="@L["SmtpUseDefaultCredentials"].Value" /> <abp-input asp-for="SmtpUseDefaultCredentials"/>
<div id="HideSectionWhenUseDefaultCredentialsIsChecked" @Html.Raw(Model.SmtpUseDefaultCredentials ? "style=\"display: none;\"" : "")> <div id="HideSectionWhenUseDefaultCredentialsIsChecked" @Html.Raw(Model.SmtpUseDefaultCredentials ? "style=\"display: none;\"" : "")>
<abp-input asp-for="SmtpDomain" label="@L["SmtpDomain"].Value" /> <abp-input asp-for="SmtpDomain"/>
<abp-input asp-for="SmtpUserName" label="@L["SmtpUserName"].Value" /> <abp-input asp-for="SmtpUserName"/>
<abp-input type="password" asp-for="SmtpPassword" label="@L["SmtpPassword"].Value" /> <abp-input type="password" asp-for="SmtpPassword"/>
</div> </div>
</div> </div>
<hr class="my-4" /> <hr class="my-4"/>
<div> <div>
<abp-button button-type="Primary" type="submit"><i class="fa fa-save"></i> @L["Save"]</abp-button> <abp-button button-type="Primary" type="submit">
<i class="fa fa-save"></i> @L["Save"]
</abp-button>
</div> </div>
</abp-column> </abp-column>
</abp-row> </abp-row>
</form> </form>

47
modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/Components/EmailSettingGroup/EmailSettingGroupViewComponent.cs

@ -1,6 +1,8 @@
using System.Threading.Tasks; using System.ComponentModel.DataAnnotations;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.Auditing;
namespace Volo.Abp.SettingManagement.Web.Pages.SettingManagement.Components.EmailSettingGroup; namespace Volo.Abp.SettingManagement.Web.Pages.SettingManagement.Components.EmailSettingGroup;
@ -17,7 +19,48 @@ public class EmailSettingGroupViewComponent : AbpViewComponent
public virtual async Task<IViewComponentResult> InvokeAsync() public virtual async Task<IViewComponentResult> InvokeAsync()
{ {
var emailSettings = await EmailSettingsAppService.GetAsync(); var emailSettings = await EmailSettingsAppService.GetAsync();
var model = ObjectMapper.Map<EmailSettingsDto, UpdateEmailSettingsDto>(emailSettings); var model = ObjectMapper.Map<EmailSettingsDto, UpdateEmailSettingsViewModel>(emailSettings);
return View("~/Pages/SettingManagement/Components/EmailSettingGroup/Default.cshtml", model); return View("~/Pages/SettingManagement/Components/EmailSettingGroup/Default.cshtml", model);
} }
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; }
}
} }

3
modules/setting-management/src/Volo.Abp.SettingManagement.Web/SettingManagementWebAutoMapperProfile.cs

@ -1,4 +1,5 @@
using AutoMapper; using AutoMapper;
using Volo.Abp.SettingManagement.Web.Pages.SettingManagement.Components.EmailSettingGroup;
namespace Volo.Abp.SettingManagement.Web; namespace Volo.Abp.SettingManagement.Web;
@ -6,6 +7,6 @@ public class SettingManagementWebAutoMapperProfile : Profile
{ {
public SettingManagementWebAutoMapperProfile() public SettingManagementWebAutoMapperProfile()
{ {
CreateMap<EmailSettingsDto, UpdateEmailSettingsDto>(); CreateMap<EmailSettingsDto, EmailSettingGroupViewComponent.UpdateEmailSettingsViewModel>();
} }
} }
Loading…
Cancel
Save