From bae1ddbed17921c6758c7140df9c10928453fb5a Mon Sep 17 00:00:00 2001 From: maliming <6908465+maliming@users.noreply.github.com> Date: Sun, 11 Oct 2020 19:22:24 +0800 Subject: [PATCH 1/7] Avoid decrypt null setting value. --- .../Volo.Abp.Settings/Volo/Abp/Settings/SettingProvider.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingProvider.cs b/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingProvider.cs index 6f5372a4cf..5ef67cbc21 100644 --- a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingProvider.cs +++ b/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingProvider.cs @@ -35,7 +35,7 @@ namespace Volo.Abp.Settings //TODO: How to implement setting.IsInherited? var value = await GetOrNullValueFromProvidersAsync(providers, setting); - if (setting.IsEncrypted) + if (value != null && setting.IsEncrypted) { value = SettingEncryptionService.Decrypt(setting, value); } @@ -84,4 +84,4 @@ namespace Volo.Abp.Settings return null; } } -} \ No newline at end of file +} From f3531a56381ab746db0d9d63a907101d1564eb62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Sun, 11 Oct 2020 14:51:45 +0300 Subject: [PATCH 2/7] Added client side setting documents --- docs/en/Settings.md | 23 ++++++------------- docs/en/UI/Angular/Settings.md | 3 +++ .../UI/AspNetCore/JavaScript-API/Settings.md | 19 +++++++++++++++ docs/en/UI/Blazor/Settings.md | 3 +++ 4 files changed, 32 insertions(+), 16 deletions(-) create mode 100644 docs/en/UI/Angular/Settings.md create mode 100644 docs/en/UI/AspNetCore/JavaScript-API/Settings.md create mode 100644 docs/en/UI/Blazor/Settings.md diff --git a/docs/en/Settings.md b/docs/en/Settings.md index 32761ff201..567cb02c4c 100644 --- a/docs/en/Settings.md +++ b/docs/en/Settings.md @@ -2,7 +2,7 @@ [Configuration system](Configuration.md) is a good way to configure the application on startup. In addition to the configurations, ABP provides another way to set and get some application settings. -A setting is a name-value pair stored in a dynamic data source, generally in a database. Setting system is extensible and there are pre-built provides for a user, a tenant, global and default. +A setting is a name-value pair stored in a dynamic data source, generally in a database. Setting system is extensible and there are pre-built providers for a user, a tenant, global and default. ## Defining Settings @@ -67,7 +67,7 @@ public class MySettingDefinitionProvider : SettingDefinitionProvider > Using constants for the setting names is a good practice and ABP packages do it. `Abp.Mailing.Smtp.Host` setting name is a constant defined by the `EmailSettingNames` class (in the `Volo.Abp.Emailing` namespace). -## Reading Setting Values +## Reading the Setting Values ### ISettingProvider @@ -108,24 +108,15 @@ public class MyService } ```` -> `ISettingProvider` is a very common service and some base classes (like `IApplicationService`) already property-inject it. You can directly use the `SettingProvider` in such cases. +> `ISettingProvider` is a very common service and some base classes (like `IApplicationService`) already property-inject it. You can directly use the `SettingProvider` property in such cases. ### Reading Setting Values on the Client Side -If a setting is allowed to be visible on the client side, current value of the setting can also be read from the JavaScript code. Examples: +If a setting is allowed to be visible on the client side, current value of the setting can also be read from the client code. See the following documents to understand how to get the setting values in different UI types; -````js -//Gets a value as string. -var language = abp.setting.get('Abp.Localization.DefaultLanguage'); - -//Gets an integer value. -var requiredLength = abp.setting.getInt('Abp.Identity.Password.RequiredLength'); - -//Gets a boolean value. -var requireDigit = abp.setting.getBoolean('Abp.Identity.Password.RequireDigit'); -```` - -In addition, use `abp.setting.values` to get a dictionary of all the setting values. +* [MVC / Razor Pages](UI/AspNetCore/JavaScript-API/Settings.md) +* [Angular](UI/Angular/Settings.md) +* [Blazor](UI/Blazor/Settings.md) ## Setting Value Providers diff --git a/docs/en/UI/Angular/Settings.md b/docs/en/UI/Angular/Settings.md new file mode 100644 index 0000000000..47868f2363 --- /dev/null +++ b/docs/en/UI/Angular/Settings.md @@ -0,0 +1,3 @@ +# Angular UI: Settings + +> This document explains how to get setting values in an Angular application. See the [settings document](../../Settings.md) to learn the setting system. \ No newline at end of file diff --git a/docs/en/UI/AspNetCore/JavaScript-API/Settings.md b/docs/en/UI/AspNetCore/JavaScript-API/Settings.md new file mode 100644 index 0000000000..9079e9776d --- /dev/null +++ b/docs/en/UI/AspNetCore/JavaScript-API/Settings.md @@ -0,0 +1,19 @@ +# ASP.NET Core MVC / Razor Pages UI: JavaScript Setting API + +Localization API allows you to get the values of the settings on the client side. You can read the current value of a setting in the client side only if it is allowed by the setting definition (on the server side). + +> This document only explains the JavaScript API. See the [settings document](../../../Settings.md) to understand the ABP setting system. + +## Basic Usage + +````js +//Gets a value as string. +var language = abp.setting.get('Abp.Localization.DefaultLanguage'); + +//Gets an integer value. +var requiredLength = abp.setting.getInt('Abp.Identity.Password.RequiredLength'); + +//Gets a boolean value. +var requireDigit = abp.setting.getBoolean('Abp.Identity.Password.RequireDigit'); +```` + diff --git a/docs/en/UI/Blazor/Settings.md b/docs/en/UI/Blazor/Settings.md new file mode 100644 index 0000000000..276462c411 --- /dev/null +++ b/docs/en/UI/Blazor/Settings.md @@ -0,0 +1,3 @@ +# Blazor UI: Settings + +Blazor applications can reuse the same `ISettingProvider` service that is explained in the [settings document](../../Settings.md). \ No newline at end of file From 27b29957e8665ade9035f6d4ea3b7fc658e2b6ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Sun, 11 Oct 2020 14:57:04 +0300 Subject: [PATCH 3/7] Update Settings.md --- docs/en/UI/AspNetCore/JavaScript-API/Settings.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/en/UI/AspNetCore/JavaScript-API/Settings.md b/docs/en/UI/AspNetCore/JavaScript-API/Settings.md index 9079e9776d..cf96cecdd0 100644 --- a/docs/en/UI/AspNetCore/JavaScript-API/Settings.md +++ b/docs/en/UI/AspNetCore/JavaScript-API/Settings.md @@ -17,3 +17,17 @@ var requiredLength = abp.setting.getInt('Abp.Identity.Password.RequiredLength'); var requireDigit = abp.setting.getBoolean('Abp.Identity.Password.RequireDigit'); ```` +## All Values + +`abp.setting.values` can be used to obtain all the setting values as an object where the object properties are setting names and property values are the setting values. + +An example value of this object is shown below: + +````js +{ + Abp.Localization.DefaultLanguage: "en", + Abp.Timing.TimeZone: "UTC", + ... +} +```` + From f2a597e610e646e9e6f2288b72c4481db7aef6af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Sun, 11 Oct 2020 14:59:10 +0300 Subject: [PATCH 4/7] Add links to the settings. --- docs/en/UI/AspNetCore/JavaScript-API/Index.md | 2 +- docs/en/docs-nav.json | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/en/UI/AspNetCore/JavaScript-API/Index.md b/docs/en/UI/AspNetCore/JavaScript-API/Index.md index bca62835f7..25251dcdbf 100644 --- a/docs/en/UI/AspNetCore/JavaScript-API/Index.md +++ b/docs/en/UI/AspNetCore/JavaScript-API/Index.md @@ -16,7 +16,7 @@ ABP provides a set of JavaScript APIs for ASP.NET Core MVC / Razor Pages applica * abp.ModalManager * [abp.notify](Notify.md) * abp.security -* abp.setting +* [abp.setting](Settings.md) * abp.ui * abp.utils * abp.ResourceLoader diff --git a/docs/en/docs-nav.json b/docs/en/docs-nav.json index e7e2a5286e..9192038ac9 100644 --- a/docs/en/docs-nav.json +++ b/docs/en/docs-nav.json @@ -451,6 +451,10 @@ "text": "Localization", "path": "UI/AspNetCore/JavaScript-API/Localization.md" }, + { + "text": "Settings", + "path": "UI/AspNetCore/JavaScript-API/Settings.md" + }, { "text": "AJAX", "path": "UI/AspNetCore/JavaScript-API/Ajax.md" From 7cfd60327c6ff50fa7c5f5c15f651c339aedaa54 Mon Sep 17 00:00:00 2001 From: h82258652 <842053625@qq.com> Date: Mon, 12 Oct 2020 10:31:30 +0800 Subject: [PATCH 5/7] update docs-nav.json --- docs/zh-Hans/docs-nav.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/zh-Hans/docs-nav.json b/docs/zh-Hans/docs-nav.json index 5df3376507..3f018ae3a4 100644 --- a/docs/zh-Hans/docs-nav.json +++ b/docs/zh-Hans/docs-nav.json @@ -12,7 +12,7 @@ "path": "Startup-Templates/Console.md" }, { - "text": "空Web应用程序t", + "text": "空Web应用程序", "path": "Getting-Started-AspNetCore-Application.md" } ] From e91275153c5bf93cbd4e968b3d7b742f65be5958 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Mon, 12 Oct 2020 13:43:27 +0800 Subject: [PATCH 6/7] Fix HTML coding error in AbpInputTagHelperService --- .../TagHelpers/Form/AbpInputTagHelperService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpInputTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpInputTagHelperService.cs index 9436acbbbf..ff5b085df5 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpInputTagHelperService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpInputTagHelperService.cs @@ -260,7 +260,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form var label = new TagBuilder("label"); label.Attributes.Add("for", GetIdAttributeValue(inputTag)); - label.InnerHtml.Append(TagHelper.Label); + label.InnerHtml.AppendHtml(TagHelper.Label); if (isCheckbox) { From 48331d48dd31e76be50e611aa62e518d2c9817ba Mon Sep 17 00:00:00 2001 From: Mladen Macanovic Date: Mon, 12 Oct 2020 10:48:58 +0200 Subject: [PATCH 7/7] After last refactor confirmations dialog was not working properly --- .../BlazoriseUiMessageService.cs | 6 +++--- .../Pages/Index.razor.cs | 20 ++++++------------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/framework/src/Volo.Abp.BlazoriseUI/BlazoriseUiMessageService.cs b/framework/src/Volo.Abp.BlazoriseUI/BlazoriseUiMessageService.cs index f22ec3b653..3e83166191 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/BlazoriseUiMessageService.cs +++ b/framework/src/Volo.Abp.BlazoriseUI/BlazoriseUiMessageService.cs @@ -69,16 +69,16 @@ namespace Volo.Abp.BlazoriseUI return Task.CompletedTask; } - public async Task ConfirmAsync(string message, string title = null, Action options = null) + public Task ConfirmAsync(string message, string title = null, Action options = null) { var uiMessageOptions = CreateDefaultOptions(); options?.Invoke(uiMessageOptions); var callback = new TaskCompletionSource(); - MessageReceived?.Invoke(this, new UiMessageEventArgs(UiMessageType.Confirmation, message, title, uiMessageOptions)); + MessageReceived?.Invoke(this, new UiMessageEventArgs(UiMessageType.Confirmation, message, title, uiMessageOptions, callback)); - return await callback.Task; + return callback.Task; } protected virtual UiMessageOptions CreateDefaultOptions() diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Pages/Index.razor.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Pages/Index.razor.cs index 0724ee6c97..c39cb6f880 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Pages/Index.razor.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Pages/Index.razor.cs @@ -45,24 +45,16 @@ namespace MyCompanyName.MyProjectName.Blazor.Pages return UiMessageService.ErrorAsync( "This is the Error message", "Error" ); } - Task OnConfirmTestClicked() + async Task OnConfirmTestClicked() { - return UiMessageService.ConfirmAsync( "Are you sure you want to delete the item?", "Confirm", options => + if ( await UiMessageService.ConfirmAsync( "Are you sure you want to delete the item?", "Confirm", options => { options.CancelButtonText = "Do not delete it"; options.ConfirmButtonText = "Yes I'm sure"; - } ) - .ContinueWith( result => - { - if ( result.Result ) - { - Console.WriteLine( "Confirmed" ); - } - else - { - Console.WriteLine( "Cancelled" ); - } - } ); + } ) ) + { + Console.WriteLine( "Confirmed" ); + } } [Inject] IUiMessageService UiMessageService { get; set; }