From 8b47fa74c84261ebb36e3f262d750ffad7893274 Mon Sep 17 00:00:00 2001 From: mikebender Date: Tue, 12 Dec 2023 11:10:40 -0500 Subject: [PATCH] feat: Add iframe/widget endpoint for displaying widgets - 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 --- .github/workflows/update-web.yml | 3 +++ .../deephaven/server/jetty/JettyBackedGrpcServer.java | 2 +- web/client-ui/Dockerfile | 10 ++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/workflows/update-web.yml b/.github/workflows/update-web.yml index 4f1db596353..40d5da41804 100644 --- a/.github/workflows/update-web.yml +++ b/.github/workflows/update-web.yml @@ -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: diff --git a/server/jetty/src/main/java/io/deephaven/server/jetty/JettyBackedGrpcServer.java b/server/jetty/src/main/java/io/deephaven/server/jetty/JettyBackedGrpcServer.java index 7b921233312..97e869601c8 100644 --- a/server/jetty/src/main/java/io/deephaven/server/jetty/JettyBackedGrpcServer.java +++ b/server/jetty/src/main/java/io/deephaven/server/jetty/JettyBackedGrpcServer.java @@ -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)); } diff --git a/web/client-ui/Dockerfile b/web/client-ui/Dockerfile index 5896054650e..2db23724969 100644 --- a/web/client-ui/Dockerfile +++ b/web/client-ui/Dockerfile @@ -5,6 +5,7 @@ WORKDIR /usr/src/app ARG WEB_VERSION=0.56.0 ARG GRID_VERSION=0.56.0 ARG CHART_VERSION=0.56.0 +ARG WIDGET_VERSION=0.56.0 # Pull in the published code-studio package from npmjs and extract is RUN set -eux; \ @@ -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;