diff --git a/src/pages/Immersion.tsx b/src/pages/Immersion.tsx
index 1d40bde..6c4b248 100644
--- a/src/pages/Immersion.tsx
+++ b/src/pages/Immersion.tsx
@@ -36,6 +36,14 @@ function Immersion() {
localStorage.setItem("username", res.data.username);
});
}, []);
+
+ useEffect(() => {
+ axios.get(`/api/ji/${id}/container`).then((res) => {
+ localStorage.setItem("container_status", res.data);
+ });
+ }, []);
+
+ const container_status = localStorage.getItem("container_status");
return (
<>
@@ -70,9 +78,9 @@ function Immersion() {
SSH:
copyText("ssh -P {$instance.port} {$username}@la-banquise.fr")}
+ onClick={() => copyText(`ssh -p ${instance.port} ${username}@la-banquise.fr`)}
>
-
ssh -P {instance.port} {username}@la-banquise.fr
+
ssh -p {instance.port} {username}@la-banquise.fr
@@ -80,28 +88,28 @@ function Immersion() {
Instance name:
- copyText(instance.name)}
- >
+
Password:
copyText(ji.pwd)}
+ onClick={() => copyText(instance.pwd)}
>
-
{ji.pwd}
+
{instance.pwd}
+
+ Status:
+
+ {container_status}
+
+
}
{
- axios
- .post("/api/users", {
+ const handleSubmit = async () => {
+ try {
+ const response = await axios.post(
+ "/api/users",
+ {
users: userData.filter((user: CSVParseType) => user.name !== ""),
- jiId: 1,
- }).then((res) => {
- if (res.status === 200) {
- alert(`Users succesfully created !\n${res}`);
+ jiId: parseInt(practical),
+ },
+ {
+ 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`);
- if (res.status === 500)
+ if (response.status === 500)
alert(`Couldn't create ANY users`);
- });
+ } catch (error) {
+ console.error('Erreur:', error);
+ alert('Erreur lors de la création des users');
};
+ };
return (