Skip to content
Snippets Groups Projects
Commit 64cc1522 authored by Jonas Zohren's avatar Jonas Zohren :speech_balloon:
Browse files

Add JSON debug data interface

parent 27479a68
No related branches found
No related tags found
No related merge requests found
Pipeline #15551 passed
<script lang="ts"> <script lang="ts">
import { element } from "svelte/internal";
import type { WorkPackage } from "./estimator"; import type { WorkPackage } from "./estimator";
import RowWorkItem from "./RowWorkItem.svelte"; import RowWorkItem from "./RowWorkItem.svelte";
import SumRow from "./SumRow.svelte"; import SumRow from "./SumRow.svelte";
...@@ -10,6 +11,7 @@ ...@@ -10,6 +11,7 @@
workPackages.push({a: null, b:null, c: null}); workPackages.push({a: null, b:null, c: null});
} }
$: dataJson = JSON.stringify(workPackages, null, 2) $: dataJson = JSON.stringify(workPackages, null, 2)
let jsonPasteArea = "";
</script> </script>
<main> <main>
...@@ -30,6 +32,38 @@ ...@@ -30,6 +32,38 @@
<SumRow {workPackages}></SumRow> <SumRow {workPackages}></SumRow>
</tbody> </tbody>
</table> </table>
<details>
<summary>
Debug: Show Input as JSON
</summary>
<pre>
{dataJson}
</pre>
</details><details>
<summary>
Debug: Paste Input as JSON
</summary>
<textarea bind:value="{jsonPasteArea}" on:input={() => {
if (jsonPasteArea.trim().length === 0) return
try {
const decoded = JSON.parse(jsonPasteArea.trim());
if (!Array.isArray(decoded))
throw TypeError("Input must be an array")
for (const elem of decoded) {
if (typeof elem.a !== 'number' && elem.a !== null)
throw TypeError("An 'a' attribute was neither number not null");
if (typeof elem.b !== 'number' && elem.b !== null)
throw TypeError("An 'b' attribute was neither number not null");
if (typeof elem.c !== 'number' && elem.c !== null)
throw TypeError("An 'c' attribute was neither number not null");
}
workPackages = decoded;
jsonPasteArea = "";
} catch (error) {
alert(error.toString())
}
}}/>
</details>
</main> </main>
<a href="https://gitlab.fachschaften.org/jfowl/swk-project-effort-estimation" <a href="https://gitlab.fachschaften.org/jfowl/swk-project-effort-estimation"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment