You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/07/22 21:37:27 UTC

[GitHub] [superset] VictorEffectiv opened a new issue, #20836: react dashboard embeded doesnt update after token refresh

VictorEffectiv opened a new issue, #20836:
URL: https://github.com/apache/superset/issues/20836

   A clear and concise description of what the bug is.
   
   #### How to reproduce the bug
   
   1. Create a React App
   2. Try to embed a dashboard using the sdk
   3. Wait for 5 min and see that after token refresh call, the dashboard doesnt update
   
   
   ### Expected results
   i would expect to see the message dashboard updated
   
   ### Actual results
   
   nothing happens. i see that the refetch token function is called but nothing else is triggered
   
   #### Screenshots
   
   If applicable, add screenshots to help explain your problem.
   
   
   ### Environment
   
   (please complete the following information):
   
   - browser type and version:
   - superset version: `superset version`
   - python version: `python --version`
   - node.js version: `node -v`
   - any feature flags active:
   
   ### Checklist
   
   Make sure to follow these steps before submitting your issue - thank you!
   
   - [ ] I have checked the superset logs for python stacktraces and included it here as text if there are any.
   - [x] I have reproduced the issue with at least the latest released version of superset.
   - [x] I have checked the issue tracker for the same issue and I haven't found one similar.
   
   ### Additional context
   
   i was able to make the dashboard refresh with a simple html and the following code
   
   ```
   <!DOCTYPE html>
   <html>
     <head>
       <!-- <meta
         http-equiv="Content-Security-Policy"
         content="default-src https: 'unsafe-eval' 'unsafe-inline':"
       /> -->
     </head>
     <body>
       <h1>Superset Embedding</h1>
   
       <p>First Dashboard Embedding</p>
       <style type="text/css">
         #my-superset-container {
           height: 100vh;
           width: 100vw;
         }
         #my-superset-container > iframe {
           height: 100%;
           width: 100%;
         }
       </style>
   
       <script src="https://unpkg.com/@preset-sdk/embedded"></script>
   
       <script type="text/javascript">
         async function fetchGuestTokenFromBackend() {
           let url = "url;
           const settings = {
             method: "POST",
             headers: {
               "Content-Type": "application/json",,
             },
             body: JSON.stringify(
           try {
             let response = await fetch(url, settings);
             let data = await response.json();
             console.log("data is", data);
           } catch (e) {
             console.error(e);
           }
         }
       </script>
   
       <div id="my-superset-container"></div>
   
       <script>
         presetSdk.embedDashboard({
           id: "id", // given by the Superset embedding UI
           supersetDomain: "iddomain",
           mountPoint: document.getElementById("my-superset-container"), // any html element that can contain an iframe
           fetchGuestToken: fetchGuestTokenFromBackend,
           debug: true,
           dashboardUiConfig: { hideTitle: false }, // dashboard UI config: hideTitle, hideTab, hideChartControls (optional)
         });
       </script>
     </body>
   </html>
   ```
   
   At first i thought it was CRA that was doing something wrong, but i copy pasted the same code as above inside my index.html from the CRA app and it worked fine.
   
   When i try to embed using normal React code for some reason the dashboard t never gets refreshed after the fetchToken happens.
   
   This is my relative React code
   
   ```
     useEffect(() => {
       if (iframeRef.current && data?.dashboardVizV2IDs && selectedTab) {
         const tab = data?.dashboardVizV2IDs.find((el) => el.id === selectedTab);
   
         if (tab) {
           embedDashboard({
             id: tab.biId, // given by the Superset embedding UI
             supersetDomain: tab.meta.superset_domain,
             mountPoint: iframeRef.current, // any html element that can contain an iframe
             fetchGuestToken: async () => {
               const result = await getDashboardToken({
                 id: tab.id,
                 useCase: id,
                 category: type,
               });
               return result.data.dashboardVizV2EmbeddingToken.token;
             },
             debug: true,
             dashboardUiConfig: { hideTitle: true, hideChartControls: false }, // dashboard UI config: hideTitle, hideTab, hideChartControls (optional)
           });
         }
       }
     }, [data?.dashboardVizV2IDs, getDashboardToken, id, selectedTab, type]);
   
   ```
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] react dashboard embeded doesnt update after token refresh [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on issue #20836:
URL: https://github.com/apache/superset/issues/20836#issuecomment-1936445565

   Closing this as stale since it's been silent for so long, and we're trying to steer toward a more actionable Issues backlog. If people are still encountering this in current versions (currently 3.x) we can happily re-open it. We haven't gotten other complaints about this issue to my knowledge, so I'm optimistic that it's been resolved or you found a workaround by now :)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] react dashboard embeded doesnt update after token refresh [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas closed issue #20836: react dashboard embeded doesnt update after token refresh 
URL: https://github.com/apache/superset/issues/20836


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org