Skip to content

Commit

Permalink
Merge pull request #83 from openedx/cag/delay
Browse files Browse the repository at this point in the history
fix: delay loading of unfocused dashboards
  • Loading branch information
Cristhian Garcia authored Sep 6, 2024
2 parents 4090e65 + a33ab58 commit dbadd89
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ Change Log
Unreleased
**********

0.11.1 - 2024-09-06
*******************

Fixes
=====

* delay loading of unfocused dashboards in LMS.

0.11.0 - 2024-09-04
*******************

Expand Down
2 changes: 1 addition & 1 deletion platform_plugin_aspects/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
import os
from pathlib import Path

__version__ = "0.11.0"
__version__ = "0.11.1"

ROOT_DIRECTORY = Path(os.path.dirname(os.path.abspath(__file__)))
24 changes: 19 additions & 5 deletions platform_plugin_aspects/static/js/embed_dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ async function fetchGuestToken() {
return data.guestToken;
}

function embedDashboard(dashboard_uuid, superset_url, xblock_id) {
xblock_id = xblock_id || "";

function _embedDashboard(dashboard_uuid, superset_url, xblock_id){
window.supersetEmbeddedSdk
.embedDashboard({
id: dashboard_uuid, // given by the Superset embedding UI
Expand All @@ -70,10 +68,26 @@ function embedDashboard(dashboard_uuid, superset_url, xblock_id) {
when the dashboard is loaded
*/
});
}

function embedDashboard(dashboard, superset_url, xblock_id, index) {
xblock_id = xblock_id || "";
let radio = document.querySelector(`#tab-${index+1}`)
if (index == 0){
dashboard.loaded = true;
_embedDashboard(dashboard.uuid, superset_url, xblock_id)
}
radio.addEventListener("change", () => {
if (dashboard.loaded){
return
}
dashboard.loaded = true;
_embedDashboard(dashboard.uuid, superset_url, xblock_id)
});
};

if (window.superset_dashboards !== undefined) {
window.superset_dashboards.forEach(function(dashboard) {
embedDashboard(dashboard.uuid, window.superset_url, dashboard.uuid);
window.superset_dashboards.forEach(function(dashboard, i) {
embedDashboard(dashboard, window.superset_url, dashboard.uuid, i);
});
}
2 changes: 1 addition & 1 deletion platform_plugin_aspects/static/js/superset.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function SupersetXBlock(runtime, element, context) {
window.from_xblock = true;

function initSuperset(supersetEmbeddedSdk) {
embedDashboard(dashboard_uuid, superset_url, xblock_id);
_embedDashboard(dashboard_uuid, superset_url, xblock_id);
}

if (typeof require === "function") {
Expand Down

0 comments on commit dbadd89

Please sign in to comment.