From 652c245d99e795aa0b98eda03f5c565cfe2d0347 Mon Sep 17 00:00:00 2001 From: Vasek Sraier Date: Sun, 27 Sep 2020 12:21:17 +0200 Subject: [PATCH] graph now works (somehow) --- frontend/src/App.svelte | 59 ++++++++++++++++++++------------- frontend/src/Graph.svelte | 47 ++++++++++++++------------ frontend/src/GraphNode.svelte | 18 ++++++++++ frontend/src/Hoverable.svelte | 15 +++++++++ frontend/src/TasksLoader.svelte | 30 +++++++++++++++++ frontend/src/task-loader.ts | 15 ++++----- 6 files changed, 130 insertions(+), 54 deletions(-) create mode 100644 frontend/src/GraphNode.svelte create mode 100644 frontend/src/Hoverable.svelte create mode 100644 frontend/src/TasksLoader.svelte diff --git a/frontend/src/App.svelte b/frontend/src/App.svelte index 500e3b2..79fafdb 100644 --- a/frontend/src/App.svelte +++ b/frontend/src/App.svelte @@ -1,30 +1,43 @@ + import Graph from "./Graph.svelte"; + import GraphNode from "./GraphNode.svelte"; + import { loadTasks } from "./task-loader"; + import type { TasksFile } from "./task-loader"; + import TasksLoader from "./TasksLoader.svelte"; -
-

Cool graf

- -
+ const tasksPromise: Promise = loadTasks(); + + +
+

Cool graf

+ + + + +
diff --git a/frontend/src/Graph.svelte b/frontend/src/Graph.svelte index 344acf3..b3fae06 100644 --- a/frontend/src/Graph.svelte +++ b/frontend/src/Graph.svelte @@ -1,7 +1,13 @@ @@ -95,4 +90,12 @@ } -
+
+ + + {#each nodes as task} + + {/each} + + +
diff --git a/frontend/src/GraphNode.svelte b/frontend/src/GraphNode.svelte new file mode 100644 index 0000000..2f205cb --- /dev/null +++ b/frontend/src/GraphNode.svelte @@ -0,0 +1,18 @@ + + + + {#if !focused} + + {:else} + + {/if} --> + {task.id} + diff --git a/frontend/src/Hoverable.svelte b/frontend/src/Hoverable.svelte new file mode 100644 index 0000000..5923a22 --- /dev/null +++ b/frontend/src/Hoverable.svelte @@ -0,0 +1,15 @@ + + + + + diff --git a/frontend/src/TasksLoader.svelte b/frontend/src/TasksLoader.svelte new file mode 100644 index 0000000..4d81661 --- /dev/null +++ b/frontend/src/TasksLoader.svelte @@ -0,0 +1,30 @@ + + +{#if data == null && err == null} +
Loading...
+{/if} + +{#if data != null } + +{/if} + +{#if err != null } +
Error - {err}
+{/if} diff --git a/frontend/src/task-loader.ts b/frontend/src/task-loader.ts index 2c00f02..77859f2 100644 --- a/frontend/src/task-loader.ts +++ b/frontend/src/task-loader.ts @@ -1,8 +1,10 @@ +import type { SimulationNodeDatum, SimulationLinkDatum } from "d3"; + export type TaskDescriptor = { id: string requires: [] comment?: string -} +} & SimulationNodeDatum export type TasksFile = { @@ -12,11 +14,6 @@ export type TasksFile = { export type TaskMap = Map; -export type Link = { - source: T, - target: T -} - export async function loadTasks(): Promise { const r = await fetch("/tasks.json") return await r.json() @@ -34,8 +31,8 @@ export function createTaskMap(tasks: TasksFile): TaskMap { return m; } -export function createLinksFromTaskMap(tasks: TasksFile): Link[] { - let links: Link[] = []; +export function createLinksFromTaskMap(tasks: TasksFile): SimulationLinkDatum[] { + let links: SimulationLinkDatum[] = []; const taskMap = createTaskMap(tasks); @@ -45,7 +42,7 @@ export function createLinksFromTaskMap(tasks: TasksFile): Link[] if (t === undefined) throw `missing task with id ${id}`; - const l: Link = {source: t, target: task}; + const l: SimulationLinkDatum = {source: t, target: task}; links.push(l); } }