Skip to content

Commit 7d26f9e

Browse files
committed
humanizeDuration on cnpg index
1 parent faf5fcd commit 7d26f9e

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

src/routes/cloud/cnpg/index.tsx

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { cache, createAsync, A, type RouteDefinition } from "@solidjs/router";
66
import { getUser } from "~/lib/auth";
77
import { StatusBadge } from "~/components/cloud/service/StatusBadge";
88
import { cnpg } from "~/lib/k8s";
9+
import humanizeDuration from "humanize-duration";
910

1011
const getDBs = cache(async () => {
1112
"use server";
@@ -68,11 +69,24 @@ export default () => {
6869
/>
6970
</td>
7071
<td>
71-
{new Date(
72-
db.status.conditions.find(
73-
(condition) => condition.type === "Ready"
74-
).lastTransitionTime
75-
).toLocaleString()}
72+
<div
73+
class="tooltip"
74+
data-tip={new Date(
75+
db.status.conditions.find(
76+
(condition) => condition.type === "Ready"
77+
)?.lastTransitionTime
78+
).toLocaleString()}
79+
>
80+
{humanizeDuration(
81+
new Date(
82+
db.status.conditions.find(
83+
(condition) => condition.type === "Ready"
84+
)?.lastTransitionTime
85+
).getTime() - Date.now(),
86+
{ round: true, largest: 1 }
87+
)}{" "}
88+
ago
89+
</div>
7690
</td>
7791
<td class="hidden md:block">{db.spec.imageName}</td>
7892
<td>

0 commit comments

Comments
 (0)