Skip to content

Commit

Permalink
Merge pull request #7 from biodiversitydata-se/sampling-event
Browse files Browse the repository at this point in the history
Fix display of event type datasets
  • Loading branch information
matsbov authored Sep 24, 2024
2 parents 60a6643 + 60e2163 commit b6b2a9c
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 8 deletions.
4 changes: 2 additions & 2 deletions grails-app/assets/javascripts/datasets.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,14 @@ function appendResource(value) {
$rowB.append('<span><strong class="resultsLabelFirst">'+ jQuery.i18n.prop('datasets.js.appendresource06') +': </strong>' + jQuery.i18n.prop('dataset.result.'+ value.resourceType) + '</span>'); // resource type
$rowB.append('<span><strong class="resultsLabel">'+ jQuery.i18n.prop('datasets.js.appendresource07') +': </strong>' + (value.licenseType == null ? '' : value.licenseType) + '</span>'); // license type

if (COLLECTORY_CONF.showExtraInfoInDataSetsView && value.resourceType == 'records') {
if (COLLECTORY_CONF.showExtraInfoInDataSetsView && (value.resourceType == 'records' || value.resourceType == 'events')) {
$rowB.append('<span><strong class="lastUpdatedDrView">'+ jQuery.i18n.prop('datasets.js.lastUpdated') +': </strong>' + formatLastUpdated() + '</span>'); // last updated
var numRecords = drCount(value.uid);
if (numRecords >= 0) {
$rowB.append('<span><strong class="drNumRecordsDrView">' + jQuery.i18n.prop('datasets.js.numRecords') + ': </strong><a title="' + jQuery.i18n.prop('datasets.js.appendresource03') + '" href="' + biocacheUrl + '/occurrences/search?q=data_resource_uid:' + value.uid + '">' + numRecords + '</a></span>'); // recors link with numbers
}
}
if (!COLLECTORY_CONF.showExtraInfoInDataSetsView && value.resourceType == 'records') {
if (!COLLECTORY_CONF.showExtraInfoInDataSetsView && (value.resourceType == 'records' || value.resourceType == 'events')) {
$rowB.append('<span class="viewRecords"><a title="' + jQuery.i18n.prop('datasets.js.appendresource03') + '" href="' + biocacheUrl + '/occurrences/search?q=data_resource_uid:' + value.uid + '">'+ jQuery.i18n.prop('datasets.js.appendresource10') +'</a></span>'); // records link

}
Expand Down
2 changes: 2 additions & 0 deletions grails-app/conf/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ disableAlertLinks: false
disableLoggerLinks: false
biocacheServicesUrl: https://biocache.ala.org.au/ws
biocacheUiURL: https://biocache.ala.org.au
#eventsUiURL: https://events.ala.org.au/?datasetKey=
#eventsURL: https://api.ala.org.au/event/graphql
isPipelinesCompatible: true
showExtraInfoInDataSetsView.enabled: false
showExtraInfoInDataSetsView.relativeTime: false
Expand Down
1 change: 1 addition & 0 deletions grails-app/i18n/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ public.show.rt.des04=Looking up... the number of records that
public.show.rt.des05=can be accessed through the {0}
public.show.rt.des06=Click to view all records for the
public.show.rt.des07=No database records for this collection can be accessed through the {0}
public.show.rt.des08=events
public.show.setprogress.01=There is no estimate of the total number of {0} in this collection.
public.show.setprogress.02=No records are available for viewing in the {0}
public.show.setprogress.accessions=accessions
Expand Down
2 changes: 1 addition & 1 deletion grails-app/views/dataResource/contribution.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
<cl:connectionParameters bean="command" connectionParameters="${command.connectionParameters}"/>
</div>

<g:if test="${command.resourceType == 'records'}">
<g:if test="${command.resourceType == 'records'} || ${command.resourceType == 'events'}">
<!-- darwin core defaults -->
<div><h3><g:message code="dataresource.contribution.table0201" /></h3></div>
<div><g:message code="dataresource.contribution.table0301" />.</div>
Expand Down
4 changes: 2 additions & 2 deletions grails-app/views/dataResource/show.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@

<cl:showConnectionParameters connectionParameters="${instance.connectionParameters}"/></p>

<g:if test="${instance.resourceType == 'records'}">
<g:if test="${instance.resourceType == 'records'} || ${instance.resourceType == 'events'}">
<!-- darwin core defaults -->
<g:set var="dwc" value="${instance.defaultDarwinCoreValues ? JSON.parse(instance.defaultDarwinCoreValues) : [:]}"/>
<h3>Default values for DwC fields</h3>
Expand Down Expand Up @@ -324,7 +324,7 @@
<g:render template="/shared/location" model="[instance: instance]"/>

<!-- Record consumers -->
<g:if test="${instance.resourceType == 'records'}">
<g:if test="${instance.resourceType == 'records'} || ${instance.resourceType == 'events'}">
<g:render template="/shared/consumers" model="[instance: instance]"/>
</g:if>

Expand Down
33 changes: 32 additions & 1 deletion grails-app/views/public/_charts.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
};

// records
if (${!instance.hasProperty('resourceType') || instance.resourceType == 'records'}) {
if (${!instance.hasProperty('resourceType') || instance.resourceType == 'records' || instance.resourceType == 'events'}) {
// summary biocache data
var queryUrl = CHARTS_CONFIG.biocacheServicesUrl + "/occurrences/search?pageSize=0&q=${facet}:${instance.uid}";

Expand Down Expand Up @@ -40,6 +40,37 @@
});
}

if (${instance.hasProperty('resourceType') && instance.resourceType == 'events' && org.apache.commons.lang.StringUtils.isNotEmpty(grailsApplication.config.eventsURL ?: '')}) {
// summary events data
var queryUrl = '${grailsApplication.config.eventsURL}';
var body = {
query: 'query list($datasetKey: JSON){' +
'eventSearch(predicate: {type: equals, key: \"datasetKey\", value: $datasetKey}) {' +
'documents(size: 1) {total}' +
'}' +
'}',
variables: '{"datasetKey":"${instance.uid}"}'
}

$.ajax({
url: queryUrl,
dataType: 'json',
data: body,
timeout: 30000,
complete: function(jqXHR, textStatus) {
if (textStatus == 'timeout' || textStatus == 'error') {
// noData();
}
},
success: function(data) {
if (data.data.eventSearch.documents.total > 0){
$('#eventRecordsWrapper').css({display:'block'});
$('#totalEventCount').html(data.data.eventSearch.documents.total.toLocaleString() + " ${g.message(code: 'public.show.rt.des08')}");
}
}
});
}

</asset:script>

<asset:script type="text/javascript">
Expand Down
6 changes: 5 additions & 1 deletion grails-app/views/public/_dataAccess.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
<a id="totalRecordCountLink" href="${grailsApplication.config.biocacheUiURL}/occurrences/search?q=${facet}:${instance.uid}">
</a>
</h3>
<h3 id="eventRecordsWrapper" style="display:none">
<a id="totalEventCount" href="${grailsApplication.config.eventsUiURL}${instance.uid}">
</a>
</h3>

<h4><g:message code="dataAccess.title"/></h4>
<div class="dataAccess btn-group-vertical">
Expand All @@ -20,4 +24,4 @@
<cl:createNewAnnotationsAlertsLink query="${facet}:${instance.uid}" displayName="${instance.name}"
linkText="${g.message(code:'dataAccess.alert.annotations.alt')}" altText="${g.message(code:'dataAccess.alert.annotations')} ${instance.name}"/>
</div>
</div>
</div>
2 changes: 1 addition & 1 deletion grails-app/views/public/showDataResource.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@
if (loadLoggerStats){
if (${instance.resourceType == 'website'}) {
loadDownloadStats("${grailsApplication.config.loggerURL}", "${instance.uid}","${instance.name}", "2000");
} else if (${instance.resourceType == 'records'}) {
} else if (${instance.resourceType == 'records'} || ${instance.resourceType == 'events'}) {
loadDownloadStats("${grailsApplication.config.loggerURL}", "${instance.uid}","${instance.name}", "1002");
}
}
Expand Down

0 comments on commit b6b2a9c

Please sign in to comment.