mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-19 07:53:02 +00:00
minor refactoring and more config util assertions
This commit is contained in:
@@ -7,21 +7,38 @@ import { hasNoValue } from '../app/shared/empty.util';
|
||||
import { AppConfig } from './app-config.interface';
|
||||
import { ThemeConfig } from './theme.model';
|
||||
|
||||
/**
|
||||
* Extend Angular environment with app config.
|
||||
*
|
||||
* @param env environment object
|
||||
* @param appConfig app config
|
||||
*/
|
||||
const extendEnvironmentWithAppConfig = (env: any, appConfig: AppConfig): void => {
|
||||
mergeConfig(env, appConfig);
|
||||
console.log(`Environment extended with app config`);
|
||||
};
|
||||
|
||||
const mergeConfig = (config: any, appConfig: AppConfig): void => {
|
||||
/**
|
||||
* Merge one config into another.
|
||||
*
|
||||
* @param destinationConfig destination config
|
||||
* @param sourceConfig source config
|
||||
*/
|
||||
const mergeConfig = (destinationConfig: any, sourceConfig: AppConfig): void => {
|
||||
const mergeOptions = {
|
||||
arrayMerge: (destinationArray, sourceArray, options) => sourceArray
|
||||
};
|
||||
Object.assign(config, merge.all([
|
||||
config,
|
||||
appConfig
|
||||
Object.assign(destinationConfig, merge.all([
|
||||
destinationConfig,
|
||||
sourceConfig
|
||||
], mergeOptions));
|
||||
};
|
||||
|
||||
/**
|
||||
* Get default them config from environment.
|
||||
*
|
||||
* @returns default theme config
|
||||
*/
|
||||
const getDefaultThemeConfig = (): ThemeConfig => {
|
||||
return environment.themes.find((themeConfig: any) =>
|
||||
hasNoValue(themeConfig.regex) &&
|
||||
|
Reference in New Issue
Block a user