functional base href from ui config namespace property

This commit is contained in:
William Welling
2017-09-26 20:11:56 -05:00
parent 26e2da93fb
commit 68d8ea00d2
4 changed files with 15 additions and 7 deletions

View File

@@ -1,5 +1,5 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { CommonModule, APP_BASE_HREF } from '@angular/common';
import { HttpModule } from '@angular/http';
import { FormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';
@@ -39,7 +39,11 @@ export function getConfig() {
return ENV_CONFIG;
}
export function getMetaReducers(config: GlobalConfig): MetaReducer<AppState>[] {
export function getBase() {
return ENV_CONFIG.ui.nameSpace;
}
export function getMetaReducers(config: GlobalConfig): Array<MetaReducer<AppState>> {
return config.production ? appMetaReducers : [...appMetaReducers, storeFreeze];
}
@@ -63,6 +67,10 @@ export function getMetaReducers(config: GlobalConfig): MetaReducer<AppState>[] {
provide: GLOBAL_CONFIG,
useFactory: (getConfig)
},
{
provide: APP_BASE_HREF,
useFactory: (getBase)
},
{
provide: META_REDUCERS,
useFactory: getMetaReducers,

View File

@@ -10,6 +10,6 @@ import { GlobalConfig } from '../../../config';
*/
export class RESTURLCombiner extends URLCombiner {
constructor(EnvConfig: GlobalConfig, ...parts: string[]) {
super(EnvConfig.rest.baseUrl, EnvConfig.rest.nameSpace, ...parts);
super(EnvConfig.rest.baseUrl, ...parts);
}
}

View File

@@ -9,6 +9,6 @@ import { GlobalConfig } from '../../../config';
*/
export class UIURLCombiner extends URLCombiner {
constructor(EnvConfig: GlobalConfig, ...parts: string[]) {
super(EnvConfig.ui.baseUrl, EnvConfig.ui.nameSpace, ...parts);
super(EnvConfig.ui.baseUrl, ...parts);
}
}

View File

@@ -77,7 +77,7 @@ function buildBaseUrls(): void {
getProtocol(ENV_CONFIG[key].ssl),
getHost(ENV_CONFIG[key].host),
getPort(ENV_CONFIG[key].port),
getContextPath(ENV_CONFIG[key].contextPath)
getNameSpace(ENV_CONFIG[key].nameSpace)
].join('');
}
}
@@ -95,8 +95,8 @@ function getPort(port: number): string {
return port ? (port !== 80 && port !== 443) ? ':' + port : '' : '';
}
function getContextPath(contextPath: string): string {
return contextPath ? '/' + contextPath : '';
function getNameSpace(nameSpace: string): string {
return nameSpace ? nameSpace.charAt(0) === '/' ? nameSpace : '/' + nameSpace : '';
}
function isDefined(value: any): boolean {