mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[ADF-2463] Moved core components to subfolder (#3062)
This commit is contained in:
committed by
Eugenio Romano
parent
f3459e1221
commit
333e8ee89c
100
docs/core/app-config.service.md
Normal file
100
docs/core/app-config.service.md
Normal file
@@ -0,0 +1,100 @@
|
||||
---
|
||||
Added: v2.0.0
|
||||
Status: Active
|
||||
---
|
||||
# App Config service
|
||||
|
||||
Supports app configuration settings, stored server side.
|
||||
|
||||
## Details
|
||||
|
||||
The `AppConfigService` service provides support for loading and accessing global application configuration settings that you store on the server side in the form of a JSON file.
|
||||
|
||||
You may need this service when deploying your ADF-based application to production servers.
|
||||
|
||||
There can be more than one server running web apps with different settings, like different addresses for Alfresco Content/Process services.
|
||||
|
||||
Or there is a need to change global settings for all the clients.
|
||||
|
||||
The service is already pre-configured to look for the "app.config.json" file in the application root address.
|
||||
|
||||
That allows deploying ADF-based web applications to multiple servers together with different settings files, for example having development, staging or production environments.
|
||||
|
||||
Example of the default settings file content:
|
||||
|
||||
**app.config.json**
|
||||
|
||||
```json
|
||||
{
|
||||
"ecmHost": "http://localhost:3000/ecm",
|
||||
"bpmHost": "http://localhost:3000/bpm",
|
||||
"application": {
|
||||
"name": "Alfresco"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Please note that settings above are default ones coming with the server.
|
||||
You can override the values in your custom `app.config.json` file if needed.
|
||||
|
||||
You can also change the path or name of the configuration file when importing the CoreModule in your main application.
|
||||
|
||||
```ts
|
||||
...
|
||||
@NgModule({
|
||||
imports: [
|
||||
...
|
||||
CoreModule.forRoot({
|
||||
appConfigFile: 'app.production.config.json'
|
||||
})
|
||||
],
|
||||
...
|
||||
}
|
||||
export class AppModule { }
|
||||
```
|
||||
|
||||
Below is a simple example of using the AppConfigService in practice.
|
||||
|
||||
**app.component.ts**
|
||||
|
||||
```ts
|
||||
import { AppConfigService } from '@alfresco/adf-core';
|
||||
|
||||
@Component({...})
|
||||
export class AppComponent {
|
||||
|
||||
constructor(appConfig: AppConfigService) {
|
||||
|
||||
// get nested properties by the path
|
||||
console.log(appConfig.get('application.name'));
|
||||
|
||||
// use generics for type safety
|
||||
let version: number = appConfig.get<number>('version');
|
||||
console.log(version);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Your custom components can also benefit from the `AppConfigService`,
|
||||
you can put an unlimited number of settings and optionally a nested JSON hierarchy.
|
||||
|
||||
### Variable substitution in configuration strings
|
||||
|
||||
The `AppConfigService` also supports a limited set of variable substitutions to greatly simplify certain scenarios.
|
||||
|
||||
```json
|
||||
{
|
||||
"ecmHost": "http://{hostname}:{port}/ecm",
|
||||
"bpmHost": "http://{hostname}:{port}/bpm",
|
||||
"application": {
|
||||
"name": "Alfresco"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The supported variables are:
|
||||
|
||||
| Variable name | Runtime value |
|
||||
| ------------- | ------------- |
|
||||
| hostname | `location.hostname` |
|
||||
| port | `location.port` |
|
Reference in New Issue
Block a user