From cb980dd7f4d5065958c66e18d014f0a73d33f985 Mon Sep 17 00:00:00 2001 From: Annika Nowak Date: Thu, 28 Mar 2024 13:44:26 +0100 Subject: [PATCH] fix: remove unused imports and ngx-timeago --- libs/angular-accelerator/package.json | 3 +- .../src/lib/angular-accelerator.module.ts | 29 +-------------- .../src/lib/utils/ocxtimeagointl.utils.ts | 37 ------------------- package-lock.json | 21 ----------- package.json | 1 - 5 files changed, 2 insertions(+), 89 deletions(-) delete mode 100644 libs/angular-accelerator/src/lib/utils/ocxtimeagointl.utils.ts diff --git a/libs/angular-accelerator/package.json b/libs/angular-accelerator/package.json index 8933aadd..0d87fc06 100644 --- a/libs/angular-accelerator/package.json +++ b/libs/angular-accelerator/package.json @@ -14,8 +14,7 @@ "chart.js": "^4.4.0", "d3-scale-chromatic": "^3.0.0", "rxjs": "~7.8.0", - "primeng": "^15.2.1", - "ngx-timeago": "^2.0.0 | ^3.0.0" + "primeng": "^15.2.1" }, "dependencies": {}, "exports": { diff --git a/libs/angular-accelerator/src/lib/angular-accelerator.module.ts b/libs/angular-accelerator/src/lib/angular-accelerator.module.ts index 86208608..afd7ebfa 100644 --- a/libs/angular-accelerator/src/lib/angular-accelerator.module.ts +++ b/libs/angular-accelerator/src/lib/angular-accelerator.module.ts @@ -9,14 +9,7 @@ import { TranslateLoader, TranslateModule, } from '@ngx-translate/core' -import { - TimeagoClock, - TimeagoCustomFormatter, - TimeagoDefaultClock, - TimeagoFormatter, - TimeagoIntl, - TimeagoModule, -} from 'ngx-timeago' + import { AppStateService, UserService } from '@onecx/angular-integration-interface' @@ -38,7 +31,6 @@ import { DynamicPipe } from './pipes/dynamic.pipe' import { IfPermissionDirective } from './directives/if-permission.directive' import { IfBreakpointDirective } from './directives/if-breakpoint.directive' import { OcxTimeAgoPipe } from './pipes/ocxtimeago.pipe' -import { OcxTimeagoIntl } from './utils/ocxtimeagointl.utils' import { createTranslateLoader } from './utils/create-translate-loader.utils' import { TranslationCacheService } from './services/translation-cache.service' import { SrcDirective } from './directives/src.directive' @@ -98,25 +90,6 @@ export class AngularAcceleratorMissingTranslationHandler implements MissingTrans }, deps: [UserService], }, - { - provide: TimeagoIntl, - useFactory: (userService: UserService) => { - return new OcxTimeagoIntl(userService) - }, - deps: [UserService], - }, - importProvidersFrom(TimeagoModule), - { - provide: TimeagoFormatter, - useFactory: (TimeagoIntl: TimeagoIntl) => { - return new TimeagoCustomFormatter(TimeagoIntl) - }, - deps: [TimeagoIntl], - }, - { - provide: TimeagoClock, - useClass: TimeagoDefaultClock, - }, ], exports: [ ColumnGroupSelectionComponent, diff --git a/libs/angular-accelerator/src/lib/utils/ocxtimeagointl.utils.ts b/libs/angular-accelerator/src/lib/utils/ocxtimeagointl.utils.ts deleted file mode 100644 index 0430419a..00000000 --- a/libs/angular-accelerator/src/lib/utils/ocxtimeagointl.utils.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { map } from 'rxjs' -import { IL10nsStrings, TimeagoIntl } from 'ngx-timeago' -import { strings as englishStrings } from 'ngx-timeago/language-strings/en' -import { strings as germanStrings } from 'ngx-timeago/language-strings/de' -import { UserService } from '@onecx/angular-integration-interface' - -export class OcxTimeagoIntl extends TimeagoIntl { - private LANG_TO_STRINGS: { [key: string]: IL10nsStrings } = { - en: englishStrings, - de: germanStrings, - } - private DEFAULT_LANG = 'en' - - constructor(protected userService: UserService) { - super() - this.strings = englishStrings - userService.lang$ - .pipe( - map((lang) => { - return this.getBestMatchLanguage(lang as string) - }) - ) - .subscribe((lang) => { - this.strings = this.LANG_TO_STRINGS[lang] - this.changes.next() - }) - } - - getBestMatchLanguage(lang: string) { - if (Object.keys(this.LANG_TO_STRINGS).includes(lang)) { - return lang - } else { - console.log(`${lang} is not supported. Using ${this.DEFAULT_LANG} as a fallback.`) - } - return this.DEFAULT_LANG - } -} diff --git a/package-lock.json b/package-lock.json index a7848a6b..290fcb9d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -35,7 +35,6 @@ "keycloak-angular": "^13.0.0", "keycloak-js": "^18.0.0", "ngx-color": "^8.0.3", - "ngx-timeago": "^2.0.0", "primeflex": "^3.3.0", "primeicons": "^6.0.1", "primeng": "15.2.1", @@ -29739,18 +29738,6 @@ "@angular/core": ">=14.0.0-0" } }, - "node_modules/ngx-timeago": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ngx-timeago/-/ngx-timeago-2.0.0.tgz", - "integrity": "sha512-5kQZeTPCkegEcSooUu3W0BSOwvxEt1q6zjodwEOYoW/FxETC8Bk1zQF1QOPZLS+Nu3GLA+g1oPXMVBonM+CYQQ==", - "dependencies": { - "tslib": "^2.0.0" - }, - "peerDependencies": { - "@angular/core": ">=10.0.0", - "rxjs": ">=6.6.0" - } - }, "node_modules/ngx-translate-testing": { "version": "6.1.0", "dev": true, @@ -59739,14 +59726,6 @@ "tslib": "^2.3.0" } }, - "ngx-timeago": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ngx-timeago/-/ngx-timeago-2.0.0.tgz", - "integrity": "sha512-5kQZeTPCkegEcSooUu3W0BSOwvxEt1q6zjodwEOYoW/FxETC8Bk1zQF1QOPZLS+Nu3GLA+g1oPXMVBonM+CYQQ==", - "requires": { - "tslib": "^2.0.0" - } - }, "ngx-translate-testing": { "version": "6.1.0", "dev": true, diff --git a/package.json b/package.json index ff161ccc..9fb404de 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,6 @@ "keycloak-angular": "^13.0.0", "keycloak-js": "^18.0.0", "ngx-color": "^8.0.3", - "ngx-timeago": "^3.0.0", "primeflex": "^3.3.0", "primeicons": "^6.0.1", "primeng": "15.2.1",