From 9f94e84454af822c1b59f12bf5a2566a452cdf1f Mon Sep 17 00:00:00 2001 From: Eino GOURDIN Date: Wed, 7 Feb 2024 12:37:26 +0100 Subject: [PATCH 1/2] feat: allow duplicate values for URL params Allow duplicate same-named params, so as to support multiple hide_filter. --- src/embed_builder.ts | 12 +++++++++--- tests/embed_builder.spec.ts | 5 +++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/embed_builder.ts b/src/embed_builder.ts index 21c1a0d..04de747 100644 --- a/src/embed_builder.ts +++ b/src/embed_builder.ts @@ -44,13 +44,19 @@ interface LookerEmbedHostSettings { } export interface UrlParams { - [key: string]: string + [key: string]: string | string[] } -function stringify(params: { [key: string]: string }) { +function stringify(params: UrlParams) { const result = [] for (const key in params) { - result.push(`${encodeURIComponent(key)}=${encodeURIComponent(params[key])}`) + const value = params[key] + const valueArray = Array.isArray(value) ? value : [value] + for (const singleValue of valueArray) { + result.push( + `${encodeURIComponent(key)}=${encodeURIComponent(singleValue)}` + ) + } } return result.join('&') } diff --git a/tests/embed_builder.spec.ts b/tests/embed_builder.spec.ts index abc1726..98773bc 100644 --- a/tests/embed_builder.spec.ts +++ b/tests/embed_builder.spec.ts @@ -250,6 +250,11 @@ describe('LookerEmbedBuilder', () => { expect(builder.embedUrl).toMatch('alpha=1&beta=2') }) + it('should allow multiple values for an url parameter', () => { + builder.withParams({ hide_filter: ['1', '2'] }) + expect(builder.embedUrl).toMatch('hide_filter=1&hide_filter=2') + }) + it('should allow specifying a theme', () => { builder.withTheme('Fancy') expect(builder.embedUrl).toMatch('theme=Fancy') From f1cf34acc35f6c2bdff90223389b58cf01499a8f Mon Sep 17 00:00:00 2001 From: Bryn Ryans Date: Mon, 29 Jul 2024 17:42:57 +0000 Subject: [PATCH 2/2] Fix docs --- docs/classes/EmbedBuilder.html | 72 +++++++++++++++++----------------- docs/interfaces/UrlParams.html | 2 +- 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/docs/classes/EmbedBuilder.html b/docs/classes/EmbedBuilder.html index e468213..322d193 100644 --- a/docs/classes/EmbedBuilder.html +++ b/docs/classes/EmbedBuilder.html @@ -1,100 +1,100 @@ EmbedBuilder | @looker/embed-sdk
Options
All
  • Public
  • Public/Protected
  • All
Menu

Class EmbedBuilder<T>

The builder class for EmbedClient. Contains methods for defining the properties of embedded Looker content.

-

Type Parameters

  • T

Hierarchy

  • EmbedBuilder

Index

Properties

_allowAttrs: string[] = []
_appendTo: null | HTMLElement = null
_classNames: string[] = []
_dialogScroll?: boolean
_dynamicIFrameHeight?: boolean
_frameBorder: string = '0'
_handlers: CallbackStore = {}
_id?: string | number
_params: UrlParams
_sandboxAttrs: string[] = []
_sandboxedHost?: boolean
_scrollMonitor?: boolean
_suffix: string = ''
_url?: null | string

Accessors

Type Parameters

  • T

Hierarchy

  • EmbedBuilder

Index

Properties

_allowAttrs: string[] = []
_appendTo: null | HTMLElement = null
_classNames: string[] = []
_dialogScroll?: boolean
_dynamicIFrameHeight?: boolean
_frameBorder: string = '0'
_handlers: CallbackStore = {}
_id?: string | number
_params: UrlParams
_sandboxAttrs: string[] = []
_sandboxedHost?: boolean
_scrollMonitor?: boolean
_suffix: string = ''
_url?: null | string

Accessors

  • get allowAttrs(): string[]
  • get allowAttrs(): string[]
  • get apiHost(): string
  • get apiHost(): string
  • get authUrl(): undefined | string
  • get authUrl(): undefined | string
  • The auth URL of this embedded content, if provided

    -
    deprecated

    Returns undefined | string

  • get classNames(): string[]
  • get classNames(): string[]
  • get dialogScroll(): undefined | boolean
  • get dialogScroll(): undefined | boolean
  • Whether cover dialogs tops are to be scrolled into view

    -

    Returns undefined | boolean

  • get dynamicIFrameHeight(): undefined | boolean
  • get dynamicIFrameHeight(): undefined | boolean
  • get el(): HTMLElement
  • get el(): HTMLElement
  • get endpoint(): string
  • get endpoint(): string
  • get frameBorder(): string
  • get frameBorder(): string
  • get id(): undefined | string | number
  • get id(): undefined | string | number
  • get isCookielessEmbed(): boolean
  • get isCookielessEmbed(): boolean
  • get sandboxAttrs(): string[]
  • get sandboxAttrs(): string[]
  • get scrollMonitor(): undefined | boolean
  • get scrollMonitor(): undefined | boolean
  • get suffix(): string
  • get suffix(): string
  • get type(): string
  • get type(): string
  • get url(): undefined | null | string
  • get url(): undefined | null | string
  • The content URL of this embedded content, if provided

    -

    Returns undefined | null | string

Methods

Methods

  • Select an element to append the embedded content to, either a content selector or the DOM element.

    Parameters

    • el: string | HTMLElement
      -

    Returns EmbedBuilder<T>

Returns EmbedBuilder<T>

  • Allows specifying allow attributes (for example fullscreen) for an embedded content iframe.

    Parameters

    • Rest ...attr: string[]

      one or more allow attributes for an embedded content iframe.

      -

    Returns EmbedBuilder<T>

Returns EmbedBuilder<T>

Returns EmbedBuilder<T>

Returns EmbedBuilder<T>

Returns EmbedBuilder<T>

  • Allows specifying classes for an embedded content

    Parameters

    • Rest ...className: string[]

      one or more sandbox attributes for an embedded content.

      -

    Returns EmbedBuilder<T>

Returns EmbedBuilder<T>

  • Listens for covering dialogs being opened in the Looker IFRAME and scrolls the top of dialog into view.

    Parameters

    • dialogScroll: boolean = true

      defaults to true

      -

    Returns EmbedBuilder<T>

  • withDynamicIFrameHeight(dynamicIFrameHeight?: boolean): EmbedBuilder<T>

Returns EmbedBuilder<T>

  • withDynamicIFrameHeight(dynamicIFrameHeight?: boolean): EmbedBuilder<T>
  • Listens for page changed events from the embedded Looker IFRAME and updates the height of the IFRAME.

    Parameters

    • dynamicIFrameHeight: boolean = true

      defaults to true

      -

    Returns EmbedBuilder<T>

Returns EmbedBuilder<T>

  • Allows specifying next generation content

    Parameters

    • suffix: string = '-next'

      Next generation suffix. Defaults to '-next'.

      -

    Returns EmbedBuilder<T>

Returns EmbedBuilder<T>

Returns EmbedBuilder<T>

  • Allows specifying sandbox attributes for an embedded content iframe. Sandbox attributes should include allow-scripts or embedded content will not execute.

    Parameters

    • Rest ...attr: string[]

      one or more sandbox attributes for an embedded content iframe.

      -

    Returns EmbedBuilder<T>

Returns EmbedBuilder<T>

  • Monitors scroll position and informs the embedded Looker IFRAME of the current scroll position and the offset of the containing IFRAME within the window. Looker uses this information to position @@ -102,7 +102,7 @@

    Requires Looker >=23.6.0

    Parameters

    • monitor: boolean = true

      defaults to true

      -

    Returns EmbedBuilder<T>

Returns EmbedBuilder<T>

  • Allows specifying a theme for the content.

    Parameters

    • theme: string

      Theme name

      diff --git a/docs/interfaces/UrlParams.html b/docs/interfaces/UrlParams.html index d0f241d..dd6951b 100644 --- a/docs/interfaces/UrlParams.html +++ b/docs/interfaces/UrlParams.html @@ -1 +1 @@ -UrlParams | @looker/embed-sdk
      Options
      All
      • Public
      • Public/Protected
      • All
      Menu

      Interface UrlParams

      Hierarchy

      • UrlParams

      Indexable

      [key: string]: string

      Legend

      • Constructor
      • Property
      • Method
      • Property
      • Method
      • Private property
      • Private method
      • Inherited method
      • Static method

      Settings

      Theme

      Generated using TypeDoc

      \ No newline at end of file +UrlParams | @looker/embed-sdk
      Options
      All
      • Public
      • Public/Protected
      • All
      Menu

      Interface UrlParams

      Hierarchy

      • UrlParams

      Indexable

      [key: string]: string | string[]

      Legend

      • Constructor
      • Property
      • Method
      • Property
      • Method
      • Private property
      • Private method
      • Inherited method
      • Static method

      Settings

      Theme

      Generated using TypeDoc

      \ No newline at end of file