src/components/PodTree.tsx hinzugefügt
This commit is contained in:
@@ -0,0 +1,37 @@
|
|||||||
|
import React, { useEffect, useState } from "react";
|
||||||
|
import { fetchPods } from "../api";
|
||||||
|
|
||||||
|
export default function PodTree({ namespace, onSelect }) {
|
||||||
|
const [pods, setPods] = useState([]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
fetchPods(namespace).then((d) => setPods(d.items || []));
|
||||||
|
}, [namespace]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div style={{ marginTop: 10 }}>
|
||||||
|
{pods.map((pod) => (
|
||||||
|
<div key={pod.metadata.name}>
|
||||||
|
<b>{pod.metadata.name}</b>
|
||||||
|
|
||||||
|
<div style={{ marginLeft: 10 }}>
|
||||||
|
{(pod.spec.containers || []).map((c) => (
|
||||||
|
<div
|
||||||
|
key={c.name}
|
||||||
|
style={{ cursor: "pointer", color: "#aaa" }}
|
||||||
|
onClick={() =>
|
||||||
|
onSelect({
|
||||||
|
pod: pod.metadata.name,
|
||||||
|
container: c.name
|
||||||
|
})
|
||||||
|
}
|
||||||
|
>
|
||||||
|
└ {c.name}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user