From 3b06aee76705465695a7aa3d15a2ce868b251e94 Mon Sep 17 00:00:00 2001 From: BrunoQuaresma Date: Tue, 21 May 2024 17:05:44 +0000 Subject: [PATCH 1/2] Improve format time --- .../TemplateInsightsPage.tsx | 37 +++++++++++++------ 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/site/src/pages/TemplatePage/TemplateInsightsPage/TemplateInsightsPage.tsx b/site/src/pages/TemplatePage/TemplateInsightsPage/TemplateInsightsPage.tsx index 5839fb044941e..dce892ad94caf 100644 --- a/site/src/pages/TemplatePage/TemplateInsightsPage/TemplateInsightsPage.tsx +++ b/site/src/pages/TemplatePage/TemplateInsightsPage/TemplateInsightsPage.tsx @@ -869,20 +869,35 @@ const TextValue: FC = ({ children }) => { }; function formatTime(seconds: number): string { - if (seconds < 60) { - return seconds + " seconds"; - } else if (seconds >= 60 && seconds < 3600) { - const minutes = Math.floor(seconds / 60); - return minutes + " minutes"; + let value: { + amount: number; + unit: "seconds" | "minutes" | "hours"; + } = { + amount: seconds, + unit: "seconds", + }; + + if (seconds >= 60 && seconds < 3600) { + value = { + amount: Math.floor(seconds / 60), + unit: "minutes", + }; } else { - const hours = seconds / 3600; - const minutes = Math.floor(seconds % 3600); - if (minutes === 0) { - return hours.toFixed(0) + " hours"; - } + value = { + amount: seconds / 3600, + unit: "hours", + }; + } - return hours.toFixed(1) + " hours"; + if (value.amount === 1) { + const singularUnit = value.unit.slice(0, -1); + return `${value.amount} ${singularUnit}`; } + + return `${value.amount.toLocaleString(undefined, { + maximumFractionDigits: 1, + minimumFractionDigits: 0, + })} ${value.unit}`; } function toISOLocal(d: Date, offset: number) { From 25bfa9f32e1ccc5e60852de3624cf8a3c6630f56 Mon Sep 17 00:00:00 2001 From: BrunoQuaresma Date: Tue, 21 May 2024 17:18:13 +0000 Subject: [PATCH 2/2] Add open x times in the usage --- .../TemplateInsightsPage.tsx | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/site/src/pages/TemplatePage/TemplateInsightsPage/TemplateInsightsPage.tsx b/site/src/pages/TemplatePage/TemplateInsightsPage/TemplateInsightsPage.tsx index dce892ad94caf..7e824b140edd6 100644 --- a/site/src/pages/TemplatePage/TemplateInsightsPage/TemplateInsightsPage.tsx +++ b/site/src/pages/TemplatePage/TemplateInsightsPage/TemplateInsightsPage.tsx @@ -52,6 +52,7 @@ import { HelpTooltipTrigger, } from "components/HelpTooltip/HelpTooltip"; import { Loader } from "components/Loader/Loader"; +import { Stack } from "components/Stack/Stack"; import { UserAvatar } from "components/UserAvatar/UserAvatar"; import { useEmbeddedMetadata } from "hooks/useEmbeddedMetadata"; import { useTemplateLayoutContext } from "pages/TemplatePage/TemplateLayout"; @@ -451,7 +452,7 @@ const TemplateUsagePanel: FC = ({ return (
= ({ }, }} /> -
{formatTime(usage.seconds)} -
+ + Opened {usage.times_used.toLocaleString()}{" "} + {usage.times_used === 1 ? "time" : "times"} + +
); })} pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy