From d5d9569404d56b28b1c8679d00670759f93e6e56 Mon Sep 17 00:00:00 2001
From: Desmarchelier Maxime <maxime.desmarchelier@ensiie.fr>
Date: Sun, 20 Nov 2022 00:16:25 +0100
Subject: [PATCH] Add new page for inserting data

---
 sg-backend/test.json                      |  0
 sg-frontend/index.html                    |  1 +
 sg-frontend/src/App.svelte                |  2 ++
 sg-frontend/src/routes/AddNode.svelte     | 21 +++++++++++++++++++++
 sg-frontend/src/routes/Index.svelte       |  2 ++
 sg-frontend/src/routes/SigmaCustom.svelte |  2 ++
 6 files changed, 28 insertions(+)
 delete mode 100644 sg-backend/test.json
 create mode 100644 sg-frontend/src/routes/AddNode.svelte

diff --git a/sg-backend/test.json b/sg-backend/test.json
deleted file mode 100644
index e69de29..0000000
diff --git a/sg-frontend/index.html b/sg-frontend/index.html
index 9873178..fb6e481 100644
--- a/sg-frontend/index.html
+++ b/sg-frontend/index.html
@@ -12,6 +12,7 @@
     <div class="topnav">
         <a id="home" class="active" href="/">Home</a>
         <a id="sigma" href="#/sigma-custom">Software graph</a>
+        <a id="add" href="#/add-node">Software graph</a>
     </div>
 </div>
 <script type="module" src="/src/main.ts"></script>
diff --git a/sg-frontend/src/App.svelte b/sg-frontend/src/App.svelte
index 1dc59f0..1ffb7ff 100644
--- a/sg-frontend/src/App.svelte
+++ b/sg-frontend/src/App.svelte
@@ -6,6 +6,7 @@
 	import NotFound from "./routes/NotFound.svelte";
     import Sigma from "./routes/Sigma.svelte";
     import SigmaCustom from "./routes/SigmaCustom.svelte";
+    import AddNode from "./routes/AddNode.svelte";
 
 		let routes = {
 			"/": Index,
@@ -13,6 +14,7 @@
 			"/graph": Graph,
             "/sigma": Sigma,
             "/sigma-custom": SigmaCustom,
+            "/add-node": AddNode,
 			"*": NotFound
 		}
 </script>
diff --git a/sg-frontend/src/routes/AddNode.svelte b/sg-frontend/src/routes/AddNode.svelte
new file mode 100644
index 0000000..6720a65
--- /dev/null
+++ b/sg-frontend/src/routes/AddNode.svelte
@@ -0,0 +1,21 @@
+<script lang="ts">
+
+    import {onMount} from 'svelte';
+
+    onMount(() => {
+        fetch("http://localhost:8000/add-node")
+            .then(response => response.json())
+            .then(data => {
+            // Retrieve some useful DOM elements:
+                const link = document.getElementById("sigma") as HTMLElement;
+                const home = document.getElementById("home") as HTMLElement;
+                const add = document.getElementById("add") as HTMLElement;
+                add.classList.add("active");
+                home.classList.remove("active");
+                link.classList.remove("active");
+            })
+    });
+</script>
+<div id="app-base">
+<h1>Add new node</h1>
+</div>
\ No newline at end of file
diff --git a/sg-frontend/src/routes/Index.svelte b/sg-frontend/src/routes/Index.svelte
index 319e961..e94811c 100644
--- a/sg-frontend/src/routes/Index.svelte
+++ b/sg-frontend/src/routes/Index.svelte
@@ -2,8 +2,10 @@
 	import SoftwareMerger from "../components/SoftwareMerger.svelte";
 	const link = document.getElementById("sigma");
 	const home = document.getElementById("home");
+	const add = document.getElementById("add");
 	home.classList.add("active");
 	link.classList.remove("active");
+	add.classList.remove("active");
 </script>
 
 <div id="app-base">
diff --git a/sg-frontend/src/routes/SigmaCustom.svelte b/sg-frontend/src/routes/SigmaCustom.svelte
index 99d63de..4305160 100644
--- a/sg-frontend/src/routes/SigmaCustom.svelte
+++ b/sg-frontend/src/routes/SigmaCustom.svelte
@@ -19,8 +19,10 @@
                 const container = document.getElementById("sigma-container") as HTMLElement;
                 const link = document.getElementById("sigma") as HTMLElement;
                 const home = document.getElementById("home") as HTMLElement;
+                const add = document.getElementById("add") as HTMLElement;
                 link.classList.add("active");
                 home.classList.remove("active");
+                add.classList.remove("active");
 
 // Instantiate sigma:
                 const graph = new Graph();
-- 
GitLab