Skip to content

Commit

Permalink
image tab fix
Browse files Browse the repository at this point in the history
  • Loading branch information
djtfmartin committed Aug 22, 2021
1 parent 3871687 commit c5fce24
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
1 change: 1 addition & 0 deletions grails-app/assets/javascripts/application-pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
//= require datatables.min.js
//= require ala/ala-charts.js
//= require collectory.js
//= require images.js
//= require_self
40 changes: 40 additions & 0 deletions grails-app/assets/javascripts/images.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* Populate Images tab body with images via AJAX call to Biocache
*/
function loadImagesTab() {
var wsBase = "/occurrences/search.json";
var uiBase = "/occurrences/search";
var imagesQueryUrl = "?facets=type_status&fq=multimedia%3AImage&pageSize=100&q=collectionUid:" + SHOW_REC.instanceUuid;
$.ajax({
url: SHOW_REC.biocacheServicesUrl + wsBase + imagesQueryUrl,
dataType: 'jsonp',
timeout: 20000,
complete: function(jqXHR, textStatus) {
if (textStatus == 'timeout') {
noBiocacheData();
}
if (textStatus == 'error') {
noBiocacheData();
}
},
success: function(data) {
// check for errors
if (data.length == 0 || data.totalRecords == undefined || data.totalRecords == 0) {
//noBiocacheData();
} else {
if(data.totalRecords > 0){
$('#imagesTabEl').css({display:'block'});
var description = ""
$('#imagesSpiel').html('<p><a href="' + SHOW_REC.biocacheWebappUrl + uiBase + imagesQueryUrl +'">' + data.totalRecords + ' images</a> have been made available from the ' + SHOW_REC.instanceName + '. <br/> ' + description + '</p>');
$.each(data.occurrences, function(idx, item){
var imageText = item.scientificName;
if(item.typeStatus !== undefined){
imageText = item.typeStatus + " - " + imageText;
}
$('#imagesList').append('<div class="imgCon"><a href="' + SHOW_REC.biocacheWebappUrl + '/occurrences/' + item.uuid + '"><img src="' + item.smallImageUrl + '"/><br/>'+ imageText + '</a></div>');
})
}
}
}
});
}
3 changes: 2 additions & 1 deletion grails-app/views/public/showCollection.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,8 @@
// stats
if (loadLoggerStats){
loadDownloadStats("${grailsApplication.config.loggerURL}", "${instance.uid}","${instance.name}", "1002");
}
}
loadImagesTab();
</asset:script>
<g:render template="charts" model="[facet:'collectionUid', instance: instance]" />
<g:render template="progress" model="[facet:'collection_uid', instance: instance]" />
Expand Down

0 comments on commit c5fce24

Please sign in to comment.