Skip to content

Commit

Permalink
Merge branch 'main' into feat/generator-harnesses
Browse files Browse the repository at this point in the history
  • Loading branch information
markuczy committed Apr 2, 2024
2 parents e45bd0d + ad0ebb4 commit 36c4f02
Show file tree
Hide file tree
Showing 20 changed files with 168 additions and 104 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
## [4.13.2](https://github.com/onecx/onecx-portal-ui-libs/compare/v4.13.1...v4.13.2) (2024-04-02)


### Bug Fixes

* ocx-time-ago-pipe ([#191](https://github.com/onecx/onecx-portal-ui-libs/issues/191)) ([27efc2f](https://github.com/onecx/onecx-portal-ui-libs/commit/27efc2fdb3cfeec079e73c32521ae12b5f9c0b7b))

## [4.13.1](https://github.com/onecx/onecx-portal-ui-libs/compare/v4.13.0...v4.13.1) (2024-03-28)


### Bug Fixes

* update dependencies for semantic release ([#190](https://github.com/onecx/onecx-portal-ui-libs/issues/190)) ([6129eb9](https://github.com/onecx/onecx-portal-ui-libs/commit/6129eb905acf2e513747e7c5f9bf0d9a223e9df6))
* update release.config.js ([59c1b41](https://github.com/onecx/onecx-portal-ui-libs/commit/59c1b41aaea64f3f42c6931fd083ecd38f4f6d58))


### Chores

* **release:** -v4.13.0 [skip ci] ([ccec05e](https://github.com/onecx/onecx-portal-ui-libs/commit/ccec05e1386c58d8d23414573fd951e83213f1d6)), closes [#189](https://github.com/onecx/onecx-portal-ui-libs/issues/189) [#188](https://github.com/onecx/onecx-portal-ui-libs/issues/188) [#190](https://github.com/onecx/onecx-portal-ui-libs/issues/190)

## [4.13.0](https://github.com/onecx/onecx-portal-ui-libs/compare/v4.12.1...v4.13.0) (2024-03-27)


Expand Down
2 changes: 1 addition & 1 deletion libs/accelerator/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onecx/accelerator",
"version": "4.13.0",
"version": "4.13.2",
"peerDependencies": {
"tslib": "^2.3.0",
"rxjs": "7.8.1"
Expand Down
13 changes: 13 additions & 0 deletions libs/angular-accelerator/assets/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,18 @@
"HORIZONTAL_BAR": "Zu horizontalem Balkendiagramm wechseln",
"VERTICAL_BAR": "Zu vertikalem Balkendiagramm wechseln"
}
},
"OCX_TIMEAGO": {
"A_DAY_AGO": "vor einem Tag",
"A_FEW_SECONDS_AGO": "vor ein paar Sekunden",
"AN_HOUR_AGO": "vor einer Stunde",
"A_MINUTE_AGO": "vor einer Minute",
"A_MONAT_AGO": "vor einem Monat",
"A_YEAR_AGO": "vor einem Jahr",
"DAYS_AGO": "vor {{days}} Tagen",
"HOURS_AGO": "vor {{hours}} Stunden",
"MINUTES_AGO": "vor {{minutes}} Minuten",
"MONTHS_AGO": "vor {{months}} Monaten",
"YEARS_AGO": "vor {{years}} Jahren"
}
}
13 changes: 13 additions & 0 deletions libs/angular-accelerator/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,18 @@
"HORIZONTAL_BAR": "Switch to horizontal bar chart",
"VERTICAL_BAR": "Switch to vertical bar chart"
}
},
"OCX_TIMEAGO": {
"A_DAY_AGO": "a day ago",
"A_FEW_SECONDS_AGO": "a few seconds ago",
"AN_HOUR_AGO": "an hour ago",
"A_MINUTE_AGO": "a minute ago",
"A_MONTH_AGO": "a month ago",
"A_YEAR_AGO": "a year ago",
"DAYS_AGO": "{{days}} days ago",
"HOURS_AGO": "{{hours}} hours ago",
"MINUTES_AGO": "{{minutes}} minutes ago",
"MONTHS_AGO": "{{months}} months ago",
"YEARS_AGO": "{{years}} years ago"
}
}
5 changes: 2 additions & 3 deletions libs/angular-accelerator/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onecx/angular-accelerator",
"version": "4.13.0",
"version": "4.13.2",
"peerDependencies": {
"@angular/common": "^15.2.7",
"@angular/core": "^15.2.7",
Expand All @@ -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"
"primeng": "^15.2.1"
},
"dependencies": {},
"exports": {
Expand Down
30 changes: 1 addition & 29 deletions libs/angular-accelerator/src/lib/angular-accelerator.module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CommonModule } from '@angular/common'
import { CUSTOM_ELEMENTS_SCHEMA, LOCALE_ID, NgModule, importProvidersFrom } from '@angular/core'
import { CUSTOM_ELEMENTS_SCHEMA, LOCALE_ID, NgModule } from '@angular/core'
import { FormsModule, ReactiveFormsModule } from '@angular/forms'
import { RouterModule } from '@angular/router'
import { HttpClient } from '@angular/common/http'
Expand All @@ -9,14 +9,6 @@ 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'

Expand All @@ -38,7 +30,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'
Expand Down Expand Up @@ -98,25 +89,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,
Expand Down
86 changes: 83 additions & 3 deletions libs/angular-accelerator/src/lib/pipes/ocxtimeago.pipe.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,88 @@
import { Pipe } from '@angular/core'
import { TimeagoPipe } from 'ngx-timeago'
import { ChangeDetectorRef, NgZone, OnDestroy, Pipe, PipeTransform } from '@angular/core'
import { TranslatePipe, TranslateService } from '@ngx-translate/core'

@Pipe({
name: 'timeago',
})
// eslint-disable-next-line @angular-eslint/use-pipe-transform-interface
export class OcxTimeAgoPipe extends TimeagoPipe {}
export class OcxTimeAgoPipe extends TranslatePipe implements OnDestroy, PipeTransform {
private timer: number | undefined | null
constructor(
private changeDetectorRef: ChangeDetectorRef,
private ngZone: NgZone,
private translateService: TranslateService
) {
super(translateService, changeDetectorRef)
}
override transform(value: string) {
this.removeTimer()
const d = new Date(value)
const now = new Date()
const seconds = Math.round(Math.abs((now.getTime() - d.getTime()) / 1000))
const timeToUpdate = Number.isNaN(seconds) ? 1000 : this.getSecondsUntilUpdate(seconds) * 1000
this.timer = this.ngZone.runOutsideAngular(() => {
if (typeof window !== 'undefined') {
return window.setTimeout(() => {
this.ngZone.run(() => this.changeDetectorRef.markForCheck())
}, timeToUpdate)
}
return null
})
const minutes = Math.round(Math.abs(seconds / 60))
const hours = Math.round(Math.abs(minutes / 60))
const days = Math.round(Math.abs(hours / 24))
const months = Math.round(Math.abs(days / 30.416))
const years = Math.round(Math.abs(days / 365))
let translationKey = 'UNKNOWN'
if (Number.isNaN(seconds)) {
translationKey = 'NAN'
} else if (seconds <= 45) {
translationKey = 'A_FEW_SECONDS_AGO'
} else if (seconds <= 90) {
translationKey = 'A_MINUTE_AGO'
} else if (minutes <= 45) {
translationKey = 'MINUTES_AGO'
} else if (minutes <= 90) {
translationKey = 'AN_HOUR_AGO'
} else if (hours <= 22) {
translationKey = 'HOURS_AGO'
} else if (hours <= 36) {
translationKey = 'A_DAY_AGO'
} else if (days <= 25) {
translationKey = 'DAYS_AGO'
} else if (days <= 45) {
translationKey = 'A_MONTH_AGO'
} else if (days <= 345) {
translationKey = 'MONTHS_AGO'
} else if (days <= 545) {
translationKey = 'A_YEAR_AGO'
} else {
translationKey = 'YEARS_AGO'
}
return super.transform('OCX_TIMEAGO.' + translationKey, { minutes, hours, days, months, years })
}
override ngOnDestroy(): void {
this.removeTimer()
super.ngOnDestroy()
}
private removeTimer() {
if (this.timer) {
window.clearTimeout(this.timer)
this.timer = null
}
}
private getSecondsUntilUpdate(seconds: number) {
const min = 60
const hr = min * 60
const day = hr * 24
if (seconds < min) {
return 2
} else if (seconds < hr) {
return 30
} else if (seconds < day) {
return 300
} else {
return 3600
}
}
}
37 changes: 0 additions & 37 deletions libs/angular-accelerator/src/lib/utils/ocxtimeagointl.utils.ts

This file was deleted.

2 changes: 1 addition & 1 deletion libs/angular-integration-interface/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onecx/angular-integration-interface",
"version": "4.13.0",
"version": "4.13.2",
"peerDependencies": {
"@angular/core": "^15.2.7",
"@onecx/integration-interface": "~4",
Expand Down
2 changes: 1 addition & 1 deletion libs/angular-remote-components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onecx/angular-remote-components",
"version": "4.13.0",
"version": "4.13.2",
"peerDependencies": {},
"dependencies": {},
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion libs/angular-testing/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onecx/angular-testing",
"version": "4.13.0",
"version": "4.13.2",
"peerDependencies": {
"@angular/cdk": "^15.2.7",
"primeng": "^15.2.1"
Expand Down
2 changes: 1 addition & 1 deletion libs/integration-interface/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onecx/integration-interface",
"version": "4.13.0",
"version": "4.13.2",
"peerDependencies": {
"tslib": "^2.3.0",
"rxjs": "7.8.1",
Expand Down
2 changes: 1 addition & 1 deletion libs/keycloak-auth/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onecx/keycloak-auth",
"version": "4.13.0",
"version": "4.13.2",
"peerDependencies": {
"@angular/common": ">=15.2.7",
"@angular/core": ">=15.2.7",
Expand Down
13 changes: 13 additions & 0 deletions libs/portal-integration-angular/assets/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,5 +147,18 @@
"HORIZONTAL_BAR": "Zu horizontalem Balkendiagramm wechseln",
"VERTICAL_BAR": "Zu vertikalem Balkendiagramm wechseln"
}
},
"OCX_TIMEAGO": {
"A_DAY_AGO": "vor einem Tag",
"A_FEW_SECONDS_AGO": "vor ein paar Sekunden",
"AN_HOUR_AGO": "vor einer Stunde",
"A_MINUTE_AGO": "vor einer Minute",
"A_MONAT_AGO": "vor einem Monat",
"A_YEAR_AGO": "vor einem Jahr",
"DAYS_AGO": "vor {{days}} Tagen",
"HOURS_AGO": "vor {{hours}} Stunden",
"MINUTES_AGO": "vor {{minutes}} Minuten",
"MONTHS_AGO": "vor {{months}} Monaten",
"YEARS_AGO": "vor {{years}} Jahren"
}
}
13 changes: 13 additions & 0 deletions libs/portal-integration-angular/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,5 +147,18 @@
"HORIZONTAL_BAR": "Switch to horizontal bar chart",
"VERTICAL_BAR": "Switch to vertical bar chart"
}
},
"OCX_TIMEAGO": {
"A_DAY_AGO": "a day ago",
"A_FEW_SECONDS_AGO": "a few seconds ago",
"AN_HOUR_AGO": "an hour ago",
"A_MINUTE_AGO": "a minute ago",
"A_MONTH_AGO": "a month ago",
"A_YEAR_AGO": "a year ago",
"DAYS_AGO": "{{days}} days ago",
"HOURS_AGO": "{{hours}} hours ago",
"MINUTES_AGO": "{{minutes}} minutes ago",
"MONTHS_AGO": "{{months}} months ago",
"YEARS_AGO": "{{years}} years ago"
}
}
2 changes: 1 addition & 1 deletion libs/portal-integration-angular/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onecx/portal-integration-angular",
"version": "4.13.0",
"version": "4.13.2",
"peerDependencies": {
"@angular-architects/module-federation": "15.0.0",
"@angular/common": "^15.2.7",
Expand Down
2 changes: 1 addition & 1 deletion libs/portal-layout-styles/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onecx/portal-layout-styles",
"version": "4.13.0",
"version": "4.13.2",
"peerDependencies": {
"tslib": "^2.5.0"
},
Expand Down
Loading

0 comments on commit 36c4f02

Please sign in to comment.