diff --git a/web-app/package-lock.json b/web-app/package-lock.json index 31afbbf..c0c9547 100644 --- a/web-app/package-lock.json +++ b/web-app/package-lock.json @@ -2924,6 +2924,15 @@ "node": ">= 12" } }, + "node_modules/data-uri-to-buffer": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz", + "integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==", + "license": "MIT", + "engines": { + "node": ">= 12" + } + }, "node_modules/data-view-buffer": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/data-view-buffer/-/data-view-buffer-1.0.2.tgz", diff --git a/web-app/src/components/layouts/chat-layout.jsx b/web-app/src/components/layouts/chat-layout.jsx index c5731d8..538ee05 100644 --- a/web-app/src/components/layouts/chat-layout.jsx +++ b/web-app/src/components/layouts/chat-layout.jsx @@ -31,9 +31,9 @@ export default function ChatLayout() { return (
- + - +
); } diff --git a/web-app/src/components/ui/chat/chat-header.jsx b/web-app/src/components/ui/chat/chat-header.jsx index 45447ab..fc89f66 100644 --- a/web-app/src/components/ui/chat/chat-header.jsx +++ b/web-app/src/components/ui/chat/chat-header.jsx @@ -2,9 +2,9 @@ import React, { useMemo, useState } from "react"; import { motion } from "motion/react"; import { Rocket } from "lucide-react"; import DeleteButton from "src/components/ui/button/delete-button"; -import FileList from "src/components/ui/file/file-list"; +import SchematicButton from "../button/schematic-button"; -export default function ChatHeader({ title = "Schematic Spelunker" }) { +export default function ChatHeader({ title = "Title of Chat", onDeleteAll }) { const isDebug = useMemo(() => { const p = new URLSearchParams(window.location.search); return p.get("debug") === "1"; @@ -34,23 +34,25 @@ export default function ChatHeader({ title = "Schematic Spelunker" }) {
- -

- {title} -

- - {isDebug && ( - - - {ingesting ? "Seeding…" : "Seed Demo Data"} - - )} + +
+

+ {title} +

+ + {isDebug && ( + + + {ingesting ? "Seeding…" : "Seed Demo Data"} + + )} +
{toast && (
diff --git a/web-app/src/index.js b/web-app/src/index.js new file mode 100644 index 0000000..259ced7 --- /dev/null +++ b/web-app/src/index.js @@ -0,0 +1,60 @@ +import express from "express"; +import bodyParser from "body-parser"; +import axios from "axios"; +import multer from "multer"; +import path from "path"; +import { fileURLToPath } from 'url'; +import fs from "fs"; + +const app = new express(); +const port = 3000; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); + +app.use(express.static('public')); +app.use('/uploads', express.static('uploads')); +app.use(bodyParser.urlencoded({extended: true})); +app.use(bodyParser.json()); + +const storage = multer.diskStorage({ + destination: function (req, file, cb) { + cb(null, path.join(__dirname,'/uploads')); + }, + filename: function (req, file, cb) { + cb(null, file.originalname); + } +}) +const upload = multer({ storage: storage }) + + + +//Render the main page +app.get("/", async (req, res) => { + try{ + const response = await axios.get(`${API_URL}/all`); + res.render("file", { data: response.data }); + }catch(error){ + console.error(error); + res.status(500).json("Error fetching items"); + } +}) + +app.post("/upload", upload.single('image'), async (req, res) => { + const data = { + ...req.body, + fileName: req.file.originalname, + path: req.file.path + } + try{ + await axios.post(`${API_URL}/add`, data); + res.redirect("/"); + }catch(error){ + console.error(error); + res.status(500).json("Error uploading item"); + } +}) + +app.listen(port, () => { + console.log("API is listening on port " + port); +}) \ No newline at end of file