Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #346 add create repo #374

Open
wants to merge 2 commits into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 36 additions & 34 deletions app/api/repo/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NextResponse } from "next/server";
import { NextRequest, NextResponse } from "next/server";
import { getEnvVariables } from "../utils";

export async function GET() {
Expand All @@ -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 });
}
}
2 changes: 1 addition & 1 deletion app/components/dataPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const excludedProperties = [
"expand",
"collapsed",
"isPath",
"isPathStartEnd",
"isPathSelected",
"visible",
"index",
"curve",
Expand Down
90 changes: 48 additions & 42 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -92,6 +94,7 @@ export default function Home() {
title: "Uh oh! Something went wrong.",
description: await result.text(),
})
setIsSubmit(false)
return
}

Expand Down Expand Up @@ -209,50 +212,53 @@ export default function Home() {
}
</DropdownMenuContent>
</DropdownMenu>
{/* <Dialog open={createOpen} onOpenChange={setCreateOpen}>
<DialogTrigger asChild>
<button
className="h-full bg-black p-4 text-white rounded-lg"
title="Create new project"
>
<p>Create new project</p>
</button>
</DialogTrigger>
<DialogContent className='max-w-[26%] gap-8'>
<DialogHeader>
<DialogTitle>{!isSubmit ? "CREATE A NEW PROJECT" : "THANK YOU FOR A NEW REQUEST"}</DialogTitle>
</DialogHeader>
<DialogDescription className='text-warp'>
{
process.env.NEXT_PUBLIC_LOCAL_MODE &&
<Dialog open={createOpen} onOpenChange={setCreateOpen}>
<DialogTrigger asChild>
<button
className="h-full bg-black p-4 text-white rounded-lg"
title="Create new project"
>
<p>Create new project</p>
</button>
</DialogTrigger>
<DialogContent className='sm:max-w-[500px]'>
<DialogHeader>
<DialogTitle>{!isSubmit ? "CREATE A NEW PROJECT" : "THANK YOU FOR A NEW REQUEST"}</DialogTitle>
</DialogHeader>
<DialogDescription className='text-black'>
{
!isSubmit
? "Please provide the URL of the project to connect and start querying data"
: "Processing your graph, this could take a while. We appreciate your patience"
}
</DialogDescription>
{
!isSubmit
? "Please provide the URL of the model to connect and start querying data"
: "Processing your graph, this could take a while. We appreciate your patience"
!isSubmit ?
<form className='flex flex-col gap-4'>
<input
className='border p-3 rounded-lg'
type="text"
value={createURL}
onChange={(e) => setCreateURL(e.target.value)}
placeholder="Type Project URL (File:// or https://)"
/>
<div className='flex flex-row-reverse'>
<button
className='bg-black p-3 text-white rounded-lg'
type='submit'
title='Create Project'
>
<p>Create</p>
</button>
</div>
</form>
: <Progress value={0} />
}
</DialogDescription>
{
!isSubmit ?
<form className='flex flex-col gap-4' onSubmit={onCreateRepo}>
<input
className='border p-3 rounded-lg'
type="text"
value={createURL}
onChange={(e) => setCreateURL(e.target.value)}
placeholder="Type URL"
/>
<div className='flex flex-row-reverse'>
<button
className='bg-black p-3 text-white rounded-lg'
type='submit'
title='Create Project'
>
<p>Create</p>
</button>
</div>
</form>
: <Progress value={0} />
}
</DialogContent>
</Dialog> */}
</DialogContent>
</Dialog>
}
</ul>
</div>
<div className='h-2.5 bg-gradient-to-r from-[#EC806C] via-[#B66EBD] to-[#7568F2]' />
Expand Down
Loading