Skip to content
Merged

Dev #70

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
24 changes: 11 additions & 13 deletions client/src/components/ClusterSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ import {
SelectValue,
} from '@/components/ui/select';
import { useCluster } from '@/contexts/ClusterContext';
import { ServerIcon, MapPinIcon } from 'lucide-react';
import { ServerIcon } from 'lucide-react';

const ClusterSelector: React.FC = () => {
const { clusters, selectedCluster, setSelectedCluster, loading } = useCluster();
const { clusters, selectedCluster, setSelectedCluster, loading } =
useCluster();

if (loading) {
return (
<div className="flex items-center gap-2 text-sm text-muted-foreground">
<div className="text-muted-foreground flex items-center gap-2 text-sm">
<ServerIcon className="h-4 w-4" />
Loading clusters...
</div>
Expand All @@ -23,7 +24,7 @@ const ClusterSelector: React.FC = () => {

if (clusters.length === 0) {
return (
<div className="flex items-center gap-2 text-sm text-muted-foreground">
<div className="text-muted-foreground flex items-center gap-2 text-sm">
<ServerIcon className="h-4 w-4" />
No clusters available
</div>
Expand All @@ -32,21 +33,23 @@ const ClusterSelector: React.FC = () => {

const handleClusterChange = (value: string) => {
const [name, location] = value.split('|');
const cluster = clusters.find(c => c.name === name && c.location === location);
const cluster = clusters.find(
(c) => c.name === name && c.location === location,
);
if (cluster) {
setSelectedCluster(cluster);
}
};

const selectedValue = selectedCluster
const selectedValue = selectedCluster
? `${selectedCluster.name}|${selectedCluster.location}`
: '';

return (
<div className="flex items-center gap-3">
<div className="flex items-center gap-2 text-sm font-medium">
<ServerIcon className="h-4 w-4 text-primary" />
<span>Cluster:</span>
<ServerIcon className="text-primary h-4 w-4" />
<span>Connected to</span>
</div>
<Select value={selectedValue} onValueChange={handleClusterChange}>
<SelectTrigger className="w-[280px]">
Expand All @@ -60,10 +63,6 @@ const ClusterSelector: React.FC = () => {
<div className="flex items-center gap-2">
<div className="flex flex-col">
<span className="font-medium">{cluster.name}</span>
<div className="flex items-center gap-1 text-xs text-muted-foreground">
<MapPinIcon className="h-3 w-3" />
{cluster.location}
</div>
</div>
</div>
</SelectItem>
Expand All @@ -76,4 +75,3 @@ const ClusterSelector: React.FC = () => {
};

export default ClusterSelector;

7 changes: 6 additions & 1 deletion client/src/components/EnhancedInfoCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
NetworkIcon,
ServerIcon,
Activity,
MapPinIcon,
} from 'lucide-react';
import { useFetchMetrics } from '../hooks/hookMetric';
import { motion } from 'motion/react';
Expand Down Expand Up @@ -43,7 +44,11 @@ const StatusBadge = ({ status }: { status: string }) => {
};

const GKEClusterCard: React.FC = () => {
const { selectedCluster: cluster, loading: clusterLoading, error } = useCluster();
const {
selectedCluster: cluster,
loading: clusterLoading,
error,
} = useCluster();

const cpuMetric = 'kubernetes.io/container/cpu/limit_utilization';
const memMetric = 'kubernetes.io/container/memory/request_utilization';
Expand Down