Skip to content

Commit a5b3d28

Browse files
authored
Merge pull request #238 from AtlasOfLivingAustralia/235-add-links-to-events
#235 add links to public event dr page
2 parents c1e8be2 + 7d9e8b1 commit a5b3d28

File tree

4 files changed

+40
-2
lines changed

4 files changed

+40
-2
lines changed

grails-app/conf/application.yml

+2
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ disableAlertLinks: false
214214
disableLoggerLinks: false
215215
biocacheServicesUrl: https://biocache.ala.org.au/ws
216216
biocacheUiURL: https://biocache.ala.org.au
217+
#eventsUiURL: https://events.ala.org.au/?datasetKey=
218+
#eventsURL: https://api.ala.org.au/event/graphql
217219
isPipelinesCompatible: true
218220
showExtraInfoInDataSetsView.enabled: false
219221
showExtraInfoInDataSetsView.relativeTime: false

grails-app/i18n/messages.properties

+1
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ public.show.rt.des04=Looking up... the number of records that
142142
public.show.rt.des05=can be accessed through the {0}
143143
public.show.rt.des06=Click to view all records for the
144144
public.show.rt.des07=No database records for this collection can be accessed through the {0}
145+
public.show.rt.des08=events
145146
public.show.setprogress.01=There is no estimate of the total number of {0} in this collection.
146147
public.show.setprogress.02=No records are available for viewing in the {0}
147148
public.show.setprogress.accessions=accessions

grails-app/views/public/_charts.gsp

+32-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
};
88

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

@@ -40,6 +40,37 @@
4040
});
4141
}
4242

43+
if (${instance.hasProperty('resourceType') && instance.resourceType == 'events' && org.apache.commons.lang.StringUtils.isNotEmpty(grailsApplication.config.eventsURL ?: '')}) {
44+
// summary events data
45+
var queryUrl = '${grailsApplication.config.eventsURL}';
46+
var body = {
47+
query: 'query list($datasetKey: JSON){' +
48+
'eventSearch(predicate: {type: equals, key: \"datasetKey\", value: $datasetKey}) {' +
49+
'documents(size: 1) {total}' +
50+
'}' +
51+
'}',
52+
variables: '{"datasetKey":"${instance.uid}"}'
53+
}
54+
55+
$.ajax({
56+
url: queryUrl,
57+
dataType: 'json',
58+
data: body,
59+
timeout: 30000,
60+
complete: function(jqXHR, textStatus) {
61+
if (textStatus == 'timeout' || textStatus == 'error') {
62+
// noData();
63+
}
64+
},
65+
success: function(data) {
66+
if (data.data.eventSearch.documents.total > 0){
67+
$('#eventRecordsWrapper').css({display:'block'});
68+
$('#totalEventCount').html(data.data.eventSearch.documents.total.toLocaleString() + " ${g.message(code: 'public.show.rt.des08')}");
69+
}
70+
}
71+
});
72+
}
73+
4374
</asset:script>
4475

4576
<asset:script type="text/javascript">

grails-app/views/public/_dataAccess.gsp

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
<a id="totalRecordCountLink" href="${grailsApplication.config.biocacheUiURL}/occurrences/search?q=${facet}:${instance.uid}">
66
</a>
77
</h3>
8+
<h3 id="eventRecordsWrapper" style="display:none">
9+
<a id="totalEventCount" href="${grailsApplication.config.eventsUiURL}${instance.uid}">
10+
</a>
11+
</h3>
812

913
<h4><g:message code="dataAccess.title"/></h4>
1014
<div class="dataAccess btn-group-vertical">
@@ -20,4 +24,4 @@
2024
<cl:createNewAnnotationsAlertsLink query="${facet}:${instance.uid}" displayName="${instance.name}"
2125
linkText="${g.message(code:'dataAccess.alert.annotations.alt')}" altText="${g.message(code:'dataAccess.alert.annotations')} ${instance.name}"/>
2226
</div>
23-
</div>
27+
</div>

0 commit comments

Comments
 (0)