Skip to content

Commit

Permalink
Show statistics link if there are statistics for an adapter
Browse files Browse the repository at this point in the history
Closes #71
  • Loading branch information
UncleSamSwiss committed Jan 10, 2025
1 parent e7280f0 commit e7919ec
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions express/frontend/src/tools/adapter/AdapterDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { CardButton } from "../../components/CardButton";
import { CardGrid, CardGridProps } from "../../components/dashboard/CardGrid";
import { DashboardCardProps } from "../../components/dashboard/DashboardCard";
import { useAdapter } from "../../contexts/AdapterContext";
import { getAllRatings, getLatest } from "../../lib/ioBroker";
import { getAllRatings, getLatest, getStatistics } from "../../lib/ioBroker";

const CATEGORY_GENERAL = "General";
const CATEGORY_FEATURES = "Features";
Expand All @@ -32,6 +32,14 @@ export function AdapterDashboard() {
getLatest(),
getAllRatings(),
]);
let hasStatistics = !!latest[name];
if (!hasStatistics) {
// check if statistics are available
try {
await getStatistics(name);
hasStatistics = true;
} catch {}
}
const generalCards: DashboardCardProps[] = [];
generalCards.push({
title: "Releases",
Expand All @@ -43,7 +51,7 @@ export function AdapterDashboard() {
to: "releases",
buttons: [<CardButton text="Manage" to="releases" />],
});
if (latest[name]) {
if (hasStatistics) {
generalCards.push({
title: "Statistics",
text: "Learn more about the usage and distribution of your adapter.",
Expand Down

0 comments on commit e7919ec

Please sign in to comment.