From 58c7fb15ea2bfa27167189f221f72a350ab37049 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luca=20Kr=C3=B6ger?= Date: Wed, 27 Sep 2023 13:24:10 +0200 Subject: [PATCH 1/5] add ping indicator style setting --- src/components/services/item.jsx | 4 +--- src/components/services/ping.jsx | 35 +++++++++++++++++++++++++------- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/components/services/item.jsx b/src/components/services/item.jsx index 6528a7b5c..aaee81cd1 100644 --- a/src/components/services/item.jsx +++ b/src/components/services/item.jsx @@ -29,8 +29,6 @@ export default function Item({ service, group }) { } }; - - return (
  • {service.ping && (
    - + Ping status
    )} diff --git a/src/components/services/ping.jsx b/src/components/services/ping.jsx index 27ea92eff..a14fa6602 100644 --- a/src/components/services/ping.jsx +++ b/src/components/services/ping.jsx @@ -1,7 +1,7 @@ import { useTranslation } from "react-i18next"; import useSWR from "swr"; -export default function Ping({ group, service }) { +export default function Ping({ group, service, style }) { const { t } = useTranslation(); const { data, error } = useSWR(`/api/ping?${new URLSearchParams({ group, service }).toString()}`, { refreshInterval: 30000 @@ -23,20 +23,41 @@ export default function Ping({ group, service }) { ); } - const statusText = `${service}: HTTP status ${data.status}`; - + var statusText = `HTTP status ${data.status}`; + var status; + if (data.status > 403) { + if (style === "basic") { + status = t("docker.offline") + } else if (style === "dot") { + status = "◉" + } else { + status = data.status + } + return (
    -
    {data.status}
    +
    {status}
    ); } - + + // Sucessful ping + var ping = t("common.ms", { value: data.latency, style: "unit", unit: "millisecond", maximumFractionDigits: 0 }) + + statusText += ` (${ping})`; + + if (style === "basic") { + status = t("docker.running") + } else if (style === "dot") { + status = "◉" + } else { + status = ping + } + return (
    -
    {t("common.ms", { value: data.latency, style: "unit", unit: "millisecond", maximumFractionDigits: 0 })}
    +
    {status}
    ); - } From 24825f90eaf00f8af75015ddba37a27c79280165 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luca=20Kr=C3=B6ger?= Date: Wed, 27 Sep 2023 13:31:39 +0200 Subject: [PATCH 2/5] fix some linter errors --- src/components/services/ping.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/services/ping.jsx b/src/components/services/ping.jsx index a14fa6602..d6fc61a4d 100644 --- a/src/components/services/ping.jsx +++ b/src/components/services/ping.jsx @@ -23,8 +23,8 @@ export default function Ping({ group, service, style }) { ); } - var statusText = `HTTP status ${data.status}`; - var status; + let statusText = `HTTP status ${data.status}`; + let status; if (data.status > 403) { if (style === "basic") { @@ -43,7 +43,7 @@ export default function Ping({ group, service, style }) { } // Sucessful ping - var ping = t("common.ms", { value: data.latency, style: "unit", unit: "millisecond", maximumFractionDigits: 0 }) + const ping = t("common.ms", { value: data.latency, style: "unit", unit: "millisecond", maximumFractionDigits: 0 }) statusText += ` (${ping})`; From 2df5baac9d114a338eba8e2e910653b60bbb1197 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luca=20Kr=C3=B6ger?= Date: Wed, 27 Sep 2023 22:07:38 +0200 Subject: [PATCH 3/5] new dot styling --- src/components/services/ping.jsx | 79 +++++++++++++++----------------- 1 file changed, 37 insertions(+), 42 deletions(-) diff --git a/src/components/services/ping.jsx b/src/components/services/ping.jsx index d6fc61a4d..7a5026a92 100644 --- a/src/components/services/ping.jsx +++ b/src/components/services/ping.jsx @@ -7,57 +7,52 @@ export default function Ping({ group, service, style }) { refreshInterval: 30000 }); - if (error) { - return ( -
    -
    {t("ping.error")}
    -
    - ); - } - - if (!data) { - return ( -
    -
    {t("ping.ping")}
    -
    - ); - } - - let statusText = `HTTP status ${data.status}`; - let status; + let textSize = "text-[8px]"; + let colorClass = "" + let backgroundClass = "bg-theme-500/10 dark:bg-theme-900/50"; + let statusTitle = "HTTP status"; + let statusText; - if (data.status > 403) { + if (error) { + colorClass = "text-rose-500" + statusText = t("ping.error") + statusTitle += " error" + } else if (!data) { + colorClass = "text-black/20 dark:text-white/40" + statusText = t("ping.ping") + statusTitle += " not available" + } else if (data.status > 403) { + colorClass = "text-rose-500/80" + statusTitle += ` ${data.status}` + if (style === "basic") { - status = t("docker.offline") + statusText = t("docker.offline") } else if (style === "dot") { - status = "◉" + statusText = "◉" + textSize += "text-[10px]" + backgroundClass = "" } else { - status = data.status + statusText = data.status } - - return ( -
    -
    {status}
    -
    - ); - } - - // Sucessful ping - const ping = t("common.ms", { value: data.latency, style: "unit", unit: "millisecond", maximumFractionDigits: 0 }) - - statusText += ` (${ping})`; - - if (style === "basic") { - status = t("docker.running") - } else if (style === "dot") { - status = "◉" } else { - status = ping + const ping = t("common.ms", { value: data.latency, style: "unit", unit: "millisecond", maximumFractionDigits: 0 }) + statusTitle += ` ${data.status} (${ping})`; + colorClass = "text-emerald-500/80" + + if (style === "basic") { + statusText = t("docker.running") + } else if (style === "dot") { + statusText = "◉" + textSize += "text-[10px]" + backgroundClass = "" + } else { + statusText = ping + } } return ( -
    -
    {status}
    +
    +
    {statusText}
    ); } From 12e6b3dabb2b1bbd71e87519a3312ce910b3621c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luca=20Kr=C3=B6ger?= Date: Thu, 28 Sep 2023 09:34:55 +0200 Subject: [PATCH 4/5] fix textsize bug --- src/components/services/ping.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/services/ping.jsx b/src/components/services/ping.jsx index 7a5026a92..de56ce516 100644 --- a/src/components/services/ping.jsx +++ b/src/components/services/ping.jsx @@ -24,12 +24,12 @@ export default function Ping({ group, service, style }) { } else if (data.status > 403) { colorClass = "text-rose-500/80" statusTitle += ` ${data.status}` - + if (style === "basic") { statusText = t("docker.offline") } else if (style === "dot") { statusText = "◉" - textSize += "text-[10px]" + textSize = "text-[14px]" backgroundClass = "" } else { statusText = data.status @@ -43,7 +43,7 @@ export default function Ping({ group, service, style }) { statusText = t("docker.running") } else if (style === "dot") { statusText = "◉" - textSize += "text-[10px]" + textSize = "text-[14px]" backgroundClass = "" } else { statusText = ping From 89c5d69372f0d306f6990531805fe60315086045 Mon Sep 17 00:00:00 2001 From: Ben Phelps Date: Fri, 29 Sep 2023 08:00:53 +0300 Subject: [PATCH 5/5] statusStyle --- src/components/services/item.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/services/item.jsx b/src/components/services/item.jsx index aaee81cd1..056d5cfc3 100644 --- a/src/components/services/item.jsx +++ b/src/components/services/item.jsx @@ -79,7 +79,7 @@ export default function Item({ service, group }) {
    {service.ping && (
    - + Ping status
    )}