Skip to content

Commit 04fa785

Browse files
authored
Merge pull request #374 from FalkorDB/add-create-repo
Fix #346 add create repo
2 parents f593090 + 13d27c1 commit 04fa785

File tree

3 files changed

+87
-82
lines changed

3 files changed

+87
-82
lines changed

app/api/repo/route.ts

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { NextResponse } from "next/server";
1+
import { NextRequest, NextResponse } from "next/server";
22
import { getEnvVariables } from "../utils";
33

44
export async function GET() {
@@ -22,39 +22,41 @@ export async function GET() {
2222
return NextResponse.json({ result: repositories }, { status: 200 })
2323
} catch (err) {
2424
console.error(err)
25-
return NextResponse.json((err as Error).message, { status: 400 })
25+
return NextResponse.json((err as Error).message, { status: 400 })
2626
}
2727
}
2828

29-
// export async function POST(request: NextRequest) {
30-
31-
// const repo_url = request.nextUrl.searchParams.get('url');
32-
33-
// try {
34-
35-
// if (!repo_url) {
36-
// throw new Error("URL parameter is missing");
37-
// }
38-
39-
// const { url, token } = getEnvVariables();
40-
41-
// const result = await fetch(`${url}/process_repo`, {
42-
// method: 'POST',
43-
// body: JSON.stringify({ repo_url, ignore: ["./.github", "./sbin", "./.git", "./deps", "./bin", "./build"] }),
44-
// headers: {
45-
// "Authorization": token,
46-
// 'Content-Type': 'application/json'
47-
// },
48-
// cache: 'no-store'
49-
// });
50-
51-
// if (!result.ok) {
52-
// throw new Error(await result.text());
53-
// }
54-
55-
// return NextResponse.json({ message: "success" }, { status: 200 });
56-
// } catch (err) {
57-
// console.error(err)
58-
// return NextResponse.json((err as Error).message, { status: 400 });
59-
// }
60-
// }
29+
export async function POST(request: NextRequest) {
30+
31+
const repo_url = request.nextUrl.searchParams.get('url');
32+
33+
try {
34+
35+
if (!repo_url) {
36+
throw new Error("URL parameter is missing");
37+
}
38+
39+
const { url, token } = getEnvVariables();
40+
41+
const isLocal = repo_url.startsWith("file://")
42+
43+
const result = await fetch(`${url}/${isLocal ? "analyze_folder" : "analyze_repo"}`, {
44+
method: 'POST',
45+
body: JSON.stringify({ repo_url, ignore: ["./.github", "./sbin", "./.git", "./deps", "./bin", "./build"] }),
46+
headers: {
47+
"Authorization": token,
48+
'Content-Type': 'application/json'
49+
},
50+
cache: 'no-store'
51+
});
52+
53+
if (!result.ok) {
54+
throw new Error(await result.text());
55+
}
56+
57+
return NextResponse.json({ message: "success" }, { status: 200 });
58+
} catch (err) {
59+
console.error(err)
60+
return NextResponse.json((err as Error).message, { status: 400 });
61+
}
62+
}

app/components/dataPanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const excludedProperties = [
1818
"expand",
1919
"collapsed",
2020
"isPath",
21-
"isPathStartEnd",
21+
"isPathSelected",
2222
"visible",
2323
"index",
2424
"curve",

app/page.tsx

Lines changed: 50 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@ import { VisuallyHidden } from '@radix-ui/react-visually-hidden';
1212
import Image from 'next/image';
1313
import { DropdownMenu, DropdownMenuContent, DropdownMenuLabel, DropdownMenuTrigger } from '@/components/ui/dropdown-menu';
1414
import { prepareArg } from './utils';
15+
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger } from '@/components/ui/dialog';
16+
import { Progress } from '@/components/ui/progress';
1517
import { Carousel, CarouselApi, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious } from '@/components/ui/carousel';
1618
import { Drawer, DrawerContent, DrawerDescription, DrawerTitle, DrawerTrigger } from '@/components/ui/drawer';
1719
import Input from './components/Input';
1820
import { ForceGraphMethods, NodeObject } from 'react-force-graph-2d';
1921
import { Labels } from './components/labels';
2022
import { Toolbar } from './components/toolbar';
2123
import { cn, handleZoomToFit, Message, Path, PathData, PathNode } from '@/lib/utils';
24+
import { GraphContext } from './components/provider';
2225

