From d592c46311b7f8dd9cc7e2314845c57e05489694 Mon Sep 17 00:00:00 2001 From: Adam Collins Date: Wed, 17 Apr 2024 08:03:26 +1000 Subject: [PATCH] #235 add links to public event dr page --- grails-app/conf/application.yml | 2 ++ grails-app/i18n/messages.properties | 1 + grails-app/views/public/_charts.gsp | 33 ++++++++++++++++++++++++- grails-app/views/public/_dataAccess.gsp | 6 ++++- 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/grails-app/conf/application.yml b/grails-app/conf/application.yml index 6a7e4efc..69e09788 100644 --- a/grails-app/conf/application.yml +++ b/grails-app/conf/application.yml @@ -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 diff --git a/grails-app/i18n/messages.properties b/grails-app/i18n/messages.properties index 40e458e2..d6ff26b0 100644 --- a/grails-app/i18n/messages.properties +++ b/grails-app/i18n/messages.properties @@ -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 diff --git a/grails-app/views/public/_charts.gsp b/grails-app/views/public/_charts.gsp index e9301609..a3babfe2 100644 --- a/grails-app/views/public/_charts.gsp +++ b/grails-app/views/public/_charts.gsp @@ -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}"; @@ -40,6 +40,37 @@ }); } + if (${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')}"); + } + } + }); + } + diff --git a/grails-app/views/public/_dataAccess.gsp b/grails-app/views/public/_dataAccess.gsp index f06da60b..ec268df6 100644 --- a/grails-app/views/public/_dataAccess.gsp +++ b/grails-app/views/public/_dataAccess.gsp @@ -5,6 +5,10 @@ +

@@ -20,4 +24,4 @@
- \ No newline at end of file +