From ad0dae46ff04d28551d2ece950d9a4d3442541d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wieland=20Sch=C3=B6bl?= Date: Fri, 21 May 2021 15:35:26 +0200 Subject: [PATCH] fix: fix various typos --- .gitlab/ci/testCIScripts.sh | 2 +- PITFALLS.md | 2 +- README.md | 2 +- src/app/modules/data/data-facets.provider.ts | 4 +-- src/app/modules/data/data.provider.ts | 8 ++--- .../data/detail/data-detail.component.spec.ts | 2 +- .../data/elements/simple-card.component.ts | 4 +-- .../data/stapps-web-http-client.provider.ts | 7 +++-- .../mensa/place-mensa-detail.component.ts | 4 +-- .../menu/context/context-menu.component.ts | 30 +++++++++---------- .../menu/navigation/navigation.component.ts | 2 +- src/app/modules/news/news.module.ts | 2 +- src/app/modules/settings/settings.provider.ts | 4 +-- src/app/modules/storage/storage.provider.ts | 3 +- src/app/translation/common-string-pipes.ts | 6 ++-- src/app/translation/thing-translate.parser.ts | 16 +++++----- 16 files changed, 49 insertions(+), 49 deletions(-) diff --git a/.gitlab/ci/testCIScripts.sh b/.gitlab/ci/testCIScripts.sh index 6cd7218a..e60382fa 100755 --- a/.gitlab/ci/testCIScripts.sh +++ b/.gitlab/ci/testCIScripts.sh @@ -8,7 +8,7 @@ TAG_VERSION=$(sh $SCRIPT_DIR/getRegistryTag.sh "v1.0.0") TAG_TEST=$(sh $SCRIPT_DIR/getRegistryTag.sh "TEST") BRANCH_NAME=$(sh $SCRIPT_DIR/getRegistryBranch.sh "very:first:test") -# Leaving out pushAsLatestVersion.sh as its controll flow +# Leaving out pushAsLatestVersion.sh as its control flow # is based on the same condition as getRegistryTag.sh if [ $TAG_VERSION != "1.0.0" ]; then diff --git a/PITFALLS.md b/PITFALLS.md index b4f6ed40..6dbb6376 100644 --- a/PITFALLS.md +++ b/PITFALLS.md @@ -21,7 +21,7 @@ in line `var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_ ### Run platform iOS #### Problem -Currently the iOS project build with cordova uses the old build system. +Currently, the iOS project build with cordova uses the old build system. The command `ionic cordova run ios` runs into the error `/platforms/ios/build/emulator/StApps.app/Info.plist file not found.` diff --git a/README.md b/README.md index 316c1024..2de3d761 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ This is a hybrid mobile app which is built using [Ionic](https://github.com/ioni ### Why not refactoring legacy app? -The StApps 1.x.x (legacy app, but current app in stores) is written using Ionic 1 framework (AngularJS). For StApps 2.x.x project (this repository) we want to use latest version of Ionic (Ionic 2+ which uses Angular 2+; at the time of writing of the documentation current versions are: Ionic 4, Angular 6), which introduces significant changes. That said, simple refactoring of the app 1.x.x was not viable solution and this project was created with goal of coding of the existing and new features, defined by in new requirements (details available in internal documents). +The StApps 1.x.x (legacy app, but current app in stores) is written using Ionic 1 framework (AngularJS). For StApps 2.x.x project (this repository) we want to use the latest version of Ionic (Ionic 2+ which uses Angular 2+; at the time of writing of the documentation current versions are: Ionic 4, Angular 6), which introduces significant changes. That said, simple refactoring of the app 1.x.x was not viable solution and this project was created with goal of coding of the existing and new features, defined by in new requirements (details available in internal documents). ## How to quickly start running the app? diff --git a/src/app/modules/data/data-facets.provider.ts b/src/app/modules/data/data-facets.provider.ts index 2adc0feb..cd31ffb5 100644 --- a/src/app/modules/data/data-facets.provider.ts +++ b/src/app/modules/data/data-facets.provider.ts @@ -80,9 +80,9 @@ export class DataFacetsProvider { } const combinedFacets: SCFacet[] = facets; const combinedFacetsMap: {[key: string]: {[key: string]: number; }; } = this.facetsToMap(combinedFacets); - (items as any[]).forEach((item) => { + items.forEach((item) => { aggregations.forEach((aggregation) => { - let fieldValues: string | string[] = item[aggregation.fieldName]; + let fieldValues = item[aggregation.fieldName as keyof SCThing] as string | string[] | undefined; if (typeof fieldValues === 'undefined') { return; } diff --git a/src/app/modules/data/data.provider.ts b/src/app/modules/data/data.provider.ts index e03ba6f0..d5e735c0 100644 --- a/src/app/modules/data/data.provider.ts +++ b/src/app/modules/data/data.provider.ts @@ -86,7 +86,7 @@ export class DataProvider { } /** - * Provides a saveable thing from the local database using the provided UID + * Provides a savable thing from the local database using the provided UID */ async get(uid: string, scope: DataScope.Local): Promise>; /** @@ -148,10 +148,10 @@ export class DataProvider { * Save a data item * * @param item Data item that needs to be saved - * @param [type] Saveable type (e.g. 'favorite'); if nothing is provided then type of the thing is used + * @param [type] Savable type (e.g. 'favorite'); if nothing is provided then type of the thing is used */ async put(item: SCThings, type?: SCThingType): Promise> { - const saveableItem: SCSaveableThing = { + const savableItem: SCSaveableThing = { data: item, name: item.name, origin: { @@ -163,7 +163,7 @@ export class DataProvider { }; // @TODO: Implementation for saving item into the backend (user's account) - return ( this.storageProvider.put>(this.getDataKey(item.uid), saveableItem)); + return ( this.storageProvider.put>(this.getDataKey(item.uid), savableItem)); } /** diff --git a/src/app/modules/data/detail/data-detail.component.spec.ts b/src/app/modules/data/detail/data-detail.component.spec.ts index f0688501..182b062f 100644 --- a/src/app/modules/data/detail/data-detail.component.spec.ts +++ b/src/app/modules/data/detail/data-detail.component.spec.ts @@ -87,7 +87,7 @@ describe('DataDetailComponent', () => { expect(comp).toBeDefined(), ); - it('should have apropriate title', async () => { + it('should have appropriate title', async () => { const title: DebugElement | null = detailPage.query(By.directive(IonTitle)); expect(title).not.toBe(null); expect(title!.nativeElement.textContent).toBe('Foo'); diff --git a/src/app/modules/data/elements/simple-card.component.ts b/src/app/modules/data/elements/simple-card.component.ts index 3e97927a..7cbd3056 100644 --- a/src/app/modules/data/elements/simple-card.component.ts +++ b/src/app/modules/data/elements/simple-card.component.ts @@ -43,14 +43,14 @@ export class SimpleCardComponent { * TODO */ // tslint:disable-next-line:prefer-function-over-method - isString(data: any): data is string { + isString(data: unknown): data is string { return typeof data === 'string'; } /** * TODO */ // tslint:disable-next-line:prefer-function-over-method - isThing(something: any): something is SCThing { + isThing(something: unknown): something is SCThing { return isThing(something); } } diff --git a/src/app/modules/data/stapps-web-http-client.provider.ts b/src/app/modules/data/stapps-web-http-client.provider.ts index 3b9a58a0..932f52b2 100644 --- a/src/app/modules/data/stapps-web-http-client.provider.ts +++ b/src/app/modules/data/stapps-web-http-client.provider.ts @@ -17,12 +17,12 @@ import {Injectable} from '@angular/core'; import {HttpClientInterface, HttpClientRequest} from '@openstapps/api/lib/http-client-interface'; /** - * HttpClient that is based on angular's HttpClient (@TODO: move it to provider or independent package) + * HttpClient that is based on the Angular HttpClient (@TODO: move it to provider or independent package) */ @Injectable() export class StAppsWebHttpClient implements HttpClientInterface { /** - * + * * @param http TODO */ constructor(private readonly http: HttpClient) { @@ -39,7 +39,7 @@ export class StAppsWebHttpClient implements HttpClientInterface { /** * TODO */ - [key: string]: any; + [key: string]: unknown; /** * TODO */ @@ -63,6 +63,7 @@ export class StAppsWebHttpClient implements HttpClientInterface { requestConfig.method || 'GET', requestConfig.url.toString(), options) .toPromise(); + // tslint:disable-next-line:prefer-object-spread return Object.assign(response, {statusCode: response.status, body: response.body || {}}); } catch (err) { throw Error(err); diff --git a/src/app/modules/data/types/place/special/mensa/place-mensa-detail.component.ts b/src/app/modules/data/types/place/special/mensa/place-mensa-detail.component.ts index 48ea83b7..c32fb140 100644 --- a/src/app/modules/data/types/place/special/mensa/place-mensa-detail.component.ts +++ b/src/app/modules/data/types/place/special/mensa/place-mensa-detail.component.ts @@ -55,7 +55,7 @@ export class PlaceMensaDetailComponent implements AfterViewInit { startingDay: Moment; - constructor(private mensaService: PlaceMensaService, private changeDectectorRef: ChangeDetectorRef) { + constructor(private mensaService: PlaceMensaService, private changeDetectorRef: ChangeDetectorRef) { // TODO: translation this.startingDay = moment(); this.startingDay.hour(0); @@ -76,7 +76,7 @@ export class PlaceMensaDetailComponent implements AfterViewInit { break; } } - this.changeDectectorRef.detectChanges(); + this.changeDetectorRef.detectChanges(); return out; }); diff --git a/src/app/modules/menu/context/context-menu.component.ts b/src/app/modules/menu/context/context-menu.component.ts index 972fe037..4e75a877 100644 --- a/src/app/modules/menu/context/context-menu.component.ts +++ b/src/app/modules/menu/context/context-menu.component.ts @@ -20,9 +20,9 @@ import { SCThingType, SCTranslations, } from '@openstapps/core'; +import {Subscription} from 'rxjs'; import {ContextMenuService} from './context-menu.service'; import {FilterContext, SortContext, SortContextOption} from './context-type'; -import {Subscription} from 'rxjs'; /** * The context menu @@ -64,16 +64,16 @@ export class ContextMenuComponent { */ sortOption: SortContext; - /** - * Core translator - */ - translator: SCThingTranslator; - /** * Array of all Subscriptions */ subscriptions: Subscription[] = []; + /** + * Core translator + */ + translator: SCThingTranslator; + constructor(private translateService: TranslateService, private readonly contextMenuService: ContextMenuService) { @@ -94,15 +94,6 @@ export class ContextMenuComponent { })); } - /** - * Unsubscribe from Observables - */ - ngOnDestroy() { - for (let sub of this.subscriptions) { - sub.unsubscribe(); - } - } - /** * Sets selected filter options and updates listener */ @@ -126,6 +117,15 @@ export class ContextMenuComponent { return this.translator.translatedPropertyValue(onlyForType, field, key); } + /** + * Unsubscribe from Observables + */ + ngOnDestroy() { + for (const sub of this.subscriptions) { + sub.unsubscribe(); + } + } + /** * Resets filter options */ diff --git a/src/app/modules/menu/navigation/navigation.component.ts b/src/app/modules/menu/navigation/navigation.component.ts index bbf6386f..0a84fc82 100644 --- a/src/app/modules/menu/navigation/navigation.component.ts +++ b/src/app/modules/menu/navigation/navigation.component.ts @@ -58,7 +58,7 @@ export class NavigationComponent { } /** - * Loads menu entris from configProvider + * Loads menu entries from configProvider */ async loadMenuEntries() { try { diff --git a/src/app/modules/news/news.module.ts b/src/app/modules/news/news.module.ts index a24db78e..62066ee3 100644 --- a/src/app/modules/news/news.module.ts +++ b/src/app/modules/news/news.module.ts @@ -20,9 +20,9 @@ import {TranslateModule} from '@ngx-translate/core'; import {MomentModule} from 'ngx-moment'; import {DataModule} from '../data/data.module'; import {SettingsProvider} from '../settings/settings.provider'; +import {NewsItemComponent} from './page/news-item.component'; import {NewsPageComponent} from './page/news-page.component'; import {SkeletonNewsItem} from './page/skeleton-news-item.component'; -import {NewsItemComponent} from './page/news-item.component'; const newsRoutes: Routes = [ {path: 'news', component: NewsPageComponent}, diff --git a/src/app/modules/settings/settings.provider.ts b/src/app/modules/settings/settings.provider.ts index cc4664a9..21960759 100644 --- a/src/app/modules/settings/settings.provider.ts +++ b/src/app/modules/settings/settings.provider.ts @@ -204,7 +204,7 @@ export class SettingsProvider { /** * Add an Setting to the Cache if not exist and set undefined value to defaultValue - * @param setting Setting with categories, defautlValue, name, input type and valid values + * @param setting Setting with categories, defaultValue, name, input type and valid values */ private addSetting(setting: SCSetting): void { if (!this.categoryExists(setting.categories[0])) { @@ -396,7 +396,7 @@ export class SettingsProvider { } /** - * Sets the order the given categories showup in the settings page + * Sets the order the given categories show up in the settings page * @param categoryNames the order of the categories */ public setCategoriesOrder(categoryNames: string[]) { diff --git a/src/app/modules/storage/storage.provider.ts b/src/app/modules/storage/storage.provider.ts index d252ba1e..37a2fb44 100644 --- a/src/app/modules/storage/storage.provider.ts +++ b/src/app/modules/storage/storage.provider.ts @@ -21,7 +21,6 @@ import {Storage} from '@ionic/storage'; @Injectable() export class StorageProvider { /** - * * @param storage TODO */ constructor(private readonly storage: Storage) { @@ -124,7 +123,7 @@ export class StorageProvider { /** * Puts a value of type T into the storage using provided key * - * @param key Unique indentifier + * @param key Unique identifier * @param value Resource to store under the key */ async put(key: string, value: T): Promise { diff --git a/src/app/translation/common-string-pipes.ts b/src/app/translation/common-string-pipes.ts index c64b57ba..6ba97fe8 100644 --- a/src/app/translation/common-string-pipes.ts +++ b/src/app/translation/common-string-pipes.ts @@ -77,13 +77,13 @@ export class StringSplitPipe implements PipeTransform { pure: false, // required to update the value when the promise is resolved }) export class NumberLocalizedPipe implements PipeTransform, OnDestroy { - decialPipe: DecimalPipe; + decimalPipe: DecimalPipe; locale: string; onLangChange: Subscription; value: unknown; constructor(private readonly translate: TranslateService) { - this.decialPipe = new DecimalPipe('de-DE'); + this.decimalPipe = new DecimalPipe('de-DE'); this.locale = translate.currentLang; } @@ -124,6 +124,6 @@ export class NumberLocalizedPipe implements PipeTransform, OnDestroy { updateValue(value: unknown, digitsInfo?: string | undefined): void { // this.value = this.locale; - this.value = this.decialPipe.transform(value, digitsInfo,this.locale); + this.value = this.decimalPipe.transform(value, digitsInfo,this.locale); } } diff --git a/src/app/translation/thing-translate.parser.ts b/src/app/translation/thing-translate.parser.ts index 3d7fb45e..84d224b0 100644 --- a/src/app/translation/thing-translate.parser.ts +++ b/src/app/translation/thing-translate.parser.ts @@ -19,30 +19,30 @@ import {Injectable} from '@angular/core'; export abstract class ThingTranslateParser { /** - * Gets a value from an object given a keypath - * paser.getValueFromKeyPath(anObject, 'property.subarray[42].etc'); + * Gets a value from an object given a keyPath + * parser.getValueFromKeyPath(anObject, 'property.subarray[42].etc'); */ - abstract getValueFromKeyPath(instance: object, keypath: string): unknown; + abstract getValueFromKeyPath(instance: object, keyPath: string): unknown; } @Injectable() export class ThingTranslateDefaultParser extends ThingTranslateParser { - getValueFromKeyPath(instance: object, keypath: string): unknown { - // keypath = aproperty[0].anotherproperty["arrayproperty"][42].finalproperty - let path = keypath.replace(/(?:\"|\')'"/gmi, '.'); + getValueFromKeyPath(instance: object, keyPath: string): unknown { + // keyPath = aproperty[0].anotherproperty["arrayproperty"][42].finalproperty + let path = keyPath.replace(/(?:\"|\')'"/gmi, '.'); // path = aproperty[0].anotherproperty[.arrayproperty.][42].finalproperty path = path.replace(/(?:\[|\])/gmi, '.'); // path = aproperty.0..anotherproperty..arrayproperty...42..finalproperty path = path.replace(/\.{2,}/gmi, '.'); // path = aproperty.0.anotherproperty.arrayproperty.42.finalproperty - const keypathChain = keypath.split('.'); + const keyPathChain = keyPath.split('.'); // tslint:disable-next-line: no-any let property = instance as any; - for(const key of keypathChain) { + for(const key of keyPathChain) { property = property[key] ?? undefined; }