WIP: update: adaptations to use the new backend #1
@ -37,6 +37,14 @@ function Immersion() {
|
|||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
axios.get(`/api/ji/${id}/container`).then((res) => {
|
||||||
|
localStorage.setItem("container_status", res.data);
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const container_status = localStorage.getItem("container_status");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{ji && (
|
{ji && (
|
||||||
@ -70,9 +78,9 @@ function Immersion() {
|
|||||||
<span>SSH:</span>
|
<span>SSH:</span>
|
||||||
<div
|
<div
|
||||||
className="flex gap-2 items-center"
|
className="flex gap-2 items-center"
|
||||||
onClick={() => copyText("ssh -P {$instance.port} {$username}@la-banquise.fr")}
|
onClick={() => copyText(`ssh -p ${instance.port} ${username}@la-banquise.fr`)}
|
||||||
>
|
>
|
||||||
<span className="font-medium">ssh -P {instance.port} {username}@la-banquise.fr</span>
|
<span className="font-medium">ssh -p {instance.port} {username}@la-banquise.fr</span>
|
||||||
<div className="h-8 w-8 hover:bg-base-100 align-middle cursor-pointer flex items-center justify-center rounded">
|
<div className="h-8 w-8 hover:bg-base-100 align-middle cursor-pointer flex items-center justify-center rounded">
|
||||||
<ClipboardIcon className="size-6" />
|
<ClipboardIcon className="size-6" />
|
||||||
</div>
|
</div>
|
||||||
@ -80,28 +88,28 @@ function Immersion() {
|
|||||||
</li>
|
</li>
|
||||||
<li className="flex justify-between align-middle items-center">
|
<li className="flex justify-between align-middle items-center">
|
||||||
<span>Instance name:</span>
|
<span>Instance name:</span>
|
||||||
<div
|
<div className="flex gap-2 items-center" >
|
||||||
className="flex gap-2 items-center"
|
|
||||||
onClick={() => copyText(instance.name)}
|
|
||||||
>
|
|
||||||
<span className="font-medium">{instance.name}</span>
|
<span className="font-medium">{instance.name}</span>
|
||||||
<div className="h-8 w-8 hover:bg-base-100 align-middle cursor-pointer flex items-center justify-center rounded">
|
|
||||||
<ClipboardIcon className="size-6" />
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li className="flex justify-between align-middle items-center">
|
<li className="flex justify-between align-middle items-center">
|
||||||
<span>Password:</span>
|
<span>Password:</span>
|
||||||
<div
|
<div
|
||||||
className="flex gap-2 items-center"
|
className="flex gap-2 items-center"
|
||||||
onClick={() => copyText(ji.pwd)}
|
onClick={() => copyText(instance.pwd)}
|
||||||
>
|
>
|
||||||
<span className="font-normal">{ji.pwd}</span>
|
<span className="font-normal">{instance.pwd}</span>
|
||||||
<div className="h-8 w-8 hover:bg-base-100 align-middle cursor-pointer flex items-center justify-center rounded">
|
<div className="h-8 w-8 hover:bg-base-100 align-middle cursor-pointer flex items-center justify-center rounded">
|
||||||
<ClipboardIcon className="size-6" />
|
<ClipboardIcon className="size-6" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
<li className="flex justify-between align-middle items-center">
|
||||||
|
<span>Status:</span>
|
||||||
|
<div className="flex gap-2 items-center" >
|
||||||
|
<span className="font-normal">{container_status}</span>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>}
|
</div>}
|
||||||
<a
|
<a
|
||||||
|
|||||||
@ -49,21 +49,42 @@ function BulkUsers() {
|
|||||||
reader.readAsText(file);
|
reader.readAsText(file);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmit = () => {
|
const handleSubmit = async () => {
|
||||||
axios
|
try {
|
||||||
.post("/api/users", {
|
const response = await axios.post(
|
||||||
|
"/api/users",
|
||||||
|
{
|
||||||
users: userData.filter((user: CSVParseType) => user.name !== ""),
|
users: userData.filter((user: CSVParseType) => user.name !== ""),
|
||||||
jiId: 1,
|
jiId: parseInt(practical),
|
||||||
}).then((res) => {
|
},
|
||||||
if (res.status === 200) {
|
{
|
||||||
alert(`Users succesfully created !\n${res}`);
|
responseType: 'blob', // AJOUTER CETTE LIGNE
|
||||||
}
|
}
|
||||||
if (res.status === 202)
|
);
|
||||||
|
|
||||||
|
if (response.status === 200) {
|
||||||
|
// REMPLACER l'alert par ce code :
|
||||||
|
const url = window.URL.createObjectURL(new Blob([response.data]));
|
||||||
|
const link = document.createElement('a');
|
||||||
|
link.href = url;
|
||||||
|
link.setAttribute('download', `created_users_${new Date().toISOString().split('T')[0]}.csv`);
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
link.remove();
|
||||||
|
window.URL.revokeObjectURL(url);
|
||||||
|
|
||||||
|
alert('Users succesfully created ! CSV downloaded.');
|
||||||
|
navigate('/admin/users');
|
||||||
|
}
|
||||||
|
if (response.status === 202)
|
||||||
alert(`Couldn't create some users`);
|
alert(`Couldn't create some users`);
|
||||||
if (res.status === 500)
|
if (response.status === 500)
|
||||||
alert(`Couldn't create ANY users`);
|
alert(`Couldn't create ANY users`);
|
||||||
});
|
} catch (error) {
|
||||||
|
console.error('Erreur:', error);
|
||||||
|
alert('Erreur lors de la création des users');
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="max-w-7xl mx-auto p-5">
|
<div className="max-w-7xl mx-auto p-5">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user