-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kolea PLESCO
authored and
Kolea PLESCO
committed
Jan 16, 2025
1 parent
fcebbda
commit 492eac5
Showing
7 changed files
with
144 additions
and
4 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
Empty file.
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,22 @@ | ||
from fastapi import APIRouter | ||
from fastapi.responses import JSONResponse | ||
from mapping_workbench.backend.config import settings | ||
|
||
ROUTE_PREFIX = "/demo" | ||
TAG = "demo" | ||
|
||
sub_router = APIRouter() | ||
|
||
|
||
@sub_router.post( | ||
"/reset", | ||
name="demo:reset" | ||
) | ||
async def metadata() -> JSONResponse: | ||
return JSONResponse(content={ | ||
"message": "Resetting the demo data" | ||
}) | ||
|
||
|
||
router = APIRouter() | ||
router.include_router(sub_router, prefix=ROUTE_PREFIX, tags=[TAG]) |
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,21 @@ | ||
import {apiPaths} from "../../paths"; | ||
import {appApi} from "../app"; | ||
|
||
class DemoConfigApi { | ||
get SECTION_TITLE() { | ||
return "Demo Config"; | ||
} | ||
|
||
constructor() { | ||
this.section = "demoConfig"; | ||
this.paths = apiPaths[this.section]; | ||
} | ||
|
||
async reset() { | ||
const endpoint = this.paths.reset; | ||
return appApi.post(endpoint); | ||
} | ||
|
||
} | ||
|
||
export const demoConfigApi = new DemoConfigApi(); |
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
65 changes: 65 additions & 0 deletions
65
mapping_workbench/frontend/src/pages/app/demo-config/index.js
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,65 @@ | ||
import {useEffect} from 'react'; | ||
|
||
import Card from '@mui/material/Card'; | ||
import Stack from '@mui/material/Stack'; | ||
import Typography from '@mui/material/Typography'; | ||
import {Seo} from 'src/components/seo'; | ||
import {usePageView} from 'src/hooks/use-page-view'; | ||
import {Layout as AppLayout} from 'src/layouts/app'; | ||
import {securityApi} from "../../../api/security"; | ||
import {useRouter} from "next/router"; | ||
import {useAuth} from "../../../hooks/use-auth"; | ||
import {paths} from "../../../paths"; | ||
import Button from "@mui/material/Button"; | ||
import ResetDemoIcon from "@mui/icons-material/RestartAlt"; | ||
import Paper from "@mui/material/Paper"; | ||
import {demoConfigApi} from "../../../api/demo-config"; | ||
|
||
|
||
const Page = () => { | ||
|
||
const auth = useAuth(); | ||
const router = useRouter(); | ||
|
||
useEffect( | ||
() => { | ||
if (!securityApi.isUserAdmin(auth?.user)) { | ||
router.replace(paths.notFound); | ||
} | ||
}, []); | ||
|
||
usePageView(); | ||
|
||
return ( | ||
<> | ||
<Seo title="Demo Config"/> | ||
|
||
<Stack spacing={4}> | ||
<Stack | ||
direction="row" | ||
justifyContent="space-between" | ||
spacing={4} | ||
> | ||
<Stack spacing={1}> | ||
<Typography variant="h4">Demo Config</Typography> | ||
</Stack> | ||
</Stack> | ||
<Card> | ||
<Paper sx={{p: 2}}> | ||
<Button variant='contained' | ||
color="warning" | ||
onClick={() => demoConfigApi.reset()} | ||
startIcon={<ResetDemoIcon/>}> | ||
Reset Demo Data | ||
</Button> | ||
|
||
</Paper> | ||
</Card> | ||
</Stack> | ||
</> | ||
); | ||
}; | ||
|
||
Page.getLayout = (page) => <AppLayout>{page}</AppLayout>; | ||
|
||
export default Page; |
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