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' )}
FITS aladin viewer : ${hda.name | h}
+ ${h.javascript_link( app_root + 'script.js' )} - \ No newline at end of file + From cf6c9805037d76be87f7ad33978f7381fc264336 Mon Sep 17 00:00:00 2001 From: Denys SAVCHENKO Date: Thu, 2 Nov 2023 14:04:11 +0100 Subject: [PATCH 4/5] fix no such directory in fits viewer build --- 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 efa0dd67be39..10799d30d02e 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/aladin-lite-galaxy && parcel build src/script.js -d static" + "build": "mkdir -p static/dist; cp -r node_modules/aladin-lite-galaxy static/dist/. && parcel build src/script.js -d static" } } From 2992ee8858d91cbc139f03c4105993fe27eb5708 Mon Sep 17 00:00:00 2001 From: francoismg <46478217+francoismg@users.noreply.github.com> Date: Mon, 13 Nov 2023 06:56:58 +0100 Subject: [PATCH 5/5] added cpy-cli dependency and updated build script Following advice from galaxy maintainer : - Switch to cpy-cli to use instead of cp (should prevent the differences in cp behaviour) --- config/plugins/visualizations/fits_image_viewer/package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/config/plugins/visualizations/fits_image_viewer/package.json b/config/plugins/visualizations/fits_image_viewer/package.json index 10799d30d02e..5e09ac1369f6 100644 --- a/config/plugins/visualizations/fits_image_viewer/package.json +++ b/config/plugins/visualizations/fits_image_viewer/package.json @@ -8,9 +8,10 @@ "license": "AFL-3.0", "dependencies": { "aladin-lite-galaxy": "^1.0.0", - "parcel-bundler": "^1.4.1" + "parcel-bundler": "^1.4.1", + "cpy-cli": "^5.0.0" }, "scripts": { - "build": "mkdir -p static/dist; cp -r node_modules/aladin-lite-galaxy static/dist/. && parcel build src/script.js -d static" + "build": "cpy --flat node_modules/aladin-lite-galaxy static/dist/aladin-lite-galaxy && parcel build src/script.js -d static" } }