mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-04-17 03:39:04 +00:00
fix: build
This commit is contained in:
18376
frontend/app/package-lock.json
generated
18376
frontend/app/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@openstapps/app",
|
||||
"version": "2.1.1",
|
||||
"description": "The generic app tailored to fulfill needs of German universities, written using Ionic Framework.",
|
||||
"version": "2.1.0",
|
||||
"license": "GPL-3.0-only",
|
||||
"author": "Karl-Philipp Wulfert <krlwlfrt@gmail.com>",
|
||||
"contributors": [
|
||||
@@ -21,6 +21,7 @@
|
||||
"build:stats": "ng build --configuration=production --stats-json",
|
||||
"changelog": "conventional-changelog -p angular -i src/assets/about/CHANGELOG.md -s -r 0",
|
||||
"check-configuration": "openstapps-configuration",
|
||||
"check-icons": "ts-node scripts/check-icon-correctness.ts",
|
||||
"cypress:open": "cypress open",
|
||||
"cypress:run": "cypress run",
|
||||
"docker:build": "sudo docker run -p 8100:8100 -p 35729:35729 -p 53703:53703 -v $PWD:/app -it registry.gitlab.com/openstapps/app bash -c \"npm install && npm run build\"",
|
||||
@@ -31,16 +32,14 @@
|
||||
"docker:serve": "sudo docker run -p 8100:8100 -p 35729:35729 -p 53703:53703 -v $PWD:/app -it registry.gitlab.com/openstapps/app bash -c \"npm run start:external\"",
|
||||
"documentation": "compodoc -p tsconfig.json -d docs",
|
||||
"e2e": "ng e2e",
|
||||
"licenses": "license-checker --json > src/assets/about/licenses.json && ts-node ./scripts/accumulate-licenses.ts",
|
||||
"minify-icons": "ts-node scripts/minify-icon-font.ts",
|
||||
"check-icons": "ts-node scripts/check-icon-correctness.ts",
|
||||
"format:check": "prettier --check .",
|
||||
"format:fix": "prettier --write .",
|
||||
"licenses": "license-checker --json > src/assets/about/licenses.json && ts-node ./scripts/accumulate-licenses.ts && git add src/assets/about/licenses.json",
|
||||
"lint": "ng lint",
|
||||
"lint:fix": "eslint --fix -c .eslintrc.json --ignore-path .eslintignore --ext .ts,.html src/",
|
||||
"minify-icons": "ts-node scripts/minify-icon-font.ts",
|
||||
"ng": "ng",
|
||||
"postinstall": "npx jetify",
|
||||
"version": "npm run changelog && npm run licenses && npm run format:fix && git add src/assets/about/CHANGELOG.md && git add src/assets/about/licenses.json",
|
||||
"prepublishOnly": "npm ci && npm run build && npm run lint && npm run format:check",
|
||||
"preversion": "npm run prepublishOnly",
|
||||
"push": "git push && git push origin \"v$npm_package_version\"",
|
||||
@@ -50,7 +49,8 @@
|
||||
"start": "ionic serve",
|
||||
"start:external": "ionic serve --external",
|
||||
"start:prod": "ionic serve -- --configuration=production",
|
||||
"test": "ng test"
|
||||
"test": "ng test",
|
||||
"version": "npm run changelog && npm run licenses && npm run format:fix"
|
||||
},
|
||||
"dependencies": {
|
||||
"@angular/animations": "13.3.11",
|
||||
@@ -83,16 +83,18 @@
|
||||
"@hugotomazi/capacitor-navigation-bar": "2.0.0",
|
||||
"@ionic-native/core": "5.36.0",
|
||||
"@ionic/angular": "6.3.9",
|
||||
"@ionic/core": "6.6.1",
|
||||
"@ionic/storage-angular": "3.0.6",
|
||||
"@ngx-translate/core": "14.0.0",
|
||||
"@ngx-translate/http-loader": "7.0.0",
|
||||
"@openstapps/api": "1.0.1",
|
||||
"@openstapps/configuration": "0.34.0",
|
||||
"@openstapps/core": "1.0.1",
|
||||
"@openid/appauth": "1.3.1",
|
||||
"@openstapps/api": "workspace:*",
|
||||
"@openstapps/configuration": "workspace:*",
|
||||
"@openstapps/core": "workspace:*",
|
||||
"@transistorsoft/capacitor-background-fetch": "1.0.2",
|
||||
"capacitor-secure-storage-plugin": "0.8.1",
|
||||
"cordova-plugin-calendar": "5.1.6",
|
||||
"deepmerge": "4.2.2",
|
||||
"deepmerge": "4.3.0",
|
||||
"form-data": "4.0.0",
|
||||
"geojson": "0.5.0",
|
||||
"ionic-appauth": "0.9.0",
|
||||
@@ -131,27 +133,28 @@
|
||||
"@cypress/schematic": "1.7.0",
|
||||
"@ionic/angular-toolkit": "6.1.0",
|
||||
"@ionic/cli": "6.20.4",
|
||||
"@openstapps/prettier-config": "1.0.0",
|
||||
"@openstapps/prettier-config": "workspace:*",
|
||||
"@types/fontkit": "1.8.0",
|
||||
"@types/glob": "7.2.0",
|
||||
"@types/geojson": "1.0.6",
|
||||
"@types/glob": "8.0.1",
|
||||
"@types/jasmine": "4.3.1",
|
||||
"@types/jasminewd2": "2.0.10",
|
||||
"@types/jsonpath": "0.2.0",
|
||||
"@types/leaflet": "1.9.0",
|
||||
"@types/leaflet.markercluster": "1.5.1",
|
||||
"@types/node": "14.18.24",
|
||||
"@typescript-eslint/eslint-plugin": "5.45.1",
|
||||
"@typescript-eslint/parser": "5.45.1",
|
||||
"@types/node": "18.15.3",
|
||||
"@typescript-eslint/eslint-plugin": "5.49.0",
|
||||
"@typescript-eslint/parser": "5.49.0",
|
||||
"conventional-changelog-cli": "2.2.2",
|
||||
"cordova-res": "0.15.4",
|
||||
"cypress": "12.0.1",
|
||||
"eslint": "8.29.0",
|
||||
"eslint-config-prettier": "8.5.0",
|
||||
"eslint-plugin-jsdoc": "39.6.4",
|
||||
"eslint": "8.33.0",
|
||||
"eslint-config-prettier": "8.6.0",
|
||||
"eslint-plugin-jsdoc": "39.7.4",
|
||||
"eslint-plugin-prettier": "4.2.1",
|
||||
"eslint-plugin-unicorn": "43.0.2",
|
||||
"eslint-plugin-unicorn": "45.0.2",
|
||||
"fontkit": "2.0.2",
|
||||
"glob": "8.0.3",
|
||||
"glob": "8.1.0",
|
||||
"is-docker": "2.2.1",
|
||||
"jasmine-core": "4.5.0",
|
||||
"jasmine-spec-reporter": "7.0.0",
|
||||
@@ -163,17 +166,13 @@
|
||||
"karma-jasmine-html-reporter": "2.0.0",
|
||||
"karma-mocha-reporter": "2.2.5",
|
||||
"license-checker": "25.0.1",
|
||||
"prettier": "2.7.1",
|
||||
"prettier": "2.8.3",
|
||||
"protractor": "7.0.0",
|
||||
"surge": "0.23.1",
|
||||
"ts-node": "10.9.1",
|
||||
"typescript": "4.4.4",
|
||||
"webpack-bundle-analyzer": "4.7.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.20.0",
|
||||
"npm": "^6.14.17"
|
||||
},
|
||||
"cordova": {
|
||||
"plugins": {},
|
||||
"platforms": [
|
||||
|
||||
@@ -130,7 +130,7 @@ export class AppComponent implements AfterContentInit {
|
||||
}
|
||||
|
||||
private async showMessage(message?: string) {
|
||||
if (typeof message === 'undefined') {
|
||||
if (message === undefined) {
|
||||
return;
|
||||
}
|
||||
const toast = await this.toastController.create({
|
||||
|
||||
@@ -58,12 +58,14 @@ export class AuthHelperService {
|
||||
public getAuthMessage(provider: SCAuthorizationProviderType, action: IAuthAction | IPAIAAuthAction) {
|
||||
let message: string | undefined;
|
||||
switch (action.action) {
|
||||
case AuthActions.SignInSuccess:
|
||||
case AuthActions.SignInSuccess: {
|
||||
message = this.translateService.instant(`auth.messages.${provider}.logged_in_success`);
|
||||
break;
|
||||
case AuthActions.SignOutSuccess:
|
||||
}
|
||||
case AuthActions.SignOutSuccess: {
|
||||
message = this.translateService.instant(`auth.messages.${provider}.logged_out_success`);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
@@ -166,10 +166,10 @@ export abstract class AuthService implements IAuthService {
|
||||
});
|
||||
}
|
||||
|
||||
if (this._configuration != undefined) {
|
||||
return Promise.resolve(this._configuration);
|
||||
} else {
|
||||
if (this._configuration == undefined) {
|
||||
throw new Error('Unable To Obtain Server Configuration');
|
||||
} else {
|
||||
return Promise.resolve(this._configuration);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,36 +186,43 @@ export abstract class AuthService implements IAuthService {
|
||||
case AuthActions.RefreshFailed:
|
||||
case AuthActions.SignInFailed:
|
||||
case AuthActions.SignOutSuccess:
|
||||
case AuthActions.SignOutFailed:
|
||||
case AuthActions.SignOutFailed: {
|
||||
this._tokenSubject.next(undefined);
|
||||
this._userSubject.next(undefined);
|
||||
this._authenticatedSubject.next(false);
|
||||
break;
|
||||
case AuthActions.LoadTokenFromStorageFailed:
|
||||
}
|
||||
case AuthActions.LoadTokenFromStorageFailed: {
|
||||
this._tokenSubject.next(undefined);
|
||||
this._userSubject.next(undefined);
|
||||
this._authenticatedSubject.next(false);
|
||||
this._initComplete.next(true);
|
||||
break;
|
||||
}
|
||||
case AuthActions.SignInSuccess:
|
||||
case AuthActions.RefreshSuccess:
|
||||
case AuthActions.RefreshSuccess: {
|
||||
this._tokenSubject.next(action.tokenResponse);
|
||||
this._authenticatedSubject.next(true);
|
||||
break;
|
||||
case AuthActions.LoadTokenFromStorageSuccess:
|
||||
}
|
||||
case AuthActions.LoadTokenFromStorageSuccess: {
|
||||
this._tokenSubject.next(action.tokenResponse);
|
||||
this._authenticatedSubject.next((action.tokenResponse as TokenResponse).isValid(0));
|
||||
this._initComplete.next(true);
|
||||
break;
|
||||
case AuthActions.RevokeTokensSuccess:
|
||||
}
|
||||
case AuthActions.RevokeTokensSuccess: {
|
||||
this._tokenSubject.next(undefined);
|
||||
break;
|
||||
case AuthActions.LoadUserInfoSuccess:
|
||||
}
|
||||
case AuthActions.LoadUserInfoSuccess: {
|
||||
this._userSubject.next(action.user);
|
||||
break;
|
||||
case AuthActions.LoadUserInfoFailed:
|
||||
}
|
||||
case AuthActions.LoadUserInfoFailed: {
|
||||
this._userSubject.next(undefined);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
this._authSubjectV2.next(action);
|
||||
@@ -240,10 +247,10 @@ export abstract class AuthService implements IAuthService {
|
||||
|
||||
if (response != undefined) {
|
||||
this.requestAccessToken(response.code, codeVerifier);
|
||||
} else if (error != undefined) {
|
||||
throw new Error(error.errorDescription);
|
||||
} else {
|
||||
} else if (error == undefined) {
|
||||
throw new Error('Unknown Error With Authentication');
|
||||
} else {
|
||||
throw new Error(error.errorDescription);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,7 +267,10 @@ export abstract class AuthService implements IAuthService {
|
||||
}
|
||||
|
||||
protected async performEndSessionRequest(state?: string): Promise<void> {
|
||||
if (this._tokenSubject.value != undefined) {
|
||||
if (this._tokenSubject.value == undefined) {
|
||||
//if user has no token they should not be logged in in the first place
|
||||
this.endSessionCallback();
|
||||
} else {
|
||||
const requestJson: EndSessionRequestJson = {
|
||||
postLogoutRedirectURI: this.authConfig.end_session_redirect_url,
|
||||
idTokenHint: this._tokenSubject.value.idToken || '',
|
||||
@@ -277,9 +287,6 @@ export abstract class AuthService implements IAuthService {
|
||||
if (returnedUrl != undefined) {
|
||||
this.endSessionCallback();
|
||||
}
|
||||
} else {
|
||||
//if user has no token they should not be logged in in the first place
|
||||
this.endSessionCallback();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -460,13 +467,13 @@ export abstract class AuthService implements IAuthService {
|
||||
|
||||
public async getValidToken(buffer: number = AUTH_EXPIRY_BUFFER): Promise<TokenResponse> {
|
||||
if (this._tokenSubject.value) {
|
||||
if (!this._tokenSubject.value.isValid(buffer)) {
|
||||
if (this._tokenSubject.value.isValid(buffer)) {
|
||||
return this._tokenSubject.value;
|
||||
} else {
|
||||
await this.refreshToken();
|
||||
if (this._tokenSubject.value) {
|
||||
return this._tokenSubject.value;
|
||||
}
|
||||
} else {
|
||||
return this._tokenSubject.value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,14 +28,18 @@ export class CapacitorRequestor extends Requestor {
|
||||
if (!settings.method) settings.method = 'GET';
|
||||
|
||||
switch (settings.method) {
|
||||
case 'GET':
|
||||
case 'GET': {
|
||||
return this.get(settings.url, settings.headers);
|
||||
case 'POST':
|
||||
}
|
||||
case 'POST': {
|
||||
return this.post(settings.url, settings.data, settings.headers);
|
||||
case 'PUT':
|
||||
}
|
||||
case 'PUT': {
|
||||
return this.put(settings.url, settings.data, settings.headers);
|
||||
case 'DELETE':
|
||||
}
|
||||
case 'DELETE': {
|
||||
return this.delete(settings.url, settings.headers);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,26 +33,30 @@ export class NgHttpService implements Requestor {
|
||||
let observable: Observable<T>;
|
||||
|
||||
switch (settings.method) {
|
||||
case 'GET':
|
||||
case 'GET': {
|
||||
observable = this.http.get<T>(settings.url, {
|
||||
headers: this.getHeaders(settings.headers),
|
||||
});
|
||||
break;
|
||||
case 'POST':
|
||||
}
|
||||
case 'POST': {
|
||||
observable = this.http.post<T>(settings.url, settings.data, {
|
||||
headers: this.getHeaders(settings.headers),
|
||||
});
|
||||
break;
|
||||
case 'PUT':
|
||||
}
|
||||
case 'PUT': {
|
||||
observable = this.http.put<T>(settings.url, settings.data, {
|
||||
headers: this.getHeaders(settings.headers),
|
||||
});
|
||||
break;
|
||||
case 'DELETE':
|
||||
}
|
||||
case 'DELETE': {
|
||||
observable = this.http.delete<T>(settings.url, {
|
||||
headers: this.getHeaders(settings.headers),
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return firstValueFrom(observable);
|
||||
|
||||
@@ -60,7 +60,7 @@ export class PAIAAuthorizationRequestHandler {
|
||||
const returnedUrl: string | undefined = await this.browser.showWindow(url, request.redirectUri);
|
||||
|
||||
// callback may come from showWindow or via another method
|
||||
if (typeof returnedUrl !== 'undefined') {
|
||||
if (returnedUrl !== undefined) {
|
||||
await this.storage.setItem(AUTHORIZATION_RESPONSE_KEY, returnedUrl);
|
||||
await this.completeAuthorizationRequestIfPossible();
|
||||
}
|
||||
@@ -88,7 +88,7 @@ export class PAIAAuthorizationRequestHandler {
|
||||
|
||||
return <PAIAAuthorizationRequestResponse>{
|
||||
request: request, // request
|
||||
response: !error ? this.getAuthorizationResponse(queryParameters) : undefined,
|
||||
response: error ? undefined : this.getAuthorizationResponse(queryParameters),
|
||||
error: error ? this.getAuthorizationError(queryParameters) : undefined,
|
||||
};
|
||||
}
|
||||
@@ -128,14 +128,14 @@ export class PAIAAuthorizationRequestHandler {
|
||||
}
|
||||
|
||||
private getQueryParams(authResponse: string | null): StringMap {
|
||||
if (authResponse != undefined) {
|
||||
if (authResponse == undefined) {
|
||||
return {};
|
||||
} else {
|
||||
const querySide: string = authResponse.split('#')[0];
|
||||
const parts: string[] = querySide.split('?');
|
||||
if (parts.length !== 2) throw new Error('Invalid auth response string');
|
||||
const hash = parts[1];
|
||||
return this.utils.parseQueryString(hash);
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -166,35 +166,42 @@ export class PAIAAuthService {
|
||||
switch (action.action) {
|
||||
case AuthActions.SignInFailed:
|
||||
case AuthActions.SignOutSuccess:
|
||||
case AuthActions.SignOutFailed:
|
||||
case AuthActions.SignOutFailed: {
|
||||
this._tokenSubject.next(undefined);
|
||||
this._userSubject.next(undefined);
|
||||
this._authenticatedSubject.next(false);
|
||||
break;
|
||||
case AuthActions.LoadTokenFromStorageFailed:
|
||||
}
|
||||
case AuthActions.LoadTokenFromStorageFailed: {
|
||||
this._tokenSubject.next(undefined);
|
||||
this._userSubject.next(undefined);
|
||||
this._authenticatedSubject.next(false);
|
||||
this._initComplete.next(true);
|
||||
break;
|
||||
case AuthActions.SignInSuccess:
|
||||
}
|
||||
case AuthActions.SignInSuccess: {
|
||||
this._tokenSubject.next(action.tokenResponse);
|
||||
this._authenticatedSubject.next(true);
|
||||
break;
|
||||
case AuthActions.LoadTokenFromStorageSuccess:
|
||||
}
|
||||
case AuthActions.LoadTokenFromStorageSuccess: {
|
||||
this._tokenSubject.next(action.tokenResponse);
|
||||
this._authenticatedSubject.next((action.tokenResponse as TokenResponse).isValid(0));
|
||||
this._initComplete.next(true);
|
||||
break;
|
||||
case AuthActions.RevokeTokensSuccess:
|
||||
}
|
||||
case AuthActions.RevokeTokensSuccess: {
|
||||
this._tokenSubject.next(undefined);
|
||||
break;
|
||||
case AuthActions.LoadUserInfoSuccess:
|
||||
}
|
||||
case AuthActions.LoadUserInfoSuccess: {
|
||||
this._userSubject.next(action.user);
|
||||
break;
|
||||
case AuthActions.LoadUserInfoFailed:
|
||||
}
|
||||
case AuthActions.LoadUserInfoFailed: {
|
||||
this._userSubject.next(undefined);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
this._authSubjectV2.next(action);
|
||||
@@ -219,10 +226,10 @@ export class PAIAAuthService {
|
||||
|
||||
if (response != undefined) {
|
||||
this.requestAccessToken(response.code, response.patron, codeVerifier);
|
||||
} else if (error != undefined) {
|
||||
throw new Error(error.errorDescription);
|
||||
} else {
|
||||
} else if (error == undefined) {
|
||||
throw new Error('Unknown Error With Authentication');
|
||||
} else {
|
||||
throw new Error(error.errorDescription);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +93,11 @@ export class ScheduleSyncService implements OnDestroy {
|
||||
},
|
||||
);
|
||||
|
||||
if (status !== BackgroundFetch.STATUS_AVAILABLE) {
|
||||
if (status === BackgroundFetch.STATUS_AVAILABLE) {
|
||||
console.info('Starting background fetch.');
|
||||
|
||||
await BackgroundFetch.start();
|
||||
} else {
|
||||
if (status === BackgroundFetch.STATUS_DENIED) {
|
||||
console.error(
|
||||
'The user explicitly disabled background behavior for this app or for the whole system.',
|
||||
@@ -101,10 +105,6 @@ export class ScheduleSyncService implements OnDestroy {
|
||||
} else if (status === BackgroundFetch.STATUS_RESTRICTED) {
|
||||
console.error('Background updates are unavailable and the user cannot enable them again.');
|
||||
}
|
||||
} else {
|
||||
console.info('Starting background fetch.');
|
||||
|
||||
await BackgroundFetch.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ export class ConfigProvider {
|
||||
* @param attribute requested attribute from app configuration
|
||||
*/
|
||||
public getValue(attribute: keyof SCAppConfiguration) {
|
||||
if (typeof this.config.app[attribute] !== 'undefined') {
|
||||
if (this.config.app[attribute] !== undefined) {
|
||||
return this.config.app[attribute];
|
||||
}
|
||||
throw new ConfigValueNotAvailable(attribute);
|
||||
@@ -106,7 +106,7 @@ export class ConfigProvider {
|
||||
* @param attribute requested attribute from the configuration
|
||||
*/
|
||||
public getAnyValue(attribute: keyof SCIndexResponse) {
|
||||
if (typeof this.config[attribute] !== 'undefined') {
|
||||
if (this.config[attribute] !== undefined) {
|
||||
return this.config[attribute];
|
||||
}
|
||||
throw new ConfigValueNotAvailable(attribute);
|
||||
@@ -141,13 +141,13 @@ export class ConfigProvider {
|
||||
fetchError = error;
|
||||
}
|
||||
// check for occurred errors and throw them
|
||||
if (typeof loadError !== 'undefined' && typeof fetchError !== 'undefined') {
|
||||
if (loadError !== undefined && fetchError !== undefined) {
|
||||
throw new ConfigInitError();
|
||||
}
|
||||
if (typeof loadError !== 'undefined') {
|
||||
if (loadError !== undefined) {
|
||||
this.logger.warn(loadError);
|
||||
}
|
||||
if (typeof fetchError !== 'undefined') {
|
||||
if (fetchError !== undefined) {
|
||||
this.logger.warn(fetchError);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ export class DashboardProvider {
|
||||
from: from,
|
||||
};
|
||||
|
||||
if (typeof filters !== 'undefined') {
|
||||
if (filters !== undefined) {
|
||||
for (const filter of filters) {
|
||||
((query.filter as SCSearchBooleanFilter).arguments as SCBooleanFilterArguments).filters.push(filter);
|
||||
}
|
||||
|
||||
@@ -189,15 +189,18 @@ export class AddEventActionChipComponent implements OnDestroy {
|
||||
return;
|
||||
}
|
||||
switch (associatedDateSeries.map(it => it.uid).filter(it => !this.uuids.includes(it)).length) {
|
||||
case 0:
|
||||
case 0: {
|
||||
this.applyState(AddEventStates.ADDED_ALL);
|
||||
break;
|
||||
case associatedDateSeries.length:
|
||||
}
|
||||
case associatedDateSeries.length: {
|
||||
this.applyState(AddEventStates.REMOVED_ALL);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
default: {
|
||||
this.applyState(AddEventStates.ADDED_SOME);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -34,11 +34,7 @@ export class DataFacetsProvider {
|
||||
// eslint-disable-next-line class-methods-use-this
|
||||
addBuckets(bucketsMap: {[key: string]: number}, fields: string[]): {[key: string]: number} {
|
||||
for (const field of fields) {
|
||||
if (typeof bucketsMap[field] !== 'undefined') {
|
||||
bucketsMap[field] = bucketsMap[field] + 1;
|
||||
} else {
|
||||
bucketsMap[field] = 1;
|
||||
}
|
||||
bucketsMap[field] = bucketsMap[field] === undefined ? 1 : bucketsMap[field] + 1;
|
||||
}
|
||||
|
||||
return bucketsMap;
|
||||
@@ -82,13 +78,13 @@ export class DataFacetsProvider {
|
||||
for (const item of items) {
|
||||
for (const aggregation of aggregations) {
|
||||
let fieldValues = item[aggregation.fieldName as keyof SCThing] as string | string[] | undefined;
|
||||
if (typeof fieldValues === 'undefined') {
|
||||
if (fieldValues === undefined) {
|
||||
continue;
|
||||
}
|
||||
if (typeof fieldValues === 'string') {
|
||||
fieldValues = [fieldValues];
|
||||
}
|
||||
if (typeof aggregation.onlyOnTypes === 'undefined') {
|
||||
if (aggregation.onlyOnTypes === undefined) {
|
||||
combinedFacetsMap[aggregation.fieldName] = this.addBuckets(
|
||||
combinedFacetsMap[aggregation.fieldName] || {},
|
||||
fieldValues,
|
||||
|
||||
@@ -133,7 +133,7 @@ export class DataProvider {
|
||||
|
||||
for (const item of items) {
|
||||
const value =
|
||||
typeof bucketMap.get(item.type) === 'undefined' ? 1 : (bucketMap.get(item.type) as number) + 1;
|
||||
bucketMap.get(item.type) === undefined ? 1 : (bucketMap.get(item.type) as number) + 1;
|
||||
bucketMap.set(item.type, value);
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ export class DataProvider {
|
||||
created: new Date().toISOString(),
|
||||
type: SCThingOriginType.User,
|
||||
},
|
||||
type: typeof type === 'undefined' ? item.type : type,
|
||||
type: type === undefined ? item.type : type,
|
||||
uid: item.uid,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ export class DataDetailComponent implements ViewWillEnter {
|
||||
* Type guard for SCSavableThing
|
||||
*/
|
||||
static isSCSavableThing(thing: SCThings | SCSaveableThing): thing is SCSaveableThing {
|
||||
return typeof (thing as SCSaveableThing).data !== 'undefined';
|
||||
return (thing as SCSaveableThing).data !== undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,12 +126,13 @@ export class DataDetailComponent implements ViewWillEnter {
|
||||
)
|
||||
: this.dataProvider.get(uid, DataScope.Remote)));
|
||||
|
||||
this.item = !item
|
||||
this.item = item
|
||||
? // eslint-disable-next-line unicorn/no-null
|
||||
null
|
||||
: DataDetailComponent.isSCSavableThing(item)
|
||||
DataDetailComponent.isSCSavableThing(item)
|
||||
? item.data
|
||||
: item;
|
||||
: item
|
||||
// eslint-disable-next-line unicorn/no-null
|
||||
: null;
|
||||
} catch {
|
||||
// eslint-disable-next-line unicorn/no-null
|
||||
this.item = null;
|
||||
@@ -150,7 +151,7 @@ export class DataDetailComponent implements ViewWillEnter {
|
||||
.get(uid)
|
||||
.pipe(take(1))
|
||||
.subscribe(item => {
|
||||
if (typeof item !== 'undefined') {
|
||||
if (item !== undefined) {
|
||||
this.item = item.data;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -41,7 +41,7 @@ export class FavoriteButtonComponent {
|
||||
this._item = item;
|
||||
this.isFavorite$ = this.favoritesService.get(this.item.uid).pipe(
|
||||
map(favorite => {
|
||||
return typeof favorite !== 'undefined';
|
||||
return favorite !== undefined;
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ export class TitleCardComponent implements OnInit, OnChanges {
|
||||
|
||||
@HostListener('window:resize', ['$event'])
|
||||
checkTextElipsis() {
|
||||
if (typeof this.accordionTextArea === 'undefined') {
|
||||
if (this.accordionTextArea === undefined) {
|
||||
return;
|
||||
}
|
||||
const element = this.accordionTextArea.nativeElement as HTMLElement;
|
||||
|
||||
@@ -106,7 +106,7 @@ export class DataListComponent implements OnChanges, OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (Array.isArray(this.items) && typeof changes.items !== 'undefined') {
|
||||
if (Array.isArray(this.items) && changes.items !== undefined) {
|
||||
this.itemStream.next(this.items);
|
||||
this.infiniteScroll.complete();
|
||||
}
|
||||
@@ -120,7 +120,7 @@ export class DataListComponent implements OnChanges, OnInit, OnDestroy {
|
||||
|
||||
ngOnInit(): void {
|
||||
this.calcSkeletonItems();
|
||||
if (typeof this.resetToTop !== 'undefined') {
|
||||
if (this.resetToTop !== undefined) {
|
||||
this.subscriptions.push(
|
||||
this.resetToTop.subscribe(() => {
|
||||
// this.viewPort.scrollToIndex(0);
|
||||
|
||||
@@ -90,10 +90,10 @@ export class ScThingListItemVirtualScrollStrategy implements VirtualScrollStrate
|
||||
for (const node of renderedItems) {
|
||||
const [item, group] = this.getItemByNode(node, renderedItems);
|
||||
|
||||
if (!this.heights.has(item)) {
|
||||
this.intersectionObserver.observe(node);
|
||||
} else {
|
||||
if (this.heights.has(item)) {
|
||||
node.style.height = `${this.getHeight(item, group)}px`;
|
||||
} else {
|
||||
this.intersectionObserver.observe(node);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -202,7 +202,7 @@ export class SearchPageComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
for (const filter of [this.forcedFilter, this.filterQuery]) {
|
||||
if (typeof filter !== 'undefined') {
|
||||
if (filter !== undefined) {
|
||||
filters.push(filter);
|
||||
}
|
||||
}
|
||||
@@ -324,7 +324,7 @@ export class SearchPageComponent implements OnInit, OnDestroy {
|
||||
this.filterQuery = query[1];
|
||||
this.sortQuery = query[2];
|
||||
this.from = 0;
|
||||
if (typeof this.filterQuery !== 'undefined' || this.queryText?.length > 0 || this.showDefaultData) {
|
||||
if (this.filterQuery !== undefined || this.queryText?.length > 0 || this.showDefaultData) {
|
||||
await this.fetchAndUpdateItems();
|
||||
this.queryChanged.next();
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ export class PlaceDetailContentComponent implements OnInit, OnDestroy {
|
||||
* @param item TODO
|
||||
*/
|
||||
hasCategories(item: SCThings): item is SCThings & {categories: string[]} {
|
||||
return typeof (item as {categories: string[]}).categories !== 'undefined';
|
||||
return (item as {categories: string[]}).categories !== undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -92,7 +92,7 @@ export class FavoritesPageComponent extends SearchPageComponent implements OnIni
|
||||
this.filterQuery = query[1];
|
||||
this.sortQuery = query[2];
|
||||
this.from = 0;
|
||||
if (typeof this.filterQuery !== 'undefined' || this.queryText?.length > 0 || this.showDefaultData) {
|
||||
if (this.filterQuery !== undefined || this.queryText?.length > 0 || this.showDefaultData) {
|
||||
await this.fetchAndUpdateItems();
|
||||
this.queryChanged.next();
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ export class FavoritesService {
|
||||
return this.favoritesChanged$.pipe(
|
||||
map(favoritesMap => {
|
||||
let items = [...favoritesMap.values()].map(favorite => favorite.data);
|
||||
if (typeof queryText !== 'undefined') {
|
||||
if (queryText !== undefined) {
|
||||
const textFilteredItems: SCIndexableThings[] = [];
|
||||
for (const item of items) {
|
||||
if (
|
||||
@@ -199,7 +199,7 @@ export class FavoritesService {
|
||||
items = textFilteredItems;
|
||||
}
|
||||
|
||||
if (typeof filterQuery !== 'undefined') {
|
||||
if (filterQuery !== undefined) {
|
||||
const filterType = FavoritesService.getFilterType(
|
||||
filterQuery as SCSearchBooleanFilter | SCSearchValueFilter,
|
||||
);
|
||||
@@ -212,7 +212,7 @@ export class FavoritesService {
|
||||
items = filteredItems;
|
||||
}
|
||||
|
||||
if (typeof sortQuery !== 'undefined') {
|
||||
if (sortQuery !== undefined) {
|
||||
items = this.sortItems(items, sortQuery[0].arguments.field as 'name' | 'type', sortQuery[0].order);
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ export class DaiaAvailabilityComponent extends DataDetailComponent implements On
|
||||
*/
|
||||
async getAvailability(uid: SCUuid) {
|
||||
this.daiaDataProvider.getAvailability(uid).then(holdings => {
|
||||
if (typeof holdings !== 'undefined') {
|
||||
if (holdings !== undefined) {
|
||||
this.holdings = holdings;
|
||||
this.holdingsByDepartments = groupByStable(holdings, holding => holding.department.id);
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ export class DaiaDataProvider {
|
||||
}
|
||||
|
||||
async getAvailability(id: string): Promise<DaiaHolding[] | undefined> {
|
||||
if (typeof this.daiaServiceUrl === 'undefined') {
|
||||
if (this.daiaServiceUrl === undefined) {
|
||||
try {
|
||||
const features = this.configProvider.getValue('features') as SCFeatureConfiguration;
|
||||
if (features.extern?.daia?.url) {
|
||||
@@ -134,7 +134,7 @@ export class DaiaDataProvider {
|
||||
dueDate: dueDate,
|
||||
online:
|
||||
Array.isArray(available) &&
|
||||
typeof available.find(item => item.service === 'remote') !== 'undefined',
|
||||
available.find(item => item.service === 'remote') !== undefined,
|
||||
available:
|
||||
(Array.isArray(available) &&
|
||||
available.find(item =>
|
||||
@@ -171,7 +171,7 @@ export class DaiaDataProvider {
|
||||
}
|
||||
|
||||
getHoldingLink(holding: DaiaHolding, open = false) {
|
||||
if (typeof this.hebisProxyUrl === 'undefined') {
|
||||
if (this.hebisProxyUrl === undefined) {
|
||||
this.logger.error('HeBIS proxy url undefined');
|
||||
|
||||
return;
|
||||
@@ -194,7 +194,7 @@ export class DaiaDataProvider {
|
||||
unavailable: unavailable.findIndex(item => item.service === 'presentation'),
|
||||
};
|
||||
|
||||
if (loan.unavailable !== -1 && typeof unavailable[loan.unavailable].expected !== 'undefined') {
|
||||
if (loan.unavailable !== -1 && unavailable[loan.unavailable].expected !== undefined) {
|
||||
return 'checked_out';
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ export class HebisDataProvider extends DataProvider {
|
||||
|
||||
let page: number | undefined = searchRequest.page;
|
||||
|
||||
if (typeof page === 'undefined') {
|
||||
if (page === undefined) {
|
||||
const preFlightResponse = await this.client.invokeRoute<HebisSearchResponse>(
|
||||
this.hebisSearchRoute,
|
||||
undefined,
|
||||
|
||||
@@ -122,7 +122,7 @@ export class LibraryAccountService {
|
||||
}
|
||||
|
||||
async getDocumentFromHDS(edition: string) {
|
||||
if (typeof edition === 'undefined') {
|
||||
if (edition === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -166,11 +166,13 @@ export class LibraryAccountService {
|
||||
return new Promise(async resolve => {
|
||||
const handleDocument = () => {
|
||||
switch (documentAction.action) {
|
||||
case 'cancel':
|
||||
case 'cancel': {
|
||||
return this.cancelReservation(documentAction.doc);
|
||||
break;
|
||||
case 'renew':
|
||||
}
|
||||
case 'renew': {
|
||||
return this.renewLending(documentAction.doc);
|
||||
}
|
||||
}
|
||||
};
|
||||
const alert = await this.alertController.create({
|
||||
|
||||
@@ -75,8 +75,13 @@ export class MapProvider {
|
||||
icon: divIcon({
|
||||
className: className,
|
||||
html:
|
||||
typeof position.heading !== 'undefined'
|
||||
position.heading === undefined
|
||||
? `<span
|
||||
name="${SCIcon`person_pin_circle`}"
|
||||
class="material-symbols-rounded map-location-pin"
|
||||
style="font-size: ${iconSize}px; color: var(--ion-color-primary);"
|
||||
>${SCIcon`person_pin_circle`}</span>`
|
||||
: `<span
|
||||
class="material-symbols-rounded map-location-pin"
|
||||
style="
|
||||
transform-origin: center;
|
||||
@@ -84,12 +89,7 @@ export class MapProvider {
|
||||
font-size: ${iconSize}px;
|
||||
color: var(--ion-color-primary);
|
||||
"
|
||||
>${SCIcon`navigation`}</span>`
|
||||
: `<span
|
||||
name="${SCIcon`person_pin_circle`}"
|
||||
class="material-symbols-rounded map-location-pin"
|
||||
style="font-size: ${iconSize}px; color: var(--ion-color-primary);"
|
||||
>${SCIcon`person_pin_circle`}</span>`,
|
||||
>${SCIcon`navigation`}</span>`,
|
||||
iconSize: [iconSize, iconSize],
|
||||
}),
|
||||
zIndexOffset: 1000,
|
||||
@@ -202,7 +202,7 @@ export class MapProvider {
|
||||
|
||||
let filter = baseFilter;
|
||||
|
||||
if (typeof contextFilter !== 'undefined') {
|
||||
if (contextFilter !== undefined) {
|
||||
filter = {
|
||||
arguments: {
|
||||
operation: 'and',
|
||||
|
||||
@@ -154,7 +154,7 @@ export class MapPageComponent {
|
||||
* @param latLng Coordinates to animate to
|
||||
*/
|
||||
private focus(latLng?: LatLng) {
|
||||
if (typeof latLng !== 'undefined') {
|
||||
if (latLng !== undefined) {
|
||||
this.map.flyTo(latLng, this.MAX_ZOOM);
|
||||
|
||||
return;
|
||||
@@ -173,7 +173,7 @@ export class MapPageComponent {
|
||||
this.removeAll();
|
||||
}
|
||||
const addSCPlace = (place: SCPlace): Layer | Marker => {
|
||||
if (typeof place.geo.polygon !== 'undefined') {
|
||||
if (place.geo.polygon !== undefined) {
|
||||
const polygonLayer = geoJSON(place.geo.polygon, {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
@@ -190,7 +190,7 @@ export class MapPageComponent {
|
||||
|
||||
items.map(thing => {
|
||||
// IMPORTANT: change this to support inPlace.geo when there is a need to show floors (the building of the floor)
|
||||
if (typeof thing.geo !== 'undefined') {
|
||||
if (thing.geo !== undefined) {
|
||||
this.layers.push(addSCPlace(thing as SCPlace));
|
||||
}
|
||||
});
|
||||
@@ -233,7 +233,7 @@ export class MapPageComponent {
|
||||
this.items = result.data as SCPlace[];
|
||||
this.addToMap(result.data as Array<SCBuilding | SCRoom>, true, animate);
|
||||
// update filter options if result contains facets
|
||||
if (typeof result.facets !== 'undefined') {
|
||||
if (result.facets !== undefined) {
|
||||
this.contextMenuService.updateContextFilter(result.facets);
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -313,9 +313,9 @@ export class MapPageComponent {
|
||||
);
|
||||
|
||||
const uid = this.route.snapshot.paramMap.get('uid');
|
||||
const response = await (uid !== null
|
||||
? this.mapProvider.searchPlace(uid)
|
||||
: this.mapProvider.searchPlaces());
|
||||
const response = await (uid === null
|
||||
? this.mapProvider.searchPlaces()
|
||||
: this.mapProvider.searchPlace(uid));
|
||||
|
||||
if (response.data.length === 0) {
|
||||
return;
|
||||
@@ -345,9 +345,9 @@ export class MapPageComponent {
|
||||
return;
|
||||
}
|
||||
|
||||
this.locationStatus = await (!Capacitor.isNativePlatform()
|
||||
? Geolocation.checkPermissions()
|
||||
: Geolocation.requestPermissions());
|
||||
this.locationStatus = await (Capacitor.isNativePlatform()
|
||||
? Geolocation.requestPermissions()
|
||||
: Geolocation.checkPermissions());
|
||||
|
||||
this.translateService
|
||||
.get(['map.page.geolocation', 'app.errors.UNKNOWN'])
|
||||
@@ -362,9 +362,9 @@ export class MapPageComponent {
|
||||
message: `${
|
||||
this.locationStatus?.location === 'denied'
|
||||
? location.NOT_ALLOWED
|
||||
: this.locationStatus?.location !== 'granted'
|
||||
? location.NOT_ENABLED
|
||||
: unknownError
|
||||
: this.locationStatus?.location === 'granted'
|
||||
? unknownError
|
||||
: location.NOT_ENABLED
|
||||
}`,
|
||||
buttons: ['OK'],
|
||||
})
|
||||
|
||||
@@ -54,7 +54,7 @@ export class MapListModalComponent implements OnInit {
|
||||
*/
|
||||
ngOnInit() {
|
||||
let geofencedFilter: SCSearchBooleanFilter | undefined;
|
||||
if (typeof this.mapBounds !== 'undefined') {
|
||||
if (this.mapBounds !== undefined) {
|
||||
geofencedFilter = {
|
||||
arguments: {
|
||||
operation: 'and',
|
||||
@@ -77,7 +77,7 @@ export class MapListModalComponent implements OnInit {
|
||||
},
|
||||
type: 'boolean',
|
||||
};
|
||||
if (typeof this.filterQuery !== 'undefined') {
|
||||
if (this.filterQuery !== undefined) {
|
||||
geofencedFilter.arguments.filters.push(this.filterQuery);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ export class PositionService {
|
||||
* @param point Point to which distance should be calculated
|
||||
*/
|
||||
getDistance(point: Point): number | undefined {
|
||||
if (typeof this.position === 'undefined') {
|
||||
if (this.position === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ export class ContextMenuService {
|
||||
buildFilterQuery = (filterContext: FilterContext): SCSearchFilter | undefined => {
|
||||
const filters: SCSearchFilter[] = [];
|
||||
|
||||
if (typeof this.forcedType !== 'undefined') {
|
||||
if (this.forcedType !== undefined) {
|
||||
filters.push({
|
||||
arguments: {
|
||||
field: 'type',
|
||||
|
||||
@@ -58,9 +58,7 @@ export class NewsSettingsFilterComponent implements OnInit {
|
||||
* @param setting The value of the filter
|
||||
*/
|
||||
stateChanged(setting: SCSetting) {
|
||||
if (typeof this.filtersMap.get(setting.name as NewsFilterSettingsNames) !== 'undefined') {
|
||||
this.filtersMap.delete(setting.name as NewsFilterSettingsNames);
|
||||
} else {
|
||||
if (this.filtersMap.get(setting.name as NewsFilterSettingsNames) === undefined) {
|
||||
this.filtersMap.set(
|
||||
setting.name as NewsFilterSettingsNames,
|
||||
DataProvider.createValueFilter(
|
||||
@@ -68,6 +66,8 @@ export class NewsSettingsFilterComponent implements OnInit {
|
||||
setting.value as string,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
this.filtersMap.delete(setting.name as NewsFilterSettingsNames);
|
||||
}
|
||||
|
||||
this.filtersChanged.emit([...this.filtersMap.values()]);
|
||||
|
||||
@@ -100,7 +100,7 @@ export class NewsProvider {
|
||||
from: from,
|
||||
};
|
||||
|
||||
if (typeof filters !== 'undefined') {
|
||||
if (filters !== undefined) {
|
||||
for (const filter of filters) {
|
||||
((query.filter as SCSearchBooleanFilter).arguments as SCBooleanFilterArguments).filters.push(filter);
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ export class ProfilePageComponent implements OnInit {
|
||||
};
|
||||
|
||||
user$ = this.authHelper.getProvider('default').user$.pipe(
|
||||
filter(user => typeof user !== 'undefined'),
|
||||
filter(user => user !== undefined),
|
||||
map(userInfo => {
|
||||
return this.authHelper.getUserFromUserInfo(userInfo as object);
|
||||
}),
|
||||
|
||||
@@ -101,14 +101,17 @@ export class ScheduleCardComponent implements OnInit {
|
||||
? this.scheduleEvent.dateSeries.event?.categories[0]
|
||||
: ''
|
||||
) {
|
||||
case 'lecture':
|
||||
case 'lecture': {
|
||||
this.cardColor.isLecture = true;
|
||||
break;
|
||||
case 'exercise':
|
||||
}
|
||||
case 'exercise': {
|
||||
this.cardColor.isExercise = true;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
default: {
|
||||
this.cardColor.isDefault = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -80,14 +80,15 @@ export class SettingsItemComponent {
|
||||
*/
|
||||
async settingChanged(): Promise<void> {
|
||||
if (
|
||||
typeof this.setting.value !== 'undefined' &&
|
||||
this.setting.value !== undefined &&
|
||||
SettingsProvider.validateValue(this.setting, this.setting.value)
|
||||
) {
|
||||
// handle general settings, with special actions
|
||||
switch (this.setting.name) {
|
||||
case 'language':
|
||||
case 'language': {
|
||||
this.translateService.use(this.setting.value as SCLanguageCode);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
}
|
||||
await this.settingsProvider.setSettingValue(
|
||||
|
||||
@@ -123,7 +123,7 @@ export class SettingsProvider {
|
||||
possibleValues: SCSettingValues | undefined,
|
||||
enteredValues: SCSettingValues,
|
||||
): boolean {
|
||||
if (typeof possibleValues === 'undefined') {
|
||||
if (possibleValues === undefined) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ export class SettingsProvider {
|
||||
possibleValues: SCSettingValues | undefined,
|
||||
enteredValue: SCSettingValue,
|
||||
): boolean {
|
||||
if (typeof possibleValues === 'undefined') {
|
||||
if (possibleValues === undefined) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -164,27 +164,31 @@ export class SettingsProvider {
|
||||
public static validateValue(setting: SCSetting, value: SCSettingValue | SCSettingValues): boolean {
|
||||
let isValueValid = false;
|
||||
switch (setting.inputType) {
|
||||
case 'number':
|
||||
case 'number': {
|
||||
if (typeof value === 'number') {
|
||||
isValueValid = true;
|
||||
}
|
||||
break;
|
||||
case 'multiple choice':
|
||||
isValueValid = !Array.isArray(value)
|
||||
? false
|
||||
: SettingsProvider.checkMultipleChoiceValue(setting.values, value);
|
||||
}
|
||||
case 'multiple choice': {
|
||||
isValueValid = Array.isArray(value)
|
||||
? SettingsProvider.checkMultipleChoiceValue(setting.values, value)
|
||||
: false;
|
||||
break;
|
||||
}
|
||||
case 'password':
|
||||
case 'text':
|
||||
case 'text': {
|
||||
if (typeof value === 'string') {
|
||||
isValueValid = true;
|
||||
}
|
||||
break;
|
||||
case 'single choice':
|
||||
}
|
||||
case 'single choice': {
|
||||
isValueValid = Array.isArray(value)
|
||||
? false
|
||||
: SettingsProvider.checkSingleChoiceValue(setting.values, value);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
}
|
||||
|
||||
@@ -227,7 +231,7 @@ export class SettingsProvider {
|
||||
for (const categoryKey of Object.keys(this.settingsCache)) {
|
||||
// iterate through keys of settingValueContainer
|
||||
for (const settingKey of Object.keys(this.settingsCache[categoryKey].settings)) {
|
||||
if (typeof settingValuesContainer[categoryKey] === 'undefined') {
|
||||
if (settingValuesContainer[categoryKey] === undefined) {
|
||||
settingValuesContainer[categoryKey] = {};
|
||||
}
|
||||
settingValuesContainer[categoryKey][settingKey] =
|
||||
@@ -342,16 +346,8 @@ export class SettingsProvider {
|
||||
// iterate through setting keys of category
|
||||
for (const settingKey of Object.keys(this.settingsCache[categoryKey].settings)) {
|
||||
// if saved setting value exists set it, otherwise set to default value
|
||||
if (
|
||||
typeof valuesContainer[categoryKey] !== 'undefined' &&
|
||||
typeof valuesContainer[categoryKey][settingKey] !== 'undefined'
|
||||
) {
|
||||
this.settingsCache[categoryKey].settings[settingKey].value =
|
||||
valuesContainer[categoryKey][settingKey];
|
||||
} else {
|
||||
this.settingsCache[categoryKey].settings[settingKey].value =
|
||||
this.settingsCache[categoryKey].settings[settingKey].defaultValue;
|
||||
}
|
||||
this.settingsCache[categoryKey].settings[settingKey].value = valuesContainer[categoryKey] !== undefined &&
|
||||
valuesContainer[categoryKey][settingKey] !== undefined ? valuesContainer[categoryKey][settingKey] : this.settingsCache[categoryKey].settings[settingKey].defaultValue;
|
||||
}
|
||||
}
|
||||
await this.saveSettingValues();
|
||||
|
||||
@@ -56,5 +56,5 @@ export class ThingTranslateDefaultParser extends ThingTranslateParser {
|
||||
* TODO
|
||||
*/
|
||||
export function isDefined<T>(value?: T | null): value is T {
|
||||
return typeof value !== 'undefined' && value !== null;
|
||||
return value !== undefined && value !== null;
|
||||
}
|
||||
|
||||
@@ -82,7 +82,9 @@ export abstract class IconReplacer implements OnInit, OnDestroy {
|
||||
ngOnInit() {
|
||||
this.init();
|
||||
|
||||
if (!this.host) {
|
||||
if (this.host) {
|
||||
this.attachObserver();
|
||||
} else {
|
||||
let tries = 0;
|
||||
console.warn('IconReplacer: host not found, trying again');
|
||||
const interval = setInterval(() => {
|
||||
@@ -96,8 +98,6 @@ export abstract class IconReplacer implements OnInit, OnDestroy {
|
||||
}
|
||||
tries++;
|
||||
}, this.retryAfterMs);
|
||||
} else {
|
||||
this.attachObserver();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user