Skip to content

Commit

Permalink
Add dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
rafal-gorecki committed Jul 25, 2024
1 parent 37996ca commit 9126615
Show file tree
Hide file tree
Showing 17 changed files with 2,730 additions and 4,323 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
.DS_Store
.webpack/
dist/
demo/
node_modules/
Dockerfile
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ dist/
node_modules/
storybook-screenshots/
storybook-static/
# for jest --coverage
coverage/

# Yarn
.yarn/*
Expand Down
1 change: 0 additions & 1 deletion .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ const storybookConfig: StorybookConfig = {
);
return {
...config,
// context is required for ForkTsCheckerWebpackPlugin to find .storybook/tsconfig.json
optimization: {
...config.optimization,
minimize: false, // disabling minification improves build performance
Expand Down
2 changes: 0 additions & 2 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import GlobalCss from "@foxglove/studio-base/components/GlobalCss";
import MultiProvider from "@foxglove/studio-base/components/MultiProvider";
import StudioToastProvider from "@foxglove/studio-base/components/StudioToastProvider";
import AppConfigurationContext from "@foxglove/studio-base/context/AppConfigurationContext";
import { UserNodeStateProvider } from "@foxglove/studio-base/context/UserNodeStateContext";
import { initI18n, Language } from "@foxglove/studio-base/i18n";
import TimelineInteractionStateProvider from "@foxglove/studio-base/providers/TimelineInteractionStateProvider";
import ReadySignalContext from "@foxglove/studio-base/stories/ReadySignalContext";
Expand Down Expand Up @@ -81,7 +80,6 @@ function StudioContextProviders({
<ReadySignalContext.Provider value={readySignal} />,
<StudioToastProvider />,
<TimelineInteractionStateProvider />,
<UserNodeStateProvider />,
/* eslint-enable react/jsx-key */
];
return (
Expand Down
2 changes: 1 addition & 1 deletion .storybook/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"compilerOptions": {
"noEmit": true,
"jsx": "react-jsx",
"lib": ["dom", "dom.iterable", "es2022", "webworker"],
"lib": ["dom", "dom.iterable", "es2022", "webworker", "ESNext.Disposable"],
"experimentalDecorators": true,
"useUnknownInCatchVariables": false,
"paths": {
Expand Down
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
"jest.autoRun": { "watch": false, "onSave": "test-file" },
"jest.jestCommandLine": "yarn test",
"eslint.lintTask.enable": true,
"[typescriptreact]": {
"editor.defaultFormatter": "vscode.typescript-language-features"
},
"[dockerfile]": {
"editor.defaultFormatter": "ms-azuretools.vscode-docker"
},
Expand Down
10 changes: 1 addition & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,11 @@
1. Launch the development environment:

```sh
# To launch the desktop app (run both scripts concurrently):
$ yarn desktop:serve # start webpack
$ yarn desktop:start # launch electron

# To launch the browser app:
# To launch the app:
$ yarn web:serve

# To launch the storybook:
$ yarn storybook

# Advanced usage: running webpack and electron on different computers (or VMs) on the same network
$ yarn desktop:serve --host 192.168.xxx.yyy # the address where electron can reach the webpack dev server
$ yarn dlx [email protected] .webpack # launch the version of electron for the current computer's platform
```

### Other useful commands
Expand Down
29 changes: 29 additions & 0 deletions Caddyfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
:8080 {
handle_path /ws {
reverse_proxy http://127.0.0.1:8765
}

handle_path /* {
root * /src

# Handle IPv6 clients
@ipv6Client {
expression {http.request.host}.startsWith("fc94")
}

handle @ipv6Client {
redir /ui /?ds=foxglove-websocket&ds.url=ws%3A%2F%2F%5B{http.request.host}%5D%3A8765
}

# Handle all other requests (from non-IPv6 clients)
handle {
redir /ui /?ds=foxglove-websocket&ds.url=ws%3A%2F%2F{http.request.host}%3A8765
}

templates {
mime "text/html"
}

file_server
}
}
49 changes: 28 additions & 21 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,32 +1,39 @@
# Build stage
FROM node:16 as build
ARG ROS_DISTRO=humble

# =========================== Foxglove builder ===============================
FROM node:16 AS foxglove_build
WORKDIR /src
COPY . ./

RUN apt-get update && \
apt-get install -y git-lfs && \
git clone -b improvements https://github.com/husarion/foxglove-docker . && \
git lfs pull

RUN corepack enable
RUN yarn install --immutable

RUN yarn run web:build:prod

# Release stage
FROM caddy:2.5.2-alpine
# =========================== Release stage ===============================
FROM caddy:2.6.2-alpine
WORKDIR /src
COPY --from=build /src/web/.webpack ./

RUN apk update && apk add \
bash \
nss-tools

COPY --from=foxglove_build /src/web/.webpack ./

COPY disable_cache.js /
COPY disable_interaction.js /

COPY Caddyfile /etc/caddy/
COPY entrypoint.sh /

EXPOSE 8080

COPY <<EOF /entrypoint.sh
# Optionally override the default layout with one provided via bind mount
mkdir -p /foxglove
touch /foxglove/default-layout.json
index_html=\$(cat index.html)
replace_pattern='/*FOXGLOVE_STUDIO_DEFAULT_LAYOUT_PLACEHOLDER*/'
replace_value=\$(cat /foxglove/default-layout.json)
echo "\${index_html/"\$replace_pattern"/\$replace_value}" > index.html

# Continue executing the CMD
exec "\$@"
EOF

ENTRYPOINT ["/bin/sh", "/entrypoint.sh"]
CMD ["caddy", "file-server", "--listen", ":8080"]
ENV DISABLE_INTERACTION=false
ENV DISABLE_CACHE=true

ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]
CMD caddy run --config /etc/caddy/Caddyfile --adapter caddyfile
86 changes: 25 additions & 61 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,95 +2,59 @@

<br/>

> [!NOTE]
> Foxglove Studio 1.x is no longer supported. To install the latest release, please visit our [downloads page](https://foxglove.dev/download). Learn more in our [Foxglove 2.0 announcement](https://foxglove.dev/blog/foxglove-2-0-unifying-robotics-observability).
<div align="center">
<h1>Foxglove Studio</h1>
<a href="https://github.com/foxglove/studio/releases"><img src="https://img.shields.io/github/v/release/foxglove/studio?label=version" /></a>
<a href="https://github.com/foxglove/studio/blob/main/LICENSE"><img src="https://img.shields.io/github/license/foxglove/studio" /></a>
<a href="https://github.com/orgs/foxglove/discussions"><img src="https://img.shields.io/github/discussions/foxglove/community.svg?logo=github" /></a>
<a href="https://foxglove.dev/join-slack"><img src="https://img.shields.io/badge/chat-slack-purple.svg?logo=slack" /></a>
<a href="https://foxglove.dev/slack"><img src="https://img.shields.io/badge/chat-slack-purple.svg?logo=slack" /></a>
<br />
<br />
<a href="https://foxglove.dev/download">Download</a>
<span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
<a href="https://foxglove.dev/docs/studio">Docs</a>
<a href="https://docs.foxglove.dev/">Docs</a>
<span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
<a href="https://docs.foxglove.dev/changelog">Changelog</a>
<span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
<a href="https://foxglove.dev/blog">Blog</a>
<a href="https://github.com/orgs/foxglove/discussions">Discussions</a>
<span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
<a href="https://foxglove.dev/slack">Slack</a>
<span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
<a href="https://twitter.com/foxglovedev">Twitter</a>
<a href="https://x.com/foxglove">X</a>
<span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
<a href="https://foxglove.dev/contact">Contact Us</a>
<a href="https://www.linkedin.com/company/foxglovedev/">LinkedIn</a>
<span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
<a href="https://foxglove.dev/contact">Contact</a>
<br />
<br />

[Foxglove Studio](https://foxglove.dev) is an integrated visualization and diagnosis tool for robotics, available [in your browser](https://studio.foxglove.dev/) or [as a desktop app](https://foxglove.dev/download) on Linux, Windows, and macOS.
Foxglove is a visualization and observability platform for robotics development.

<p align="center">
<a href="https://foxglove.dev"><img alt="Foxglove Studio screenshot" src="/resources/screenshot.png"></a>
<a href="https://foxglove.dev"><img alt="Foxglove screenshot" src="/resources/screenshot.png"></a>
</p>
</div>

<hr />

To learn more, visit the following resources:

[About](https://foxglove.dev/about)
&nbsp;&nbsp;
[Documentation](https://foxglove.dev/docs)
&nbsp;&nbsp;
[Release notes](https://github.com/foxglove/studio/releases)
&nbsp;&nbsp;
[Blog](https://foxglove.dev/blog)

You can join us on the following platforms to ask questions, share feedback, and stay up to date on what our team is working on:

[GitHub Discussions](https://github.com/orgs/foxglove/discussions)
&nbsp;&nbsp;
[Slack](https://foxglove.dev/slack)
&nbsp;&nbsp;
[Newsletter](https://foxglove.dev/#footer)
&nbsp;&nbsp;
[Twitter](https://twitter.com/foxglovedev)
&nbsp;&nbsp;
[LinkedIn](https://www.linkedin.com/company/foxglovedev/)

<br />

## Installation

Foxglove Studio is available online at [studio.foxglove.dev](https://studio.foxglove.dev/), or desktop releases can be downloaded from [foxglove.dev/download](https://foxglove.dev/download).

## Open Source

Foxglove Studio follows an open core licensing model. Most functionality is available in this repository, and can be reproduced or modified per the terms of the [Mozilla Public License v2.0](/LICENSE).

The official binary distributions available at [studio.foxglove.dev](https://studio.foxglove.dev/) or [foxglove.dev/download](https://foxglove.dev/download) incorporate some closed-source functionality, such as integration with [Foxglove Data Platform](https://foxglove.dev/data-platform), multiple layouts, private extensions, and more. For more information on free and paid features, see our [Pricing](https://foxglove.dev/pricing).

## Self-hosting

Foxglove Studio can be self-hosted using our [docker image](https://ghcr.io/foxglove/studio). Please note that this build does not contain any closed source functionality.

```sh
docker run --rm -p "8080:8080" ghcr.io/foxglove/studio:latest
```

Foxglove Studio will be accessible in your browser at [localhost:8080](http://localhost:8080/).
[Create a free account](https://app.foxglove.dev/signup) or [download Foxglove](https://foxglove.dev/download) for Linux, Windows, or macOS to get started.

### Overriding the default layout
## Documentation

[Bind-mount](https://docs.docker.com/storage/bind-mounts/) a layout JSON file at `/foxglove/default-layout.json` to set the default layout used when loading Studio from the Docker image.
Documentation is hosted at [docs.foxglove.dev](https://docs.foxglove.dev/).

```sh
docker run --rm -p "8080:8080" -v /path/to/custom_layout.json:/foxglove/default-layout.json ghcr.io/foxglove/studio:latest
```
## Support

## Contributing
Support for Foxglove is available via the following channels:

Foxglove Studio is written in TypeScript – contributions are welcome!
- [GitHub Discussions](https://github.com/orgs/foxglove/discussions)
- [Foxglove Community Slack](https://foxglove.dev/slack)
- [Contact Us](https://foxglove.dev/contact)

Note: All contributors must agree to our [Contributor License Agreement](https://github.com/foxglove/cla). See [CONTRIBUTING.md](CONTRIBUTING.md) for more details.
## License

## Credits
This project is availabile under the [Mozilla Public License v2.0](/LICENSE).

Foxglove Studio originally began as a fork of [Webviz](https://github.com/cruise-automation/webviz), an open source project developed by [Cruise](https://getcruise.com/). Most of the Webviz code has been rewritten, but some files still carry a Cruise license header where appropriate.
Foxglove is a trademark of Foxglove Technologies Inc.
2 changes: 2 additions & 0 deletions disable_cache.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
localStorage.clear();

Check failure on line 1 in disable_cache.js

View workflow job for this annotation

GitHub Actions / lint (ubuntu-20.04)

Missing license header
sessionStorage.clear();
14 changes: 14 additions & 0 deletions disable_interaction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
document.addEventListener("DOMContentLoaded", function() {

Check failure on line 1 in disable_interaction.js

View workflow job for this annotation

GitHub Actions / lint (ubuntu-20.04)

Insert `·`
var blocker = document.createElement("div");

Check failure on line 2 in disable_interaction.js

View workflow job for this annotation

GitHub Actions / lint (ubuntu-20.04)

Delete `··`

blocker.style.position = "fixed";

Check failure on line 4 in disable_interaction.js

View workflow job for this annotation

GitHub Actions / lint (ubuntu-20.04)

Delete `··`
blocker.style.top = "0";

Check failure on line 5 in disable_interaction.js

View workflow job for this annotation

GitHub Actions / lint (ubuntu-20.04)

Replace `····` with `··`
blocker.style.left = "0";

Check failure on line 6 in disable_interaction.js

View workflow job for this annotation

GitHub Actions / lint (ubuntu-20.04)

Delete `··`
blocker.style.width = "100%";

Check failure on line 7 in disable_interaction.js

View workflow job for this annotation

GitHub Actions / lint (ubuntu-20.04)

Delete `··`
blocker.style.height = "100%";

Check failure on line 8 in disable_interaction.js

View workflow job for this annotation

GitHub Actions / lint (ubuntu-20.04)

Delete `··`
blocker.style.backgroundColor = "rgba(0, 0, 0, 0)";

Check failure on line 9 in disable_interaction.js

View workflow job for this annotation

GitHub Actions / lint (ubuntu-20.04)

Replace `····blocker.style.backgroundColor·=·"rgba(0,·0,·0,·0)";·` with `··blocker.style.backgroundColor·=·"rgba(0,·0,·0,·0)";`
blocker.style.zIndex = "9999";

Check failure on line 10 in disable_interaction.js

View workflow job for this annotation

GitHub Actions / lint (ubuntu-20.04)

Replace `····` with `··`
blocker.style.pointerEvents = "all";

document.body.appendChild(blocker);
});
44 changes: 44 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash
set -e

cp /foxglove/default-layout.json /foxglove/local-layout.json
if [ -n "$ROBOT_NAMESPACE" ]; then
sed -i "s|<robot_namespace>|/$ROBOT_NAMESPACE|g" /foxglove/local-layout.json
else
sed -i "s|<robot_namespace>||g" /foxglove/local-layout.json
fi

# Optionally override the default layout with one provided via bind mount
index_html=$(cat index.html)
replace_pattern='/*FOXGLOVE_STUDIO_DEFAULT_LAYOUT_PLACEHOLDER*/'
replace_value=$(cat /foxglove/local-layout.json)
echo "${index_html/"$replace_pattern"/$replace_value}" > index.html

# Check if ENABLE_SCRIPT1 is set to true
if [[ "$DISABLE_CACHE" == "true" ]]; then
echo "Cache is disabled"
# Read the content of script1.js into a variable
script1_content=$(</disable_cache.js)

# Escape certain characters in the content that might break sed
escaped_script1_content=$(echo "$script1_content" | sed 's/[&/\]/\\&/g')

# Use sed to insert the content into index.html just before </body>
sed -i "s|<div id=\"root\"></div>|<script>\n$(echo $escaped_script1_content)\n</script>\n&|" index.html
fi

# Check if ENABLE_SCRIPT2 is set to true
if [[ "$DISABLE_INTERACTION" == "true" ]]; then
echo "Interaction is disabled"
# Read the content of script2.js into a variable
script2_content=$(</disable_interaction.js)

# Escape certain characters in the content that might break sed
escaped_script2_content=$(echo "$script2_content" | sed 's/[&/\]/\\&/g')

# Use sed to insert the content into index.html just before </body>
sed -i "s|<div id=\"root\"></div>|<script>\n$(echo $escaped_script2_content)\n</script>\n&|" index.html
fi

# Continue executing the CMD
exec "$@"
8 changes: 2 additions & 6 deletions jest.config.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
{
"//": "Our top level jest config to reference all the projects under our monorepo. We exclude the desktop test since it involves performing a webpack build and doesn't support 'watch' or 'debug' in the same way",
"projects": [
"<rootDir>/ci/jest.config.json",
"<rootDir>/desktop/jest.config.json",
"<rootDir>/packages/*/jest.config.json"
]
"//": "Our top level jest config to reference all the projects under our monorepo",
"projects": ["<rootDir>/ci/jest.config.json", "<rootDir>/packages/*/jest.config.json"]
}
Loading

0 comments on commit 9126615

Please sign in to comment.