Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for fits_image_viewer visualization plugin #17002

Merged
merged 5 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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": "mkdir -p static/dist; cp -r node_modules/aladin-lite-galaxy static/dist/. && parcel build src/script.js -d static"
francoismg marked this conversation as resolved.
Show resolved Hide resolved
}
}
36 changes: 30 additions & 6 deletions config/plugins/visualizations/fits_image_viewer/src/script.js
Original file line number Diff line number Diff line change
@@ -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);
});
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);
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,19 @@
<html>
<head>
${h.stylesheet_link( app_root + 'style.css' )}
${h.javascript_link( app_root + 'dist/aladin-lite-galaxy/aladin.js' )}
</head>
<body>
<div id="div_title"><span id="span_plugin_name">FITS aladin viewer</span> : <span id="span_file_name">${hda.name | h}</span></div>
<div id="aladin-lite-div"></div>

<script>
let file_url = '${file_url}';
const fileUrl = '${file_url}';
const appRoot = '${app_root}'
const aladinLiteCDNUrl = "https://aladin.cds.unistra.fr/AladinLite/api/v3/latest/aladin.js"
const aladinLiteScriptLocation = "dist/aladin-lite-galaxy/aladin.js"
const aladinLiteScriptAlternativeLocation = "dist/aladin.js"
</script>

${h.javascript_link( app_root + 'script.js' )}
</body>
</html>
</html>
Loading