mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-11 20:13:07 +00:00
functional base href from ui config namespace property
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule, APP_BASE_HREF } from '@angular/common';
|
||||||
import { HttpModule } from '@angular/http';
|
import { HttpModule } from '@angular/http';
|
||||||
import { FormsModule } from '@angular/forms';
|
import { FormsModule } from '@angular/forms';
|
||||||
import { RouterModule } from '@angular/router';
|
import { RouterModule } from '@angular/router';
|
||||||
@@ -39,7 +39,11 @@ export function getConfig() {
|
|||||||
return ENV_CONFIG;
|
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];
|
return config.production ? appMetaReducers : [...appMetaReducers, storeFreeze];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,6 +67,10 @@ export function getMetaReducers(config: GlobalConfig): MetaReducer<AppState>[] {
|
|||||||
provide: GLOBAL_CONFIG,
|
provide: GLOBAL_CONFIG,
|
||||||
useFactory: (getConfig)
|
useFactory: (getConfig)
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
provide: APP_BASE_HREF,
|
||||||
|
useFactory: (getBase)
|
||||||
|
},
|
||||||
{
|
{
|
||||||
provide: META_REDUCERS,
|
provide: META_REDUCERS,
|
||||||
useFactory: getMetaReducers,
|
useFactory: getMetaReducers,
|
||||||
|
@@ -10,6 +10,6 @@ import { GlobalConfig } from '../../../config';
|
|||||||
*/
|
*/
|
||||||
export class RESTURLCombiner extends URLCombiner {
|
export class RESTURLCombiner extends URLCombiner {
|
||||||
constructor(EnvConfig: GlobalConfig, ...parts: string[]) {
|
constructor(EnvConfig: GlobalConfig, ...parts: string[]) {
|
||||||
super(EnvConfig.rest.baseUrl, EnvConfig.rest.nameSpace, ...parts);
|
super(EnvConfig.rest.baseUrl, ...parts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -9,6 +9,6 @@ import { GlobalConfig } from '../../../config';
|
|||||||
*/
|
*/
|
||||||
export class UIURLCombiner extends URLCombiner {
|
export class UIURLCombiner extends URLCombiner {
|
||||||
constructor(EnvConfig: GlobalConfig, ...parts: string[]) {
|
constructor(EnvConfig: GlobalConfig, ...parts: string[]) {
|
||||||
super(EnvConfig.ui.baseUrl, EnvConfig.ui.nameSpace, ...parts);
|
super(EnvConfig.ui.baseUrl, ...parts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -77,7 +77,7 @@ function buildBaseUrls(): void {
|
|||||||
getProtocol(ENV_CONFIG[key].ssl),
|
getProtocol(ENV_CONFIG[key].ssl),
|
||||||
getHost(ENV_CONFIG[key].host),
|
getHost(ENV_CONFIG[key].host),
|
||||||
getPort(ENV_CONFIG[key].port),
|
getPort(ENV_CONFIG[key].port),
|
||||||
getContextPath(ENV_CONFIG[key].contextPath)
|
getNameSpace(ENV_CONFIG[key].nameSpace)
|
||||||
].join('');
|
].join('');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -95,8 +95,8 @@ function getPort(port: number): string {
|
|||||||
return port ? (port !== 80 && port !== 443) ? ':' + port : '' : '';
|
return port ? (port !== 80 && port !== 443) ? ':' + port : '' : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getContextPath(contextPath: string): string {
|
function getNameSpace(nameSpace: string): string {
|
||||||
return contextPath ? '/' + contextPath : '';
|
return nameSpace ? nameSpace.charAt(0) === '/' ? nameSpace : '/' + nameSpace : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
function isDefined(value: any): boolean {
|
function isDefined(value: any): boolean {
|
||||||
|
Reference in New Issue
Block a user