Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
working-directory: telemetry/ui
strategy:
matrix:
node-version: [16.x]
node-version: [22.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Not part of the CLI (yet), but running just the UI is simple:

.. code-block:: bash

$ cd burr/ui
$ cd telemetry/ui
$ npm run start

Package data
Expand Down
18 changes: 9 additions & 9 deletions burr/tracking/server/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,15 +363,15 @@ async def version() -> dict:

if serve_static:
base_asset_directory = str(files("burr").joinpath("tracking/server/build"))
static_directory = os.path.join(base_asset_directory, "static")
assets_directory = os.path.join(base_asset_directory, "assets")

ui_app.mount(
"/static",
StaticFiles(directory=static_directory),
"/static",
"/assets",
StaticFiles(directory=assets_directory),
"/assets",
)
# public assets in create react app don't get put under build/static,
# we need to route them over
# public assets (favicon, manifest, logo, etc.) are in the build root,
# routed under /public for the UI to reference
ui_app.mount("/public", StaticFiles(directory=base_asset_directory, html=True), "/public")

# Read index.html once at startup
Expand All @@ -392,8 +392,8 @@ async def manifest_json():
async def react_app(req: Request, rest_of_path: str):
"""Serves the React app, rewriting asset paths to respect the mount prefix.

When mounted as a sub-app (e.g. under /burr), the CRA build's hardcoded
absolute paths (/static/js/..., /api/v0/...) need to be prefixed with the
When mounted as a sub-app (e.g. under /burr), the build's hardcoded
absolute paths (/assets/..., /api/v0/...) need to be prefixed with the
mount path so the browser fetches them from the correct location.

This rewrites both the HTML (href/src attributes) and injects a script that
Expand All @@ -404,7 +404,7 @@ async def react_app(req: Request, rest_of_path: str):

root_path = req.scope.get("root_path", "")
if root_path:
# Rewrite CRA's absolute paths to include the mount prefix
# Rewrite absolute paths to include the mount prefix
html = _index_html_template.replace('href="/', f'href="{root_path}/')
html = html.replace('src="/', f'src="{root_path}/')
# Inject a script before </head> that patches the OpenAPI BASE config
Expand Down
2 changes: 1 addition & 1 deletion docs/contributing/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Not part of the CLI (yet), but running just the UI is simple:

.. code-block:: bash

$ cd burr/ui
$ cd telemetry/ui
$ npm run start

Package data
Expand Down
4 changes: 2 additions & 2 deletions docs/contributing/iterating.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ Then, you can run the following commands:
$ npm run start

This will start the UI on port 3000. You can then navigate to ``http://localhost:3000`` to see the UI.
It currently assumes that the tracking server is running on port 7241. The proxy is set up in the
``package.json`` file.
It currently assumes that the tracking server is running on port 7241. The proxy is configured in
``vite.config.ts``.

Note that if you want to just develop off the server you'll first have to build the UI and symlink the
``tracking/server/build`` directory to the ``telemetry/ui/build`` directory. We have this structure to
Expand Down
7 changes: 4 additions & 3 deletions scripts/ci_smoke_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def main() -> None:
env = os.environ.copy()
env["burr_path"] = str(burr_data_dir)
env["PYTHONUNBUFFERED"] = "1"
with open(server_log, "w") as log_fh:
with open(server_log, "w", encoding="utf-8") as log_fh:
server_proc = subprocess.Popen(
[str(venv_burr), "--port", str(port), "--no-open"],
cwd=str(work_dir),
Expand All @@ -232,7 +232,7 @@ def main() -> None:
if server_proc.poll() is not None:
_log(f"Server process exited with code {server_proc.returncode}")
_log("--- server log ---")
print(server_log.read_text(), flush=True)
print(server_log.read_text(encoding="utf-8"), flush=True)
_log("--- end server log ---")
_fail("Server did not become ready")
_log("Server is up")
Expand Down Expand Up @@ -277,7 +277,8 @@ def inc(state: State) -> State:
app.step()

print(f"count={{app.state['count']}} app_id={{app.uid}}")
"""
""",
encoding="utf-8",
)
subprocess.run([str(venv_py), str(app_script)], check=True, cwd=str(work_dir), env=env)

Expand Down
3 changes: 3 additions & 0 deletions telemetry/ui/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@

build/*
tailwind.config.js
postcss.config.js
vite.config.ts
vitest.config.ts
.eslintrc.js
src/api # generated code
2 changes: 1 addition & 1 deletion telemetry/ui/.prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@

build/*
tailwind.config.js
.eslitrc.js
.eslintrc.js
37 changes: 12 additions & 25 deletions telemetry/ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
Expand All @@ -17,49 +17,36 @@
under the License.
-->

# Getting Started with Create React App
# Burr Tracking UI

This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
Burr's telemetry tracking UI, built with React and Vite.

## Available Scripts

In the project directory, you can run:

### `npm start`

Runs the app in the development mode.\
Runs the app in development mode with hot module replacement.\
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.

### `npm 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.
Runs the test suite with Vitest in watch mode.

### `npm run 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.

### `npm run 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.
### `npm run preview`

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.
Previews the production build locally using Vite's preview server.

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.
### `npm run lint`

## Learn More
Runs ESLint on the project.

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
### `npm run lint:fix`

To learn React, check out the [React documentation](https://reactjs.org/).
Runs ESLint with auto-fix on the project.
36 changes: 36 additions & 0 deletions telemetry/ui/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

<!doctype html>
<html lang="en" class="h-full bg-white">
<head>
<meta charset="utf-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta name="description" content="Burr tracking UI" />
<link rel="manifest" href="/manifest.json" />
<title>Burr</title>
</head>
<body class="h-full">
<noscript>You need to enable JavaScript to run this app.</noscript>
<script type="module" src="/src/index.tsx"></script>
<div id="root"></div>
</body>
</html>
Loading
Loading