fix: use new endpoint to fetch instance owner
This commit is contained in:
parent
014a476177
commit
e0b950f1c4
@ -13,6 +13,7 @@ function Immersion() {
|
||||
const [allInstances, setAllInstances] = useState<Instance[]>([]);
|
||||
const [instancesStatus, setInstancesStatus] = useState<Record<number, string>>({});
|
||||
const [containerStatus, setContainerStatus] = useState<string>("");
|
||||
const [instancesOwner, setInstancesOwner] = useState<string>("");
|
||||
const username = localStorage.getItem("username");
|
||||
|
||||
const copyText = (copy: string) => {
|
||||
@ -35,6 +36,21 @@ function Immersion() {
|
||||
});
|
||||
}, [id]);
|
||||
|
||||
useEffect(() => {
|
||||
axios.get(`/api/ji/${id}/all-instances`).then((res) => {
|
||||
setAllInstances(res.data);
|
||||
// Récupérer l owner de chaque instance
|
||||
res.data.forEach((inst: Instance) => {
|
||||
axios.get(`/api/ji/${id}/instance-owner?instId=${inst.id}`).then((ownerRes) => {
|
||||
setInstancesOwner(prev => ({
|
||||
...prev,
|
||||
[inst.id]: ownerRes.data
|
||||
}));
|
||||
});
|
||||
});
|
||||
});
|
||||
}, [id]);
|
||||
|
||||
useEffect(() => {
|
||||
axios.get(`/api/ji/${id}/all-instances`).then((res) => {
|
||||
setAllInstances(res.data);
|
||||
@ -328,7 +344,11 @@ function Immersion() {
|
||||
<td className="p-4">{index + 1}</td>
|
||||
<td className="p-4">{inst.name}</td>
|
||||
<td className="p-4">{inst.port}</td>
|
||||
<td className="p-4">{username}</td>
|
||||
<td className="p-4">
|
||||
<span className="badge badge-primary">
|
||||
{instancesOwner[inst.id] || "Loading..."}
|
||||
</span>
|
||||
</td>
|
||||
<td className="p-4">
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="font-mono">{inst.password}</span>
|
||||
@ -349,7 +369,7 @@ function Immersion() {
|
||||
<div className="flex gap-2">
|
||||
<button
|
||||
className="btn btn-sm btn-primary"
|
||||
onClick={() => copyText(`ssh -p ${inst.port} ${username}@la-banquise.fr`)}
|
||||
onClick={() => copyText(`ssh -p ${inst.port} ${instancesOwner[inst.id] || "Loading..."}@la-banquise.fr`)}
|
||||
>
|
||||
Copy SSH
|
||||
</button>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user