2024-03-06 14:01:07 +01:00
|
|
|
<script lang="ts">
|
2024-04-10 14:27:23 +02:00
|
|
|
import Grid from "$lib/grid";
|
2024-04-15 22:13:43 +02:00
|
|
|
import GraphInterface from "$lib/graph-interface";
|
2024-03-19 16:41:15 +01:00
|
|
|
import { MemoryRuntimeExecutor } from "$lib/runtime-executor";
|
2024-04-15 18:46:34 +02:00
|
|
|
import { RemoteNodeRegistry } from "$lib/node-registry";
|
2024-04-10 15:40:01 +02:00
|
|
|
import * as templates from "$lib/graph-templates";
|
2024-04-10 21:57:03 +02:00
|
|
|
import type { Graph } from "@nodes/types";
|
2024-04-16 15:32:23 +02:00
|
|
|
import Viewer from "$lib/viewer/Viewer.svelte";
|
2024-04-18 18:39:24 +02:00
|
|
|
import Settings from "$lib/settings/Settings.svelte";
|
|
|
|
import { AppSettings, AppSettingTypes } from "$lib/settings/app-settings";
|
2024-04-19 02:36:11 +02:00
|
|
|
import { get, writable, type Writable } from "svelte/store";
|
|
|
|
import Keymap from "$lib/settings/Keymap.svelte";
|
2024-04-19 22:00:43 +02:00
|
|
|
import type { createKeyMap } from "$lib/helpers/createKeyMap";
|
2024-04-18 00:02:50 +02:00
|
|
|
|
2024-04-10 14:27:23 +02:00
|
|
|
const nodeRegistry = new RemoteNodeRegistry("http://localhost:3001");
|
2024-03-19 16:41:15 +01:00
|
|
|
const runtimeExecutor = new MemoryRuntimeExecutor(nodeRegistry);
|
|
|
|
|
2024-04-16 15:32:23 +02:00
|
|
|
let res: Int32Array;
|
2024-03-19 16:56:42 +01:00
|
|
|
|
2024-04-10 15:40:01 +02:00
|
|
|
let graph = localStorage.getItem("graph")
|
|
|
|
? JSON.parse(localStorage.getItem("graph")!)
|
|
|
|
: templates.grid(3, 3);
|
2024-03-19 16:56:42 +01:00
|
|
|
|
2024-04-19 02:36:11 +02:00
|
|
|
let managerStatus: Writable<"loading" | "error" | "idle">;
|
|
|
|
|
2024-04-19 22:00:43 +02:00
|
|
|
let keymap: ReturnType<typeof createKeyMap>;
|
|
|
|
|
2024-04-10 21:57:03 +02:00
|
|
|
function handleResult(event: CustomEvent<Graph>) {
|
2024-04-18 18:39:24 +02:00
|
|
|
res = runtimeExecutor.execute(event.detail, get(settings?.graph?.settings));
|
2024-04-10 15:40:01 +02:00
|
|
|
}
|
2024-03-06 18:31:06 +01:00
|
|
|
|
2024-04-10 21:57:03 +02:00
|
|
|
function handleSave(event: CustomEvent<Graph>) {
|
2024-04-10 15:40:01 +02:00
|
|
|
localStorage.setItem("graph", JSON.stringify(event.detail));
|
|
|
|
}
|
2024-04-18 18:39:24 +02:00
|
|
|
|
|
|
|
let settings: Record<string, any> = {
|
|
|
|
general: {
|
|
|
|
id: "general",
|
|
|
|
icon: "i-tabler-settings",
|
|
|
|
settings: AppSettings,
|
|
|
|
definition: AppSettingTypes,
|
|
|
|
},
|
2024-04-19 22:00:43 +02:00
|
|
|
shortcuts: {},
|
2024-04-19 02:36:11 +02:00
|
|
|
graph: {},
|
2024-04-19 22:00:43 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
$: if (keymap) {
|
|
|
|
settings.shortcuts = {
|
2024-04-19 02:36:11 +02:00
|
|
|
id: "shortcuts",
|
|
|
|
icon: "i-tabler-keyboard",
|
2024-04-19 22:00:43 +02:00
|
|
|
props: { keymap },
|
2024-04-19 02:36:11 +02:00
|
|
|
component: Keymap,
|
2024-04-19 22:00:43 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
settings = settings;
|
|
|
|
console.log({ settings });
|
|
|
|
}
|
2024-04-18 18:39:24 +02:00
|
|
|
|
|
|
|
function handleSettings(
|
|
|
|
ev: CustomEvent<{
|
|
|
|
values: Record<string, unknown>;
|
|
|
|
types: Record<string, unknown>;
|
|
|
|
}>,
|
|
|
|
) {
|
2024-04-19 02:36:11 +02:00
|
|
|
settings.general.definition.stressTest.loadGrid.callback = function () {
|
|
|
|
const store = get(settings.general.settings);
|
|
|
|
graph = templates.grid(store.amount, store.amount);
|
|
|
|
};
|
|
|
|
|
|
|
|
settings.general.definition.stressTest.loadTree.callback = function () {
|
|
|
|
const store = get(settings.general.settings);
|
|
|
|
graph = templates.tree(store.amount);
|
|
|
|
};
|
|
|
|
|
|
|
|
settings.graph = {
|
|
|
|
icon: "i-tabler-chart-bar",
|
|
|
|
id: "graph",
|
|
|
|
settings: writable(ev.detail.values),
|
|
|
|
definition: ev.detail.types,
|
2024-04-18 18:39:24 +02:00
|
|
|
};
|
2024-04-19 02:36:11 +02:00
|
|
|
settings = settings;
|
2024-04-18 18:39:24 +02:00
|
|
|
}
|
2024-03-06 14:01:07 +01:00
|
|
|
</script>
|
|
|
|
|
2024-04-19 02:36:11 +02:00
|
|
|
<div class="wrapper manager-{$managerStatus}">
|
|
|
|
<header></header>
|
2024-04-10 14:27:23 +02:00
|
|
|
<Grid.Row>
|
|
|
|
<Grid.Cell>
|
2024-04-16 15:32:23 +02:00
|
|
|
<Viewer result={res} />
|
2024-04-10 15:40:01 +02:00
|
|
|
</Grid.Cell>
|
|
|
|
<Grid.Cell>
|
|
|
|
{#key graph}
|
2024-04-10 21:57:03 +02:00
|
|
|
<GraphInterface
|
2024-04-10 15:40:01 +02:00
|
|
|
registry={nodeRegistry}
|
|
|
|
{graph}
|
2024-04-19 22:00:43 +02:00
|
|
|
bind:keymap
|
2024-04-19 02:36:11 +02:00
|
|
|
bind:status={managerStatus}
|
2024-04-18 18:39:24 +02:00
|
|
|
settings={settings?.graph?.settings}
|
|
|
|
on:settings={handleSettings}
|
2024-04-10 15:40:01 +02:00
|
|
|
on:result={handleResult}
|
|
|
|
on:save={handleSave}
|
|
|
|
/>
|
2024-04-19 02:36:11 +02:00
|
|
|
<Settings panels={settings}></Settings>
|
2024-04-10 15:40:01 +02:00
|
|
|
{/key}
|
2024-04-10 14:27:23 +02:00
|
|
|
</Grid.Cell>
|
|
|
|
</Grid.Row>
|
2024-03-06 14:01:07 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<style>
|
2024-04-10 14:27:23 +02:00
|
|
|
header {
|
2024-04-19 01:27:11 +02:00
|
|
|
border-bottom: solid thin var(--outline);
|
|
|
|
background-color: var(--layer-1);
|
2024-03-06 14:01:07 +01:00
|
|
|
}
|
|
|
|
|
2024-03-20 02:17:58 +01:00
|
|
|
.wrapper {
|
2024-04-10 14:27:23 +02:00
|
|
|
height: 100vh;
|
|
|
|
width: 100vw;
|
|
|
|
color: white;
|
|
|
|
display: grid;
|
|
|
|
grid-template-rows: 50px 1fr;
|
|
|
|
}
|
|
|
|
|
2024-04-19 02:36:11 +02:00
|
|
|
.wrapper :global(canvas) {
|
|
|
|
transition: opacity 0.3s ease;
|
|
|
|
opacity: 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
.manager-loading :global(.graph-wrapper),
|
|
|
|
.manager-loading :global(canvas) {
|
|
|
|
opacity: 0.2;
|
|
|
|
pointer-events: none;
|
|
|
|
}
|
|
|
|
|
2024-03-06 14:01:07 +01:00
|
|
|
:global(html) {
|
|
|
|
background: rgb(13, 19, 32);
|
|
|
|
background: linear-gradient(
|
|
|
|
180deg,
|
|
|
|
rgba(13, 19, 32, 1) 0%,
|
|
|
|
rgba(8, 12, 21, 1) 100%
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
:global(body) {
|
|
|
|
margin: 0;
|
|
|
|
position: relative;
|
|
|
|
}
|
|
|
|
</style>
|