mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-26 17:24:56 +00:00
[ADF-2961] support for protocol substition in app config files (#3324)
* support for protocol substition in app config files * Update app-config.service.spec.ts * Update app-config.service.spec.ts
This commit is contained in:
parent
f159fbaa2c
commit
db7d0b7c08
@ -109,8 +109,8 @@ The `AppConfigService` also supports a limited set of variable substitutions to
|
|||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"ecmHost": "http://{hostname}:{port}/ecm",
|
"ecmHost": "{protocol}//{hostname}:{port}/ecm",
|
||||||
"bpmHost": "http://{hostname}:{port}/bpm",
|
"bpmHost": "{protocol}//{hostname}:{port}/bpm",
|
||||||
"application": {
|
"application": {
|
||||||
"name": "Alfresco"
|
"name": "Alfresco"
|
||||||
}
|
}
|
||||||
@ -121,6 +121,7 @@ The supported variables are:
|
|||||||
|
|
||||||
| Variable name | Runtime value |
|
| Variable name | Runtime value |
|
||||||
| ------------- | ------------- |
|
| ------------- | ------------- |
|
||||||
|
| protocol | `location.protocol` |
|
||||||
| hostname | `location.hostname` |
|
| hostname | `location.hostname` |
|
||||||
| port | `location.port` |
|
| port | `location.port` |
|
||||||
|
|
||||||
|
@ -113,6 +113,18 @@ describe('AppConfigService', () => {
|
|||||||
expect(appConfigService.get('testUrl')).toBe('http://localhost:9090');
|
expect(appConfigService.get('testUrl')).toBe('http://localhost:9090');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should use protocol value', () => {
|
||||||
|
spyOn(appConfigService, 'getLocationPort').and.returnValue('9090');
|
||||||
|
const protocolSpy = spyOn(appConfigService, 'getLocationProtocol');
|
||||||
|
appConfigService.config.testUrl = '{protocol}//{hostname}:{port}';
|
||||||
|
|
||||||
|
protocolSpy.and.returnValue('https:');
|
||||||
|
expect(appConfigService.get('testUrl')).toBe('https://localhost:9090');
|
||||||
|
|
||||||
|
protocolSpy.and.returnValue('ftp:');
|
||||||
|
expect(appConfigService.get('testUrl')).toBe('ftp://localhost:9090');
|
||||||
|
});
|
||||||
|
|
||||||
it('should load external settings', () => {
|
it('should load external settings', () => {
|
||||||
appConfigService.load().then(config => {
|
appConfigService.load().then(config => {
|
||||||
expect(config).toEqual(mockResponse);
|
expect(config).toEqual(mockResponse);
|
||||||
|
@ -66,6 +66,7 @@ export class AppConfigService {
|
|||||||
map.set('hostname', this.getLocationHostname());
|
map.set('hostname', this.getLocationHostname());
|
||||||
map.set(':port', this.getLocationPort(':'));
|
map.set(':port', this.getLocationPort(':'));
|
||||||
map.set('port', this.getLocationPort());
|
map.set('port', this.getLocationPort());
|
||||||
|
map.set('protocol', this.getLocationProtocol());
|
||||||
result = this.formatString(result, map);
|
result = this.formatString(result, map);
|
||||||
}
|
}
|
||||||
if (result === undefined) {
|
if (result === undefined) {
|
||||||
@ -74,6 +75,13 @@ export class AppConfigService {
|
|||||||
return <T> result;
|
return <T> result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the location.protocol value.
|
||||||
|
*/
|
||||||
|
getLocationProtocol(): string {
|
||||||
|
return location.protocol;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the location.hostname property.
|
* Gets the location.hostname property.
|
||||||
* @returns Value of the property
|
* @returns Value of the property
|
||||||
|
Loading…
x
Reference in New Issue
Block a user