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 (
|
||||
<>
|
||||
{ji && (
|
||||
@ -70,9 +78,9 @@ function Immersion() {
|
||||
<span>SSH:</span>
|
||||
<div
|
||||
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">
|
||||
<ClipboardIcon className="size-6" />
|
||||
</div>
|
||||
@ -80,28 +88,28 @@ function Immersion() {
|
||||
</li>
|
||||
<li className="flex justify-between align-middle items-center">
|
||||
<span>Instance name:</span>
|
||||
<div
|
||||
className="flex gap-2 items-center"
|
||||
onClick={() => copyText(instance.name)}
|
||||
>
|
||||
<div className="flex gap-2 items-center" >
|
||||
<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>
|
||||
</li>
|
||||
<li className="flex justify-between align-middle items-center">
|
||||
<span>Password:</span>
|
||||
<div
|
||||
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">
|
||||
<ClipboardIcon className="size-6" />
|
||||
</div>
|
||||
</div>
|
||||
</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>
|
||||
</div>}
|
||||
<a
|
||||
|
||||
@ -49,20 +49,41 @@ function BulkUsers() {
|
||||
reader.readAsText(file);
|
||||
};
|
||||
|
||||
const handleSubmit = () => {
|
||||
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 (
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user