Merge pull request #600 from benphelps/fix-444

Feature: Add default interval setting for coinmarketcap
pull/609/head
Jason Fischer 2 years ago committed by GitHub
commit 01704ec38b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -118,6 +118,7 @@ export function cleanServiceGroups(groups) {
container, container,
currency, // coinmarketcap widget currency, // coinmarketcap widget
symbols, symbols,
defaultinterval
} = cleanedService.widget; } = cleanedService.widget;
cleanedService.widget = { cleanedService.widget = {
@ -129,6 +130,7 @@ export function cleanServiceGroups(groups) {
if (currency) cleanedService.widget.currency = currency; if (currency) cleanedService.widget.currency = currency;
if (symbols) cleanedService.widget.symbols = symbols; if (symbols) cleanedService.widget.symbols = symbols;
if (defaultinterval) cleanedService.widget.defaultinterval = defaultinterval;
if (type === "docker") { if (type === "docker") {
if (server) cleanedService.widget.server = server; if (server) cleanedService.widget.server = server;

@ -17,11 +17,12 @@ export default function Component({ service }) {
{ label: t("coinmarketcap.30days"), value: "30d" }, { label: t("coinmarketcap.30days"), value: "30d" },
]; ];
const [dateRange, setDateRange] = useState(dateRangeOptions[0].value);
const { widget } = service; const { widget } = service;
const { symbols } = widget; const { symbols } = widget;
const currencyCode = widget.currency ?? "USD"; const currencyCode = widget.currency ?? "USD";
const interval = widget.defaultinterval ?? dateRangeOptions[0].value;
const [dateRange, setDateRange] = useState(interval);
const { data: statsData, error: statsError } = useWidgetAPI(widget, "v1/cryptocurrency/quotes/latest", { const { data: statsData, error: statsError } = useWidgetAPI(widget, "v1/cryptocurrency/quotes/latest", {
symbol: `${symbols.join(",")}`, symbol: `${symbols.join(",")}`,

Loading…
Cancel
Save