From 501811a0b5af346187cc0ad17c5239d99981539f Mon Sep 17 00:00:00 2001 From: julius Date: Mon, 10 Feb 2025 16:40:19 +0100 Subject: [PATCH] feat: out-source footer and header --- src/Analysis.tsx | 104 +++++++++++++++++++++++++++++++++++++++++++++ src/App.tsx | 1 - src/Footer.tsx | 14 ++++++ src/Header.tsx | 11 +++++ tsconfig.node.json | 10 +++-- 5 files changed, 135 insertions(+), 5 deletions(-) create mode 100644 src/Analysis.tsx create mode 100644 src/Footer.tsx create mode 100644 src/Header.tsx diff --git a/src/Analysis.tsx b/src/Analysis.tsx new file mode 100644 index 0000000..fb6902e --- /dev/null +++ b/src/Analysis.tsx @@ -0,0 +1,104 @@ +import { useEffect, useState } from "react"; +import { baseUrl } from "./api"; + +interface Params { + nodeSize: number; + edgeWidth: number; + arrowSize: number; + fontSize: number; +} + +export default function Analysis() { + const [image, setImage] = useState(""); + const [params, setParams] = useState({ + nodeSize: 1600, + edgeWidth: 1, + arrowSize: 20, + fontSize: 10, + }); + const [showControlPanel, setShowControlPanel] = useState(false); + const [loading, setLoading] = useState(false); + + // Function to generate and fetch the graph image + async function loadImage() { + setLoading(true); + await fetch(`${baseUrl}analysis/image`, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(params) + }) + .then((resp) => resp.json()) + .then((data) => { + setImage(data.image); + setLoading(false); + }); + } + useEffect(() => { + loadImage(); + }, []); + + return ( +
+ + {showControlPanel && ( +
+ + + setParams({ ...params, nodeSize: Number(evt.target.value) })} + onMouseUp={() => loadImage()} + /> + {params.nodeSize} + + + setParams({ ...params, fontSize: Number(evt.target.value) })} + onMouseUp={() => loadImage()} + /> + {params.fontSize} + + + setParams({ ...params, edgeWidth: Number(evt.target.value) })} + onMouseUp={() => loadImage()} + /> + {params.edgeWidth} + + + setParams({ ...params, arrowSize: Number(evt.target.value) })} + onMouseUp={() => loadImage()} + /> + {params.arrowSize} + +
+ )} + {loading ? ( + + ) : ( + + )} +
+ ); +} diff --git a/src/App.tsx b/src/App.tsx index 665aa55..3d9367d 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,5 +1,4 @@ import Analysis from "./Analysis"; -import { baseUrl } from "./api"; import "./App.css"; import Footer from "./Footer"; import Header from "./Header"; diff --git a/src/Footer.tsx b/src/Footer.tsx new file mode 100644 index 0000000..9f4ddee --- /dev/null +++ b/src/Footer.tsx @@ -0,0 +1,14 @@ +export default function Footer() { + return
+

+ something not working? +
+ message me. +
+ or fix it here:{" "} + + gitea + +

+
+} diff --git a/src/Header.tsx b/src/Header.tsx new file mode 100644 index 0000000..e7d35b8 --- /dev/null +++ b/src/Header.tsx @@ -0,0 +1,11 @@ +import { baseUrl } from "./api"; + +export default function Header() { + return
+ + logo +

cutt

+
+ cool ultimate team tool +
+} diff --git a/tsconfig.node.json b/tsconfig.node.json index db0becc..99b7876 100644 --- a/tsconfig.node.json +++ b/tsconfig.node.json @@ -2,17 +2,17 @@ "compilerOptions": { "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", "target": "ES2022", - "lib": ["ES2023"], + "lib": [ + "ES2023" + ], "module": "ESNext", "skipLibCheck": true, - /* Bundler mode */ "moduleResolution": "bundler", "allowImportingTsExtensions": true, "isolatedModules": true, "moduleDetection": "force", "noEmit": true, - /* Linting */ "strict": true, "noUnusedLocals": true, @@ -20,5 +20,7 @@ "noFallthroughCasesInSwitch": true, "noUncheckedSideEffectImports": true }, - "include": ["vite.config.ts"] + "include": [ + "vite.config.ts" + ] }