Started implementing adding routes
This commit is contained in:
parent
02ba2faef0
commit
3b579f1f97
2 changed files with 63 additions and 27 deletions
38
app/page.tsx
38
app/page.tsx
|
|
@ -7,18 +7,54 @@ import { useRoutes } from '@/lib/clientActions';
|
||||||
import Image from 'next/image';
|
import Image from 'next/image';
|
||||||
import Loading from '@/components/Loading';
|
import Loading from '@/components/Loading';
|
||||||
import Error from '@/components/Error';
|
import Error from '@/components/Error';
|
||||||
|
import { useState } from 'react';
|
||||||
|
import { RouteDialog } from '@/components/RouteDialog';
|
||||||
|
|
||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
|
|
||||||
|
const [routeDialog, setRouteDialog] = useState(false);
|
||||||
const { data: routes, error, isLoading } = useRoutes();
|
const { data: routes, error, isLoading } = useRoutes();
|
||||||
let routesMap: Route[] = routes as Route[];
|
let routesMap: Route[] = routes as Route[];
|
||||||
|
|
||||||
if (error) return <Error />
|
if (error) return <Error />
|
||||||
if (isLoading) return <Loading />
|
if (isLoading) return <Loading />
|
||||||
|
|
||||||
|
let route = {
|
||||||
|
"handle": [
|
||||||
|
{
|
||||||
|
"handler": "subroute",
|
||||||
|
"routes": [
|
||||||
|
{
|
||||||
|
"handle": [
|
||||||
|
{
|
||||||
|
"handler": "reverse_proxy",
|
||||||
|
"upstreams": [
|
||||||
|
{
|
||||||
|
"dial": "1.1.1.1"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"match": [
|
||||||
|
{
|
||||||
|
"host": [
|
||||||
|
"containers.grug.dev",
|
||||||
|
"containers.daddyimpregnant.com",
|
||||||
|
"containers.mizuledevelopment.com"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"terminal": true
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main>
|
<main>
|
||||||
|
{routeDialog && <RouteDialog route={route as Route} />}
|
||||||
<div className='flex items-center justify-center p-6'>
|
<div className='flex items-center justify-center p-6'>
|
||||||
<Card className='flex'>
|
<Card className='flex'>
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
|
|
@ -31,7 +67,7 @@ export default function Home() {
|
||||||
</div>
|
</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
<CardFooter>
|
<CardFooter>
|
||||||
<Button className='translate-y-2.5'>Create</Button>
|
<Button onClick={() => setRouteDialog(!routeDialog)} className='translate-y-2.5'>Create</Button>
|
||||||
</CardFooter>
|
</CardFooter>
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -53,12 +53,12 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updateRoute(index: number, route: Route) {
|
export async function updateRoute(index: number, route: Route) {
|
||||||
return fetch(`http://192.168.1.69:2019/config/apps/http/servers/srv0/routes/${index}`, {
|
return await fetch(`http://192.168.1.69:2019/config/apps/http/servers/srv0/routes/${index}`, {
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
},
|
},
|
||||||
cache: 'no-cache',
|
cache: 'no-cache',
|
||||||
body: JSON.stringify(route)
|
body: JSON.stringify(route)
|
||||||
}).then((res) => res.json()).catch((err) => console.log(err));
|
}).then((res) => res.json())
|
||||||
}
|
}
|
||||||
Loading…
Add table
Reference in a new issue