Closed erdemcer closed 1 week ago
Merhaba @erdemcer! I'm here to help you with any bugs or questions you have while waiting for a human maintainer. Let's solve this together!
To refresh the Superset dashboard in an iframe without reloading the entire iframe, you can use the postMessage
API to communicate with the iframe and trigger a refresh. Superset provides a way to handle custom events or messages using the Switchboard
class, which facilitates communication between the parent window and the iframe.
Here's a basic outline of how you can achieve this:
Set up a MessageChannel: Establish a communication channel between the parent window and the iframe.
Define a refresh method in the iframe: Use the Switchboard
class to define a method in the iframe that handles the refresh logic.
Emit a refresh message from the parent: Use the emit
method to send a message to the iframe to trigger the refresh.
Example code snippet:
// In the parent window
const switchboard = new Switchboard({ port: yourMessagePort });
// Emit a message to trigger the refresh
switchboard.emit('refresh');
// In the iframe
switchboard.defineMethod('refresh', () => {
// Logic to refresh the dashboard content
});
This setup allows you to refresh the dashboard content without reloading the entire iframe [1].
To continue talking to Dosu, mention @dosu.
Hi @dosu
Thanks for reply . But i have following error while initialize Switchboard in the parent window.
Uncaught ReferenceError: Switchboard is not defined
Could you please give detail about your outline ?
Thanks.
To resolve the "Uncaught ReferenceError: Switchboard is not defined" error, ensure that the Switchboard
class is properly imported or included in your script. The Switchboard
class is exported as a default instance, so you need to import it correctly in your parent window script. Here's how you can do it:
Import the Switchboard: Make sure you have the correct import statement in your parent window script.
import Switchboard from 'path-to-switchboard-file';
Replace 'path-to-switchboard-file'
with the actual path to the file where the Switchboard
class is defined.
Ensure Script Order: If you are not using a module system, ensure that the script containing the Switchboard
class is loaded before any script that tries to use it.
By following these steps, you should be able to initialize the Switchboard
without encountering the reference error [1].
To continue talking to Dosu, mention @dosu.
Hi @dosu I am not using module system. I am trying to import it from supersetEmbeddedSdk with "onst switchboard = new supersetEmbeddedSdk.Switchboard({ port: channel.port1 });" But gives another error ; Uncaught TypeError: supersetEmbeddedSdk.Switchboard is not a constructor
Thanks.
Hello @erdemcer I am closing this issue as this is not supported at the moment, but feel free to open up a PR to make this possible. Thank you!
I have a simple application which has iframe contains Superset dashboard. I would like to refresh dashboard from custom button in main page but everytime when refresh button is called full whole iframe is reloading. Is there any way to refresh dashboard in iframe without reloading whole iframe.
Thanks