diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 4a0c047..311ec83 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,8 +1,9 @@ -import { Component, OnDestroy } from '@angular/core'; +import { Component, OnDestroy, Inject} from '@angular/core'; import { Store } from '@ngrx/store'; import { getUserState, UserState } from '@eui/core'; import { Observable, Subscription } from 'rxjs'; import { I18nService } from '@eui/core'; +import { StorageService,LocalForageService } from '@eui/core'; @Component({ selector: 'app-root', @@ -25,14 +26,26 @@ export class AppComponent implements OnDestroy { { label: 'Title label 4', subLabel: 'Subtitle label' }, ]; - constructor(private store: Store,protected i18nService: I18nService,) { + constructor(private store: Store,protected i18nService: I18nService, private localForage : LocalForageService, + private sessionStorageService: StorageService, + @Inject('LocalStorageService') private localStorageService: StorageService, + + ) { this.userState = this.store.select(getUserState); this.subs.push(this.userState.subscribe((user: UserState) => { this.userInfos = { ...user }; })); this.i18nService.init(); + + } + + ngOnInit() { + this.sessionStorageService.set('SESSION\_STORAGE', "testSession"); + this.localStorageService.set('STORAGE', "local"); + this.localForage.set('name', 'uma'); } + ngOnDestroy() { this.subs.forEach((s: Subscription) => s.unsubscribe()); } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 4847486..00b8a6b 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -1,32 +1,61 @@ -import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; -import { FormsModule } from '@angular/forms'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import { APP_INITIALIZER, NgModule } from '@angular/core'; import { AppComponent } from './app.component'; -import { HelloComponent } from './hello.component'; - -import { EuiIconModule } from '@eui/components/atoms/eui-icon'; -import { EuiButtonModule } from '@eui/components/eui-button'; -import { EuiCardModule } from '@eui/components/eui-card'; -import { EuiLabelModule } from '@eui/components/atoms/eui-label'; -import { CommonModule } from '@angular/common'; import { CoreModule } from './core/core.module'; -import { EuiAppModule, EuiNotificationsModule } from '@eui/components/layout'; +import { CoreModule as UxCoreModule, + StorageService, + SessionStorageService, + LocalStorageService, + AsyncStorageService, + LocalForageService, LOCAL_FORAGE_SERVICE_CONFIG_TOKEN} from '@eui/core'; + import * as localForage from 'localforage'; + + + import { FormsModule } from '@angular/forms'; + + import { HelloComponent } from './hello.component'; + + import { EuiIconModule } from '@eui/components/atoms/eui-icon'; + import { EuiButtonModule } from '@eui/components/eui-button'; + import { EuiCardModule } from '@eui/components/eui-card'; + import { EuiLabelModule } from '@eui/components/atoms/eui-label'; + import { CommonModule } from '@angular/common'; + import { EuiAppModule, EuiNotificationsModule } from '@eui/components/layout'; + import { CachePreventionInterceptor } from '@eui/core'; + import { CorsSecurityInterceptor } from '@eui/core'; + import { AddLangParamInterceptor } from '@eui/core'; + import { HTTP_INTERCEPTORS } from '@angular/common/http'; + + @NgModule({ - imports: [ - CoreModule, - CommonModule, - BrowserModule, - FormsModule, - EuiButtonModule, - EuiIconModule, - EuiCardModule, - EuiLabelModule, - EuiAppModule, - EuiNotificationsModule, - ], - declarations: [AppComponent, HelloComponent], - bootstrap: [AppComponent], + declarations: [ + AppComponent, + ], + imports: [ + BrowserModule, + BrowserAnimationsModule, + CoreModule, + BrowserModule, + FormsModule, + EuiButtonModule, + EuiIconModule, + EuiCardModule, + EuiLabelModule, + EuiAppModule, + EuiNotificationsModule, + + + ], + providers: [ + { provide: 'LocalStorageService', useExisting: LocalStorageService }, + { provide: StorageService, useExisting: SessionStorageService }, + + ], + bootstrap: [ + AppComponent, + ], }) export class AppModule {} diff --git a/src/app/core/core.module.ts b/src/app/core/core.module.ts index c56465d..f6adde7 100644 --- a/src/app/core/core.module.ts +++ b/src/app/core/core.module.ts @@ -15,6 +15,13 @@ import { import { appConfig } from '../../config'; import { environment } from '../../environments/environment'; import { REDUCER_TOKEN, getReducers, metaReducers } from './reducers'; +import * as localForage from 'localforage'; +import { StorageService, SessionStorageService,LocalStorageService, + AsyncStorageService, + LocalForageService, + LOCAL_FORAGE_SERVICE_CONFIG_TOKEN, + +} from '@eui/core'; @NgModule({ imports: [ @@ -40,7 +47,13 @@ import { REDUCER_TOKEN, getReducers, metaReducers } from './reducers'; }, { provide: APP_BASE_HREF, useValue: '/' - } + }, + SessionStorageService, + LocalStorageService, + { provide: StorageService, useExisting: LocalStorageService }, + LocalForageService, + { provide: AsyncStorageService, useExisting: LocalForageService }, + ] }) export class CoreModule {