Skip to content

Commit

Permalink
feat: Add embed-widget
Browse files Browse the repository at this point in the history
- Loads the widget
- Fixes deephaven#1629
  • Loading branch information
mofojed committed Dec 6, 2023
1 parent 4c0200e commit 1b8a33e
Show file tree
Hide file tree
Showing 26 changed files with 642 additions and 22 deletions.
51 changes: 51 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,23 @@
"types": "tsc --build",
"watch:types": "tsc --build --watch --preserveWatchOutput",
"build": "run-s build:necessary types build:packages build:apps",
"build:apps": "lerna run --scope=@deephaven/{code-studio,embed-chart,embed-grid} build",
"build:apps": "lerna run --scope=@deephaven/{code-studio,embed-chart,embed-grid,embed-widget} build",
"build:app": "lerna run --scope=@deephaven/code-studio build",
"build:embed-chart": "lerna run --scope=@deephaven/embed-chart build",
"build:embed-grid": "lerna run --scope=@deephaven/embed-grid build",
"build:packages": "lerna run --ignore=@deephaven/{code-studio,embed-chart,embed-grid} build --stream",
"build:embed-widget": "lerna run --scope=@deephaven/embed-widget build",
"build:packages": "lerna run --ignore=@deephaven/{code-studio,embed-chart,embed-grid,embed-widget} build --stream",
"build:profile": "lerna run build --stream --profile",
"build:necessary": "lerna run build --scope=@deephaven/icons",
"analyze": "lerna run analyze",
"preview": "lerna run --scope=@deephaven/{code-studio,embed-chart,embed-grid} preview --stream",
"preview": "lerna run --scope=@deephaven/{code-studio,embed-chart,embed-grid,embed-widget} preview --stream",
"preview:app": "lerna run --scope=@deephaven/code-studio preview --stream",
"prestart": "npm run build:necessary",
"start": "run-p watch:types start:*",
"start:app": "lerna run start --scope=@deephaven/code-studio --stream",
"start:embed-chart": "lerna run start --scope=@deephaven/embed-chart --stream",
"start:embed-grid": "lerna run start --scope=@deephaven/embed-grid --stream",
"start:embed-widget": "lerna run start --scope=@deephaven/embed-widget --stream",
"pretest": "npm run build:necessary",
"test": "jest --watch --changedSince origin/main",
"test:debug": "node --inspect-brk node_modules/.bin/jest --config jest.config.unit.cjs --runInBand --watch",
Expand Down Expand Up @@ -162,6 +164,7 @@
"@deephaven/dashboard-core-plugins": "file:packages/dashboard-core-plugins",
"@deephaven/embed-chart": "file:packages/embed-chart",
"@deephaven/embed-grid": "file:packages/embed-grid",
"@deephaven/embed-widget": "file:packages/embed-widget",
"@deephaven/file-explorer": "file:packages/file-explorer",
"@deephaven/filters": "file:packages/filters",
"@deephaven/golden-layout": "file:packages/golden-layout",
Expand Down
20 changes: 2 additions & 18 deletions packages/embed-chart/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Embedded Deephaven Chart

This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). It is to provide an example React application connecting to Deephaven and displaying a chart or plot.
This project uses [Vite](https://vitejs.dev/guide/). It is to provide an example React application connecting to Deephaven and displaying a chart or plot.

## Getting Started

Expand All @@ -22,7 +22,7 @@ Once Deephaven is running, you can open a chart with a specific name by adding t

### Configuring Server Address

By default, this project assumes you are hosting Deephaven with Python on the default port at http://localhost:10000. If Deephaven is running on a different port/server, update the `VITE_CORE_API_URL` environment variable to point to the correct server. See [.env](./.env) file for the default definition, and [create-react-app docs](https://create-react-app.dev/docs/adding-custom-environment-variables/) for other ways to set this environment variable.
By default, this project assumes you are hosting Deephaven with Python on the default port at http://localhost:10000. If Deephaven is running on a different port/server, update the `VITE_CORE_API_URL` environment variable to point to the correct server. See [.env](./.env) file for the default definition, and [vite docs](https://vitejs.dev/guide/env-and-mode.html#env-variables-and-modes) for other ways to set this environment variable.

## Available Scripts

Expand Down Expand Up @@ -50,19 +50,3 @@ 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.

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/).
10 changes: 10 additions & 0 deletions packages/embed-widget/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# See the values in [code sudio](../code-studio/.env) for more details
BASE_URL=./
# We assume embed-chart is served at a nested path, e.g. '/iframe/chart'
VITE_CORE_API_URL=../../jsapi
VITE_MODULE_PLUGINS_URL=/js-plugins
VITE_CORE_API_NAME=dh-core.js
VITE_BUILD_PATH=./build
VITE_LOG_LEVEL=2
VITE_FAVICON=/favicon-cc-app.svg
VITE_PROXY_URL=http://localhost:10000
7 changes: 7 additions & 0 deletions packages/embed-widget/.env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
BASE_URL=/iframe/chart/
VITE_LOG_LEVEL=4
VITE_ENABLE_LOG_PROXY=false
VITE_FAVICON=./favicon-cc-app-dev.svg

# 4030 So not to conflict with code-studio
PORT=4030
1 change: 1 addition & 0 deletions packages/embed-widget/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./public/__mocks__/dh-core.js
52 changes: 52 additions & 0 deletions packages/embed-widget/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Embedded Deephaven Widget

