File

src/lib/service/config/config.service.ts

Description

Collection of all Configurations

Index

Methods

Methods

Public getAgentConfig
getAgentConfig()

Getter for the Agent Configuration

Returns : any
Public getClientLocales
getClientLocales()

Getter for the available client locales

Returns : any[]

available client locales

getContextPath
getContextPath()
Returns : string
Public getDashboardBackgroundImage
getDashboardBackgroundImage()

Get the dashboards background image

Returns : string

background image uri for the dashboards background image

Public getDefaultClientLocale
getDefaultClientLocale()

Get the default client locale

Returns : any

ISO string of the locale

getLoginBase
getLoginBase()
Returns : string
Public getNavigationBarImage
getNavigationBarImage()

Get the navigation bar image (Logo) only accepts svg.

Returns : string

background image uri for the Navigationbar (Logo)

Public getRaw
getRaw(property: string)

Returns nested property of config | complete config by default

Parameters :
Name Type Optional Description
property string no

The name of the property to be retrieved

Returns : any
Public getSideBarHeaderImage
getSideBarHeaderImage()

Get the sidebars header background image

Returns : string

background image uri for the sidebars header background image

Public getSupportedClientLocales
getSupportedClientLocales()

Getter for the supported client locales

Returns : string[]

supported client locales

Public getUri
getUri(property: string)

Getter for the URI

Parameters :
Name Type Optional Description
property string no

The name of the property/uri to be retrieved

Returns : string

value of the property from the URI-Section of the config

config.service

import {Injectable} from '@angular/core';
import {TranslateService} from '@ngx-translate/core';
import {Utils} from '../../util/utils';
import {EventService} from '../events/event.service';
import {EnaioConfig} from './config.interface';
import {EnaioEvent} from '../events/events';

/**
 * Collection of all Configurations
 */
@Injectable({
  providedIn: 'root'
})
export class Config {

  private cfg: EnaioConfig = null;

  private fixServiceUris = null;

  /**
   * @ignore
   */
  constructor(private translate: TranslateService, private event: EventService) {
  }

  /**
   * @ignore
   */
  private initializeGrid() {
    this.event.trigger(EnaioEvent.EO_LICENSE_GRID);
  }

  /**
   * @ignore
   * Set during app init (see CoreInit)
   */
  public set(cfg: EnaioConfig) {
    this.cfg = cfg;
    this.fixServiceUris = new Map<string, string>([
      ['serviceBase', '/rest-ws/service'],
      ['searchBase', '/search'],
      ['contextBase', '/structure'],
      ['inboxBase', '/inboxservice'],
      ['bpmBase', '/bpm'],
      ['agentBase', '/agent'],
      ['statusBase', '/status']]);
    const languages = this.getClientLocales().map(lang => lang.iso);
    this.translate.addLangs(languages);
    this.translate.setDefaultLang(this.getDefaultClientLocale());
    this.initializeGrid();
  }

  /**
   * @Deprecated replaced by getContextPath
   */
  getLoginBase(): string {
    return this.getContextPath();
  }

  getContextPath(): string {
    let cp = this.getUri('contextPath')
      // TODO: remove when not supported anymore
      || this.getUri('loginBase');
    return (cp && cp !== '/') ? cp : '';
  }

  /**
   * Returns nested property of config | complete config by default
   * @param property The name of the property to be retrieved
   */
  public getRaw(property: string): any {
    return property ? Utils.getProperty(this.cfg, property) : this.cfg;
  }

  /**
   * Getter for the URI
   * @param property The name of the property/uri to be retrieved
   * @returns value of the property from the URI-Section of the config
   */
  public getUri(property: string): string {
    return (this.cfg['uri'] && this.cfg['uri'][property]) || this.fixServiceUris.get(property);
  }

  /**
   * Getter for the available client locales
   * @returns available client locales
   */
  public getClientLocales(): any[] {
    return this.cfg['languages'];
  }

  /**
   * Getter for the supported client locales
   * @returns supported client locales
   */
  public getSupportedClientLocales(): string[] {
    return ['en', 'de', 'ar', 'es', 'pt', 'fr', 'zh', 'lv', 'ru', 'it', 'nl', 'sk', 'pl', 'uk', 'ja', 'ko', 'hi', 'bn', 'de-CH', 'zh-Hant',
      'th', 'vi', 'en-GB', 'he', 'fi', 'se', 'da', 'nb', 'nn', 'id', 'ms'];
  }

  /**
   * Get the dashboards background image
   * @returns background image uri for the dashboards background image
   */
  public getDashboardBackgroundImage(): string {
    return this.cfg['dashboardBackgroundImage'];
  }

  /**
   * Get the sidebars header background image
   * @returns background image uri for the sidebars header background image
   */
  public getSideBarHeaderImage(): string {
    return this.cfg['sideBarHeaderImage'];
  }

  /**
   * Get the navigation bar image (Logo)
   * only accepts svg.
   * @returns background image uri for the Navigationbar (Logo)
   */
  public getNavigationBarImage(): string {
    let logo = this.cfg['navBarLogo'];
    logo = logo.endsWith('.svg') ? logo : `<svg></svg>`;
    return logo;
  }

  /**
   * Get the default client locale
   * @returns ISO string of the locale
   */
  public getDefaultClientLocale() {
    const lang = this.getClientLocales().find(_ => _.fallback);
    return lang ? lang.iso : 'en';
  }

  /**
   * Getter for the Agent Configuration
   */
  public getAgentConfig(): any {
    return this.cfg['agent'];
  }
}

results matching ""

    No results matching ""