mirror of
https://github.com/Noratrieb/haesli.git
synced 2026-01-14 19:55:03 +01:00
cleanup
This commit is contained in:
parent
5befe288e5
commit
d7b574cef4
6 changed files with 23 additions and 57 deletions
|
|
@ -10,4 +10,6 @@ amqp_core = { path = "../amqp_core" }
|
|||
axum = "0.4.5"
|
||||
serde = { version = "1.0.136", features = ["derive"] }
|
||||
tokio = { version = "1.17.0", features = ["full"] }
|
||||
tower = "0.4.12"
|
||||
tower-http = { version = "0.2.3", features = ["cors"] }
|
||||
tracing = "0.1.31"
|
||||
|
|
|
|||
|
|
@ -1,46 +1 @@
|
|||
# Getting Started with Create React App
|
||||
|
||||
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
|
||||
|
||||
## Available Scripts
|
||||
|
||||
In the project directory, you can run:
|
||||
|
||||
### `yarn start`
|
||||
|
||||
Runs the app in the development mode.\
|
||||
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
|
||||
|
||||
The page will reload if you make edits.\
|
||||
You will also see any lint errors in the console.
|
||||
|
||||
### `yarn test`
|
||||
|
||||
Launches the test runner in the interactive watch mode.\
|
||||
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
|
||||
|
||||
### `yarn build`
|
||||
|
||||
Builds the app for production to the `build` folder.\
|
||||
It correctly bundles React in production mode and optimizes the build for the best performance.
|
||||
|
||||
The build is minified and the filenames include the hashes.\
|
||||
Your app is ready to be deployed!
|
||||
|
||||
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
|
||||
|
||||
### `yarn eject`
|
||||
|
||||
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
|
||||
|
||||
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
|
||||
|
||||
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
|
||||
|
||||
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
|
||||
|
||||
## Learn More
|
||||
|
||||
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
|
||||
|
||||
To learn React, check out the [React documentation](https://reactjs.org/).
|
||||
# Dashboard frontend for the AMQP broker
|
||||
|
|
|
|||
|
|
@ -2,6 +2,12 @@
|
|||
"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"
|
||||
},
|
||||
"dependencies": {
|
||||
"@testing-library/jest-dom": "^5.14.1",
|
||||
"@testing-library/react": "^12.0.0",
|
||||
|
|
@ -19,12 +25,6 @@
|
|||
"devDependencies": {
|
||||
"prettier": "^2.5.1"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "react-scripts start",
|
||||
"build": "react-scripts build",
|
||||
"test": "react-scripts test",
|
||||
"eject": "react-scripts eject"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": [
|
||||
"react-app",
|
||||
|
|
|
|||
|
|
@ -3,11 +3,13 @@
|
|||
use amqp_core::GlobalData;
|
||||
use axum::{
|
||||
body::{boxed, Full},
|
||||
http::Method,
|
||||
response::{Html, IntoResponse, Response},
|
||||
routing::get,
|
||||
Json, Router,
|
||||
};
|
||||
use serde::Serialize;
|
||||
use tower_http::cors::{Any, CorsLayer};
|
||||
use tracing::info;
|
||||
|
||||
const INDEX_HTML: &str = include_str!("../assets/index.html");
|
||||
|
|
@ -15,13 +17,17 @@ const SCRIPT_JS: &str = include_str!("../assets/script.js");
|
|||
const STYLE_CSS: &str = include_str!("../assets/style.css");
|
||||
|
||||
pub async fn dashboard(global_data: GlobalData) {
|
||||
let cors = CorsLayer::new()
|
||||
.allow_methods(vec![Method::GET])
|
||||
.allow_origin(Any);
|
||||
|
||||
let app = Router::new()
|
||||
.route("/", get(get_index_html))
|
||||
.route("/script.js", get(get_script_js))
|
||||
.route("/style.css", get(get_style_css))
|
||||
.route("/api/data", get(move || get_data(global_data)));
|
||||
.route("/api/data", get(move || get_data(global_data)).layer(cors));
|
||||
|
||||
let socket_addr = "0.0.0.0:3000".parse().unwrap();
|
||||
let socket_addr = "0.0.0.0:8080".parse().unwrap();
|
||||
|
||||
info!(%socket_addr, "Starting up dashboard on address");
|
||||
|
||||
|
|
@ -57,6 +63,7 @@ struct Data {
|
|||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct Connection {
|
||||
id: String,
|
||||
peer_addr: String,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue