diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 201da572..492ae637 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -66,7 +66,6 @@ export class AppComponent { * TODO */ async initializeApp() { - // tslint:disable-next-line: no-floating-promises this.platform.ready().then(async () => { // Okay, so the platform is ready and our plugins are available. // Here you can do any higher level native things you might need. diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 64f20a7a..e724b6f7 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -12,7 +12,12 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {CommonModule, LocationStrategy, PathLocationStrategy, registerLocaleData} from '@angular/common'; +import { + CommonModule, + LocationStrategy, + PathLocationStrategy, + registerLocaleData, +} from '@angular/common'; import {HttpClient} from '@angular/common/http'; import localeDe from '@angular/common/locales/de'; import {APP_INITIALIZER, NgModule, Provider} from '@angular/core'; diff --git a/src/app/modules/data/detail/data-detail-content.html b/src/app/modules/data/detail/data-detail-content.html index 62e427ef..6b5309ad 100644 --- a/src/app/modules/data/detail/data-detail-content.html +++ b/src/app/modules/data/detail/data-detail-content.html @@ -1,19 +1,64 @@
- - - - - - - - - - - - - - - + + + + + + + + + + + + + + + @@ -23,14 +68,18 @@
-

{{item.name}}

- {{item.type}} +

{{ item.name }}

+ {{ item.type }}
- +
- + diff --git a/src/app/modules/data/elements/origin-in-list.html b/src/app/modules/data/elements/origin-in-list.html index a16b9e3f..3d7343ac 100644 --- a/src/app/modules/data/elements/origin-in-list.html +++ b/src/app/modules/data/elements/origin-in-list.html @@ -1,7 +1,7 @@
-

{{origin.created | dateFormat}}

+

{{ origin.created | dateFormat }}

-

{{origin.indexed | dateFormat}}

+

{{ origin.indexed | dateFormat }}

diff --git a/src/app/modules/data/types/place/place-detail-content.component.ts b/src/app/modules/data/types/place/place-detail-content.component.ts index 83c1c4ad..2ff45f4a 100644 --- a/src/app/modules/data/types/place/place-detail-content.component.ts +++ b/src/app/modules/data/types/place/place-detail-content.component.ts @@ -42,9 +42,7 @@ export class PlaceDetailContentComponent { * * @param item TODO */ - // tslint:disable-next-line:completed-docs prefer-function-over-method hasCategories(item: SCThings): item is SCThings & {categories: string[]} { - // tslint:disable-next-line:completed-docs return typeof (item as {categories: string[]}).categories !== 'undefined'; } diff --git a/src/app/modules/data/types/place/place-list-item.html b/src/app/modules/data/types/place/place-list-item.html index 2131cf74..d9c3983c 100644 --- a/src/app/modules/data/types/place/place-list-item.html +++ b/src/app/modules/data/types/place/place-list-item.html @@ -2,26 +2,28 @@
- {{'name' | thingTranslate: item}} + {{ 'name' | thingTranslate: item }}

- {{item.openingHours | openingHours}} + {{ item.openingHours | openingHours }}

- - {{'categories' | thingTranslate: item | join:', ' | titlecase }} + + {{ 'categories' | thingTranslate: item | join: ', ' | titlecase }}

- {{'type' | thingTranslate: item}} + {{ 'type' | thingTranslate: item }}

- {{'description' | thingTranslate: item}} + {{ 'description' | thingTranslate: item }}

    @@ -36,7 +38,8 @@
    - {{'name' | thingTranslate: item.inPlace}} + {{ 'name' | thingTranslate: item.inPlace }}
    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 8200a291..85d4d371 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 @@ -57,8 +57,7 @@ export class PlaceMensaDetailComponent implements AfterViewInit { startingDay: Moment; constructor(private readonly mensaService: PlaceMensaService) { - this.startingDay = moment() - .startOf('day'); + this.startingDay = moment().startOf('day'); } /** @@ -66,7 +65,7 @@ export class PlaceMensaDetailComponent implements AfterViewInit { */ ngAfterViewInit() { this.dishes = this.mensaService.getAllDishes(this.item, this.displayRange); - this.dishes.then((result) => { + this.dishes.then(result => { for (const [key, value] of Object.entries(result)) { if (value.length === 0) { delete result[key]; diff --git a/src/app/modules/data/types/place/special/mensa/place-mensa.html b/src/app/modules/data/types/place/special/mensa/place-mensa.html index 021293d4..600f417e 100644 --- a/src/app/modules/data/types/place/special/mensa/place-mensa.html +++ b/src/app/modules/data/types/place/special/mensa/place-mensa.html @@ -1,9 +1,16 @@
    - - {{day.key | dateFormat:'weekday:long,month:numeric,day:numeric'}} - {{day.key | dateFormat:'weekday:short,month:numeric,day:numeric' }} + + {{ + day.key | dateFormat: 'weekday:long,month:numeric,day:numeric' + }} + {{ + day.key | dateFormat: 'weekday:short,month:numeric,day:numeric' + }}
    diff --git a/src/app/modules/data/types/semester/semester-list-item.html b/src/app/modules/data/types/semester/semester-list-item.html index 37338075..863a2d23 100644 --- a/src/app/modules/data/types/semester/semester-list-item.html +++ b/src/app/modules/data/types/semester/semester-list-item.html @@ -5,7 +5,10 @@

    {{ 'name' | thingTranslate: item }}

    - {{item.startDate | dateFormat}} - {{item.endDate | dateFormat}} + {{ item.startDate | dateFormat }} - + {{ item.endDate | dateFormat }}

    {{ 'type' | thingTranslate: item }}
    diff --git a/src/app/modules/map/map.provider.ts b/src/app/modules/map/map.provider.ts index 80595d1f..2a441ec4 100644 --- a/src/app/modules/map/map.provider.ts +++ b/src/app/modules/map/map.provider.ts @@ -46,9 +46,7 @@ export class MapProvider { static getPointMarker(point: Point) { return marker(geoJSON(point).getBounds().getCenter(), { icon: icon({ - // tslint:disable-next-line:no-magic-numbers iconAnchor: [13, 41], - // tslint:disable-next-line:no-magic-numbers iconSize: [25, 41], iconUrl: '../assets/marker-icon.png', shadowUrl: '../assets/marker-shadow.png', diff --git a/src/app/modules/news/page/news-item.html b/src/app/modules/news/page/news-item.html index 43231384..4941c897 100644 --- a/src/app/modules/news/page/news-item.html +++ b/src/app/modules/news/page/news-item.html @@ -1,25 +1,41 @@ - - - - - - - + + + + + + + - + - {{item.datePublished | amCalendar | sentencecase}} + {{ + item.datePublished | amCalendar | sentencecase + }} - {{item.name}} - {{item.name}} + {{ item.name }} + {{ item.name }} - {{item.messageBody}} + {{ item.messageBody }} diff --git a/src/app/translation/common-string-pipes.ts b/src/app/translation/common-string-pipes.ts index 3c736226..addfee8d 100644 --- a/src/app/translation/common-string-pipes.ts +++ b/src/app/translation/common-string-pipes.ts @@ -19,11 +19,9 @@ import moment from 'moment'; import {Subscription} from 'rxjs'; import {logger} from '../_helpers/ts-logger'; -// tslint:disable-next-line: no-var-requires +// eslint-disable-next-line @typescript-eslint/no-var-requires, unicorn/prefer-module const openingHoursFn = require('opening_hours'); -// tslint:disable: completed-docs - @Injectable() @Pipe({ name: 'join', @@ -58,13 +56,13 @@ export class SentenceCasePipe implements PipeTransform { value = ''; transform(aString: string | unknown): string { - - if (typeof aString !== 'string'){ - throw new SyntaxError(`Wrong parameter in StringSplitPipe. Expected a valid String, received: ${aString}`); + if (typeof aString !== 'string') { + throw new SyntaxError( + `Wrong parameter in StringSplitPipe. Expected a valid String, received: ${aString}`, + ); } - this.value = aString.substr(0,1) - .toUpperCase() + aString.substr(1); + this.value = aString.slice(0, 1).toUpperCase() + aString.slice(1); return this.value; } @@ -102,7 +100,9 @@ export class StringSplitPipe implements PipeTransform { }) export class OpeningHoursPipe implements PipeTransform { locale: string; + onLangChange?: Subscription; + value = ''; constructor(private readonly translate: TranslateService) { @@ -115,29 +115,30 @@ export class OpeningHoursPipe implements PipeTransform { } } - transform(aString: string | unknown): string { this.updateValue(aString); this._dispose(); if (this.onLangChange?.closed === true) { - this.onLangChange = this.translate.onLangChange.subscribe((event: LangChangeEvent) => { - this.locale = event.lang; - this.updateValue(aString); - }); + this.onLangChange = this.translate.onLangChange.subscribe( + (event: LangChangeEvent) => { + this.locale = event.lang; + this.updateValue(aString); + }, + ); } return this.value; } updateValue(aString: string | unknown) { - if (typeof aString !== 'string'){ + if (typeof aString !== 'string') { logger.warn(`openingHours pipe unable to parse input: ${aString}`); return; } const openingHours = new openingHoursFn(aString); - if ((openingHours.getWarnings() as string[]).length > 0){ + if ((openingHours.getWarnings() as string[]).length > 0) { logger.warn((openingHours.getWarnings() as string[]).join('. ')); return; @@ -146,27 +147,24 @@ export class OpeningHoursPipe implements PipeTransform { const isOpen: boolean = openingHours.getState(); const nextChange: Date = openingHours.getNextChange(); - let prefixKey = isOpen ? - 'common.openingHours.open_until' : - 'common.openingHours.closed_until'; + let prefixKey = isOpen + ? 'common.openingHours.open_until' + : 'common.openingHours.closed_until'; - let formattedCalender = moment(nextChange) - .calendar(); + let formattedCalender = moment(nextChange).calendar(); - if (moment(nextChange) - .isBefore(moment() - .add(1, 'hours'))) { - prefixKey= isOpen ? - 'common.openingHours.closing_soon' : - 'common.openingHours.opening_soon'; - formattedCalender = formattedCalender.substr(0,1) - .toUpperCase() + formattedCalender.substr(1); + if (moment(nextChange).isBefore(moment().add(1, 'hours'))) { + prefixKey = isOpen + ? 'common.openingHours.closing_soon' + : 'common.openingHours.opening_soon'; + formattedCalender = + formattedCalender.slice(0, 1).toUpperCase() + + formattedCalender.slice(1); } this.value = `${this.translate.instant(prefixKey)} ${formattedCalender}`; } } - @Injectable() @Pipe({ name: 'numberLocalized', @@ -174,7 +172,9 @@ export class OpeningHoursPipe implements PipeTransform { }) export class NumberLocalizedPipe implements PipeTransform, OnDestroy { locale: string; + onLangChange?: Subscription; + value: string; constructor(private readonly translate: TranslateService) { @@ -200,10 +200,12 @@ export class NumberLocalizedPipe implements PipeTransform, OnDestroy { this.updateValue(value, formatOptions); this._dispose(); if (this.onLangChange?.closed === true) { - this.onLangChange = this.translate.onLangChange.subscribe((event: LangChangeEvent) => { - this.locale = event.lang; - this.updateValue(value, formatOptions); - }); + this.onLangChange = this.translate.onLangChange.subscribe( + (event: LangChangeEvent) => { + this.locale = event.lang; + this.updateValue(value, formatOptions); + }, + ); } return this.value; @@ -215,10 +217,19 @@ export class NumberLocalizedPipe implements PipeTransform, OnDestroy { return; } - const options = formatOptions?.split(',') - .map((element) => element.split(':')) - .reduce((acc, [key, val]) => ({...acc, [key.trim()]: val.trim()}),{}) as Intl.NumberFormatOptions; - const float = typeof value === 'string' ? Number.parseFloat(value) : value as number; + const options = formatOptions + ?.split(',') + .map(element => element.split(':')) + // eslint-disable-next-line unicorn/no-array-reduce + .reduce( + (accumulator, [key, value_]) => ({ + ...accumulator, + [key.trim()]: value_.trim(), + }), + {}, + ) as Intl.NumberFormatOptions; + const float = + typeof value === 'string' ? Number.parseFloat(value) : (value as number); this.value = new Intl.NumberFormat(this.locale, options).format(float); } } @@ -230,7 +241,9 @@ export class NumberLocalizedPipe implements PipeTransform, OnDestroy { }) export class DateLocalizedFormatPipe implements PipeTransform, OnDestroy { locale: string; + onLangChange?: Subscription; + value: string; constructor(private readonly translate: TranslateService) { @@ -257,32 +270,48 @@ export class DateLocalizedFormatPipe implements PipeTransform, OnDestroy { this.updateValue(value, formatOptions); this._dispose(); if (this.onLangChange?.closed === true) { - this.onLangChange = this.translate.onLangChange.subscribe((event: LangChangeEvent) => { - this.locale = event.lang; - this.updateValue(value, formatOptions); - }); + this.onLangChange = this.translate.onLangChange.subscribe( + (event: LangChangeEvent) => { + this.locale = event.lang; + this.updateValue(value, formatOptions); + }, + ); } return this.value; } updateValue(value: string | Date | unknown, formatOptions?: string): void { - if (typeof value !== 'string' && Object.prototype.toString.call(value) !== '[object Date]') { + if ( + typeof value !== 'string' && + Object.prototype.toString.call(value) !== '[object Date]' + ) { logger.warn(`dateFormat pipe unable to parse input: ${value}`); return; } - const options = formatOptions?.split(',') - .map((element) => element.split(':')) - .reduce((acc, [key, val]) => ({...acc, [key.trim()]: val.trim()}),{}) as Intl.DateTimeFormatOptions; - const date = typeof value === 'string' ? Date.parse(value) : value as Date; - this.value = new Intl.DateTimeFormat(this.locale, options ?? { - day: 'numeric', - month: 'numeric', - year: 'numeric', - hour: 'numeric', - minute: 'numeric', - }) - .format(date); + const options = formatOptions + ?.split(',') + .map(element => element.split(':')) + // eslint-disable-next-line unicorn/no-array-reduce + .reduce( + (accumulator, [key, value_]) => ({ + ...accumulator, + [key.trim()]: value_.trim(), + }), + {}, + ) as Intl.DateTimeFormatOptions; + const date = + typeof value === 'string' ? Date.parse(value) : (value as Date); + this.value = new Intl.DateTimeFormat( + this.locale, + options ?? { + day: 'numeric', + month: 'numeric', + year: 'numeric', + hour: 'numeric', + minute: 'numeric', + }, + ).format(date); } } diff --git a/src/app/translation/thing-translate.module.ts b/src/app/translation/thing-translate.module.ts index bb8b72b1..ebeac613 100644 --- a/src/app/translation/thing-translate.module.ts +++ b/src/app/translation/thing-translate.module.ts @@ -14,9 +14,22 @@ */ import {ModuleWithProviders, NgModule, Provider} from '@angular/core'; -import {ArrayJoinPipe, DateLocalizedFormatPipe, NumberLocalizedPipe, SentenceCasePipe, StringSplitPipe, OpeningHoursPipe} from './common-string-pipes'; -import {ThingTranslateDefaultParser, ThingTranslateParser} from './thing-translate.parser'; -import {ThingPropertyNameTranslatePipe, ThingTranslatePipe} from './thing-translate.pipe'; +import { + ArrayJoinPipe, + DateLocalizedFormatPipe, + NumberLocalizedPipe, + SentenceCasePipe, + StringSplitPipe, + OpeningHoursPipe, +} from './common-string-pipes'; +import { + ThingTranslateDefaultParser, + ThingTranslateParser, +} from './thing-translate.parser'; +import { + ThingPropertyNameTranslatePipe, + ThingTranslatePipe, +} from './thing-translate.pipe'; import {ThingTranslateService} from './thing-translate.service'; export interface ThingTranslateModuleConfig { diff --git a/src/app/translation/thing-translate.pipe.ts b/src/app/translation/thing-translate.pipe.ts index 33f00ce4..28931ec4 100644 --- a/src/app/translation/thing-translate.pipe.ts +++ b/src/app/translation/thing-translate.pipe.ts @@ -19,8 +19,6 @@ import {isThing, SCThings, SCThingType} from '@openstapps/core'; import {Subscription} from 'rxjs'; import {ThingTranslateService} from './thing-translate.service'; -// tslint:disable: member-ordering prefer-function-over-method completed-docs - @Injectable() @Pipe({ name: 'thingTranslate', diff --git a/src/main.ts b/src/main.ts index 39f69a94..bb87505a 100644 --- a/src/main.ts +++ b/src/main.ts @@ -23,5 +23,4 @@ if (environment.production) { platformBrowserDynamic() .bootstrapModule(AppModule) - // tslint:disable-next-line:no-console .catch(async error => console.error(error));