This project uses [Vite](https://vitejs.dev/guide/). It is to provide an example React application connecting to Deephaven and displaying a widget.

## Getting Started

1. **Start the server**: Following instructions on GitHub to run deephaven-core with python: https://github.com/deephaven/deephaven-core/#run-deephaven.
2. **Install dependencies**: Run `npm install` to install all dependencies required.
3. **Start the UI**: Run `npm start` to start up the UI. It should automatically open up at http://localhost:4030.

## Query Parameters

- `name`: Required. The name of the widget to load

## Advanced

### Application Mode

See the guide for how to set up core in Application Mode: https://deephaven.io/core/docs/how-to-guides/application-mode/

Once Deephaven is running, you can open a widget with a specific name by adding the query param `name`, e.g. http://localhost:4030/?name=world

### Configuring Server Address

By default, this project assumes you are hosting Deephaven with Python on the default port at http://localhost:10000. If Deephaven is running on a different port/server, update the `VITE_CORE_API_URL` environment variable to point to the correct server. See [.env](./.env) file for the default definition, and [vite docs](https://vitejs.dev/guide/env-and-mode.html#env-variables-and-modes) for other ways to set this environment variable.

## Available Scripts

In the project directory, you can run:

### `npm start`

Runs the app in the development mode.\
Open [http://localhost:4030](http://localhost:4030) 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.

### `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.
26 changes: 26 additions & 0 deletions packages/embed-widget/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html lang="en">
<head>
<base href="%BASE_URL%" />
<meta name="ui-version" content="v%npm_package_version%" />
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
<meta name="theme-color" content="#2d2a2e" />
<!--
manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
-->
<link rel="manifest" href="/manifest.json" />

<link rel="icon" href="%VITE_FAVICON%" />
<title>Deephaven Embedded Chart</title>
</head>
<body>
<noscript> You need to enable JavaScript to run this app. </noscript>
<div id="root"></div>
<script type="module" src="/src/index.tsx"></script>
</body>
</html>
8 changes: 8 additions & 0 deletions packages/embed-widget/jest.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const baseConfig = require('../../jest.config.base.cjs');
const packageJson = require('./package');

module.exports = {
...baseConfig,
displayName: packageJson.name,
resetMocks: false,
};
22 changes: 22 additions & 0 deletions packages/embed-widget/licenses.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
├─ @deephaven/code-studio@0.0.1
│ ├─ licenses: Apache-2.0
│ └─ repository: https://github.com/deephaven/web-client-ui
├─ @deephaven/components@0.0.1
│ ├─ licenses: Apache-2.0
│ └─ repository: https://github.com/deephaven/web-client-ui
├─ @deephaven/grid@0.0.1
│ ├─ licenses: Apache-2.0
│ └─ repository: https://github.com/deephaven/web-client-ui
├─ @deephaven/icons@0.0.1
│ ├─ licenses: Apache-2.0
│ └─ repository: https://github.com/deephaven/web-client-ui
├─ @deephaven/jsapi-shim@0.0.1
│ ├─ licenses: Apache-2.0
│ └─ repository: https://github.com/deephaven/web-client-ui
├─ @deephaven/log@0.0.1
│ ├─ licenses: Apache-2.0
│ └─ repository: https://github.com/deephaven/web-client-ui
└─ @deephaven/utils@0.0.1
├─ licenses: Apache-2.0
└─ repository: https://github.com/deephaven/web-client-ui

47 changes: 47 additions & 0 deletions packages/embed-widget/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "@deephaven/embed-widget",
"version": "0.55.0",
"description": "Deephaven Embedded Chart",
"author": "Deephaven Data Labs LLC",
"license": "Apache-2.0",
"type": "module",
"repository": {
"type": "git",
"url": "https://github.com/deephaven/web-client-ui.git",
"directory": "packages/embed-widget"
},
"homepage": ".",
"main": "public/index.js",
"files": [
"build"
],
"dependencies": {
"@deephaven/app-utils": "file:../app-utils",
"@deephaven/components": "file:../components",
"@deephaven/dashboard-core-plugins": "file:../dashboard-core-plugins",
"@deephaven/jsapi-bootstrap": "file:../jsapi-bootstrap",
"@deephaven/jsapi-components": "file:../jsapi-components",
"@deephaven/jsapi-types": "file:../jsapi-types",
"@deephaven/jsapi-utils": "file:../jsapi-utils",
"@deephaven/log": "file:../log",
"@deephaven/plugin": "file:../plugin",
"fira": "mozilla/fira#4.202",
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
"scripts": {
"analyze": "source-map-explorer build/assets/*.js --no-border-checks",
"start": "vite",
"build": "NODE_OPTIONS='--max-old-space-size=4096' vite build",
"preview": "vite preview"
},
"devDependencies": {
"@deephaven/eslint-config": "file:../eslint-config",
"@deephaven/mocks": "file:../mocks",
"@deephaven/prettier-config": "file:../prettier-config",
"@deephaven/stylelint-config": "file:../stylelint-config"
},
"publishConfig": {
"access": "public"
}
}
11 changes: 11 additions & 0 deletions packages/embed-widget/public/favicon-cc-app-dev.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions packages/embed-widget/public/favicon-cc-app.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/embed-widget/public/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions packages/embed-widget/public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"short_name": "Deephaven",
"name": "Deephaven Community App",
"icons": [
{
"src": "favicon-cc-app.svg",
"sizes": "any",
"type": "image/svg+xml"
}
],
"start_url": "./index.html",
"display": "standalone",
"theme_color": "#2d2a2e",
"background_color": "#2d2a2e"
}
14 changes: 14 additions & 0 deletions packages/embed-widget/src/App.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Import Deephaven styling so we can use it's variables
@import '@deephaven/components/scss/custom.scss';

.App {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
height: 100%;
width: 100%;
background: $black;
color: $white;
}
Loading

0 comments on commit 1b8a33e

Please sign in to comment.