looker-open-source / embed-sdk

The Looker browser embedding SDK
MIT License
70 stars 45 forks source link

withFilters doesn't actually set initial filter values #81

Open joeyorlando opened 3 years ago

joeyorlando commented 3 years ago
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

hitpopdimestop commented 2 years ago

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

fabio-looker commented 2 years ago

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 commented 2 years ago

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

bogekt commented 2 years ago

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:

nuwen commented 2 years ago

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

benwilson512 commented 1 year ago

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

ninabohm commented 1 month ago

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!