Skip to content

Commit 47f8b5d

Browse files
authored
Merge pull request #73 from aws-samples/feature/report
Feature/report add frontend code
2 parents 6431f50 + 5e9d6fb commit 47f8b5d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+2957
-1
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ celerybeat.pid
120120
*.sage.py
121121

122122
# Environments
123-
.env
124123
.venv
125124
env/
126125
venv/

report-front-end/.env

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Server 端的API地址, 例如 https://aws.com/
2+
# 注意浏览器https的安全策略问题
3+
# 仅在构建时会打包进代码, 更新后要重新构建和部署代码
4+
REACT_APP_BACKEND_URL=

report-front-end/.gitignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# production
12+
/build
13+
14+
# misc
15+
.DS_Store
16+
.env.local
17+
.env.development.local
18+
.env.test.local
19+
.env.production.local
20+
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*

report-front-end/Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM public.ecr.aws/docker/library/node:20.9.0 AS builder
2+
COPY . /tmp/frontend/
3+
RUN cd /tmp/frontend/ && npm ci && npm run build
4+
5+
FROM public.ecr.aws/docker/library/nginx:1.23-alpine
6+
COPY --from=builder /tmp/frontend/build/ /usr/share/nginx/public/
7+
COPY nginx-config/ /etc/nginx/
8+
EXPOSE 8800
9+
CMD ["nginx", "-g", "daemon off;"]
10+
11+
# run on linux ec2/lambda/ecs(amd64)
12+
# docker buildx build --platform linux/amd64 --network host -t my_tag .
13+
14+
# run on lambda/macOS(arm64)
15+
# docker buildx build --platform linux/arm64 --network host -t my_tag .

