From d89626131b55f211fc57ef01f51227afb10f10a7 Mon Sep 17 00:00:00 2001 From: Yin Yue Date: Tue, 3 Sep 2024 10:54:09 +0530 Subject: [PATCH 1/8] SCAL-116040 host-event current iframe url --- src/types.ts | 5 +++++ src/utils/processTrigger.ts | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/types.ts b/src/types.ts index 84b7ed80..074f76c6 100644 --- a/src/types.ts +++ b/src/types.ts @@ -2268,6 +2268,11 @@ export enum HostEvent { * @hidden */ Reload = 'reload', + /** + * Reload the answer or visualization + * @hidden + */ + GetIframeUrl = 'getIframeUrl', /** * Display specific visualizations on a Liveboard. * @param - An array of GUIDs of the visualization to show. The visualization IDs not passed diff --git a/src/utils/processTrigger.ts b/src/utils/processTrigger.ts index 3507a83b..3a49a914 100644 --- a/src/utils/processTrigger.ts +++ b/src/utils/processTrigger.ts @@ -13,6 +13,14 @@ export const reload = (iFrame: HTMLIFrameElement) => { }, 100); }; +/** + * Get Current iframe url + * @param iFrame + */ +export const getIframeUrl = (iFrame: HTMLIFrameElement) => { + return iFrame.src; +} + /** * Post iframe message. * @param iFrame @@ -51,6 +59,9 @@ export function processTrigger( reload(iFrame); return res(null); } + if(messageType === HostEvent.GetIframeUrl) { + return getIframeUrl(iFrame); + } const channel = new MessageChannel(); channel.port1.onmessage = ({ data: responseData }) => { channel.port1.close(); From a20cf8bb8a30d32b21caebea5cf710a89958cd1c Mon Sep 17 00:00:00 2001 From: Yin Yue Date: Tue, 3 Sep 2024 10:56:40 +0530 Subject: [PATCH 2/8] SCAL-116040 --- src/types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types.ts b/src/types.ts index 074f76c6..ff866e0e 100644 --- a/src/types.ts +++ b/src/types.ts @@ -2269,7 +2269,7 @@ export enum HostEvent { */ Reload = 'reload', /** - * Reload the answer or visualization + * Get current iframe src * @hidden */ GetIframeUrl = 'getIframeUrl', From 9e9c2c4e4c9fb727cf3ce96f68c559d132f80230 Mon Sep 17 00:00:00 2001 From: Yin Yue Date: Tue, 3 Sep 2024 11:46:44 +0530 Subject: [PATCH 3/8] SCAL-116040 better name --- src/types.ts | 2 +- src/utils/processTrigger.ts | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/types.ts b/src/types.ts index ff866e0e..62a079d1 100644 --- a/src/types.ts +++ b/src/types.ts @@ -2272,7 +2272,7 @@ export enum HostEvent { * Get current iframe src * @hidden */ - GetIframeUrl = 'getIframeUrl', + GetIframeSrc = 'getIframeSrc', /** * Display specific visualizations on a Liveboard. * @param - An array of GUIDs of the visualization to show. The visualization IDs not passed diff --git a/src/utils/processTrigger.ts b/src/utils/processTrigger.ts index 3a49a914..71d97ef6 100644 --- a/src/utils/processTrigger.ts +++ b/src/utils/processTrigger.ts @@ -14,12 +14,13 @@ export const reload = (iFrame: HTMLIFrameElement) => { }; /** - * Get Current iframe url + * Get the source URL of an iframe * @param iFrame + * @returns The src URL of the iframe */ -export const getIframeUrl = (iFrame: HTMLIFrameElement) => { - return iFrame.src; -} +export const getIframeSrc = (iframe: HTMLIFrameElement): string => { + return iframe.src; +}; /** * Post iframe message. @@ -59,8 +60,8 @@ export function processTrigger( reload(iFrame); return res(null); } - if(messageType === HostEvent.GetIframeUrl) { - return getIframeUrl(iFrame); + if (messageType === HostEvent.GetIframeSrc) { + return getIframeSrc(iFrame); } const channel = new MessageChannel(); channel.port1.onmessage = ({ data: responseData }) => { From 07da4e051bfe4da76f898f07fbd15f062f4eb402 Mon Sep 17 00:00:00 2001 From: Yin Yue Date: Tue, 3 Sep 2024 11:52:44 +0530 Subject: [PATCH 4/8] SCAL-116040 lint fix --- src/utils/processTrigger.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/utils/processTrigger.ts b/src/utils/processTrigger.ts index 71d97ef6..7594aa25 100644 --- a/src/utils/processTrigger.ts +++ b/src/utils/processTrigger.ts @@ -16,11 +16,9 @@ export const reload = (iFrame: HTMLIFrameElement) => { /** * Get the source URL of an iframe * @param iFrame - * @returns The src URL of the iframe + * @returns The src URL of the iframe as a string */ -export const getIframeSrc = (iframe: HTMLIFrameElement): string => { - return iframe.src; -}; +export const getIframeSrc = (iframe: HTMLIFrameElement): string => iframe.src; /** * Post iframe message. From f2f25c96e6ce3bd75fea33527fbbd616a934906d Mon Sep 17 00:00:00 2001 From: Yin Yue Date: Mon, 9 Sep 2024 10:59:49 +0530 Subject: [PATCH 5/8] SCAL-116040 hostevent for current iframe src --- src/types.ts | 2 +- src/utils/processTrigger.ts | 9 --------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/src/types.ts b/src/types.ts index 62a079d1..285e8dbb 100644 --- a/src/types.ts +++ b/src/types.ts @@ -2272,7 +2272,7 @@ export enum HostEvent { * Get current iframe src * @hidden */ - GetIframeSrc = 'getIframeSrc', + GetIframeUrl = 'GetIframeUrl', /** * Display specific visualizations on a Liveboard. * @param - An array of GUIDs of the visualization to show. The visualization IDs not passed diff --git a/src/utils/processTrigger.ts b/src/utils/processTrigger.ts index 7594aa25..809ede4e 100644 --- a/src/utils/processTrigger.ts +++ b/src/utils/processTrigger.ts @@ -13,12 +13,6 @@ export const reload = (iFrame: HTMLIFrameElement) => { }, 100); }; -/** - * Get the source URL of an iframe - * @param iFrame - * @returns The src URL of the iframe as a string - */ -export const getIframeSrc = (iframe: HTMLIFrameElement): string => iframe.src; /** * Post iframe message. @@ -58,9 +52,6 @@ export function processTrigger( reload(iFrame); return res(null); } - if (messageType === HostEvent.GetIframeSrc) { - return getIframeSrc(iFrame); - } const channel = new MessageChannel(); channel.port1.onmessage = ({ data: responseData }) => { channel.port1.close(); From 071391f83375cb6ba1235558b3146cf1936fb2e0 Mon Sep 17 00:00:00 2001 From: Yin Yue Date: Mon, 9 Sep 2024 11:04:00 +0530 Subject: [PATCH 6/8] SCAL-116040 empty space --- src/utils/processTrigger.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/utils/processTrigger.ts b/src/utils/processTrigger.ts index 809ede4e..3507a83b 100644 --- a/src/utils/processTrigger.ts +++ b/src/utils/processTrigger.ts @@ -13,7 +13,6 @@ export const reload = (iFrame: HTMLIFrameElement) => { }, 100); }; - /** * Post iframe message. * @param iFrame From a0b1920f354c961a0630e4ed762e43117674cc4e Mon Sep 17 00:00:00 2001 From: Yin Yue Date: Mon, 9 Sep 2024 14:28:49 +0530 Subject: [PATCH 7/8] SCAL-116040 adding versions sdk and ts --- src/types.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/types.ts b/src/types.ts index 285e8dbb..89a604c7 100644 --- a/src/types.ts +++ b/src/types.ts @@ -2270,6 +2270,11 @@ export enum HostEvent { Reload = 'reload', /** * Get current iframe src + * @example + * ```js + * const frameUrl = AppEmbed.trigger(HostEvent.GetIframeUrl) + * ``` + * @version SDK: 1.35.0 | Thoughtspot: 10.4.cl * @hidden */ GetIframeUrl = 'GetIframeUrl', From ef44915fade1e762cd305033ad6d097882039844 Mon Sep 17 00:00:00 2001 From: Yin Yue Date: Mon, 9 Sep 2024 15:16:35 +0530 Subject: [PATCH 8/8] SCAL-116040 will be added to docs --- src/types.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/types.ts b/src/types.ts index 89a604c7..fd1a2834 100644 --- a/src/types.ts +++ b/src/types.ts @@ -2274,8 +2274,7 @@ export enum HostEvent { * ```js * const frameUrl = AppEmbed.trigger(HostEvent.GetIframeUrl) * ``` - * @version SDK: 1.35.0 | Thoughtspot: 10.4.cl - * @hidden + * @version SDK: 1.35.0 | Thoughtspot: 10.4.0.cl */ GetIframeUrl = 'GetIframeUrl', /**