embed-sdk icon indicating copy to clipboard operation
embed-sdk copied to clipboard

withFilters doesn't actually set initial filter values

Open joeyorlando opened this issue 3 years ago • 7 comments

const embedDashboard = await LookerEmbedSDK.createDashboardWithUrl(mySignedUrl)
            .appendTo(embedContainer.current)
            .withClassName('w-full', 'h-full')
            .withFilters({ 'License Num': '12345' })
            .withNext()
            .build()
            .connect();

I was poking around the source code a bit. It look like:

  1. EmbedBuilder.withFilters sets the passed in object to `this._params
  2. EmbedBuilder.build is called, which returns an EmbedClient object),
  3. EmbedClient.connect internally calls this.createIframe (since I'm using createDashboardWithUrl), which sets up a Chatty instance. I feel like the _params should be sent into the Chatty instance here but they are not?

Using version 1.6.0

joeyorlando avatar Jul 09 '21 20:07 joeyorlando

On version 1.6.1 this issue is still present, filters are not updated

hitpopdimestop avatar Oct 15 '21 10:10 hitpopdimestop

Hi @joeyorlando and @hitpopdimestop - I believe this is working as intended. The createDashboardWithUrl method accepts a signed URL, and the target embed URL which is where the filters are specified is part of this signed value, so it can't be changed (as this would invalidate the signature)

Basically, unlike createDashboardWithId, the use case for createDashboardWithUrl is to let you provide a URL which could not be constructed using the out-of-the-box URL construction logic (where withFilters is part of that standard URL construction)

I'd be curious to better understand your use case. For example, what kind of URL are you trying to pass in as the mySignedUrl value?

fabio-looker avatar Jan 13 '22 21:01 fabio-looker

Also pinging anyone who gave this a thumbs up to possibly provide more context? @dnaport22 @fantua @charmingelle @rbob86

fabio-looker avatar Jan 13 '22 21:01 fabio-looker

Hi @fabio-looker. If there is a limitation in using withfilters for createDashboardWithUrl then why there is nothing about it in docs? Also, there can be done next improvements:

  • create a special type for the result of createDashboardWithUrl, which will not expose withfilters method
  • implement withfilters even for createDashboardWithUrl, which will override filters from url

bogekt avatar Jan 25 '22 13:01 bogekt

Hello,

Just wanted to mention that I'm using the createDashboardWithId method and it appears to behave the same as @joeyorlando described in the original post. End Date Param appears in the eventual db object under _params once the dashboard is fully loaded, however the filter is not applied.

const db = LookerEmbedSDK.createDashboardWithId(dashboardId)
  .appendTo(el)
  .withParams({
    _theme: JSON.stringify({
      show_filters_bar: false,
    }),
  })
  .withNext() // Using Dashboard next
  .withFilters(
    {
      'End Date Param': '2022/04/07',
    }
  )
  .build()
  .connect()

Using version 1.6.1

nuwen avatar Apr 07 '22 18:04 nuwen

Chiming in here, we have:

    console.log(filters)
    LookerEmbedSDK.createDashboardWithId(this.getDashboardId())
      .appendTo(this.el)
      .withFilters(filters)
      .withClassName('looker-dashboard-big')
      .build()
      .connect()

And the initial filters are not being set. If we do dashboard.updateFilters(same_exact_filters) and then a run() we can see the filters set, and then the dashboard updated.

Version 1.8.1

benwilson512 avatar Mar 21 '23 04:03 benwilson512

Hi @joeyorlando and @hitpopdimestop - I believe this is working as intended. The createDashboardWithUrl method accepts a signed URL, and the target embed URL which is where the filters are specified is part of this signed value, so it can't be changed (as this would invalidate the signature)

Basically, unlike createDashboardWithId, the use case for createDashboardWithUrl is to let you provide a URL which could not be constructed using the out-of-the-box URL construction logic (where withFilters is part of that standard URL construction)

I'd be curious to better understand your use case. For example, what kind of URL are you trying to pass in as the mySignedUrl value?

Thank you!

ninabohm avatar Aug 14 '24 14:08 ninabohm