report-front-end/README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Getting Started with Create React App
2+
3+
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4+
5+
## Available Scripts
6+
7+
In the project directory, you can run:
8+
9+
### `npm start`
10+
11+
Runs the app in the development mode.\
12+
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
13+
14+
The page will reload if you make edits.\
15+
You will also see any lint errors in the console.
16+
17+
### `npm test`
18+
19+
Launches the test runner in the interactive watch mode.\
20+
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21+
22+
### `npm run build`
23+
24+
Builds the app for production to the `build` folder.\
25+
It correctly bundles React in production mode and optimizes the build for the best performance.
26+
27+
The build is minified and the filenames include the hashes.\
28+
Your app is ready to be deployed!
29+
30+
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31+
32+
### `npm run eject`
33+
34+
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
35+
36+
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.
37+
38+
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.
39+
40+
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.
41+
42+
## Learn More
43+
44+
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45+
46+
To learn React, check out the [React documentation](https://reactjs.org/).
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
worker_processes 1;
2+
3+
error_log /dev/stderr warn;
4+
pid /tmp/nginx.pid;
5+
6+
7+
events {
8+
worker_connections 1024;
9+
}
10+
11+
http {
12+
server {
13+
listen 8800 default_server;
14+
location / {
15+
root /usr/share/nginx/public;
16+
index index.html index.htm;
17+
try_files $uri $uri/ /index.html;
18+
}
19+
20+
error_page 500 502 503 504 /50x.html;
21+
location = /50x.html {
22+
root /usr/share/nginx/public;
23+
}
24+
25+
server_tokens off;
26+
proxy_hide_header X-Powered-By;
27+
add_header X-Frame-Options deny;
28+
add_header X-Content-Type-Options nosniff;
29+
# CSP策略相关配置
30+
# add_header Content-Security-Policy "default-src 'self' tmnk.net; img-src 'self' blob: data:; style-src 'self' 'unsafe-inline' blob: data:; font-src 'self' blob: data:; script-src 'self' 'unsafe-inline' 'unsafe-eval';";
31+
if ($request_method !~ ^(GET|HEAD|POST)$ ) {
32+
return 444;
33+
}
34+
}
35+
36+
include /etc/nginx/mime.types;
37+
default_type application/octet-stream;
38+
39+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
40+
'$status $body_bytes_sent "$http_referer" '
41+
'"$http_user_agent" "$http_x_forwarded_for"';
42+
43+
access_log /dev/stdout main;
44+
45+
client_body_temp_path /tmp 1 2;
46+
proxy_temp_path /tmp 1 2;
47+
fastcgi_temp_path /tmp 1 2;
48+
uwsgi_temp_path /tmp 1 2;
49+
scgi_temp_path /tmp 1 2;
50+
51+
sendfile on;
52+
53+
keepalive_timeout 65;
54+
55+
gzip on;
56+
57+
# include /etc/nginx/conf.d/*.conf;
58+
}

report-front-end/package.json

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{
2+
"name": "report-front-end",
3+
"version": "0.1.0",
4+
"private": true,
5+
"dependencies": {
6+
"@aws-amplify/ui-react": "^6.1.9",
7+
"@cloudscape-design/code-view": "^3.0.15",
8+
"@cloudscape-design/components": "^3.0.625",
9+
"@cloudscape-design/design-tokens": "^3.0.28",
10+
"@cloudscape-design/global-styles": "^1.0.27",
11+
"aws-amplify": "^6.1.9",
12+
"axios": "^1.6.8",
13+
"lodash": "^4.17.21",
14+
"react": "^18.3.1",
15+
"react-dom": "^18.3.1",
16+
"react-redux": "^9.1.2",
17+
"react-router-dom": "^6.23.0",
18+
"react-scripts": "5.0.1",
19+
"react-speech-recognition": "^3.10.0",
20+
"react-syntax-highlighter": "^15.5.0",
21+
"react-textarea-autosize": "^8.5.3",
22+
"redux": "^5.0.1",
23+
"typescript": "^4.9.5",
24+
"web-vitals": "^2.1.4"
25+
},
26+
"devDependencies": {
27+
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
28+
"@babel/plugin-proposal-optional-chaining": "^7.21.0",
29+
"@testing-library/jest-dom": "^5.17.0",
30+
"@testing-library/react": "^13.4.0",
31+
"@testing-library/user-event": "^13.5.0",
32+
"@types/jest": "^27.5.2",
33+
"@types/lodash": "^4.17.1",
34+
"@types/node": "^16.18.96",
35+
"@types/react": "^18.3.1",
36+
"@types/react-dom": "^18.3.0",
37+
"@types/react-syntax-highlighter": "^15.5.13",
38+
"classnames": "^2.5.1",
39+
"sass": "^1.76.0",
40+
"sass-loader": "^14.2.1"
41+
},
42+
"scripts": {
43+
"start": "react-scripts start",
44+
"build": "react-scripts build",
45+
"test": "react-scripts test",
46+
"eject": "react-scripts eject"
47+
},
48+
"eslintConfig": {
49+
"extends": [
50+
"react-app",
51+
"react-app/jest"
52+
]
53+
},
54+
"browserslist": {
55+
"production": [
56+
">0.2%",
57+
"not dead",
58+
"not op_mini all"
59+
],
60+
"development": [
61+
"last 1 chrome version",
62+
"last 1 firefox version",
63+
"last 1 safari version"
64+
]
65+
}
66+
}
892 Bytes
Loading
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"aws_api_key": "",
3+
"aws_appsync_authenticationType": "AMAZON_COGNITO_USER_POOLS",
4+
"aws_appsync_graphqlEndpoint": "",
5+
"aws_appsync_region": "",
6+
"aws_project_region": "",
7+
"aws_user_pools_id": "",
8+
"aws_user_pools_web_client_id": "",
9+
"aws_cognito_region": "",
10+
"aws_user_pools_web_client_secret": "",
11+
"build_time": ""
12+
}

report-front-end/public/favicon.ico

1.12 KB
Binary file not shown.

0 commit comments

Comments
 (0)