diff --git a/public/locales/de/common.json b/public/locales/de/common.json index bbb5ff66..2198488c 100644 --- a/public/locales/de/common.json +++ b/public/locales/de/common.json @@ -109,8 +109,12 @@ "downloaded": "Downloaded" }, "coinmarketcap": { - "configure": "Configure one or more crypto currencies to track" - }, + "configure": "Configure one or more crypto currencies to track", + "1hour": "1 Hour", + "1day": "1 Day", + "7days": "7 Days", + "30days": "30 Days" + }, "gotify": { "apps": "Applications", "clients": "Clients", diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 5fbaaf21..60bfef6b 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -126,7 +126,11 @@ "total": "Total" }, "coinmarketcap": { - "configure": "Configure one or more crypto currencies to track" + "configure": "Configure one or more crypto currencies to track", + "1hour": "1 Hour", + "1day": "1 Day", + "7days": "7 Days", + "30days": "30 Days" }, "gotify": { "apps": "Applications", diff --git a/public/locales/es/common.json b/public/locales/es/common.json index d61bda0e..b9f928fb 100644 --- a/public/locales/es/common.json +++ b/public/locales/es/common.json @@ -109,8 +109,12 @@ "downloaded": "Descargado" }, "coinmarketcap": { - "configure": "Configurar una o varias criptomonedas para su seguimiento" - }, + "configure": "Configure one or more crypto currencies to track", + "1hour": "1 Hour", + "1day": "1 Day", + "7days": "7 Days", + "30days": "30 Days" + }, "gotify": { "apps": "Aplicaciones", "clients": "Clientes", diff --git a/public/locales/fr/common.json b/public/locales/fr/common.json index 924d88a6..0f3cc5e3 100644 --- a/public/locales/fr/common.json +++ b/public/locales/fr/common.json @@ -120,8 +120,12 @@ "rate": "Évaluer" }, "coinmarketcap": { - "configure": "Configurer une ou plusieurs crypto-monnaies à suivre" - }, + "configure": "Configure one or more crypto currencies to track", + "1hour": "1 Hour", + "1day": "1 Day", + "7days": "7 Days", + "30days": "30 Days" + }, "gotify": { "apps": "Applications", "clients": "Clients", diff --git a/public/locales/it/common.json b/public/locales/it/common.json index 585aae1e..0d53c8cb 100644 --- a/public/locales/it/common.json +++ b/public/locales/it/common.json @@ -109,8 +109,12 @@ "downloaded": "Downloaded" }, "coinmarketcap": { - "configure": "Configure one or more crypto currencies to track" - }, + "configure": "Configure one or more crypto currencies to track", + "1hour": "1 Hour", + "1day": "1 Day", + "7days": "7 Days", + "30days": "30 Days" + }, "gotify": { "apps": "Applications", "clients": "Clients", diff --git a/public/locales/nb-NO/common.json b/public/locales/nb-NO/common.json index 141378e8..62f6fa33 100644 --- a/public/locales/nb-NO/common.json +++ b/public/locales/nb-NO/common.json @@ -109,8 +109,12 @@ "remaining": "Gjenstående" }, "coinmarketcap": { - "configure": "Sett opp én eller flere kryptovalutaer å holde øye med" - }, + "configure": "Configure one or more crypto currencies to track", + "1hour": "1 Hour", + "1day": "1 Day", + "7days": "7 Days", + "30days": "30 Days" + }, "gotify": { "apps": "Programmer", "clients": "Klienter", diff --git a/public/locales/nl/common.json b/public/locales/nl/common.json index d2975cd2..6ca2a79b 100644 --- a/public/locales/nl/common.json +++ b/public/locales/nl/common.json @@ -109,8 +109,12 @@ "downloaded": "Downloaded" }, "coinmarketcap": { - "configure": "Configure one or more crypto currencies to track" - }, + "configure": "Configure one or more crypto currencies to track", + "1hour": "1 Hour", + "1day": "1 Day", + "7days": "7 Days", + "30days": "30 Days" + }, "gotify": { "apps": "Applications", "clients": "Clients", diff --git a/public/locales/pt/common.json b/public/locales/pt/common.json index 4dafc19f..eb18e087 100644 --- a/public/locales/pt/common.json +++ b/public/locales/pt/common.json @@ -120,8 +120,12 @@ "downloaded": "Downloaded" }, "coinmarketcap": { - "configure": "Configure one or more crypto currencies to track" - }, + "configure": "Configure one or more crypto currencies to track", + "1hour": "1 Hour", + "1day": "1 Day", + "7days": "7 Days", + "30days": "30 Days" + }, "gotify": { "apps": "Aplicações", "clients": "Clientes", diff --git a/public/locales/ru/common.json b/public/locales/ru/common.json index 0f4ae8af..a35c8869 100644 --- a/public/locales/ru/common.json +++ b/public/locales/ru/common.json @@ -109,8 +109,12 @@ "downloaded": "Downloaded" }, "coinmarketcap": { - "configure": "Configure one or more crypto currencies to track" - }, + "configure": "Configure one or more crypto currencies to track", + "1hour": "1 Hour", + "1day": "1 Day", + "7days": "7 Days", + "30days": "30 Days" + }, "gotify": { "apps": "Applications", "clients": "Clients", diff --git a/public/locales/vi/common.json b/public/locales/vi/common.json index ab6122f7..4572e4c7 100644 --- a/public/locales/vi/common.json +++ b/public/locales/vi/common.json @@ -109,8 +109,12 @@ "downloaded": "Downloaded" }, "coinmarketcap": { - "configure": "Configure one or more crypto currencies to track" - }, + "configure": "Configure one or more crypto currencies to track", + "1hour": "1 Hour", + "1day": "1 Day", + "7days": "7 Days", + "30days": "30 Days" + }, "gotify": { "apps": "Applications", "clients": "Clients", diff --git a/public/locales/zh-CN/common.json b/public/locales/zh-CN/common.json index b324f35b..ba4f896b 100644 --- a/public/locales/zh-CN/common.json +++ b/public/locales/zh-CN/common.json @@ -109,8 +109,12 @@ "downloaded": "下载" }, "coinmarketcap": { - "configure": "配置一个或多个需要追踪的加密" - }, + "configure": "Configure one or more crypto currencies to track", + "1hour": "1 Hour", + "1day": "1 Day", + "7days": "7 Days", + "30days": "30 Days" + }, "gotify": { "apps": "应用", "clients": "客户端", diff --git a/public/locales/zh-Hant/common.json b/public/locales/zh-Hant/common.json index 63df5369..c02d976c 100644 --- a/public/locales/zh-Hant/common.json +++ b/public/locales/zh-Hant/common.json @@ -114,8 +114,12 @@ "total": "Total" }, "coinmarketcap": { - "configure": "Configure one or more crypto currencies to track" - }, + "configure": "Configure one or more crypto currencies to track", + "1hour": "1 Hour", + "1day": "1 Day", + "7days": "7 Days", + "30days": "30 Days" + }, "prowlarr": { "enableIndexers": "Indexers", "numberOfGrabs": "Grabs", diff --git a/src/components/services/dropdown.jsx b/src/components/services/dropdown.jsx new file mode 100644 index 00000000..c7aad96e --- /dev/null +++ b/src/components/services/dropdown.jsx @@ -0,0 +1,44 @@ +import { Fragment } from "react"; +import { Menu, Transition } from "@headlessui/react"; +import { BiCog } from "react-icons/bi"; + +export default function Dropdown({ options, state }) { + return ( + +
+ + {state.value.label} + +
+ + + +
+ {options.map((i) => ( + + + + ))} +
+
+
+
+ ); +} diff --git a/src/components/services/item.jsx b/src/components/services/item.jsx index 2d50276e..dbdd0f01 100644 --- a/src/components/services/item.jsx +++ b/src/components/services/item.jsx @@ -1,9 +1,11 @@ import Image from "next/future/image"; import { Disclosure } from "@headlessui/react"; +import { useState } from "react"; import Status from "./status"; import Widget from "./widget"; import Docker from "./widgets/service/docker"; +import Dropdown from "./dropdown"; function resolveIcon(icon) { if (icon.startsWith("http")) { @@ -28,6 +30,19 @@ export default function Item({ service }) { } }; + const cmcValues = [ + { label: "1 Hour", value: "1h" }, + { label: "1 Day", value: "24h" }, + { label: "7 Days", value: "7d" }, + { label: "30 Days", value: "30d" }, + ]; + + const [cmcV, cmcSet] = useState(cmcValues[0]); + + const states = { + coinmarketcap: { value: cmcV, set: cmcSet }, + }; + const hasLink = service.href && service.href !== "#"; return ( @@ -82,6 +97,7 @@ export default function Item({ service }) { )} + {service?.widget?.type === "coinmarketcap" && } @@ -90,7 +106,7 @@ export default function Item({ service }) { - {service.widget && } + {service.widget && } diff --git a/src/components/services/widget.jsx b/src/components/services/widget.jsx index d2c8fbf7..415b24f3 100644 --- a/src/components/services/widget.jsx +++ b/src/components/services/widget.jsx @@ -45,16 +45,16 @@ const widgetMappings = { npm: Npm, tautulli: Tautulli, gotify: Gotify, - prowlarr: Prowlarr + prowlarr: Prowlarr, }; -export default function Widget({ service }) { +export default function Widget({ service, state }) { const { t } = useTranslation("common"); const ServiceWidget = widgetMappings[service.widget.type]; if (ServiceWidget) { - return ; + return ; } return ( diff --git a/src/components/services/widgets/service/coinmarketcap.jsx b/src/components/services/widgets/service/coinmarketcap.jsx index c5e66ebc..5262eb02 100644 --- a/src/components/services/widgets/service/coinmarketcap.jsx +++ b/src/components/services/widgets/service/coinmarketcap.jsx @@ -1,13 +1,12 @@ import useSWR from "swr"; import { useTranslation } from "react-i18next"; -import getSymbolFromCurrency from "currency-symbol-map"; import Widget from "../widget"; import Block from "../block"; import { formatApiUrl } from "utils/api-helpers"; -export default function CoinMarketCap({ service }) { +export default function CoinMarketCap({ service, state }) { const { t } = useTranslation(); const config = service.widget; @@ -39,7 +38,6 @@ export default function CoinMarketCap({ service }) { } const { data } = statsData; - const currencySymbol = getSymbolFromCurrency(currencyCode); return ( @@ -52,15 +50,20 @@ export default function CoinMarketCap({ service }) {
{data[key].name}
- {currencySymbol} - {data[key].quote[currencyCode].price.toFixed(2)} + {t("common.number", { + value: data[key].quote[currencyCode].price, + style: "currency", + currency: currencyCode, + })}
0 ? "text-emerald-300" : "text-rose-300" + data[key].quote[currencyCode][`percent_change_${state.value.value}`] > 0 + ? "text-emerald-300" + : "text-rose-300" }`} > - {data[key].quote[currencyCode].percent_change_1h.toFixed(2)}% + {data[key].quote[currencyCode][`percent_change_${state.value.value}`].toFixed(2)}%