mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-20 08:33:11 +00:00
refactor(setting): adjust setting module to new core translation
Closes #53
This commit is contained in:
@@ -17,12 +17,7 @@ import {SCIndexResponse, SCThingOriginType, SCThingType, SCSettingInputType} fro
|
||||
import {StAppsWebHttpClient} from '../data/stapps-web-http-client.provider';
|
||||
import {StorageProvider} from '../storage/storage.provider';
|
||||
import {ConfigProvider, STORAGE_KEY_CONFIG} from './config.provider';
|
||||
import {
|
||||
ConfigFetchError,
|
||||
ConfigInitError,
|
||||
SavedConfigNotAvailable,
|
||||
WrongConfigVersionInStorage,
|
||||
} from './errors';
|
||||
import {ConfigFetchError, ConfigInitError, SavedConfigNotAvailable, WrongConfigVersionInStorage,} from './errors';
|
||||
|
||||
describe('ConfigProvider', () => {
|
||||
let configProvider: ConfigProvider;
|
||||
@@ -218,11 +213,9 @@ const sampleIndexResponse: SCIndexResponse = {
|
||||
},
|
||||
translations: {
|
||||
de: {
|
||||
categories: ['Anmeldedaten'],
|
||||
name: 'Benutzername',
|
||||
},
|
||||
en: {
|
||||
categories: ['Credentials'],
|
||||
name: 'Username',
|
||||
},
|
||||
},
|
||||
@@ -233,11 +226,13 @@ const sampleIndexResponse: SCIndexResponse = {
|
||||
},
|
||||
backend: {
|
||||
SCVersion: '1.0.0',
|
||||
externalRequestTimeout: 5000,
|
||||
hiddenTypes: [
|
||||
SCThingType.DateSeries,
|
||||
SCThingType.Diff,
|
||||
SCThingType.Floor,
|
||||
],
|
||||
mappingIgnoredTags: [],
|
||||
maxMultiSearchRouteQueries: 5,
|
||||
maxRequestBodySize: 512 * 1024,
|
||||
name: 'Technische Universität Berlin',
|
||||
|
||||
@@ -40,22 +40,23 @@ export const STORAGE_KEY_CONFIG = 'stapps.config';
|
||||
@Injectable()
|
||||
export class ConfigProvider {
|
||||
/**
|
||||
* TODO
|
||||
* Api client
|
||||
*/
|
||||
client: Client;
|
||||
/**
|
||||
* TODO
|
||||
* App configuration as IndexResponse
|
||||
*/
|
||||
config: SCIndexResponse;
|
||||
/**
|
||||
* TODO
|
||||
* Initialised status flag of config provider
|
||||
*/
|
||||
initialised = false;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param storageProvider TODO
|
||||
* @param swHttpClient TODO
|
||||
* Constructor, initialise api client
|
||||
*
|
||||
* @param storageProvider StorageProvider to load persistet configuration
|
||||
* @param swHttpClient Api client
|
||||
*/
|
||||
constructor(private readonly storageProvider: StorageProvider, swHttpClient: StAppsWebHttpClient) {
|
||||
this.client = new Client(swHttpClient, environment.backend_url, environment.backend_version);
|
||||
@@ -108,7 +109,7 @@ export class ConfigProvider {
|
||||
try {
|
||||
this.config = await this.loadLocal();
|
||||
this.initialised = true;
|
||||
Logger.log(`initialised configuration from storage: ${JSON.stringify(this.config)}`);
|
||||
Logger.log(`initialised configuration from storage`);
|
||||
if (this.config.backend.SCVersion !== environment.backend_version) {
|
||||
loadError = new WrongConfigVersionInStorage(environment.backend_version, this.config.backend.SCVersion);
|
||||
Logger.warn(loadError);
|
||||
@@ -121,7 +122,7 @@ export class ConfigProvider {
|
||||
const fetchedConfig: SCIndexResponse = await this.fetch();
|
||||
await this.set(fetchedConfig);
|
||||
this.initialised = true;
|
||||
Logger.log(`initialised configuration from remote: ${JSON.stringify(this.config)}`);
|
||||
Logger.log(`initialised configuration from remote`);
|
||||
} catch (error) {
|
||||
fetchError = error;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user