Skip to content

Commit

Permalink
Merge pull request #526 from brucehyslop/develop
Browse files Browse the repository at this point in the history
Pre-grails4 branch changes
  • Loading branch information
brucehyslop committed Dec 22, 2021
2 parents 6a2f787 + df501d5 commit d59e4e4
Show file tree
Hide file tree
Showing 42 changed files with 892 additions and 439 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# biocache-hubs [![Build Status](https://travis-ci.com/AtlasOfLivingAustralia/biocache-hubs.svg?branch=master)](https://travis-ci.com/AtlasOfLivingAustralia/biocache-hubs)
# biocache-hubs [![Build Status](https://travis-ci.com/AtlasOfLivingAustralia/biocache-hubs.svg?branch=develop)](https://travis-ci.com/AtlasOfLivingAustralia/biocache-hubs)

**biocache-hubs** is a Grails plugin that provides the core functionality for the _Atlas of Living Australia_ (ALA) [Occurrence search portal](https://biocache.ala.org.au/search) (Biocache) front-end.

Expand Down
6 changes: 4 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ buildscript {
}
}

version "3.0.6-SNAPSHOT"
version "3.0.9-SNAPSHOT"
group "au.org.ala.plugins.grails"

apply plugin:"eclipse"
Expand Down Expand Up @@ -44,6 +44,7 @@ dependencies {
def noCache = {
exclude group: 'org.grails.plugins', module: 'cache'
exclude group: 'org.ehcache', module: 'ehcache'
exclude group: 'org.grails.plugins', module: 'cache-ehcache'
}

compile "org.springframework.boot:spring-boot-starter-logging"
Expand All @@ -53,7 +54,8 @@ dependencies {
compile "org.springframework.boot:spring-boot-starter-tomcat"
compile "org.grails:grails-dependencies"
compile "org.grails:grails-web-boot"
compile "org.grails.plugins:cache"
compile "org.grails.plugins:cache:4.0.0"
compile "org.grails.plugins:cache-ehcache:3.0.0"
compile "org.grails.plugins:scaffolding"
console "org.grails:grails-console"
profile "org.grails.profiles:web-plugin"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,15 @@
*/
jQuery(document).ready(function() {
// Autocomplete
var bieBaseUrl = BC_CONF.bieWebServiceUrl;
var bieParams = { limit: 20 };
var autoHints = BC_CONF.autocompleteHints; // expects { fq: "kingdom:Plantae" }
$.extend( bieParams, autoHints ); // merge autoHints into bieParams
var autocompleteUrl = BC_CONF.autocompleteUrl;
var params = {};
if (BC_CONF.autocompleteUseBie) {
$.extend(params, {limit: 20});
var autoHints = BC_CONF.autocompleteHints; // expects { fq: "kingdom:Plantae" }
$.extend(params, autoHints); // merge autoHints into params
} else {
$.extend(params, {pageSize: 20});
}

function getMatchingName(item) {
if (item.scientificNameMatches && item.scientificNameMatches.length) {
Expand All @@ -34,7 +39,7 @@ jQuery(document).ready(function() {
} else {
return item.name;
}
};
}

function formatAutocompleteList(list) {
var results = [];
Expand All @@ -46,17 +51,17 @@ jQuery(document).ready(function() {
}

return results;
};
}

$.ui.autocomplete({
source: function (request, response) {
bieParams.q = request.term;
params.q = request.term;
$.ajax( {
url: bieBaseUrl + '/search/auto.json',
url: autocompleteUrl,
dataType: "json",
data: bieParams,
data: params,
success: function( data ) {
response( formatAutocompleteList(data.autoCompleteList) );
response( formatAutocompleteList(BC_CONF.autocompleteUseBie ? data.autoCompleteList : data.searchResults.results) );
}
} );
}
Expand Down
1 change: 0 additions & 1 deletion grails-app/assets/javascripts/biocache-hubs.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
/************************************************************\
* i18n
\************************************************************/
//= require jquery_i18n
if (typeof BC_CONF != 'undefined' && BC_CONF.hasOwnProperty('contextPath')) {
jQuery.i18n.properties({
name: 'messages',
Expand Down
11 changes: 6 additions & 5 deletions grails-app/assets/javascripts/exploreYourArea.js
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,7 @@ function loadRecordsLayer(retry) {
}, true);

// records popups need to know the species group
MAP_VAR.removeFqs = "&fq=species_group:" + (speciesGroup == "ALL_SPECIES" ? "*" : speciesGroup) + "&fq=taxon_name:" + (taxon ? taxon : "*");

MAP_VAR.removeFqs = "&fq=species_group:" + (speciesGroup === "ALL_SPECIES" ? "*" : speciesGroup) + "&fq=taxon_name:" + (taxon ? ("\"" + taxon + "\""): "*");
// console.log("alaParams = ", alaParams, speciesGroupParam);

var alaMapUrl = MAP_VAR.biocacheServiceUrl + "/ogc/wms/reflect?" + alaParams;
Expand Down Expand Up @@ -627,20 +626,22 @@ function groupClicked(el) {
if (MAP_VAR.map) loadRecordsLayer();
// AJAX...
var uri = MAP_VAR.biocacheServiceUrl + "/explore/group/"+speciesGroup+".json";
var sortField = "count"
var params = {
lat: $('#latitude').val(),
lon: $('#longitude').val(),
radius: $('#radius').val(),
fq: "geospatial_kosher:true",
qc: MAP_VAR.queryContext,
sort: "count",
sort: sortField,
pageSize: 50
};
//var params = "?latitude=${latitude}&longitude=${longitude}&radius=${radius}&taxa="+taxa+"&rank="+rank;
$('#taxaDiv').html('[loading...]');
$("div#rightList").data("sort", sortField); // save 'sort' value to the DOM
$.getJSON(uri, params, function(data) {
// process JSON data from request
if (data) processSpeciesJsonData(data);
if (data) processSpeciesJsonData(data, false);
});
}

Expand Down Expand Up @@ -748,7 +749,7 @@ function processSpeciesJsonData(data, appendResults) {
taxa = []; // array of taxa
taxa = (thisTaxon.indexOf("|") > 0) ? thisTaxon.split("|") : thisTaxon;
var start = $(this).attr('href');
var sortOrder = $(this).data("sort") ? $(this).data("sort") : "index";
var sortOrder = $(this).data("sort") ? $(this).data("sort") : "count";
var sortParam = sortOrder;
var commonName = false;
if (sortOrder == "common") {
Expand Down
2 changes: 1 addition & 1 deletion grails-app/assets/javascripts/leafletPlugins.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//= require jquery_i18n

//= require leaflet/leaflet-src.js
//= require leaflet-fullscreen.js
//= require leaflet-plugins/layer/tile/Google.js
Expand Down
65 changes: 48 additions & 17 deletions grails-app/assets/javascripts/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,14 @@ $(document).ready(function() {
$('.exclude-loader').hide();
for (var key in data) {
var categoryEnabled = $('.exclude-count-label[data-category='+key+']').data('enabled')
data[key] = categoryEnabled ? (new Intl.NumberFormat()).format(parseInt(data[key])) : 0
data[key] = categoryEnabled ? (new Intl.NumberFormat()).format(parseInt(data[key])) : '0';
$('.exclude-count-label[data-category='+key+']').text(data[key]).show();
$('.exclude-count-facet[data-category='+key+']').text("-("+data[key]+")").show();

if (data[key] === '0') {
$('.exclude-count-facet[data-category=' + key + ']').text('(' + data[key] + ')').show();
} else {
$('.exclude-count-facet[data-category=' + key + ']').text('(-' + data[key] + ')').show();
}
}
excludeCounts = data;
});
Expand Down Expand Up @@ -165,7 +170,8 @@ $(document).ready(function() {

//Check user has selected at least 1 facet
if (selectedFacets.length > 0 && selectedFacets.length <= BC_CONF.maxFacets) {
// save facets to the user_facets cookie
// save facets to the user_facets cookie as string
$.cookie.json = false;
$.cookie("user_facets", selectedFacets, { expires: 7 });
// reload page
document.location.reload(true);
Expand Down Expand Up @@ -242,8 +248,8 @@ $(document).ready(function() {
synListSize++;
synList1 += "<input type='checkbox' name='raw_taxon_guid' id='rawTaxon_" + index + "_" + j +
"' class='rawTaxonCheckBox' value='" + el1.label + "'/>&nbsp;" +
"<a href='" + BC_CONF.contextPath + "/occurrences/search?q=raw_taxon_name:%22" + el1.label +
"%22'>" + el1.label + "</a> (" + el1.count + ")<br/>";
"<a href=\"" + BC_CONF.contextPath + "/occurrences/search?q=raw_taxon_name:%22" + encodeURIComponent(el1.label) +
"%22\">" + el1.label + "</a> (" + el1.count + ")<br/>";
});
}
});
Expand Down Expand Up @@ -349,13 +355,19 @@ $(document).ready(function() {
loadMoreFacets(facetName, displayName, null);
});

$('#profiles-selection').click(function(e) {
e.preventDefault();
$('#active-profile-name').text(e.target.innerText)
window.location.href = e.target.href
})

// When user clicks the 'view profile description' icon next to profiles selection drop-down
$('.DQProfileDetailsLink').click(function() {
$.each($(".cat-table"), function(idx, el) {
var filters = $(el).data('filters');

var filterlist = filters.split(' AND ');
var filterlist = $(el).data('filters');
var keys = [];

for (var i = 0; i < filterlist.length; i++) {
var val = parseFilter(filterlist[i]);
if (val.length > 0) {
Expand Down Expand Up @@ -416,8 +428,8 @@ $(document).ready(function() {
// when use clicks <i/> to view details of a category
$('.DQCategoryDetailsLink').click(function() {
var link = this;
var filters = $(link).data("filters");
var fq = $(link).data("fq");
var fqs = fq.split(' AND ')

var description = $(link).data("description");
var dqCategoryLabel = $(link).data('categorylabel')
Expand All @@ -430,10 +442,10 @@ $(document).ready(function() {
$('#DQDetailsModal .modal-body #filter-value').html("<b>Filter applied: </b><i>fq=" + fq + "</i>");
$("#view-excluded").attr('href', dqInverse);

if (excludeCounts[dqCategoryLabel]) {
if (excludeCounts[dqCategoryLabel] !== '0') {
$("#excluded .exclude-count-label").text(excludeCounts[dqCategoryLabel]).removeData('category').removeAttr('category');
} else {
$("#excluded .exclude-count-label").text('').data('category', dqCategoryLabel).attr('data-category', dqCategoryLabel);
$("#excluded .exclude-count-label").text(excludeCounts[dqCategoryLabel]).data('category', dqCategoryLabel).attr('data-category', dqCategoryLabel);
}

var pos = 0;
Expand Down Expand Up @@ -495,10 +507,9 @@ $(document).ready(function() {
}
})

var descs = description.split(' and ')
var valuesHtml = ""

$.each(fqs, function(idx, el) {
$.each(filters, function(idx, el) {
var vals = parseFilter(el);
if (vals.length > 0) {
var key = vals[0];
Expand All @@ -515,10 +526,11 @@ $(document).ready(function() {
wiki = replaceURL(map.get(key)[1], 'Link');
}

// make sure no beak between '-' and key
var els = el.split(':');
el = '<span style="white-space: nowrap;">' + els[0] + '</span>:' + els[1];
valuesHtml += '<tr><td style=\"word-break: break-word\">' + replaceURL(descs[idx]) + '</td><td style=\"word-break: normal\">' + el + '</td><td>' + wiki + '</td></tr>';
valuesHtml += '<tr>'
valuesHtml += '<td class="filter-description" style="word-break: break-word">' + replaceURL(description[idx]) + '</td>'
valuesHtml += '<td class="filter-value" style="word-break: normal"><span style="white-space: nowrap;">' + el + '</span></td>'
valuesHtml += '<td class="filter-wiki">' + wiki + '</td>'
valuesHtml += '</tr>'
}
})

Expand Down Expand Up @@ -633,6 +645,25 @@ $(document).ready(function() {
window.location.href = BC_CONF.serverName + "/occurrences/facets/download" + BC_CONF.facetDownloadQuery + '&facets=' + facetName;
});

$('#copy-al4r').on('click', function() {
var input = document.querySelector('#al4rcode');
navigator.clipboard.writeText(input.value)
.then(() => {
$(this).qtip({
content: jQuery.i18n.prop('list.copylinks.tooltip.copied'),
show: true,
hide: { when: { event: 'mouseout'} }
})})
.catch((error) => { alert(jQuery.i18n.prop('list.copylinks.alert.failed') + error) })
});

$('#copy-al4r').on('mouseleave', function() {
$(this).qtip({
content: jQuery.i18n.prop('list.copylinks.tooltip.copytoclipboard'),
show: { when: { event: 'mouseover'} }
})
})

// when open the user preference dlg
$('.DQPrefSettingsLink').click(function() {
var prefSettings = $('#DQPrefSettings');
Expand Down Expand Up @@ -1173,7 +1204,7 @@ $(document).ready(function() {
});

// user preference settings and download link tooltips will be above the control
$("#usersettings, a.newDownload").qtip({
$("#usersettings, a.copyLink").qtip({
style: {
classes: 'ui-tooltip-rounded ui-tooltip-shadow'
},
Expand Down
42 changes: 33 additions & 9 deletions grails-app/assets/javascripts/show.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,42 @@
//= require linkifyjs/linkify-jquery.js
//= require leaflet/leaflet.js
//= require leaflet-plugins/layer/tile/Google.js
//= require biocache-hubs.js
//= require_self
*/
/**
* JQuery on document ready callback
*/

function updatei18n() {
$('.i8nupdate').each(function() {
var key = $(this).attr('i18nkey')
if (key !== undefined) {
$(this).text(jQuery.i18n.prop(key));
}
});
}

$(document).ready(function() {
if (typeof BC_CONF != 'undefined' && BC_CONF.hasOwnProperty('contextPath')) {
jQuery.i18n.properties({
name: 'messages',
path: BC_CONF.contextPath + '/messages/i18n/',
mode: 'map',
async: true,
cache: true,
language: BC_CONF.locale, // default is to use browser specified locale
callback: updatei18n
});
}

$('#showUncheckedTests').on('click', function(e){
$('.uncheckTestResult').toggle();
});

$('#showPassedPropResult').on('click', function(e){
$('.passedPropResult').toggle();
});

$('#showMissingPropResult').on('click', function(e){
$('.missingPropResult').toggle();
});
Expand Down Expand Up @@ -196,7 +220,7 @@ $(document).ready(function() {
// when add assertion succeeds, we update alert settings (only when myannotation is enabled)
if (OCC_REC.myAnnotationEnabled) {
var new_state = $('#notifyChangeCheckbox').prop('checked');
var actionpath = new_state ? "/occurrences/subscribeMyAnnotation" : "/occurrences/unsubscribeMyAnnotation";
var actionpath = new_state ? "/api/subscribeMyAnnotation" : "/api/unsubscribeMyAnnotation";
$.post(OCC_REC.contextPath + actionpath);
}

Expand All @@ -216,7 +240,7 @@ $(document).ready(function() {
}
).error(function () {
$('#assertionSubmitProgress').css({'display': 'none'});
$("#submitSuccess").html("There was problem flagging the issue. Please try again later.");
$("#submitSuccess").html(jQuery.i18n.prop('show.issueform.flagfail.message'));
});
}

Expand All @@ -237,7 +261,7 @@ $(document).ready(function() {
if (OCC_REC.myAnnotationEnabled) {
// by default off
$("#notifyChangeCheckbox").prop('checked', false);
var getAlerts = OCC_REC.contextPath + "/occurrences/alerts";
var getAlerts = OCC_REC.contextPath + "/api/alerts";
$.getJSON(getAlerts, function (data) {
var myAnnotationEnabled = data && data.myannotation && data.myannotation.length > 0;
$("#notifyChangeCheckbox").prop('checked', myAnnotationEnabled);
Expand Down Expand Up @@ -477,7 +501,7 @@ function refreshUserAnnotations(){
// if the code == 50000, then we have verification - so don't display here
if (userAssertion.code != 50000) {
$clone.prop('id', "userAnnotation_" + userAssertion.uuid);
$clone.find('.issue').text(jQuery.i18n.prop(userAssertion.name));
$clone.find('.issue').text(jQuery.i18n.prop(userAssertion.name)).attr('i18nkey', userAssertion.name);
$clone.find('.user').text(userAssertion.userDisplayName);
if (userAssertion.hasOwnProperty('comment')) {
$clone.find('.comment').text('Comment: ' + userAssertion.comment);
Expand Down Expand Up @@ -529,8 +553,8 @@ function refreshUserAnnotations(){
}
if (userAssertion.relatedRecordReason) {
$clone.find('.related-record-reason').show();
$clone.find('.related-record-reason-span').text(jQuery.i18n.prop('related.record.reason.' + userAssertion.relatedRecordReason));
$clone.find('.related-record-reason-explanation').text(jQuery.i18n.prop('related.record.reason.explanation.' + userAssertion.relatedRecordReason)).show();
$clone.find('.related-record-reason-span').text(jQuery.i18n.prop('related.record.reason.' + userAssertion.relatedRecordReason)).attr('i18nkey', 'related.record.reason.' + userAssertion.relatedRecordReason);
$clone.find('.related-record-reason-explanation').text(jQuery.i18n.prop('related.record.reason.explanation.' + userAssertion.relatedRecordReason)).attr('i18nkey', 'related.record.reason.explanation.' + userAssertion.relatedRecordReason).show();
}
if (userAssertion.userRole != null) {
$clone.find('.userRole').text(', ' + userAssertion.userRole);
Expand Down Expand Up @@ -571,7 +595,7 @@ function refreshUserAnnotations(){
var $clone = $('#userVerificationTemplate').clone();
$clone.prop('id', "userVerificationAnnotation_" + sortedVerifiedAssertion[i].uuid);
var qaStatusMessage = jQuery.i18n.prop("user_assertions." + sortedVerifiedAssertion[i].qaStatus);
$clone.find('.qaStatus').text(qaStatusMessage);
$clone.find('.qaStatus').text(qaStatusMessage).attr('i18nkey', "user_assertions." + sortedVerifiedAssertion[i].qaStatus);
$clone.find('.comment').text(sortedVerifiedAssertion[i].comment);
$clone.find('.userDisplayName').text(sortedVerifiedAssertion[i].userDisplayName);
$clone.find('.created').text((moment(sortedVerifiedAssertion[i].created, "YYYY-MM-DDTHH:mm:ssZ").format('YYYY-MM-DD HH:mm:ss')));
Expand Down Expand Up @@ -720,7 +744,7 @@ function getDataQualityItem(code) {
url: url,
dataType: 'json',
success: function(data) {
if (data && data[1]) {
if (data) {
$.each(data, function(key, val) {
//console.log("data", key, val);
dataQualityItems[key] = val;
Expand Down
Loading

0 comments on commit d59e4e4

Please sign in to comment.