Merge pull request #2 from devaine/mincy
"making the delete button works"
This commit is contained in:
commit
c67cbb148b
4 changed files with 92 additions and 21 deletions
9
web-app/package-lock.json
generated
9
web-app/package-lock.json
generated
|
|
@ -2924,6 +2924,15 @@
|
||||||
"node": ">= 12"
|
"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": {
|
"node_modules/data-view-buffer": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/data-view-buffer/-/data-view-buffer-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/data-view-buffer/-/data-view-buffer-1.0.2.tgz",
|
||||||
|
|
|
||||||
|
|
@ -31,9 +31,9 @@ export default function ChatLayout() {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col flex-start w-full max-w-3xl gap-4 p-4">
|
<div className="flex flex-col flex-start w-full max-w-3xl gap-4 p-4">
|
||||||
<ChatHeader />
|
<ChatHeader onDeleteAll={handleDeleteAll} />
|
||||||
<ChatWindow messages={messages} />
|
<ChatWindow messages={messages} />
|
||||||
<MessageInput onSend={handleSend} onDeleteAll={handleDeleteAll} />
|
<MessageInput onSend={handleSend} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,9 @@ import React, { useMemo, useState } from "react";
|
||||||
import { motion } from "motion/react";
|
import { motion } from "motion/react";
|
||||||
import { Rocket } from "lucide-react";
|
import { Rocket } from "lucide-react";
|
||||||
import DeleteButton from "src/components/ui/button/delete-button";
|
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 isDebug = useMemo(() => {
|
||||||
const p = new URLSearchParams(window.location.search);
|
const p = new URLSearchParams(window.location.search);
|
||||||
return p.get("debug") === "1";
|
return p.get("debug") === "1";
|
||||||
|
|
@ -34,23 +34,25 @@ export default function ChatHeader({ title = "Schematic Spelunker" }) {
|
||||||
<div className="w-full flex justify-center">
|
<div className="w-full flex justify-center">
|
||||||
<header className="text-slate-100 fixed top-4 max-w-3xl w-full px-4">
|
<header className="text-slate-100 fixed top-4 max-w-3xl w-full px-4">
|
||||||
<div className="flex justify-between items-center gap-4">
|
<div className="flex justify-between items-center gap-4">
|
||||||
<FileList />
|
<SchematicButton />
|
||||||
<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">
|
<div className="flex items-center gap-3">
|
||||||
{title}
|
<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">
|
||||||
</h1>
|
{title}
|
||||||
<DeleteButton />
|
</h1>
|
||||||
{isDebug && (
|
<DeleteButton onClick={onDeleteAll} />
|
||||||
<motion.button
|
{isDebug && (
|
||||||
onClick={triggerDemoIngest}
|
<motion.button
|
||||||
className="bg-gray-800 border-2 border-gray-700 rounded-xl px-3 py-2 flex items-center gap-2"
|
onClick={triggerDemoIngest}
|
||||||
whileHover={{ scale: 1.05 }}
|
className="bg-gray-800 border-2 border-gray-700 rounded-xl px-3 py-2 flex items-center gap-2"
|
||||||
whileTap={{ scale: 0.95 }}
|
whileHover={{ scale: 1.05 }}
|
||||||
disabled={ingesting}
|
whileTap={{ scale: 0.95 }}
|
||||||
>
|
disabled={ingesting}
|
||||||
<Rocket size={16} />
|
>
|
||||||
{ingesting ? "Seeding…" : "Seed Demo Data"}
|
<Rocket size={16} />
|
||||||
</motion.button>
|
{ingesting ? "Seeding…" : "Seed Demo Data"}
|
||||||
)}
|
</motion.button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{toast && (
|
{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">
|
<div className="mt-2 text-xs text-slate-300 bg-gray-800/80 border border-gray-700 rounded px-2 py-1 inline-block">
|
||||||
|
|
|
||||||
60
web-app/src/index.js
Normal file
60
web-app/src/index.js
Normal 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);
|
||||||
|
})
|
||||||
Loading…
Add table
Add a link
Reference in a new issue