-
Notifications
You must be signed in to change notification settings - Fork 38
/
config-helper.ts
44 lines (35 loc) · 1.46 KB
/
config-helper.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { SessionStorageKeys } from './constants'
import { trimTrailingSlashURL } from './common-util'
export default class ConfigHelper {
static keycloakConfigUrl: string = ''
static addToSession (key: string, value: any): void {
sessionStorage.setItem(key, value)
}
static getFromSession (key: string): string | null {
return sessionStorage.getItem(key)
}
static removeFromSession (key: string): void {
sessionStorage.removeItem(key)
}
static clearSession (): void {
sessionStorage.clear()
}
static getStatusAPIUrl (): string {
const apiConfig = JSON.parse(sessionStorage.getItem(SessionStorageKeys.ApiConfigKey) || '{}')
return trimTrailingSlashURL(apiConfig ? apiConfig['VUE_APP_STATUS_ROOT_API'] : '')
}
static getAuthAPIUrl (): string {
const apiConfig = JSON.parse(sessionStorage.getItem(SessionStorageKeys.ApiConfigKey) || '{}')
return trimTrailingSlashURL((apiConfig && apiConfig['VUE_APP_AUTH_ROOT_API']) || sessionStorage.getItem(SessionStorageKeys.AuthApiUrl) || '')
}
static getAuthContextPath (): string {
const apiConfig = JSON.parse(sessionStorage.getItem(SessionStorageKeys.ApiConfigKey) || '{}')
return trimTrailingSlashURL((apiConfig && apiConfig['AUTH_URL']) || sessionStorage.getItem('AUTH_URL') || '')
}
static setKeycloakConfigUrl (keycloakConfigUrl: string) {
this.keycloakConfigUrl = keycloakConfigUrl
}
static getKeycloakConfigUrl (): string {
return this.keycloakConfigUrl
}
}