Skip to content

Commit

Permalink
feat: Add iframe/widget endpoint for displaying widgets (#4938)
Browse files Browse the repository at this point in the history
- Opens widgets from plugins or any table just by name by adding the iframe/widget path
- Exposed at `/iframe/widget`
- Tested by running the following code to create a plotly-express widget and some tables:
```
import deephaven.plot.express as dx
from deephaven import time_table
import random
import pandas as pd
import deephaven.pandas as dhpd

df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/earthquakes-23k.csv')

t = dhpd.to_table(df)

sourceh = time_table("PT1S").update(formulas=[
    "X = (int)random.uniform(0, 180) - 90",
    "Y = (int)random.uniform(0, 360) - 180",
    "Z = (float)random.gauss(30, 3)",
    "l1 = i % 20",
    "l2 = i % 30",
    ])

fig = dx.density_mapbox(t,  lat='Latitude', lon='Longitude', z='Magnitude', radius=10,
                        center=dict(lat=0, lon=180), zoom=0,
                        mapbox_style="stamen-terrain")
```
- Then tested that each table/widget opened correctly by opening the following links:
1. plot.express: http://localhost:10000/iframe/widget/?name=fig
2. table: http://localhost:10000/iframe/widget/?name=t
3. Pandas data frame: http://localhost:10000/iframe/widget/?name=df
  • Loading branch information
mofojed authored Dec 15, 2023
1 parent a5eb055 commit 13ea304
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .github/workflows/update-web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,18 @@ jobs:
echo "WEB_VERSION=$(npm info @deephaven/code-studio@latest version)" >> $GITHUB_OUTPUT
echo "GRID_VERSION=$(npm info @deephaven/embed-grid@latest version)" >> $GITHUB_OUTPUT
echo "CHART_VERSION=$(npm info @deephaven/embed-chart@latest version)" >> $GITHUB_OUTPUT
echo "WIDGET_VERSION=$(npm info @deephaven/embed-widget@latest version)" >> $GITHUB_OUTPUT
- name: Update deephaven-core
env:
WEB_VERSION: ${{steps.web_versions.outputs.WEB_VERSION}}
GRID_VERSION: ${{steps.web_versions.outputs.GRID_VERSION}}
CHART_VERSION: ${{steps.web_versions.outputs.CHART_VERSION}}
WIDGET_VERSION: ${{steps.web_versions.outputs.WIDGET_VERSION}}
run: |
sed -i "s/^ARG WEB_VERSION=.*/ARG WEB_VERSION=$WEB_VERSION/" ./web/client-ui/Dockerfile
sed -i "s/^ARG GRID_VERSION=.*/ARG GRID_VERSION=$GRID_VERSION/" ./web/client-ui/Dockerfile
sed -i "s/^ARG CHART_VERSION=.*/ARG CHART_VERSION=$CHART_VERSION/" ./web/client-ui/Dockerfile
sed -i "s/^ARG WIDGET_VERSION=.*/ARG WIDGET_VERSION=WIDGET_VERSION/" ./web/client-ui/Dockerfile
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
env:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public JettyBackedGrpcServer(
context.setInitParameter(DefaultServlet.CONTEXT_INIT + "dirAllowed", "false");

// Cache all of the appropriate assets folders
for (String appRoot : List.of("/ide/", "/iframe/table/", "/iframe/chart/")) {
for (String appRoot : List.of("/ide/", "/iframe/table/", "/iframe/chart/", "/iframe/widget/")) {
context.addFilter(NoCacheFilter.class, appRoot + "*", EnumSet.noneOf(DispatcherType.class));
context.addFilter(CacheFilter.class, appRoot + "assets/*", EnumSet.noneOf(DispatcherType.class));
}
Expand Down
10 changes: 10 additions & 0 deletions web/client-ui/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ WORKDIR /usr/src/app
ARG WEB_VERSION=0.57.1
ARG GRID_VERSION=0.57.1
ARG CHART_VERSION=0.57.1
ARG WIDGET_VERSION=0.57.1

# Pull in the published code-studio package from npmjs and extract is
RUN set -eux; \
Expand All @@ -31,3 +32,12 @@ RUN set -eux; \
mv package/build iframe/chart; \
rm -r package; \
rm deephaven-embed-chart-${CHART_VERSION}.tgz;

# Pull in the published embed-widget package from npmjs and extract is
RUN set -eux; \
npm pack @deephaven/embed-widget@${WIDGET_VERSION}; \
tar --touch -xf deephaven-embed-widget-${WIDGET_VERSION}.tgz; \
mkdir -p iframe; \
mv package/build iframe/widget; \
rm -r package; \
rm deephaven-embed-widget-${WIDGET_VERSION}.tgz;

0 comments on commit 13ea304

Please sign in to comment.