Skip to content

Commit

Permalink
Merge pull request #425 from AtlasOfLivingAustralia/release/3.0.2
Browse files Browse the repository at this point in the history
Release/3.0.2
  • Loading branch information
alexhuang091 authored Mar 8, 2021
2 parents 8749eb0 + 55f24d0 commit fe6c6dc
Show file tree
Hide file tree
Showing 27 changed files with 686 additions and 233 deletions.
4 changes: 2 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.1"
version "3.0.2"
group "au.org.ala.plugins.grails"

apply plugin:"eclipse"
Expand Down Expand Up @@ -82,7 +82,7 @@ dependencies {
//compile 'org.grails.plugins:cache-ehcache:3.0.0.M1'
compile 'org.grails.plugins:http-builder-helper:1.0.2.ALA'
compile "org.grails.plugins:ala-admin-plugin:2.2", noCache
compile "org.grails.plugins:ala-auth:3.2.2", noCache
compile "org.grails.plugins:ala-auth:3.2.3", noCache

if(!inplace) {
compile "au.org.ala.plugins.grails:images-client-plugin:1.2", noCache
Expand Down
15 changes: 9 additions & 6 deletions grails-app/assets/javascripts/exploreYourArea.js
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,7 @@ function groupClicked(el) {
radius: $('#radius').val(),
fq: "geospatial_kosher:true",
qc: MAP_VAR.queryContext,
sort: "count",
pageSize: 50
};
//var params = "?latitude=${latitude}&longitude=${longitude}&radius=${radius}&taxa="+taxa+"&rank="+rank;
Expand All @@ -659,21 +660,23 @@ function processSpeciesJsonData(data, appendResults) {
var infoTitle = "view species page";
var recsTitle = "view list of records";
// iterate over list of species from search
for (i=0;i<data.length;i++) {
for (i = 0; i < data.length; i++) {
// create new table row
var count = i + lastRow;
// add count
var tr = '<tr><td class="speciesIndex">'+(count+1)+'.</td>';
// add scientific name
tr = tr + '<td class="sciName"><a id="' + data[i].guid + '" class="taxonBrowse2" title="'+linkTitle+'" href="'+ // id=taxon_name
data[i].name+'"><i>'+data[i].name+'</i></a>';
// add common name
if (data[i].commonName) {
tr = tr + ' : ' + data[i].commonName+'';
tr = tr + '<td class="sciName">' + data[i].commonName +'</td>';
} else {
tr = tr + ' <td class="sciName"> [Not supplied] </td>';
}
// add scientific name
tr = tr + '<td class="sciName"><a id="' + data[i].guid + '" class="taxonBrowse2" title="'+linkTitle+'" href="'+ // id=taxon_name
data[i].name+'"><i>'+data[i].name+'</i></a>';

// add links to species page and occurrence search (inside hidden div)
if(MAP_VAR.speciesPageUrl) {

var speciesInfo = '<div class="speciesInfo">';
if (data[i].guid) {
speciesInfo = speciesInfo + '<a class="speciesPageLink" title="' + infoTitle + '" href="' + MAP_VAR.speciesPageUrl + data[i].guid +
Expand Down
235 changes: 231 additions & 4 deletions grails-app/assets/javascripts/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ $(document).ready(function() {

// when user clicks 'ok' button in the 'data profiles applied' warning dialog
$('#hide-dq-warning').click(function() {
document.cookie = 'dq_warn_off=true; path=/';
$.cookie('dq_warn_off', true, { expires: 365, path: '/' });
})

// when use clicks <i/> to view details of a category
Expand Down Expand Up @@ -575,9 +575,20 @@ $(document).ready(function() {
url = appendURL(url, 'fq=' + encodeURIComponent(filters[i]).replace(/%20/g, "+").replace(/[()]/g, escape));
}

// profile in URL may be invalid, replace it with the actual profile being used
url = replaceInvalidProfile(url, $.url().param('qualityProfile'), $(this).attr('data-profile'))

window.location.href = url;
})

function replaceInvalidProfile(url, profileInURL, actualProfile) {
if (profileInURL !== undefined && profileInURL !== actualProfile) {
url = removeFromURL(url, "qualityProfile=", false);
url = prependURL(url, "qualityProfile=" + encodeURIComponent(actualProfile).replace(/%20/g, "+").replace(/[()]/g, escape), true);
}
return url
}

function removeDuplicates(data) {
var unique = [];
data.forEach(function(el) {
Expand Down Expand Up @@ -622,6 +633,145 @@ $(document).ready(function() {
window.location.href = BC_CONF.serverName + "/occurrences/facets/download" + BC_CONF.facetDownloadQuery + '&facets=' + facetName;
});

// when open the user preference dlg
$('.DQPrefSettingsLink').click(function() {
var prefSettings = $('#DQPrefSettings');
var userPref = prefSettings.data('userpref-json');
var profiles = prefSettings.data('profiles');

var userProfileEnabled = false;

// if not disable all
if (!userPref.disableAll) {
// if preferred profile set
var userProfileSet = userPref.dataProfile != null && userPref.dataProfile.length > 0;

for (var i = 0; i < profiles.length; i++) {
if (profiles[i] === userPref.dataProfile) {
userProfileEnabled = true;
break;
}
}
}

var profileSelect = $('#prefer_profile');

if (userPref.disableAll) { // if disable all
profileSelect.val('disableall-option');
} else if (userProfileEnabled && userPref.dataProfile !== null) { // if a profile selected and enabled
profileSelect.val(userPref.dataProfile);
} else { // if no profile selected or selected profile disabled, use system default
profileSelect.val(prefSettings.data('defaultprofilename'));
}

$('#profile_expand').val(userPref.expand ? 'expanded' : 'collapsed');
})

// when submit the user preference dlg
$("#submitPref :input.submit").on("click", function(e) {
e.preventDefault();
var prefSettings = $('#DQPrefSettings');
var userPref = prefSettings.data('userpref-json');

// check user preferred profile
var prefProfile = $('#prefer_profile').val();
if (prefProfile === 'disableall-option') {
userPref.disableAll = true;
userPref.dataProfile = null;
} else {
userPref.disableAll = false;
userPref.dataProfile = prefProfile;
}

// set expand
userPref.expand = $('#profile_expand').val() === 'expanded';
$.cookie.json = true;
// if user logged in
if (BC_CONF.userId) {
// save the dq profile detail expand/collapse state
$.cookie(BC_CONF.expandKey, {expand: userPref.expand});
$.ajax({
url: BC_CONF.serverName + "/user/" + BC_CONF.prefKey,
type: "POST",
contentType: 'application/json',
data: JSON.stringify(userPref),
success: applyUserPreference, // reload on success
error: function() {
window.alert(jQuery.i18n.prop('dq.warning.failedtosave'));
}
}).always(function() {
$('#DQPrefSettings').modal('hide');
})
} else { // else save in cookie
$.cookie(BC_CONF.prefKey, userPref, { expires: 365 });
// save the dq profile detail expand/collapse state
$.cookie(BC_CONF.expandKey, {expand: userPref.expand});
$('#DQPrefSettings').modal('hide');
applyUserPreference(userPref)
}
})

function applyUserPreference(userPref) {
var prefSettings = $('#DQPrefSettings');

// enabled filters of current profile, used to remove expanded fqs in url
var filtersvalue = prefSettings.data('filters');
var filterSet = new Set();
for (var i = 0; i < filtersvalue.length; i++) {
filterSet.add(filtersvalue[i]);
}

// get current url
var url = $(location).attr('href');

// 1. remove qualityProfile from URL
url = removeFromURL(url, "qualityProfile=", false);
// 2. remove disable all from URL
url = removeFromURL(url, "disableAllQualityFilters=", false);
// 3. remove disableQualityFilter from URL
var disabledQualityFilters = $.url().param('disableQualityFilter');
if (disabledQualityFilters !== undefined) {
// if only 1 category disabled
if (typeof disabledQualityFilters === "string") {
url = removeFromURL(url, "disableQualityFilter=", false);
} else {
for (var i = 0; i < disabledQualityFilters.length; i++) {
url = removeFromURL(url, "disableQualityFilter=", false);
}
}
}

// fqs contains current fqs in url, it could be expanded or user specified
var fqList = $.url().param('fq');
var fqs = [];
if (fqList !== undefined) {
if (typeof fqList === "object") {
for (var i = 0; i < fqList.length; i++) {
fqs.push(fqList[i]);
}
} else if (typeof fqList === "string") {
fqs.push(fqList);
}
}

// 4. remove fqs from URL
for (var i = 0; i < fqs.length; i++) {
// remove those belong to this profile so only user specified fqs stay
if (filterSet.has(fqs[i])) {
url = removeFromURL(url, 'fq=' + encodeURIComponent(fqs[i]).replace(/%20/g, "+").replace(/[()]/g, escape), true);
}
}

// 5. add qualityProfile=xxx or disableAllQualityFilter=true to URL
if (userPref.disableAll) {
url = prependURL(url,"disableAllQualityFilters=true", true);
} else {
url = prependURL(url, "qualityProfile=" + encodeURIComponent(userPref.dataProfile).replace(/%20/g, "+").replace(/[()]/g, escape), true);
}

window.location.href = url;
}

// form validation for form#facetRefineForm
$("#submitFacets :input.submit").on("click", function(e) {
e.preventDefault();
Expand Down Expand Up @@ -674,13 +824,18 @@ $(document).ready(function() {

// switch caret style
$('.dq-filters-collapse').click(function (e) {
$.cookie.json = true;
var el = $(this).find('i');
if ($(el).hasClass('fa-caret-right')) {
$(el).removeClass('fa-caret-right');
$(el).addClass('fa-caret-down');
// save the expand/collapse state to cookie so when page refresh
// we can restore the state
$.cookie(BC_CONF.expandKey, {expand: true});
} else if ($(el).hasClass('fa-caret-down')) {
$(el).removeClass('fa-caret-down');
$(el).addClass('fa-caret-right');
$.cookie(BC_CONF.expandKey, {expand: false});
}
});

Expand Down Expand Up @@ -838,9 +993,10 @@ $(document).ready(function() {
// get current url
var url = $(location).attr('href');

var fitlers = $("form#filterRefineForm").find("td.filternames");
var filterStatus = $("form#filterRefineForm").find(":input.filters");
var expanded = $("form#filterRefineForm").find(".expanded");
var filterForm = $("form#filterRefineForm")
var fitlers = filterForm.find("td.filternames");
var filterStatus = filterForm.find(":input.filters");
var expanded = filterForm.find(".expanded");

// replace url encoded %20 with '+' because groovy encodes space to '+'
$.each(filterStatus, function( i, status ) {
Expand Down Expand Up @@ -870,6 +1026,9 @@ $(document).ready(function() {
}
})

// profile in URL may be invalid, replace it with the actual profile being used
url = replaceInvalidProfile(url, $.url().param('qualityProfile'), filterForm.attr('data-profile'))

window.location.href = url;
})

Expand Down Expand Up @@ -914,6 +1073,43 @@ $(document).ready(function() {
}
}

function prependURL(url, queryParamsToAppend, afterSearchKey) {
var anchorpos = url.indexOf("#");
var ancchorpart = '';
if (anchorpos !== -1) {
ancchorpart = url.substring(anchorpos);
url = url.substring(0, anchorpos);
}

var queryStringpos = url.indexOf('?');
var queryString = ''
if (queryStringpos !== -1) {
queryString = url.substring(queryStringpos + 1);
url = url.substring(0, queryStringpos);
}

// trim query string
queryString = queryString.trim();
var queries = []
if (queryString !== '') {
queries = queryString.split('&');
}

var idx = 0;
// if insert it after search keys: q=, qid=, lat=, lng=, radius=
if (afterSearchKey) {
for (; idx < queries.length; idx++) {
var query = queries[idx];
if (!query.startsWith('q=') && !query.startsWith('qid=') && !query.startsWith('lat=') && !query.startsWith('lng=') && !query.startsWith('radius=') && !query.startsWith('taxa=')) {
break;
}
}
}

queries.splice(idx, 0, queryParamsToAppend)
return url + '?' + queries.join('&') + ancchorpart;
}

function removeFromURL(url, sToRemove, exactMatch) {
var anchorpos = url.indexOf('#');
var anchorpart = "";
Expand Down Expand Up @@ -976,6 +1172,18 @@ $(document).ready(function() {
}
});

// user preference settings and download link tooltips will be above the control
$("#usersettings, a.newDownload").qtip({
style: {
classes: 'ui-tooltip-rounded ui-tooltip-shadow'
},
position: {
target: 'mouse',
my: 'bottom center',
adjust: { x: -6, y: -10 }
}
});

// maultiple facets popup - sortable column heading links
$("a.fsort").on("click", function(e) {
e.preventDefault();
Expand Down Expand Up @@ -1152,6 +1360,25 @@ $(document).ready(function() {
}

$('#modal-dismiss-dq').modal()

// expand / collapse data profile details
var dqFilterCollapse = $('#dq-filters-collapse')
dqFilterCollapse.collapse({
toggle: BC_CONF.expandProfileDetails
})

switchCaretStyle($('.dq-filters-collapse'));

function switchCaretStyle(elem) {
var el = elem.find('i');
if (elem.hasClass('collapsed')) {
$(el).removeClass('fa-caret-down');
$(el).addClass('fa-caret-right');
} else {
$(el).removeClass('fa-caret-right');
$(el).addClass('fa-caret-down');
}
}
}); // end JQuery document ready

/**
Expand Down
3 changes: 2 additions & 1 deletion grails-app/assets/stylesheets/exploreYourArea.css
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ table#cellCountsLegend {
width: 5%;
}
#rightList .sciName {
width: 85%;
text-align: left;
width: 50%;
}
#rightList .rightCounts {
padding-right: 5px;
Expand Down
4 changes: 3 additions & 1 deletion grails-app/conf/plugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ auth.admin_role = "ROLE_ADMIN"
serverName = 'http://dev.ala.org.au:8080'

dataquality.enabled = false
dataquality.baseUrl = 'https://biocache.ala.org.au/data-quality/'
dataquality.baseUrl = 'https://data-quality-service-test.ala.org.au'
dataquality.recordCountCacheSpec = 'expireAfterWrite=1d'
dataquality.prefkey = 'dqUserProfile'
dataquality.expandKey = 'dqDetailExpand'

// skin settings
organisation.baseUrl = "https://www.ala.org.au"
Expand Down
Loading

0 comments on commit fe6c6dc

Please sign in to comment.