-
Notifications
You must be signed in to change notification settings - Fork 1
fix: use datepipe for date formating #115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
The head ref may contain hidden characters: "114-pou\u017E\u00EDvat-date-pipe-na-zobrazen\u00ED-expirace-token\u016F"
Changes from 1 commit
0a7a208
f99a0e4
c992fd5
dd02cea
4aa9e9a
d04e868
e253cc0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,6 @@ | ||
| <div class="info" label="Username">{{username}}</div> | ||
| <div class="info" label="Scopes">{{scopes}}</div> | ||
| <div class="info" label="Access token expires on">{{access_token_expire}} ‒ {{time_to_access_token_expire}}</div> | ||
| <div class="info" label="Refresh token expires on">{{refresh_token_expire}} ‒ {{time_to_refresh_token_expire}}</div> | ||
| <div class="info" label="Access token expires on">{{access_token_expire | date: date_format}} ‒ | ||
| {{time_to_access_token_expire}}</div> | ||
| <div class="info" label="Refresh token expires on">{{refresh_token_expire | date: date_format}} ‒ | ||
| {{time_to_refresh_token_expire}}</div> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| import { Component, inject, OnDestroy } from "@angular/core"; | ||
| import { Component, inject, Input, OnDestroy } from "@angular/core"; | ||
| import { AuthService } from "src/app/services/auth.service"; | ||
|
|
||
| @Component({ | ||
|
|
@@ -11,6 +11,7 @@ export class UserInfoComponent implements OnDestroy { | |
| time_to_access_token_expire: string = ""; | ||
| time_to_refresh_token_expire: string = ""; | ||
| #refreshingInterval: number | null = null; | ||
| @Input() date_format: string = 'medium'; | ||
|
|
||
| constructor() { | ||
| this.#refreshingInterval = window.setInterval(() => { this.#updateCountdown(); }, 1_000) | ||
|
|
@@ -86,28 +87,12 @@ export class UserInfoComponent implements OnDestroy { | |
| get access_token_expire() { | ||
| const exp = this.#auth.getDecodedAccessToken()?.exp; | ||
| if (!exp) return 'undefined'; | ||
|
|
||
| const userLocale = navigator.languages?.[0] || navigator.language || 'cs-CZ'; | ||
| return new Intl.DateTimeFormat( | ||
| userLocale, | ||
| { | ||
| dateStyle: 'short', | ||
| timeStyle: 'medium' | ||
| } | ||
| ).format(new Date(exp * 1000)); | ||
| return new Date(exp * 1000); | ||
|
||
| } | ||
|
|
||
| get refresh_token_expire() { | ||
| const exp = this.#auth.getDecodedRefreshToken()?.exp; | ||
| if (!exp) return 'undefined'; | ||
|
|
||
| const userLocale = navigator.languages?.[0] || navigator.language || 'cs-CZ'; | ||
| return new Intl.DateTimeFormat( | ||
| userLocale, | ||
| { | ||
| dateStyle: 'short', | ||
| timeStyle: 'medium' | ||
| } | ||
| ).format(new Date(exp * 1000)); | ||
| return new Date(exp * 1000); | ||
|
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,6 +1,6 @@ | ||||||
| <div class="details"> | ||||||
| <h1>User details</h1> | ||||||
| <app-user-info></app-user-info> | ||||||
| <app-user-info date_format="full"></app-user-info> | ||||||
|
||||||
| <app-user-info date_format="full"></app-user-info> | |
| <app-user-info dateFormat="full"></app-user-info> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
date_formatas an@Inputname (and corresponding attribute) deviates from the codebase’s existing camelCase input naming (e.g.,autosaveDebounce,placeholder). Consider renaming this input todateFormatand updating call sites accordingly for consistency and to better align with Angular style.