diff --git a/app/page.tsx b/app/page.tsx index 08076be..2c54c63 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -7,37 +7,73 @@ import { useRoutes } from '@/lib/clientActions'; import Image from 'next/image'; import Loading from '@/components/Loading'; import Error from '@/components/Error'; +import { useState } from 'react'; +import { RouteDialog } from '@/components/RouteDialog'; export default function Home() { + const [routeDialog, setRouteDialog] = useState(false); const { data: routes, error, isLoading } = useRoutes(); let routesMap: Route[] = routes as Route[]; - if(error) return - if(isLoading) return + if (error) return + if (isLoading) return - return ( -
-
- - - Active Routes - Amount of configured routes - - -
-

{routesMap.length}

-
-
- - - -
-
-
- -
-
- ) + 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 ( +
+ {routeDialog && } +
+ + + Active Routes + Amount of configured routes + + +
+

{routesMap.length}

+
+
+ + + +
+
+
+ +
+
+ ) } \ No newline at end of file diff --git a/lib/serverActions.ts b/lib/serverActions.ts index 513df27..618f558 100644 --- a/lib/serverActions.ts +++ b/lib/serverActions.ts @@ -53,12 +53,12 @@ } 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', headers: { 'Content-Type': 'application/json' }, cache: 'no-cache', body: JSON.stringify(route) - }).then((res) => res.json()).catch((err) => console.log(err)); + }).then((res) => res.json()) } \ No newline at end of file