Skip to content

Dev #48

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

Merged
merged 2 commits into from
Jun 4, 2025
Merged

Dev #48

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
15 changes: 11 additions & 4 deletions client/src/components/InfoCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@

import { useEffect, useState } from 'react';
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
import { CpuIcon, HardHatIcon, MemoryStickIcon, NetworkIcon, ServerIcon } from 'lucide-react';
import {
CpuIcon,
HardHatIcon,
MemoryStickIcon,
NetworkIcon,
ServerIcon,
} from 'lucide-react';
import { useFetchMetrics } from '../hooks/hookMetric';
import axios from 'axios';

const duration = 5;

interface ClusterInfo {
interface ClusterInfo {
name: string;
location: string;
status: string;
Expand All @@ -25,7 +31,8 @@ const useClusterInfo = () => {
const fetchCluster = async () => {
setLoading(true);
try {
const res = await axios.get<ClusterInfo>('/api/gke/cluster');
const baseUrl = import.meta.env.VITE_API_URL || '';
const res = await axios.get<ClusterInfo>(`${''}/api/gke/cluster`);
setData(res.data);
} catch (err) {
setError(`Failed to fetch cluster info, ${err}`);
Expand Down Expand Up @@ -63,7 +70,7 @@ const GKEClusterCard: React.FC = () => {
const memVal = memData?.[0]?.points?.[0]?.value?.doubleValue;

if (cpuVal != null) setCpu(`${(cpuVal * 100).toFixed(2)}%`);
if (memVal != null) setMemory(`${(memVal).toFixed(2)}%`);
if (memVal != null) setMemory(`${memVal.toFixed(2)}%`);
}, [cpuData, memData]);

if (clusterLoading) return <p>Loading cluster info...</p>;
Expand Down
10 changes: 4 additions & 6 deletions client/src/hooks/hookMetric.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,10 @@ export const useFetchMetrics = (metricType: string, duration: number) => {
const fetchData = async () => {
setLoading(true);
try {
const res = await axios.get<TimeSeries[]>(
`${import.meta.env.VITE_API_URL}/api/metrics`,
{
params: { metricType, duration },
},
);
const baseUrl = import.meta.env.VITE_API_URL || '';
const res = await axios.get<TimeSeries[]>(`${baseUrl}/api/metrics`, {
params: { metricType, duration },
});
setData(res.data);
} catch (err) {
setError(`Failed to fetch metrics, ${err}`);
Expand Down
1 change: 1 addition & 0 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"scripts": {
"dev": "nodemon --watch src --ext ts --exec vite-node src/index.ts",
"typecheck": "tsc --noEmit",
"prebuild": "rm -rf node_modules package-lock.json && npm install",
"build": "vite build",
"start": "node dist/index.js",
"test": "vitest run",
Expand Down