From 744c32deb405ec579386a33ed30e62b49c656b6e Mon Sep 17 00:00:00 2001 From: Arman Ozak Date: Mon, 26 Oct 2020 13:38:19 +0300 Subject: [PATCH 1/3] docs: explain how to get settings in Angular --- docs/en/UI/Angular/Settings.md | 60 ++++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 2 deletions(-) diff --git a/docs/en/UI/Angular/Settings.md b/docs/en/UI/Angular/Settings.md index 47868f2363e..744df0a8303 100644 --- a/docs/en/UI/Angular/Settings.md +++ b/docs/en/UI/Angular/Settings.md @@ -1,3 +1,59 @@ -# Angular UI: Settings +# 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 +You can get settings on the client-side using the [config state service](./Config-State.md) if they are allowed by their setting definition on the server-side. + +> This document only explains how settings work in the Angular UI projects. See the [settings document](../../../Settings.md) to understand the ABP setting system. + +## Before Use + +To use the `ConfigStateService`, you must inject it in your class as a dependency. You do not have to provide the service explicitly, because it is already **provided in root**. + +```js +import { ConfigStateService } from '@abp/ng.core'; + +@Component({ + /* class metadata here */ +}) +class DemoComponent { + constructor(private config: ConfigStateService) {} +} +``` + +## How to Get a Specific Setting + +You can use the `getSetting` method of `ConfigStateService` to get a specific setting from the configuration state. Here is an example: + +```js +// this.config is instance of ConfigStateService + +const defaultLang = this.config.getSetting("Abp.Localization.DefaultLanguage"); +// 'en' +``` + +### How to Get All Settings From the Store + +You can use the `getSettings` method of `ConfigStateService` to obtain all settings as an object where the object properties are setting names and property values are setting values. + +```js +// this.config is instance of ConfigStateService + +const settings = this.config.getSettings(); +// all settings as a key value pair +``` + +Additionally, the method lets you search settings by **passing a keyword** to it. + +```js +const localizationSettings = this.config.getSettings("Localization"); +/* +{ + 'Abp.Localization.DefaultLanguage': 'en' +} +*/ +``` + +Beware though, **settings search is case-sensitive**. + +## What's Next? + +- [Permission Management](./Permission-Management.md) From 22e41edcafebad82ff0126f57db0db33a099735b Mon Sep 17 00:00:00 2001 From: Arman Ozak Date: Mon, 26 Oct 2020 13:39:11 +0300 Subject: [PATCH 2/3] docs: add navigation to Angular settings doc --- docs/en/UI/Angular/Localization.md | 2 +- docs/en/docs-nav.json | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/en/UI/Angular/Localization.md b/docs/en/UI/Angular/Localization.md index c8073585e16..1efdbca3592 100644 --- a/docs/en/UI/Angular/Localization.md +++ b/docs/en/UI/Angular/Localization.md @@ -237,4 +237,4 @@ import( ## What's Next? -* [Permission Management](./Permission-Management.md) +* [Settings](./Settings.md) diff --git a/docs/en/docs-nav.json b/docs/en/docs-nav.json index 2409bbc4fc3..56eb8d8e202 100644 --- a/docs/en/docs-nav.json +++ b/docs/en/docs-nav.json @@ -584,6 +584,10 @@ "text": "Localization", "path": "UI/Angular/Localization.md" }, + { + "text": "Settings", + "path": "UI/Angular/Settings.md" + }, { "text": "Permission Management", "path": "UI/Angular/Permission-Management.md" From 194832ff855e1718b8f2510bdb51c174412121a1 Mon Sep 17 00:00:00 2001 From: Arman Ozak Date: Mon, 26 Oct 2020 13:42:24 +0300 Subject: [PATCH 3/3] docs: remove settings part from config state service --- docs/en/UI/Angular/Config-State.md | 38 ++++-------------------------- 1 file changed, 4 insertions(+), 34 deletions(-) diff --git a/docs/en/UI/Angular/Config-State.md b/docs/en/UI/Angular/Config-State.md index 0c1070f54dc..d00e4639249 100644 --- a/docs/en/UI/Angular/Config-State.md +++ b/docs/en/UI/Angular/Config-State.md @@ -93,40 +93,6 @@ const searchUrl = this.config.getApiUrl("search"); This method returns the `url` of a specific API based on the key given as its only parameter. If there is no key, `'default'` is used. -### How to Get All Settings From the Store - -You can use the `getSettings` method of `ConfigStateService` to get all of the settings object from the configuration state. Here is how you get all settings: - -```js -// this.config is instance of ConfigStateService - -const settings = this.config.getSettings(); -``` - -In addition, the method lets you search settings by **passing a keyword** to it. - -```js -const localizationSettings = this.config.getSettings("Localization"); -/* -{ - 'Abp.Localization.DefaultLanguage': 'en' -} -*/ -``` - -Beware though, **settings search is case sensitive**. - -### How to Get a Specific Setting From the Store - -You can use the `getSetting` method of `ConfigStateService` to get a specific setting from the configuration state. Here is an example: - -```js -// this.config is instance of ConfigStateService - -const defaultLang = this.config.getSetting("Abp.Localization.DefaultLanguage"); -// 'en' -``` - ### How to Get a Specific Feature From the Store You can use the `getFeature` method of `ConfigStateService` to get a specific feature from the configuration state. Here is an example: @@ -231,6 +197,10 @@ Note that **you do not have to call this method at application initiation**, bec Please refer to `Config.Environment` type for all the properties you can pass to `dispatchSetEnvironment` as parameter. It can be found in the [config.ts file](https://github.com/abpframework/abp/blob/dev/npm/ng-packs/packages/core/src/lib/models/config.ts#L13). +## See Also + +- [Settings](./Settings.md) + ## What's Next? - [HTTP Requests](./Http-Requests)