/** Angular Imports */ import { Injectable , EventEmitter } from '@angular/core' ; /** Custom Model */ import { Theme } from './theme.model' ; /** Custom Services */ import { ThemeManagerService } from './theme-manager.service' ; /**
 * Theme storage service.
 */ @ Injectable ( { providedIn : 'root' } ) export class ThemeStorageService { /** Key to store current theme of application in local storage. */ private themeStorageKey = 'mifosXTheme' ; /** Theme update event. */ onThemeUpdate : EventEmitter < Theme > ; param { ThemeManagerService } themeManagerService constructor ( public themeManagerService ) { this . onThemeUpdate = new EventEmitter < Theme > ( ) ; } param mifosXTheme storeTheme ( mifosXTheme ) { localStorage . setItem ( this . themeStorageKey , JSON . stringify ( mifosXTheme ) ) ; this . onThemeUpdate . emit ( mifosXTheme ) ; } returns getTheme ( ) { return JSON . parse ( localStorage . getItem ( this . themeStorageKey ) ) ; } /**
     * Removes current theme from local storage.
     */ clearTheme ( ) { localStorage . removeItem ( this . themeStorageKey ) ; } param { Theme } theme installTheme ( theme ) { if ( theme . isDefault ) { this . themeManagerService . removeTheme ( ) ; } else { this . themeManagerService . setTheme ( `theme/${ theme . href }` ) ; } this . storeTheme ( theme ) ; } }