From b552396749e9c120687540003b535a670706f450 Mon Sep 17 00:00:00 2001 From: francoismg <46478217+francoismg@users.noreply.github.com> Date: Tue, 31 Oct 2023 13:58:39 +0100 Subject: [PATCH 1/5] fix for folder location --- config/plugins/visualizations/fits_image_viewer/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/plugins/visualizations/fits_image_viewer/package.json b/config/plugins/visualizations/fits_image_viewer/package.json index f895a17bf537..efa0dd67be39 100644 --- a/config/plugins/visualizations/fits_image_viewer/package.json +++ b/config/plugins/visualizations/fits_image_viewer/package.json @@ -11,6 +11,6 @@ "parcel-bundler": "^1.4.1" }, "scripts": { - "build": "cp -r node_modules/aladin-lite-galaxy static/dist && parcel build src/script.js -d static" + "build": "cp -r node_modules/aladin-lite-galaxy/. static/dist/aladin-lite-galaxy && parcel build src/script.js -d static" } } From 077393641b2cc4c4b6ba6adda0f48601dedba817 Mon Sep 17 00:00:00 2001 From: francoismg <46478217+francoismg@users.noreply.github.com> Date: Tue, 31 Oct 2023 13:59:48 +0100 Subject: [PATCH 2/5] added cdn + fallback --- .../fits_image_viewer/src/script.js | 36 +++++++++++++++---- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/config/plugins/visualizations/fits_image_viewer/src/script.js b/config/plugins/visualizations/fits_image_viewer/src/script.js index 1568f1408465..3cebefd5b8e7 100644 --- a/config/plugins/visualizations/fits_image_viewer/src/script.js +++ b/config/plugins/visualizations/fits_image_viewer/src/script.js @@ -1,7 +1,31 @@ -let aladin; +var aladin; -A.init.then(() => { - aladin = A.aladin('#aladin-lite-div', {showCooGridControl: true}); - aladin.displayFITS(file_url) - aladin.showCooGrid(true); -}); \ No newline at end of file +function initializeAladinLite() { + A.init.then(() => { + aladin = A.aladin('#aladin-lite-div', {showCooGridControl: true}); + aladin.displayFITS(fileUrl) + aladin.showCooGrid(true); + }); +} + +function localScriptLoadingError() { + addScriptToHead(appRoot+aladinLiteScriptAlternativeLocation); +} + +function cdnLoadingError() { + addScriptToHead(appRoot+aladinLiteScriptLocation, localScriptLoadingError); +} + +function addScriptToHead(url, onerrorFunction) { + const scriptToAdd = document.createElement("script"); + scriptToAdd.onload = initializeAladinLite; + + if(onerrorFunction) { + scriptToAdd.onerror = onerrorFunction + } + + document.head.appendChild(scriptToAdd); + scriptToAdd.src = url; +} + +addScriptToHead(aladinLiteCDNUrl, cdnLoadingError); From dcbcccc31014f251f5f3f8a3781bde5a0ec4e59a Mon Sep 17 00:00:00 2001 From: francoismg <46478217+francoismg@users.noreply.github.com> Date: Tue, 31 Oct 2023 14:02:47 +0100 Subject: [PATCH 3/5] added cdn and fallback urls + refactor --- .../fits_image_viewer/templates/fits_image_viewer.mako | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/config/plugins/visualizations/fits_image_viewer/templates/fits_image_viewer.mako b/config/plugins/visualizations/fits_image_viewer/templates/fits_image_viewer.mako index 63a8cb17e731..064171af8b45 100644 --- a/config/plugins/visualizations/fits_image_viewer/templates/fits_image_viewer.mako +++ b/config/plugins/visualizations/fits_image_viewer/templates/fits_image_viewer.mako @@ -13,15 +13,19 @@
${h.stylesheet_link( app_root + 'style.css' )} - ${h.javascript_link( app_root + 'dist/aladin-lite-galaxy/aladin.js' )}