-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1072 from notmd/1068_admin_system_config
System config parameter view
- Loading branch information
Showing
12 changed files
with
219 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { useRouter } from "next/router"; | ||
import { useSession } from "next-auth/react"; | ||
import { ReactNode, useEffect } from "react"; | ||
|
||
export const AdminArea = ({ children }: { children: ReactNode }) => { | ||
const router = useRouter(); | ||
const { data: session, status } = useSession(); | ||
|
||
useEffect(() => { | ||
if (status === "loading") { | ||
return; | ||
} | ||
if (session?.user.role === "admin") { | ||
return; | ||
} | ||
router.push("/"); | ||
}, [router, session, status]); | ||
return <main>{status === "loading" ? "loading..." : children}</main>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Card, CardBody, CircularProgress } from "@chakra-ui/react"; | ||
import Head from "next/head"; | ||
import { AdminArea } from "src/components/AdminArea"; | ||
import { getAdminLayout } from "src/components/Layout"; | ||
import { get } from "src/lib/api"; | ||
import useSWRImmutable from "swr/immutable"; | ||
export { getDefaultStaticProps as getStaticProps } from "src/lib/default_static_props"; | ||
|
||
export default function Parameters() { | ||
const { data, isLoading, error } = useSWRImmutable("/api/admin/parameters", get); | ||
|
||
return ( | ||
<> | ||
<Head> | ||
<title>Parameters - Open Assistant</title> | ||
</Head> | ||
<AdminArea> | ||
<Card> | ||
<CardBody> | ||
{isLoading && <CircularProgress isIndeterminate></CircularProgress>} | ||
{error && "Unable to load data"} | ||
{data && ( | ||
<Card variant="json" overflowX="auto"> | ||
<CardBody> | ||
<pre>{JSON.stringify(data, null, 2)}</pre> | ||
</CardBody> | ||
</Card> | ||
)} | ||
</CardBody> | ||
</Card> | ||
</AdminArea> | ||
</> | ||
); | ||
} | ||
|
||
Parameters.getLayout = getAdminLayout; |
Oops, something went wrong.