Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Noryev/fix webui #122

Merged
merged 2 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/info-dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"start": "next start",
"lint": "next lint",
"test": "vitest",
"preview": "pnpm dlx http-server out"
"preview": "pnpm dlx http-server out",
"boot": "doppler run --preserve-env --command=\"pnpm i && pnpm -r build\""
},
"dependencies": {
"@floating-ui/react": "^0.26.17",
Expand Down
19 changes: 15 additions & 4 deletions apps/info-dashboard/src/lib/fetchers/leaderboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,21 @@ import {
import { NodesEndpointReturnType } from "./nodes";

export async function fetchLeaderboard() {
const API_HOST = process.env.NEXT_PUBLIC_API_HOST;
const leaderboard_url = `${API_HOST}metrics-dashboard/leaderboard`;
const raw = await fetch(leaderboard_url);
return (await raw.json()) as LeaderboardReturnType;
// Add default value and trim any trailing slashes
const API_HOST = (process.env.NEXT_PUBLIC_API_HOST || '').replace(/\/$/, '');
// Add error handling and logging
try {
const leaderboard_url = `${API_HOST}/metrics-dashboard/leaderboard`;
console.log('Fetching from:', leaderboard_url); // Debug log
const raw = await fetch(leaderboard_url);
if (!raw.ok) {
throw new Error(`HTTP error! status: ${raw.status}`);
}
return (await raw.json()) as LeaderboardReturnType;
} catch (error) {
console.error('Error fetching leaderboard:', error);
throw error;
}
}

export function toTableData({
Expand Down
19 changes: 14 additions & 5 deletions apps/info-dashboard/src/lib/fetchers/nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,20 @@ export type NodesEndpointReturnElement = {
export type NodesEndpointReturnType = NodesEndpointReturnElement[];

export async function fetchNodes() {
const API_HOST = process.env.NEXT_PUBLIC_API_HOST;
const URL = `${API_HOST}metrics-dashboard/nodes`;
const raw = await fetch(URL);
const res = (await raw.json()) as NodesEndpointReturnType;
return res;
const API_HOST = (process.env.NEXT_PUBLIC_API_HOST || '').replace(/\/$/, '');
try {
const URL = `${API_HOST}/metrics-dashboard/nodes`;
console.log('Fetching nodes from:', URL); // Debug log
const raw = await fetch(URL);
if (!raw.ok) {
throw new Error(`HTTP error! status: ${raw.status}`);
}
const res = (await raw.json()) as NodesEndpointReturnType;
return res;
} catch (error) {
console.error('Error fetching nodes:', error);
throw error;
}
}

export function toGeoJson(data: NodesEndpointReturnType) {
Expand Down
102 changes: 102 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.