[ADF-3887] Different local storages for different ADF apps (#4539)

* [ADF-3887] Different local storages for different ADF apps

* [ADF-3887] Add documentation

* [ADF-3887] Add unit tests and improve code

* [ADF-3887] Add unit tests

* [ADF-3887] Fix e2e tests

* fix test

* fix test

* Update storage.service.md
This commit is contained in:
davidcanonieto
2019-04-08 15:23:46 +01:00
committed by Eugenio Romano
parent f89bf507f5
commit dee63e3f3b
22 changed files with 181 additions and 43 deletions

View File

@@ -17,21 +17,26 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { StorageService } from '../services/storage.service';
import { AppConfigService, AppConfigValues } from '../app-config/app-config.service';
@Injectable()
export class DebugAppConfigService extends AppConfigService {
constructor(private storage: StorageService, http: HttpClient) {
constructor(http: HttpClient) {
super(http);
}
/** @override */
get<T>(key: string, defaultValue?: T): T {
if (key === AppConfigValues.OAUTHCONFIG) {
return <T> (JSON.parse(this.storage.getItem(key)) || super.get<T>(key, defaultValue));
return <T> (JSON.parse(this.getItem(key)) || super.get<T>(key, defaultValue));
} else if (key === AppConfigValues.APPLICATION) {
return undefined;
} else {
return <T> (<any> this.storage.getItem(key) || super.get<T>(key, defaultValue));
return <T> (<any> this.getItem(key) || super.get<T>(key, defaultValue));
}
}
getItem(key: string): string | null {
return localStorage.getItem(key);
}
}