refactor(setting): adjust setting module to new core translation

Closes #53
This commit is contained in:
Sebastian Lange
2019-02-26 08:22:49 +01:00
parent 24dbb42b34
commit 49b7c6d383
12 changed files with 9876 additions and 545 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018, 2019 StApps
* Copyright (C) 2019 StApps
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
@@ -12,8 +12,15 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {HTTP_INTERCEPTORS, HttpClient,
HttpEvent, HttpHandler, HttpInterceptor, HttpRequest, HttpResponse} from '@angular/common/http';
import {
HTTP_INTERCEPTORS,
HttpClient,
HttpEvent,
HttpHandler,
HttpInterceptor,
HttpRequest,
HttpResponse,
} from '@angular/common/http';
import {Injectable} from '@angular/core';
import {SCIndexResponse, SCSettingInputType, SCThingOriginType, SCThingType} from '@openstapps/core';
import {Observable, of} from 'rxjs';
@@ -71,20 +78,28 @@ const sampleIndexResponse: SCIndexResponse = {
},
translations: {
de: {
categories: ['Benutzer'],
description: 'Mit welcher Benutzergruppe soll die App verwendet werden?'
+ ' Die Einstellung wird beispielsweise für die Vorauswahl der Preiskategorie der Mensa verwendet.',
name: 'Gruppe',
values: [
'Student',
'Angestellter',
'Gast',
],
},
en: {
categories: ['User'],
description: 'The user group the app is going to be used.'
+ 'This settings for example is getting used for the predefined price category of mensa meals.',
name: 'Group',
values: [
'Student',
'Employee',
'Guest',
],
},
},
type: SCThingType.Setting,
uid: '',
uid: '2c97aa36-4aa2-43de-bc5d-a2b2cb3a530e',
values: ['student', 'employee', 'guest'],
},
{
@@ -101,19 +116,25 @@ const sampleIndexResponse: SCIndexResponse = {
},
translations: {
de: {
categories: ['Benutzer'],
description: 'Die Sprache in der die App angezeigt werden soll',
description: 'Die Sprache in der die App angezeigt wird.',
name: 'Sprache',
values: [
'Deutsch',
'English',
],
},
en: {
categories: ['User'],
description: 'The language this app is going to use',
description: 'The language this app is going to use.',
name: 'Language',
values: [
'Deutsch',
'English',
],
},
},
type: SCThingType.Setting,
uid: '',
values: ['en', 'de'],
uid: 'dc9d6dec-6576-45ef-9e35-3598c0d6a662',
values: ['de', 'en'],
},
{
categories: ['privacy'],
@@ -129,31 +150,33 @@ const sampleIndexResponse: SCIndexResponse = {
},
translations: {
de: {
categories: ['Privatsphäre'],
description: 'Berechtigung für die Verwendung des Ortungsdienstes, für die Anzeige der aktuellen ' +
'Position \'\n auf der Karte und zur Berechnung der Entfernung zu Gebäuden und Orten des Campus',
description: `Berechtigung für die Verwendung des Ortungsdienstes, für die Anzeige der aktuellen Position '
auf der Karte und zur Berechnung der Entfernung zu Gebäuden und Orten des Campus.`,
name: 'Position',
values: ['ja', 'nein'],
},
en: {
categories: ['Privacy'],
description: 'Allow the App to use the device location to provide additional informationsbased ' +
'on your actual location',
description: 'Allow the App to use the device location to provide additional information\'s based ' +
'on your actual location.',
name: 'Position',
values: ['yes', 'no'],
},
},
type: SCThingType.Setting,
uid: '',
uid: '0dbff2de-23b4-442b-9aa7-7bd2c707c199',
values: [true, false],
},
],
},
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',
@@ -228,6 +251,12 @@ const sampleIndexResponse: SCIndexResponse = {
*/
@Injectable()
export class FakeBackendInterceptor implements HttpInterceptor {
/**
* Delay time of faked responses
*/
RESPONSE_DELAY = 1000;
/**
* TODO
*/
@@ -240,6 +269,7 @@ export class FakeBackendInterceptor implements HttpInterceptor {
/**
* TODO
*/
// tslint:disable-next-line:no-any
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
if (request.method === 'POST') {
if (request.url.endsWith('/') && request.method === 'POST') {
@@ -251,16 +281,18 @@ export class FakeBackendInterceptor implements HttpInterceptor {
if (typeof request.body.filter !== 'undefined' && typeof request.body.filter.arguments !== 'undefined') {
if (request.body.filter.arguments.field === 'uid') {
return this.sampleFetcher.getSampleThing(request.body.filter.arguments.value)
// tslint:disable-next-line:no-any
.pipe(map((sampleData: any) => {
return new HttpResponse({status: 200, body: {data: sampleData}});
}), delay(1000)); // add delay for skeleton screens to be seen (see !16)
}), delay(this.RESPONSE_DELAY)); // add delay for skeleton screens to be seen (see !16)
}
}
return this.sampleFetcher.getSampleThings()
// tslint:disable-next-line:no-any
.pipe(map((sampleData: any) => {
return new HttpResponse({status: 200, body: {data: sampleData}});
}), delay(1000)); // add delay for skeleton screens to be seen (see !16)
}), delay(this.RESPONSE_DELAY)); // add delay for skeleton screens to be seen (see !16)
}
}