rename lol

This commit is contained in:
nora 2022-03-19 14:27:30 +01:00
parent c68cd04af7
commit 543e39f129
70 changed files with 283 additions and 266 deletions

23
haesli_dashboard/frontend/.gitignore vendored Normal file
View file

@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*

View file

@ -0,0 +1 @@
build

View file

@ -0,0 +1,3 @@
{
"singleQuote": true
}

View file

@ -0,0 +1 @@
# Dashboard frontend for the AMQP broker

View file

@ -0,0 +1,48 @@
{
"name": "frontend",
"version": "0.1.0",
"private": true,
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"fmt": "prettier -w .",
"check-fmt": "prettier -c ."
},
"dependencies": {
"@testing-library/jest-dom": "^5.14.1",
"@testing-library/react": "^12.0.0",
"@testing-library/user-event": "^13.2.1",
"@types/jest": "^27.0.1",
"@types/node": "^16.7.13",
"@types/react": "^17.0.20",
"@types/react-dom": "^17.0.9",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "5.0.0",
"typescript": "^4.4.2",
"web-vitals": "^2.1.0"
},
"devDependencies": {
"prettier": "^2.5.1"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View file

@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
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.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

View file

@ -0,0 +1,25 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}

View file

@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:

View file

@ -0,0 +1,17 @@
html {
font-family: arial, sans-serif;
background-color: #282c34;
color: white;
}
.app {
margin: 50px;
}
table,
th,
td {
border: 1px solid white;
border-collapse: collapse;
padding: 10px;
}

View file

@ -0,0 +1,20 @@
import React from 'react';
import DataPage from './components/data-page';
import './app.css';
const IS_PROD = process.env.NODE_ENV === 'production';
const URL_PREFIX = IS_PROD ? '' : 'http://localhost:8080/';
const App = () => {
return (
<div className="app">
<header className="header">
<h1>Haesli Dashboard</h1>
</header>
<DataPage prefix={URL_PREFIX} />
</div>
);
};
export default App;

View file

@ -0,0 +1,88 @@
import React, { FC, useCallback, useEffect, useState } from 'react';
import Table from './table';
import type { Data } from '../types';
const fetchData = async (prefix: string): Promise<Data> => {
const url = `${prefix}api/data`;
return fetch(url).then((res) => res.json());
};
type Props = {
prefix: string;
};
const DataPage: FC<Props> = ({ prefix }) => {
const [data, setData] = useState<Data | null>(null);
const refresh = useCallback(async () => {
const newData = await fetchData(prefix);
setData(newData);
}, [setData, prefix]);
useEffect(() => {
const interval = setInterval(refresh, 1000);
return () => clearInterval(interval);
}, [refresh]);
return (
<div>
<section>
<h2>Connections</h2>
{data ? (
<Table
headers={['Connection ID', 'Client Address', 'Channels']}
rows={data.connections.map((connection) => [
connection.id,
connection.peerAddr,
connection.channels.length,
])}
/>
) : (
<div>Loading...</div>
)}
</section>
<section>
<h2>Queues</h2>
{data ? (
<Table
headers={['Queue ID', 'Name', 'Durable', 'Message Count']}
rows={data.queues.map((queue) => [
queue.id,
queue.name,
queue.durable ? 'Yes' : 'No',
queue.messages,
])}
/>
) : (
<div>Loading...</div>
)}
</section>
<section>
<h2>Channels</h2>
{data ? (
<Table
headers={['Channel ID', 'Connection ID', 'Number']}
rows={data.connections
.map((connection) =>
connection.channels.map((channel) => ({
...channel,
connectionId: connection.id,
}))
)
.flat()
.map((channel) => [
channel.id,
channel.connectionId,
channel.number,
])}
/>
) : (
<div>Loading...</div>
)}
</section>
</div>
);
};
export default DataPage;

View file

@ -0,0 +1,31 @@
import React, { FC } from 'react';
type Cell = string | number;
type Row = ReadonlyArray<Cell>;
type Props = {
headers: ReadonlyArray<string>;
rows: ReadonlyArray<Row>;
};
const Table: FC<Props> = ({ headers, rows }) => {
return (
<table>
<tr>
{headers.map((header) => (
<th>{header}</th>
))}
</tr>
{rows.map((row) => (
<tr>
{row.map((cell) => (
<td>{cell}</td>
))}
</tr>
))}
</table>
);
};
export default Table;

View file

@ -0,0 +1,13 @@
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}

View file

@ -0,0 +1,11 @@
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './app';
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
);

View file

@ -0,0 +1,22 @@
export type Channel = {
id: string;
number: number;
};
export type Connection = {
id: string;
peerAddr: string;
channels: ReadonlyArray<Channel>;
};
export type Queue = {
id: string;
name: string;
durable: boolean;
messages: number;
};
export type Data = {
connections: ReadonlyArray<Connection>;
queues: ReadonlyArray<Queue>;
};

View file

@ -0,0 +1,20 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": ["src"]
}

File diff suppressed because it is too large Load diff