web: Tidy temporal utilities. (#13755)
This commit is contained in:
@ -2,7 +2,7 @@ import { EventGeo, EventUser } from "@goauthentik/admin/events/utils";
|
||||
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
||||
import { EventWithContext } from "@goauthentik/common/events";
|
||||
import { actionToLabel } from "@goauthentik/common/labels";
|
||||
import { getRelativeTime } from "@goauthentik/common/utils";
|
||||
import { formatElapsedTime } from "@goauthentik/common/temporal";
|
||||
import "@goauthentik/components/ak-event-info";
|
||||
import "@goauthentik/elements/Tabs";
|
||||
import "@goauthentik/elements/buttons/Dropdown";
|
||||
@ -74,7 +74,7 @@ export class RecentEventsCard extends Table<Event> {
|
||||
html`<div><a href="${`#/events/log/${item.pk}`}">${actionToLabel(item.action)}</a></div>
|
||||
<small>${item.app}</small>`,
|
||||
EventUser(item),
|
||||
html`<div>${getRelativeTime(item.created)}</div>
|
||||
html`<div>${formatElapsedTime(item.created)}</div>
|
||||
<small>${item.created.toLocaleString()}</small>`,
|
||||
html` <div>${item.clientIp || msg("-")}</div>
|
||||
<small>${EventGeo(item)}</small>`,
|
||||
|
||||
@ -2,7 +2,7 @@ import "@goauthentik/admin/blueprints/BlueprintForm";
|
||||
import "@goauthentik/admin/rbac/ObjectPermissionModal";
|
||||
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
||||
import { EVENT_REFRESH } from "@goauthentik/common/constants";
|
||||
import { getRelativeTime } from "@goauthentik/common/utils";
|
||||
import { formatElapsedTime } from "@goauthentik/common/temporal";
|
||||
import "@goauthentik/components/ak-status-label";
|
||||
import "@goauthentik/elements/buttons/ActionButton";
|
||||
import "@goauthentik/elements/buttons/SpinnerButton";
|
||||
@ -141,7 +141,7 @@ export class BlueprintListPage extends TablePage<BlueprintInstance> {
|
||||
html`<div>${item.name}</div>
|
||||
${description ? html`<small>${description}</small>` : html``}`,
|
||||
html`${BlueprintStatus(item)}`,
|
||||
html`<div>${getRelativeTime(item.lastApplied)}</div>
|
||||
html`<div>${formatElapsedTime(item.lastApplied)}</div>
|
||||
<small>${item.lastApplied.toLocaleString()}</small>`,
|
||||
html`<ak-status-label ?good=${item.enabled}></ak-status-label>`,
|
||||
html`<ak-forms-modal>
|
||||
|
||||
@ -2,7 +2,7 @@ import "@goauthentik/admin/enterprise/EnterpriseLicenseForm";
|
||||
import "@goauthentik/admin/enterprise/EnterpriseStatusCard";
|
||||
import "@goauthentik/admin/rbac/ObjectPermissionModal";
|
||||
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
||||
import { getRelativeTime } from "@goauthentik/common/utils";
|
||||
import { formatElapsedTime } from "@goauthentik/common/temporal";
|
||||
import { PFColor } from "@goauthentik/elements/Label";
|
||||
import "@goauthentik/elements/Spinner";
|
||||
import "@goauthentik/elements/buttons/SpinnerButton";
|
||||
@ -186,7 +186,7 @@ export class EnterpriseLicenseListPage extends TablePage<License> {
|
||||
>
|
||||
${this.summary &&
|
||||
this.summary?.status !== LicenseSummaryStatusEnum.Unlicensed
|
||||
? html`<div>${getRelativeTime(this.summary.latestValid)}</div>
|
||||
? html`<div>${formatElapsedTime(this.summary.latestValid)}</div>
|
||||
<small>${this.summary.latestValid.toLocaleString()}</small>`
|
||||
: "-"}
|
||||
</ak-aggregate-card>
|
||||
|
||||
@ -3,7 +3,7 @@ import { EventGeo, EventUser } from "@goauthentik/admin/events/utils";
|
||||
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
||||
import { EventWithContext } from "@goauthentik/common/events";
|
||||
import { actionToLabel } from "@goauthentik/common/labels";
|
||||
import { getRelativeTime } from "@goauthentik/common/utils";
|
||||
import { formatElapsedTime } from "@goauthentik/common/temporal";
|
||||
import "@goauthentik/components/ak-event-info";
|
||||
import { PaginatedResponse } from "@goauthentik/elements/table/Table";
|
||||
import { TableColumn } from "@goauthentik/elements/table/Table";
|
||||
@ -78,7 +78,7 @@ export class EventListPage extends TablePage<Event> {
|
||||
html`<div>${actionToLabel(item.action)}</div>
|
||||
<small>${item.app}</small>`,
|
||||
EventUser(item),
|
||||
html`<div>${getRelativeTime(item.created)}</div>
|
||||
html`<div>${formatElapsedTime(item.created)}</div>
|
||||
<small>${item.created.toLocaleString()}</small>`,
|
||||
html`<div>${item.clientIp || msg("-")}</div>
|
||||
<small>${EventGeo(item)}</small>`,
|
||||
|
||||
@ -2,7 +2,7 @@ import { EventGeo, EventUser } from "@goauthentik/admin/events/utils";
|
||||
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
||||
import { EventWithContext } from "@goauthentik/common/events";
|
||||
import { actionToLabel } from "@goauthentik/common/labels";
|
||||
import { getRelativeTime } from "@goauthentik/common/utils";
|
||||
import { formatElapsedTime } from "@goauthentik/common/temporal";
|
||||
import "@goauthentik/components/ak-event-info";
|
||||
import { AKElement } from "@goauthentik/elements/Base";
|
||||
import "@goauthentik/elements/PageHeader";
|
||||
@ -104,7 +104,7 @@ export class EventViewPage extends AKElement {
|
||||
</dt>
|
||||
<dd class="pf-c-description-list__description">
|
||||
<div class="pf-c-description-list__text">
|
||||
<div>${getRelativeTime(this.event.created)}</div>
|
||||
<div>${formatElapsedTime(this.event.created)}</div>
|
||||
<small>${this.event.created.toLocaleString()}</small>
|
||||
</div>
|
||||
</dd>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
||||
import { getRelativeTime } from "@goauthentik/common/utils";
|
||||
import { formatElapsedTime } from "@goauthentik/common/temporal";
|
||||
import "@goauthentik/components/ak-status-label";
|
||||
import "@goauthentik/elements/buttons/SpinnerButton";
|
||||
import { PaginatedResponse } from "@goauthentik/elements/table/Table";
|
||||
@ -105,7 +105,7 @@ export class MemberSelectTable extends TableModal<User> {
|
||||
<small>${item.name}</small>`,
|
||||
html` <ak-status-label type="warning" ?good=${item.isActive}></ak-status-label>`,
|
||||
html`${item.lastLogin
|
||||
? html`<div>${getRelativeTime(item.lastLogin)}</div>
|
||||
? html`<div>${formatElapsedTime(item.lastLogin)}</div>
|
||||
<small>${item.lastLogin.toLocaleString()}</small>`
|
||||
: msg("-")}`,
|
||||
];
|
||||
|
||||
@ -8,8 +8,8 @@ import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
||||
import { PFSize } from "@goauthentik/common/enums.js";
|
||||
import { parseAPIResponseError, pluckErrorDetail } from "@goauthentik/common/errors/network";
|
||||
import { MessageLevel } from "@goauthentik/common/messages";
|
||||
import { formatElapsedTime } from "@goauthentik/common/temporal";
|
||||
import { me } from "@goauthentik/common/users";
|
||||
import { getRelativeTime } from "@goauthentik/common/utils";
|
||||
import "@goauthentik/components/ak-status-label";
|
||||
import { WithBrandConfig } from "@goauthentik/elements/Interface/brandProvider";
|
||||
import {
|
||||
@ -194,7 +194,7 @@ export class RelatedUserList extends WithBrandConfig(WithCapabilitiesConfig(Tabl
|
||||
</a>`,
|
||||
html`<ak-status-label ?good=${item.isActive}></ak-status-label>`,
|
||||
html`${item.lastLogin
|
||||
? html`<div>${getRelativeTime(item.lastLogin)}</div>
|
||||
? html`<div>${formatElapsedTime(item.lastLogin)}</div>
|
||||
<small>${item.lastLogin.toLocaleString()}</small>`
|
||||
: msg("-")}`,
|
||||
html`<ak-forms-modal>
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { getRelativeTime } from "@goauthentik/common/utils";
|
||||
import { formatElapsedTime } from "@goauthentik/common/temporal";
|
||||
import { AKElement } from "@goauthentik/elements/Base";
|
||||
import { PFColor } from "@goauthentik/elements/Label";
|
||||
import "@goauthentik/elements/Spinner";
|
||||
@ -51,7 +51,7 @@ export class OutpostHealthElement extends AKElement {
|
||||
<div class="pf-c-description-list__text">
|
||||
<ak-label color=${PFColor.Green} ?compact=${true}>
|
||||
${msg(
|
||||
str`${getRelativeTime(this.outpostHealth.lastSeen)} (${this.outpostHealth.lastSeen?.toLocaleTimeString()})`,
|
||||
str`${formatElapsedTime(this.outpostHealth.lastSeen)} (${this.outpostHealth.lastSeen?.toLocaleTimeString()})`,
|
||||
)}
|
||||
</ak-label>
|
||||
</div>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
||||
import { EVENT_REFRESH } from "@goauthentik/common/constants";
|
||||
import { getRelativeTime } from "@goauthentik/common/utils";
|
||||
import { formatElapsedTime } from "@goauthentik/common/temporal";
|
||||
import { AKElement } from "@goauthentik/elements/Base";
|
||||
import { PFColor } from "@goauthentik/elements/Label";
|
||||
import "@goauthentik/elements/Spinner";
|
||||
@ -69,7 +69,7 @@ export class OutpostHealthSimpleElement extends AKElement {
|
||||
const lastSeen = this.outpostHealths[0].lastSeen;
|
||||
return html`<ak-label color=${PFColor.Green}>
|
||||
${msg(
|
||||
str`Last seen: ${getRelativeTime(lastSeen)} (${lastSeen.toLocaleTimeString()})`,
|
||||
str`Last seen: ${formatElapsedTime(lastSeen)} (${lastSeen.toLocaleTimeString()})`,
|
||||
)}</ak-label
|
||||
>`;
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import "@goauthentik/admin/rbac/ObjectPermissionModal";
|
||||
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
||||
import { getRelativeTime } from "@goauthentik/common/utils";
|
||||
import { formatElapsedTime } from "@goauthentik/common/temporal";
|
||||
import "@goauthentik/elements/buttons/ModalButton";
|
||||
import "@goauthentik/elements/buttons/SpinnerButton";
|
||||
import "@goauthentik/elements/forms/DeleteBulkForm";
|
||||
@ -89,7 +89,7 @@ export class ReputationListPage extends TablePage<Reputation> {
|
||||
: html``}
|
||||
${item.ip}`,
|
||||
html`${item.score}`,
|
||||
html`<div>${getRelativeTime(item.updated)}</div>
|
||||
html`<div>${formatElapsedTime(item.updated)}</div>
|
||||
<small>${item.updated.toLocaleString()}</small>`,
|
||||
html`
|
||||
<ak-rbac-object-permission-modal
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import "@goauthentik/admin/common/ak-flow-search/ak-flow-search";
|
||||
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
||||
import { dateTimeLocal, first } from "@goauthentik/common/utils";
|
||||
import { dateTimeLocal } from "@goauthentik/common/temporal";
|
||||
import { first } from "@goauthentik/common/utils";
|
||||
import "@goauthentik/elements/CodeMirror";
|
||||
import { CodeMirrorMode } from "@goauthentik/elements/CodeMirror";
|
||||
import "@goauthentik/elements/forms/HorizontalFormElement";
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
||||
import { EVENT_REFRESH } from "@goauthentik/common/constants";
|
||||
import { getRelativeTime } from "@goauthentik/common/utils";
|
||||
import { formatElapsedTime } from "@goauthentik/common/temporal";
|
||||
import { PFColor } from "@goauthentik/elements/Label";
|
||||
import "@goauthentik/elements/buttons/ActionButton";
|
||||
import "@goauthentik/elements/buttons/SpinnerButton";
|
||||
@ -100,7 +100,7 @@ export class SystemTaskListPage extends TablePage<SystemTask> {
|
||||
item.expires || new Date()
|
||||
).toLocaleString()}
|
||||
>
|
||||
${getRelativeTime(item.expires || new Date())}
|
||||
${formatElapsedTime(item.expires || new Date())}
|
||||
</pf-tooltip>
|
||||
`
|
||||
: msg("-")}
|
||||
@ -128,7 +128,7 @@ export class SystemTaskListPage extends TablePage<SystemTask> {
|
||||
return [
|
||||
html`<pre>${item.name}${item.uid ? `:${item.uid}` : ""}</pre>`,
|
||||
html`${item.description}`,
|
||||
html`<div>${getRelativeTime(item.finishTimestamp)}</div>
|
||||
html`<div>${formatElapsedTime(item.finishTimestamp)}</div>
|
||||
<small>${item.finishTimestamp.toLocaleString()}</small>`,
|
||||
this.taskStatus(item),
|
||||
html`<ak-action-button
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
||||
import { dateTimeLocal, first } from "@goauthentik/common/utils";
|
||||
import { dateTimeLocal } from "@goauthentik/common/temporal";
|
||||
import { first } from "@goauthentik/common/utils";
|
||||
import "@goauthentik/elements/forms/FormGroup";
|
||||
import "@goauthentik/elements/forms/HorizontalFormElement";
|
||||
import { ModelForm } from "@goauthentik/elements/forms/ModelForm";
|
||||
|
||||
@ -2,7 +2,7 @@ import "@goauthentik/admin/rbac/ObjectPermissionModal";
|
||||
import "@goauthentik/admin/tokens/TokenForm";
|
||||
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
||||
import { intentToLabel } from "@goauthentik/common/labels";
|
||||
import { getRelativeTime } from "@goauthentik/common/utils";
|
||||
import { formatElapsedTime } from "@goauthentik/common/temporal";
|
||||
import "@goauthentik/components/ak-status-label";
|
||||
import "@goauthentik/elements/buttons/Dropdown";
|
||||
import "@goauthentik/elements/buttons/TokenCopyButton";
|
||||
@ -107,7 +107,7 @@ export class TokenListPage extends TablePage<Token> {
|
||||
html`<a href="#/identity/users/${item.userObj?.pk}">${item.userObj?.username}</a>`,
|
||||
html`<ak-status-label type="warning" ?good=${item.expiring}></ak-status-label>`,
|
||||
html`${item.expires && item.expiring
|
||||
? html`<div>${getRelativeTime(item.expires)}</div>
|
||||
? html`<div>${formatElapsedTime(item.expires)}</div>
|
||||
<small>${item.expires.toLocaleString()}</small>`
|
||||
: msg("-")}`,
|
||||
html`${intentToLabel(item.intent ?? IntentEnum.Api)}`,
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
||||
import { dateTimeLocal } from "@goauthentik/common/utils";
|
||||
import { dateTimeLocal } from "@goauthentik/common/temporal";
|
||||
import { Form } from "@goauthentik/elements/forms/Form";
|
||||
import "@goauthentik/elements/forms/HorizontalFormElement";
|
||||
import { ModalForm } from "@goauthentik/elements/forms/ModalForm";
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
||||
import { deviceTypeName } from "@goauthentik/common/labels";
|
||||
import { SentryIgnoredError } from "@goauthentik/common/sentry";
|
||||
import { getRelativeTime } from "@goauthentik/common/utils";
|
||||
import { formatElapsedTime } from "@goauthentik/common/temporal";
|
||||
import "@goauthentik/elements/forms/DeleteBulkForm";
|
||||
import { PaginatedResponse } from "@goauthentik/elements/table/Table";
|
||||
import { Table, TableColumn } from "@goauthentik/elements/table/Table";
|
||||
@ -108,15 +108,15 @@ export class UserDeviceTable extends Table<Device> {
|
||||
${item.extraDescription ? ` - ${item.extraDescription}` : ""}`,
|
||||
html`${item.confirmed ? msg("Yes") : msg("No")}`,
|
||||
html`${item.created.getTime() > 0
|
||||
? html`<div>${getRelativeTime(item.created)}</div>
|
||||
? html`<div>${formatElapsedTime(item.created)}</div>
|
||||
<small>${item.created.toLocaleString()}</small>`
|
||||
: html`-`}`,
|
||||
html`${item.lastUpdated
|
||||
? html`<div>${getRelativeTime(item.lastUpdated)}</div>
|
||||
? html`<div>${formatElapsedTime(item.lastUpdated)}</div>
|
||||
<small>${item.lastUpdated.toLocaleString()}</small>`
|
||||
: html`-`}`,
|
||||
html`${item.lastUsed
|
||||
? html`<div>${getRelativeTime(item.lastUsed)}</div>
|
||||
? html`<div>${formatElapsedTime(item.lastUsed)}</div>
|
||||
<small>${item.lastUsed.toLocaleString()}</small>`
|
||||
: html`-`}`,
|
||||
];
|
||||
|
||||
@ -10,9 +10,9 @@ import { PFSize } from "@goauthentik/common/enums.js";
|
||||
import { parseAPIResponseError } from "@goauthentik/common/errors/network";
|
||||
import { userTypeToLabel } from "@goauthentik/common/labels";
|
||||
import { MessageLevel } from "@goauthentik/common/messages";
|
||||
import { formatElapsedTime } from "@goauthentik/common/temporal";
|
||||
import { DefaultUIConfig, uiConfig } from "@goauthentik/common/ui/config";
|
||||
import { me } from "@goauthentik/common/users";
|
||||
import { getRelativeTime } from "@goauthentik/common/utils";
|
||||
import "@goauthentik/components/ak-status-label";
|
||||
import { rootInterface } from "@goauthentik/elements/Base";
|
||||
import { WithBrandConfig } from "@goauthentik/elements/Interface/brandProvider";
|
||||
@ -244,7 +244,7 @@ export class UserListPage extends WithBrandConfig(WithCapabilitiesConfig(TablePa
|
||||
</a>`,
|
||||
html`<ak-status-label ?good=${item.isActive}></ak-status-label>`,
|
||||
html`${item.lastLogin
|
||||
? html`<div>${getRelativeTime(item.lastLogin)}</div>
|
||||
? html`<div>${formatElapsedTime(item.lastLogin)}</div>
|
||||
<small>${item.lastLogin.toLocaleString()}</small>`
|
||||
: msg("-")}`,
|
||||
html`${userTypeToLabel(item.type)}`,
|
||||
|
||||
@ -15,8 +15,8 @@ import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
||||
import { EVENT_REFRESH } from "@goauthentik/common/constants";
|
||||
import { PFSize } from "@goauthentik/common/enums.js";
|
||||
import { userTypeToLabel } from "@goauthentik/common/labels";
|
||||
import { formatElapsedTime } from "@goauthentik/common/temporal";
|
||||
import { me } from "@goauthentik/common/users";
|
||||
import { getRelativeTime } from "@goauthentik/common/utils";
|
||||
import "@goauthentik/components/DescriptionList";
|
||||
import {
|
||||
type DescriptionPair,
|
||||
@ -155,11 +155,11 @@ export class UserViewPage extends WithCapabilitiesConfig(AKElement) {
|
||||
[msg("Name"), user.name],
|
||||
[msg("Email"), user.email || "-"],
|
||||
[msg("Last login"), user.lastLogin
|
||||
? html`<div>${getRelativeTime(user.lastLogin)}</div>
|
||||
? html`<div>${formatElapsedTime(user.lastLogin)}</div>
|
||||
<small>${user.lastLogin.toLocaleString()}</small>`
|
||||
: html`${msg("-")}`],
|
||||
[msg("Last password change"), user.passwordChangeDate
|
||||
? html`<div>${getRelativeTime(user.passwordChangeDate)}</div>
|
||||
? html`<div>${formatElapsedTime(user.passwordChangeDate)}</div>
|
||||
<small>${user.passwordChangeDate.toLocaleString()}</small>`
|
||||
: html`${msg("-")}`],
|
||||
[msg("Active"), html`<ak-status-label type="warning" ?good=${user.isActive}></ak-status-label>`],
|
||||
|
||||
Reference in New Issue
Block a user