diff --git a/app/api/repo/route.ts b/app/api/repo/route.ts index 95aa6cf..8fb38de 100644 --- a/app/api/repo/route.ts +++ b/app/api/repo/route.ts @@ -1,4 +1,4 @@ -import { NextResponse } from "next/server"; +import { NextRequest, NextResponse } from "next/server"; import { getEnvVariables } from "../utils"; export async function GET() { @@ -22,39 +22,41 @@ export async function GET() { return NextResponse.json({ result: repositories }, { status: 200 }) } catch (err) { console.error(err) - return NextResponse.json((err as Error).message, { status: 400 }) + return NextResponse.json((err as Error).message, { status: 400 }) } } -// export async function POST(request: NextRequest) { - -// const repo_url = request.nextUrl.searchParams.get('url'); - -// try { - -// if (!repo_url) { -// throw new Error("URL parameter is missing"); -// } - -// const { url, token } = getEnvVariables(); - -// const result = await fetch(`${url}/process_repo`, { -// method: 'POST', -// body: JSON.stringify({ repo_url, ignore: ["./.github", "./sbin", "./.git", "./deps", "./bin", "./build"] }), -// headers: { -// "Authorization": token, -// 'Content-Type': 'application/json' -// }, -// cache: 'no-store' -// }); - -// if (!result.ok) { -// throw new Error(await result.text()); -// } - -// return NextResponse.json({ message: "success" }, { status: 200 }); -// } catch (err) { -// console.error(err) -// return NextResponse.json((err as Error).message, { status: 400 }); -// } -// } +export async function POST(request: NextRequest) { + + const repo_url = request.nextUrl.searchParams.get('url'); + + try { + + if (!repo_url) { + throw new Error("URL parameter is missing"); + } + + const { url, token } = getEnvVariables(); + + const isLocal = repo_url.startsWith("file://") + + const result = await fetch(`${url}/${isLocal ? "analyze_folder" : "process_repo"}`, { + method: 'POST', + body: JSON.stringify({ repo_url, ignore: ["./.github", "./sbin", "./.git", "./deps", "./bin", "./build"] }), + headers: { + "Authorization": token, + 'Content-Type': 'application/json' + }, + cache: 'no-store' + }); + + if (!result.ok) { + throw new Error(await result.text()); + } + + return NextResponse.json({ message: "success" }, { status: 200 }); + } catch (err) { + console.error(err) + return NextResponse.json((err as Error).message, { status: 400 }); + } +} \ No newline at end of file diff --git a/app/components/dataPanel.tsx b/app/components/dataPanel.tsx index 21469cb..ca04fca 100644 --- a/app/components/dataPanel.tsx +++ b/app/components/dataPanel.tsx @@ -18,7 +18,7 @@ const excludedProperties = [ "expand", "collapsed", "isPath", - "isPathStartEnd", + "isPathSelected", "visible", "index", "curve", diff --git a/app/page.tsx b/app/page.tsx index ef7fa37..f6670b3 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -12,6 +12,8 @@ import { GraphContext } from './components/provider'; import Image from 'next/image'; import { DropdownMenu, DropdownMenuContent, DropdownMenuLabel, DropdownMenuTrigger } from '@/components/ui/dropdown-menu'; import { prepareArg } from './utils'; +import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger } from '@/components/ui/dialog'; +import { Progress } from '@/components/ui/progress'; export type PathNode = { id?: number @@ -92,6 +94,7 @@ export default function Home() { title: "Uh oh! Something went wrong.", description: await result.text(), }) + setIsSubmit(false) return } @@ -209,50 +212,53 @@ export default function Home() { } - {/* */} + + + }