From 982d2cb09f9793fbdfcf8a1d2b2b27e4fd272469 Mon Sep 17 00:00:00 2001
From: Furkan Sahin <furkan-dev@proton.me>
Date: Fri, 15 Jul 2022 23:18:36 -0400
Subject: Read database from local file for TESTING purposes

---
 src/components/Sidebar.svelte | 106 +++++++++++++++++++++++-------------------
 1 file changed, 58 insertions(+), 48 deletions(-)

(limited to 'src/components/Sidebar.svelte')

diff --git a/src/components/Sidebar.svelte b/src/components/Sidebar.svelte
index 53982bb..b5b33c9 100644
--- a/src/components/Sidebar.svelte
+++ b/src/components/Sidebar.svelte
@@ -1,60 +1,70 @@
 <script lang="ts">
-    import DarkModeSwitch from "./DarkModeSwitch.svelte";
-    import AssignLabs from "./AssignLabs/AssignLabs.svelte";
-    import FileUploads from "./FileUploads.svelte";
+  import DarkModeSwitch from "./DarkModeSwitch.svelte";
+  import AssignLabs from "./AssignLabs/AssignLabs.svelte";
+  import FileUploads from "./FileUploads.svelte";
+  import { onMount } from "svelte";
+  import { parseDatabase, parseDatabaseLocal } from "../util/parser";
+  import { parseDatabaseFile } from "../logic/EditorActions";
+  import * as local_db from "../../pt-db.json";
 
-    let sections = [
-        { name: "File Uploads", component: FileUploads },
-        { name: "Peer Teachers", component: null },
-        { name: "Assign Labs", component: AssignLabs },
-        { name: "Labs", component: null },
-        { name: "Active Peer Teachers", component: null },
-        { name: "Stats", component: null },
-        { name: "TAMU Html Output", component: null },
-    ];
+  let sections = [
+    { name: "File Uploads", component: FileUploads },
+    { name: "Peer Teachers", component: null },
+    { name: "Assign Labs", component: AssignLabs },
+    { name: "Labs", component: null },
+    { name: "Active Peer Teachers", component: null },
+    { name: "Stats", component: null },
+    { name: "TAMU Html Output", component: null },
+  ];
 
-    // Set initial page to Assign Labs while I work on it
-    let selected = sections[2];
+  // Set initial page to Assign Labs while I work on it
+  let selected = sections[2];
 
-    function chooseSection(sec) {
-        selected = sec;
-    }
+  onMount(async () => {
+    // load database on mount for testing purposes
+    console.log("reading local database")
+    parseDatabaseLocal(local_db)
+  });
+
+  function chooseSection(sec) {
+    selected = sec;
+  }
 </script>
 
 <!-- Entire Page -->
 <div class="flex flex-row h-screen">
-    <!-- SIDEBAR -->
-    <div class="w-2/12 flex flex-col border-r">
-        <!-- Header for sidebar sections -->
-        <div
-            class="font-serif flex-none text-center text-2xl text-neutral-900 p-4 border-b font-black overflow-hidden"
-        >
-            <!-- Text -->
-            <div>Peer Teacher Manager</div>
-            <div>
-                <DarkModeSwitch />
-            </div>
-        </div>
-
-        <!-- Sidebar sections -->
-        <div class="flex-col overflow-y-auto">
-            <ul class="menu bg-base-100 w-full text-xl">
-                {#each sections as sec}
-                    <li>
-                        <div
-                            class={selected == sec ? "active" : ""}
-                            on:click={() => chooseSection(sec)}
-                        >
-                            {sec.name}
-                        </div>
-                    </li>
-                {/each}
-            </ul>
-        </div>
+  <!-- SIDEBAR -->
+  <div class="w-2/12 flex flex-col border-r">
+    <!-- Header for sidebar sections -->
+    <div
+      class="font-serif flex-none text-center text-2xl text-neutral-900 p-4 border-b font-black overflow-hidden"
+    >
+      <!-- Text -->
+      <div>Peer Teacher Manager</div>
+      <div>
+        <DarkModeSwitch />
+      </div>
     </div>
 
-    <!-- Chosen Section / Component -->
-    <div class="flex-auto">
-        <svelte:component this={selected.component} />
+    <!-- Sidebar sections -->
+    <div class="flex-col overflow-y-auto">
+      <ul class="menu bg-base-100 w-full text-xl">
+        {#each sections as sec}
+          <li>
+            <div
+              class={selected == sec ? "active" : ""}
+              on:click={() => chooseSection(sec)}
+            >
+              {sec.name}
+            </div>
+          </li>
+        {/each}
+      </ul>
     </div>
+  </div>
+
+  <!-- Chosen Section / Component -->
+  <div class="flex-auto">
+    <svelte:component this={selected.component} />
+  </div>
 </div>
-- 
cgit v1.2.3

