Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
4rthem committed Dec 13, 2023
1 parent a448b65 commit 015aaef
Show file tree
Hide file tree
Showing 10 changed files with 349 additions and 25 deletions.
2 changes: 1 addition & 1 deletion dashboard/client/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
...require('../.prettierrc'),
...require('../../.prettierrc'),
};
37 changes: 36 additions & 1 deletion dashboard/client/config-compiler.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,41 @@
(function (config, env) {
const whiteList = [
'DATABOX_API_URL',
'DATABOX_CLIENT_URL',
'DEV_MODE',
'DISPLAY_SERVICES_MENU',
'DOCKER_TAG',
'ELASTICHQ_URL',
'EXPOSE_API_URL',
'EXPOSE_CLIENT_URL',
'KEYCLOAK_URL',
'MAILHOG_URL',
'MATOMO_URL',
'NOTIFY_API_URL',
'PGADMIN_URL',
'PHPMYADMIN_URL',
'RABBITMQ_CONSOLE_URL',
'REPORT_API_URL',
'SAML_URL',
'SAML2_URL',
'STACK_NAME',
'TRAEFIK_CONSOLE_URL',
'UPLOADER_API_URL',
'UPLOADER_CLIENT_URL',
'ZIPPY_URL',
];

const e = {};

Object.entries(env).forEach(([key, value]) => {
if (whiteList.includes(key)) {
e[key] = value;
}
})


return {
locales: config.available_locales,
env,
env: e,
};
});
40 changes: 22 additions & 18 deletions dashboard/client/index.tpl.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<head>
<meta charset="utf-8"/>
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
<!--
manifest.json provides metadata used when your web app is installed on a
Expand All @@ -21,20 +21,24 @@
-->
<title>Phrasea Dashboard</title>
__TPL_CONFIG__
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script type="module" src="/src/index.tsx"></script>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.

