import { Injectable } from '@angular/core' ; import { RenderMode } from '../../../../ts/protocol/data' ; import { environment } from '../environments/environment' ; const PROVIDER_BASE_URL_KEY = 'providerBaseUrl' ; const RENDER_MODE_KEY = 'renderMode' ; @ Injectable ( ) export class SettingsService { getProviderBaseUrl ( ) { let baseUrl = localStorage . getItem ( PROVIDER_BASE_URL_KEY ) ; if ( ! ! baseUrl ) { return baseUrl ; } return environment . defaultProviderUrl ; } setProviderBaseUrl ( providerUrl ) { if ( ! providerUrl || providerUrl . length < 1 ) { localStorage . removeItem ( PROVIDER_BASE_URL_KEY ) ; return ; } localStorage . setItem ( PROVIDER_BASE_URL_KEY , providerUrl ) ; } getRenderMode ( ) { let renderMode = localStorage . getItem ( RENDER_MODE_KEY ) ; if ( ! renderMode || renderMode . length < 1 ) { return null ; } return ( renderMode as any ) ; } setRenderMode ( renderMode ) { if ( ! renderMode || renderMode . length < 1 ) { localStorage . removeItem ( RENDER_MODE_KEY ) ; return ; } localStorage . setItem ( RENDER_MODE_KEY , renderMode ) ; } }