Merge pull request #2 from devaine/mincy

"making the delete button works"
This commit is contained in:
Minh Ho 2025-10-19 08:32:22 -05:00 committed by GitHub
commit c67cbb148b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 92 additions and 21 deletions

View file

@ -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",

View file

@ -31,9 +31,9 @@ export default function ChatLayout() {
return (
<div className="flex flex-col flex-start w-full max-w-3xl gap-4 p-4">
<ChatHeader />
<ChatHeader onDeleteAll={handleDeleteAll} />
<ChatWindow messages={messages} />
<MessageInput onSend={handleSend} onDeleteAll={handleDeleteAll} />
<MessageInput onSend={handleSend} />
</div>
);
}

View file

@ -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,11 +34,12 @@ export default function ChatHeader({ title = "Schematic Spelunker" }) {
<div className="w-full flex justify-center">
<header className="text-slate-100 fixed top-4 max-w-3xl w-full px-4">
<div className="flex justify-between items-center gap-4">
<FileList />
<h1 className="text-sm lg:text-lg font-semibold shadow-md shadow-indigo-600 bg-gray-900 px-6 py-2 rounded-4xl border-2 border-gray-800">
<SchematicButton />
<div className="flex items-center gap-3">
<h1 className="text-lg font-semibold shadow-md shadow-indigo-600 bg-gray-900 px-6 py-2 rounded-4xl border-2 border-gray-800">
{title}
</h1>
<DeleteButton />
<DeleteButton onClick={onDeleteAll} />
{isDebug && (
<motion.button
onClick={triggerDemoIngest}
@ -52,6 +53,7 @@ export default function ChatHeader({ title = "Schematic Spelunker" }) {
</motion.button>
)}
</div>
</div>
{toast && (
<div className="mt-2 text-xs text-slate-300 bg-gray-800/80 border border-gray-700 rounded px-2 py-1 inline-block">
{toast}

60
web-app/src/index.js Normal file
View file

@ -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);
})