2326
type Tip = {
2427
title: string
@@ -118,6 +121,7 @@ export default function Home() {
118121
title: "Uh oh! Something went wrong.",
119122
description: await result.text(),
120123
})
124+
setIsSubmit(false)
121125
return
122126
}
123127

@@ -329,60 +333,59 @@ export default function Home() {
329333
}
330334
</DropdownMenuContent>
331335
</DropdownMenu>
332-
{/* <Dialog open={createOpen} onOpenChange={setCreateOpen}>
333-
<DialogTrigger asChild>
334-
<button
335-
className="h-full bg-black p-4 text-white rounded-lg"
336-
title="Create new project"
337-
>
338-
<p>Create new project</p>
339-
</button>
340-
</DialogTrigger>
341-
<DialogContent className='max-w-[26%] gap-8'>
342-
<DialogHeader>
343-
<DialogTitle>{!isSubmit ? "CREATE A NEW PROJECT" : "THANK YOU FOR A NEW REQUEST"}</DialogTitle>
344-
</DialogHeader>
345-
<DialogDescription className='text-warp'>
346336
{
347-
!isSubmit
348-
? "Please provide the URL of the model to connect and start querying data"
349-
: "Processing your graph, this could take a while. We appreciate your patience"
350-
}
351-
</DialogDescription>
352-
{
353-
!isSubmit ?
354-
<form className='flex flex-col gap-4' onSubmit={onCreateRepo}>
355-
<input
356-
className='border p-3 rounded-lg'
357-
type="text"
358-
value={createURL}
359-
onChange={(e) => setCreateURL(e.target.value)}
360-
placeholder="Type URL"
361-
/>
362-
<div className='flex flex-row-reverse'>
363-
<button
364-
className='bg-black p-3 text-white rounded-lg'
365-
type='submit'
366-
title='Create Project'
367-
>
368-
<p>Create</p>
369-
</button>
370-
</div>
371-
</form>
372-
: <Progress value={0} />
373-
}
337+
process.env.NEXT_PUBLIC_LOCAL_MODE &&
338+
<Dialog open={createOpen} onOpenChange={setCreateOpen}>
339+
<DialogTrigger asChild>
340+
<button
341+
className="h-full bg-black p-4 text-white rounded-lg"
342+
title="Create new project"
343+
>
344+
<p>Create new project</p>
345+
</button>
346+
</DialogTrigger>
347+
<DialogContent className='sm:max-w-[500px]'>
348+
<DialogHeader>
349+
<DialogTitle>{!isSubmit ? "CREATE A NEW PROJECT" : "THANK YOU FOR A NEW REQUEST"}</DialogTitle>
350+
</DialogHeader>
351+
<DialogDescription className='text-black'>
352+
{
353+
!isSubmit
354+
? "Please provide the URL of the project to connect and start querying data"
355+
: "Processing your graph, this could take a while. We appreciate your patience"
356+
}
357+
</DialogDescription>
358+
{
359+
!isSubmit ?
360+
<form onSubmit={onCreateRepo} className='flex flex-col gap-4'>
361+
<input
362+
className='border p-3 rounded-lg'
363+
type="text"
364+
value={createURL}
365+
onChange={(e) => setCreateURL(e.target.value)}
366+
placeholder="Type Project URL (File:// or https://)"
367+
/>
368+
<div className='flex flex-row-reverse'>
369+
<button
370+
className='bg-black p-3 text-white rounded-lg'
371+
type='submit'
372+
title='Create Project'
373+
>
374+
<p>Create</p>
375+
</button>
376+
</div>
377+
</form>
378+
: <Progress value={0} />
379+
}
374380
</DialogContent>
375-
</Dialog> */}
381+
</Dialog>
382+
}
376383
</ul>
377384
</div>
378385
<div className='h-2.5 bg-gradient-to-r from-[#EC806C] via-[#B66EBD] to-[#7568F2]' />
379386
</header>
380387
<PanelGroup direction="horizontal" className="w-full h-full">
381-
<Panel
382-
defaultSize={graph.Id ? 70 : 100}
383-
maxSize={100}
384-
minSize={50}
385-
>
388+
<Panel defaultSize={70} className="flex flex-col" minSize={50}>
386389
<CodeGraph
387390
graph={graph}
388391
data={data}

0 commit comments

Comments
 (0)