Supports app configuration settings, stored server side.
string
, defaultValue?: )string
- Name of the propertystring
string
- Value of the propertystring
= ""
): string
string
- Text added before port valuestring
- Port with prefixstring
string
- The location.protocol stringPromise
<any>
Promise
<any>
- Notification when loading is completestring
): Promise
<
OpenidConfiguration
>
string
- Promise
<
OpenidConfiguration
>
- Discovery configurationstring
): Observable
<any>
string
- The desired property valueObservable
<any>
- Property value, when loadedThe 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.
You may also use the service if 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. This allows you to deploy ADF-based web applications to multiple servers together with different settings files. You could use this, for example, to create separate development, staging, and production environments.
Example of the default settings file content:
app.config.json
{
"ecmHost": "http://localhost:3000/ecm",
"bpmHost": "http://localhost:3000/bpm",
"application": {
"name": "Alfresco"
}
}
Note that the settings in the example above are the default ones supplied with the server.
You can override the values in your custom app.config.json
file if necessary.
Below is a simple example of using the AppConfigService
in practice.
app.component.ts
import { AppConfigService } from '@alfresco/adf-core';
@Component({...})
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 create an unlimited number of settings and optionally organize them as a nested JSON hierarchy.
The AppConfigService
supports a limited set of variable substitutions to greatly simplify certain scenarios.
{
"ecmHost": "{protocol}//{hostname}:{port}/ecm",
"bpmHost": "{protocol}//{hostname}:{port}/bpm",
"application": {
"name": "Alfresco"
}
}
The supported variables are:
Variable name | Runtime value |
---|---|
protocol | location.protocol |
hostname | location.hostname |
port | location.port |
When the app config is loaded correctly, an onChange
event is emitted with the whole set of app
config properties. This comes in handy when a component needs to react to some property change or
interact with the app config when it is finished loading:
appConfig.onLoad.subscribe((appConfig) => {
console.log(appConfig); //this is the representation of the app-config
});
The select
method lets you specify the name of a variable that should be set with the value
of a property when the app config is loaded:
appconfig : { logLevel : 'trace' }
appConfig.select('logLevel').subscribe((logLevelValue) => {
console.log(logLevelValue); //this will be 'trace';
});
In the configuration file, you can enable XMLHttpRequest.withCredentials for @alfresco/js-api calls and PDF Viewer.
{
"auth": {
"withCredentials": true
}
}
© 2023 Alfresco Software, Inc. All Rights Reserved.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.