|
|
@ -1,11 +1,12 @@ |
|
|
|
|
|
import { Injectable } from '@angular/core'; |
|
|
import { Action, createSelector, Selector, State, StateContext, Store } from '@ngxs/store'; |
|
|
import { Action, createSelector, Selector, State, StateContext, Store } from '@ngxs/store'; |
|
|
import { of } from 'rxjs'; |
|
|
import { of } from 'rxjs'; |
|
|
import { switchMap, tap } from 'rxjs/operators'; |
|
|
import { switchMap, tap } from 'rxjs/operators'; |
|
|
import snq from 'snq'; |
|
|
import snq from 'snq'; |
|
|
import { |
|
|
import { |
|
|
|
|
|
AddRoute, |
|
|
GetAppConfiguration, |
|
|
GetAppConfiguration, |
|
|
PatchRouteByName, |
|
|
PatchRouteByName, |
|
|
AddRoute, |
|
|
|
|
|
SetEnvironment, |
|
|
SetEnvironment, |
|
|
} from '../actions/config.actions'; |
|
|
} from '../actions/config.actions'; |
|
|
import { SetLanguage } from '../actions/session.actions'; |
|
|
import { SetLanguage } from '../actions/session.actions'; |
|
|
@ -14,7 +15,6 @@ import { Config } from '../models/config'; |
|
|
import { ApplicationConfigurationService } from '../services/application-configuration.service'; |
|
|
import { ApplicationConfigurationService } from '../services/application-configuration.service'; |
|
|
import { organizeRoutes } from '../utils/route-utils'; |
|
|
import { organizeRoutes } from '../utils/route-utils'; |
|
|
import { SessionState } from './session.state'; |
|
|
import { SessionState } from './session.state'; |
|
|
import { Injectable } from '@angular/core'; |
|
|
|
|
|
|
|
|
|
|
|
@State<Config.State>({ |
|
|
@State<Config.State>({ |
|
|
name: 'ConfigState', |
|
|
name: 'ConfigState', |
|
|
@ -88,28 +88,24 @@ export class ConfigState { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static getSetting(key: string) { |
|
|
static getSetting(key: string) { |
|
|
const selector = createSelector([ConfigState], (state: Config.State) => { |
|
|
return createSelector([ConfigState], (state: Config.State) => { |
|
|
return snq(() => state.setting.values[key]); |
|
|
return snq(() => state.setting.values[key]); |
|
|
}); |
|
|
}); |
|
|
return selector; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static getSettings(keyword?: string) { |
|
|
static getSettings(keyword?: string) { |
|
|
const selector = createSelector([ConfigState], (state: Config.State) => { |
|
|
return createSelector([ConfigState], (state: Config.State) => { |
|
|
if (keyword) { |
|
|
const settings = snq(() => state.setting.values, {}); |
|
|
const keys = snq( |
|
|
|
|
|
() => Object.keys(state.setting.values).filter(key => key.indexOf(keyword) > -1), |
|
|
|
|
|
[], |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
if (keys.length) { |
|
|
|
|
|
return keys.reduce((acc, key) => ({ ...acc, [key]: state.setting.values[key] }), {}); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return snq(() => state.setting.values, {}); |
|
|
if (!keyword) return settings; |
|
|
|
|
|
|
|
|
|
|
|
const keysFound = Object.keys(settings).filter(key => key.indexOf(keyword) > -1); |
|
|
|
|
|
|
|
|
|
|
|
return keysFound.reduce((acc, key) => { |
|
|
|
|
|
acc[key] = settings[key]; |
|
|
|
|
|
return acc; |
|
|
|
|
|
}, {}); |
|
|
}); |
|
|
}); |
|
|
return selector; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static getGrantedPolicy(key: string) { |
|
|
static getGrantedPolicy(key: string) { |
|
|
|