src/client/app/modules/core/utils/config.ts
Properties |
|
Methods |
|
Public ENVIRONMENT |
ENVIRONMENT()
|
Returns :
EnvConfig
|
Public GET_SUPPORTED_LANGUAGES |
GET_SUPPORTED_LANGUAGES()
|
Returns :
{}
|
Public IS_DEBUG_MODE |
IS_DEBUG_MODE()
|
Returns :
boolean
|
Public IS_DESKTOP |
IS_DESKTOP()
|
Returns :
boolean
|
Public IS_MOBILE_HYBRID |
IS_MOBILE_HYBRID()
|
Returns :
boolean
|
Public IS_MOBILE_NATIVE |
IS_MOBILE_NATIVE()
|
Returns :
boolean
|
Public IS_WEB |
IS_WEB()
|
Returns :
boolean
|
Public RESET |
RESET()
|
Returns :
void
|
Public DEBUG |
DEBUG:
|
Public PageClass |
PageClass:
|
Type : any
|
Public PLATFORM_TARGET |
PLATFORM_TARGET:
|
Type : string
|
Public PLATFORMS |
PLATFORMS:
|
Type : IPlatforms
|
export interface EnvConfig {
API?: string;
ENV?: string;
}
export interface IPlatforms {
WEB: string;
MOBILE_NATIVE: string;
MOBILE_HYBRID: string;
DESKTOP: string;
}
export class Config {
public static PageClass: any;
public static DEBUG = {
LEVEL_1: false, // .info only
LEVEL_2: false, // .warn only
LEVEL_3: false, // .error only
LEVEL_4: false // .log + all the above
};
// supported platforms
public static PLATFORMS: IPlatforms = {
WEB: 'web',
MOBILE_NATIVE: 'mobile_native',
MOBILE_HYBRID: 'mobile_hybrid',
DESKTOP: 'desktop'
};
// current target (defaults to web)
public static PLATFORM_TARGET: string = Config.PLATFORMS.WEB;
// convenient platform checks
public static IS_WEB(): boolean {
return Config.PLATFORM_TARGET === Config.PLATFORMS.WEB;
}
public static IS_MOBILE_NATIVE(): boolean {
return Config.PLATFORM_TARGET === Config.PLATFORMS.MOBILE_NATIVE;
}
public static IS_MOBILE_HYBRID(): boolean {
return Config.PLATFORM_TARGET === Config.PLATFORMS.MOBILE_HYBRID;
}
public static IS_DESKTOP(): boolean {
return Config.PLATFORM_TARGET === Config.PLATFORMS.DESKTOP;
}
public static ENVIRONMENT(): EnvConfig {
try {
return JSON.parse('<%= ENV_CONFIG %>');
} catch (exp) {
return {};
}
}
// supported languages
public static GET_SUPPORTED_LANGUAGES() {
return [
{ code: 'en', title: 'English' },
{ code: 'es', title: 'Spanish' },
{ code: 'fr', title: 'French' },
{ code: 'ru', title: 'Russian' },
{ code: 'bg', title: 'Bulgarian' }
];
}
public static IS_DEBUG_MODE(): boolean {
for (let key in Config.DEBUG) {
if (Config.DEBUG[key]) {
// if any level is on, debug mode is on
return true;
}
}
return false;
}
// reset debug defaults
public static RESET() {
for (let key in Config.DEBUG) {
Config.DEBUG[key] = false;
}
}
}