You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@100;400;700&display=swap" rel="stylesheet">
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script type="module" src="/src/index.tsx"></script>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
6 changes: 4 additions & 2 deletions dashboard/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
},
"dependencies": {
"@alchemy/theme-editor": "workspace:*",
"@mui/material": "^5.15.0",
"@mui/icons-material": "^5.15.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"vite-plugin-svgr": "^4.2.0",
"@mui/material": "^5.15.0"
"react-google-font-loader": "^1.1.0",
"vite-plugin-svgr": "^4.2.0"
},
"devDependencies": {
"@types/node": "^18.8.5",
Expand Down
32 changes: 32 additions & 0 deletions dashboard/client/src/ClientApp.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import Service, {ServiceBaseProps} from "./Service.tsx";
import AdminPanelSettingsIcon from '@mui/icons-material/AdminPanelSettings';
import ApiIcon from '@mui/icons-material/Api';

type Props = {
apiUrl: string;
clientUrl: string;
} & ServiceBaseProps;

export default function ClientApp({
apiUrl,
clientUrl,
...props
}: Props) {

return <Service
mainUrl={clientUrl}
links={[
{
icon: <AdminPanelSettingsIcon/>,
href: `${apiUrl}/admin`,
title: `Admin of ${props.title}`
},
{
icon: <ApiIcon/>,
href: apiUrl,
title: `API documentation of ${props.title}`
},
]}
{...props}
/>
}
61 changes: 60 additions & 1 deletion dashboard/client/src/Root.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,65 @@
import {Container, Grid} from "@mui/material";
import Service from "./Service";
import ClientApp from "./ClientApp.tsx";
import config from "./config.ts";

type Props = {};

export default function Root({}: Props) {
const {
DATABOX_API_URL,
EXPOSE_API_URL,
UPLOADER_API_URL,
NOTIFY_API_URL,
KEYCLOAK_URL,
DATABOX_CLIENT_URL,
EXPOSE_CLIENT_URL,
UPLOADER_CLIENT_URL,
} = config.env;

console.log('config.env', config.env);

return <>Dashboard!</>
return <Container>
<Grid
sx={{
pt: 2,
}}
container
spacing={2}
>
<Service
mainUrl={KEYCLOAK_URL}
title={`Identity Manager`}
description={`Keycloak IAM`}
logo={'/src/images/keycloak.png'}
/>
{DATABOX_API_URL && <ClientApp
apiUrl={DATABOX_API_URL}
clientUrl={DATABOX_CLIENT_URL}
title={`Databox`}
description={`Your DAM`}
logo={'/src/images/databox.png'}
/>}
{EXPOSE_API_URL && <ClientApp
apiUrl={EXPOSE_API_URL}
clientUrl={EXPOSE_CLIENT_URL}
title={`Expose`}
description={`Share Publications`}
logo={'/src/images/expose.png'}
/>}
{UPLOADER_API_URL && <ClientApp
apiUrl={UPLOADER_API_URL}
clientUrl={UPLOADER_CLIENT_URL}
title={`Uploader`}
description={`Standalone Asset deposit`}
logo={'/src/images/uploader.png'}
/>}
{NOTIFY_API_URL && <Service
mainUrl={`${NOTIFY_API_URL}/admin`}
title={`Notify`}
description={`Mail Sender`}
logo={'/src/images/notify.png'}
/>}
</Grid>
</Container>
}
91 changes: 91 additions & 0 deletions dashboard/client/src/Service.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import {Button, Card, CardActions, CardContent, CardMedia, Grid, IconButton, Typography,} from '@mui/material';
import {JSX, PropsWithChildren, ReactNode} from "react";

type BaseProps = {
title: string;
mainUrl?: string;
description?: ReactNode;
logo?: string;
};

type AppLink = {
icon: ReactNode;
title: string;
href: string;
}

type Props = {
links?: AppLink[];
} & BaseProps;

export type {BaseProps as ServiceBaseProps};

export default function Service({
title,
logo,
description,
mainUrl,
links = [],
}: Props) {
return <Grid
item
xs={6}
sm={4}
md={3}
>
<Card>
<Link
href={mainUrl}
>
<CardMedia
sx={(theme) => ({
height: 140,
backgroundSize: 'contain',
backgroundColor: theme.palette.background.default,
})}
image={logo}
title="green iguana"
/>
</Link>
<CardContent>
<Link href={mainUrl}>
<Typography gutterBottom variant="h5" component="div">
{title}
</Typography>
</Link>
{description && <Typography variant="body2" color="text.secondary">
{description}
</Typography>}
</CardContent>
<CardActions>
{links.map(({href, icon, title}, i) => <IconButton
size="small"
key={i}
href={href}
title={title}
>
{icon}
</IconButton>)}
</CardActions>
</Card>
</Grid>
}

function Link({href, children}: PropsWithChildren<{
href: string | undefined;
}>) {
if (href) {
return <a
style={{
textDecoration: 'none',
}}
href={href}
target={'_blank'}
rel={'noreferrer noopener'}
>
{children}
</a>
}

return children as JSX.Element;
}
26 changes: 25 additions & 1 deletion dashboard/client/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,31 @@ declare global {
interface Window {
config: {
locales: string[];
env: Record<string, string>;
env: {
DATABOX_API_URL: string;
DATABOX_CLIENT_URL: string;
DEV_MODE: string;
DISPLAY_SERVICES_MENU: string;
DOCKER_TAG: string;
ELASTICHQ_URL: string;
EXPOSE_API_URL: string;
EXPOSE_CLIENT_URL: string;
KEYCLOAK_URL: string;
MAILHOG_URL: string;
MATOMO_URL: string;
NOTIFY_API_URL: string;
PGADMIN_URL: string;
PHPMYADMIN_URL: string;
RABBITMQ_CONSOLE_URL: string;
REPORT_API_URL: string;
SAML_URL: string;
SAML2_URL: string;
STACK_NAME: string;
TRAEFIK_CONSOLE_URL: string;
UPLOADER_API_URL: string;
UPLOADER_CLIENT_URL: string;
ZIPPY_URL: string;
};
};
}
}
Expand Down
Loading

0 comments on commit 015aaef

Please sign in to comment.