-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
13 changed files
with
212 additions
and
53 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
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 was deleted.
Oops, something went wrong.
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,30 @@ | ||
import Typography from "@mui/material/Typography" | ||
import { tss } from "tss-react/mui" | ||
|
||
export const AppVersion = () => { | ||
const { classes } = useStyles() | ||
return ( | ||
<div className={classes.footer}> | ||
<Typography variant="body1" color="textSecondary"> | ||
Drama Queen version {APP_VERSION} | ||
</Typography> | ||
</div> | ||
) | ||
} | ||
|
||
|
||
|
||
const useStyles = tss | ||
.create(({ theme }) => ({ | ||
footer: { | ||
backgroundColor: '#f5f5f5', | ||
borderTop: '1px solid black', | ||
position: 'fixed', | ||
left: 0, | ||
bottom: 0, | ||
width: '100%', | ||
textAlign: 'center', | ||
padding: '2px 0 2px 0', | ||
}, | ||
}) | ||
) |
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,3 @@ | ||
export function Orchestrator() { | ||
return <>Orchestrator</> | ||
} |
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 |
---|---|---|
@@ -1,21 +1,35 @@ | ||
import { Container, Typography } from "@mui/material" | ||
import { useTranslate } from "hooks/useTranslate" | ||
import { tss } from "tss-react/mui"; | ||
import { useSearchParams } from "react-router-dom"; | ||
import { z } from "zod"; | ||
import { makeSearchParamsObjSchema } from "ui/tools/makeSearchParamsObjectSchema"; | ||
import { VisualizeForm } from "./VisualizeForm"; | ||
|
||
const searchParamsSchema = z.object({ | ||
questionnaire: z.string().optional(), | ||
data: z.string().optional(), | ||
nomenclature: z.record(z.string()).optional(), | ||
readonly: z.boolean().optional() | ||
}) | ||
|
||
|
||
export function Visualize() { | ||
const { t } = useTranslate() | ||
const { classes } = useStyles() | ||
|
||
//const { classes } = useStyles(); | ||
|
||
const [searchParams] = useSearchParams() | ||
|
||
const params = makeSearchParamsObjSchema(searchParamsSchema).safeParse(searchParams) | ||
|
||
console.log(params.success ? params.data : params.error); | ||
|
||
return ( | ||
<Container> | ||
<Typography variant="h3" className={classes.title}>{t("vizu")}</Typography> | ||
</Container> | ||
<VisualizeForm /> | ||
) | ||
} | ||
|
||
|
||
const useStyles = tss.create( | ||
() => ({ | ||
title: { | ||
textAlign: 'center', | ||
} | ||
|
||
}) | ||
) |
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,40 @@ | ||
import { Button, FormControl, FormControlLabel, FormGroup, InputLabel, MenuItem, Radio, RadioGroup, Select, Stack, Switch, TextField, Typography } from "@mui/material" | ||
import { useTranslate } from "hooks/useTranslate" | ||
import { tss } from "tss-react/mui"; | ||
|
||
|
||
export function VisualizeForm() { | ||
const { t } = useTranslate() | ||
const { classes } = useStyles() | ||
return ( | ||
<Stack spacing={3} alignItems="center"> | ||
<Stack spacing={2}> | ||
<Typography variant="h3" className={classes.title}>{t("vizu")}</Typography> | ||
<TextField id="questionnaire-url-form" | ||
label={t("vizu.input.survey.label")} helperText={t('vizu.input.survey.helper')} /> | ||
<TextField id="data-url-form" | ||
label={t("vizu.input.data.label")} helperText={t('vizu.input.data.helper')} /> | ||
<TextField id="nomenclature-url-form" | ||
label={t("vizu.input.nomenclatures.label")} helperText={t('vizu.input.nomenclatures.helper')} /> | ||
</Stack> | ||
<Stack direction={"row"} alignItems="center"> | ||
<FormGroup> | ||
<FormControlLabel control={<Switch />} label="Lecture Seul" /> | ||
</FormGroup> | ||
</Stack> | ||
<Button variant="contained" type="submit">{t('vizu.button.label')}</Button> | ||
</Stack> | ||
) | ||
} | ||
|
||
|
||
const useStyles = tss.create( | ||
() => ({ | ||
title: { | ||
textAlign: 'center', | ||
}, | ||
selectExample: { | ||
minWidth: 120 | ||
} | ||
}) | ||
) |
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,11 @@ | ||
import { Outlet } from "react-router-dom"; | ||
import { AppVersion } from "ui/components/appVersion"; | ||
|
||
export function Layout() { | ||
return ( | ||
<> | ||
<Outlet /> | ||
<AppVersion /> | ||
</> | ||
); | ||
} |
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,30 @@ | ||
import { z } from 'zod' | ||
|
||
function safeParseJSON ( string: string ): any { | ||
try { return JSON.parse( string ) } | ||
catch { return string } | ||
} | ||
|
||
function searchParamsToValues ( searchParams: URLSearchParams ): Record<string, any> { | ||
return Array.from( searchParams.keys() ).reduce( ( record, key ) => { | ||
const values = searchParams.getAll( key ).map( safeParseJSON ) | ||
return { ...record, [ key ]: values.length > 1 ? values : values[ 0 ] } | ||
}, {} as Record<string, any> ) | ||
} | ||
|
||
export function makeSearchParamsObjSchema< | ||
Schema extends z.ZodObject<z.ZodRawShape> | ||
> ( schema: Schema ) { | ||
return z.instanceof( URLSearchParams ) | ||
.transform( searchParamsToValues ) | ||
.pipe( schema ) | ||
} | ||
|
||
function coerceToArray< | ||
Schema extends z.ZodArray<z.ZodTypeAny> | ||
> ( schema: Schema ) { | ||
return z.union( [ | ||
z.any().array(), | ||
z.any().transform( x => [ x ] ), | ||
] ).pipe( schema ) | ||
} |
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