Skip to content
Extraits de code Groupes Projets
Valider 055e5cff rédigé par Maxime DESMARCHELIER's avatar Maxime DESMARCHELIER
Parcourir les fichiers

Rework Javascript using Svelte feature

parent b129768a
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
<script> <script>
import {onMount} from "svelte";
const BACKEND_URL = import.meta.env.VITE_BACKEND_URL; const BACKEND_URL = import.meta.env.VITE_BACKEND_URL;
let newNodeName = "";
let softwares = [], function postSoftwareInsert() {
result, if (newNodeName) {
node; fetch(BACKEND_URL + "/software-insert", {
onMount(async () => {
const softwareName = document.getElementById("softwareName");
const newNodeButton = document.getElementById("newNodeButton");
newNodeButton.addEventListener("click", (e) => {
postSoftwareInsert();
e.preventDefault();
window.location.reload();
});
async function postSoftwareInsert() {
const res = await fetch(BACKEND_URL + "/software-insert", {
method: "POST", method: "POST",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
body: JSON.stringify({"newNodeName": softwareName.value}), body: JSON.stringify({"newNodeName": newNodeName}),
}); }).then(() => window.location.reload());
} }
}
});
</script> </script>
<form class="form-inline"> <div class="form-inline">
<label for="softwareName">Software Name :</label> <label>Software Name :</label>
<input type="text" id="softwareName" placeholder="" name="softwareName"> <input type="text" bind:value={newNodeName} placeholder="">
<button id="newNodeButton">Submit</button> <button on:click={postSoftwareInsert}>Submit</button>
</form> </div>
<style> <style>
/* Style the form - display items horizontally */ /* Style the form - display items horizontally */
.form-inline { .form-inline {
display: flex; display: flex;
flex-flow: row wrap;
align-items: center; align-items: center;
} }
...@@ -74,7 +58,7 @@ ...@@ -74,7 +58,7 @@
} }
} }
form { .form-inline {
max-width: 400px; max-width: 400px;
background: #f4f4f4; background: #f4f4f4;
padding: 20px; padding: 20px;
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter