Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature my annotation #435

Merged
merged 26 commits into from
Apr 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
792aae6
Increment version number for next development iteration
sbearcsiro Nov 16, 2020
d287374
AtlasOfLivingAustralia/DataQuality#182 Add duplicate assertion type t…
sbearcsiro Nov 26, 2020
419e470
AtlasOfLivingAustralia/DataQuality#208 Add duplicate user assertion s…
sbearcsiro Nov 29, 2020
3af21a1
AtlasOfLivingAustralia/DataQuality#187 Add duplicate reason to duplic…
sbearcsiro Dec 1, 2020
1e4bd59
AtlasOfLivingAustralia/DataQuality#208 Add duplicate reason display
sbearcsiro Dec 1, 2020
34c49b7
AtlasOfLivingAustralia/DataQuality#187 Lower logging level for exists…
sbearcsiro Dec 1, 2020
cf43901
AtlasOfLivingAustralia/DataQuality#214 preview record when flagging a…
sbearcsiro Dec 3, 2020
b313e76
AtlasOfLivingAustralia/DataQuality#187 Review feedback
sbearcsiro Dec 14, 2020
df1e332
Feature my annotations (#391)
alexhuang091 Dec 14, 2020
e4c4e1d
removed unused param from processUserFQInteraction
alexhuang091 Dec 20, 2020
1feef6f
updated biocache-hubs to use dq-client 1.1.0 with user profile feature
alexhuang091 Dec 22, 2020
a787499
changes needed for my annotation changes on alerts side
alexhuang091 Dec 23, 2020
45c3c1b
Merge remote-tracking branch 'remotes/origin/dq_feature_user_profile'…
alexhuang091 Jan 5, 2021
1157eae
to use dq-service-client 1.2.0-SNAPSHOT for user-specific profile
alexhuang091 Jan 7, 2021
a037da3
Refined the way apiKey is set in ApiClient
alexhuang091 Jan 8, 2021
72bc136
removed 'myannotation.name' which is never used.
alexhuang091 Jan 19, 2021
693320f
Merge pull request #401 from alexhuang091/feature/data-quality
alexhuang091 Jan 19, 2021
b9fad6d
fixed an issue when disableAllQualityFilters = true
alexhuang091 Feb 1, 2021
bebd021
UI update for flag a duplicate record & DQ#217
alexhuang091 Feb 3, 2021
12e7113
DQ#217, handle 'user input id retrieves more than 1 record'
alexhuang091 Feb 5, 2021
3db615c
fixed an issue in displaying comment.
alexhuang091 Feb 7, 2021
5ced833
Merge remote-tracking branch 'upstream/develop' into feature/data-qua…
alexhuang091 Feb 9, 2021
cd1bdd2
Merge branch 'feature/data-quality' into feature_my_annotation
alexhuang091 Mar 25, 2021
fed9e31
do alerts related url mappings conditionally
alexhuang091 Apr 8, 2021
9e24459
fixed typo
alexhuang091 Apr 9, 2021
5bb0a83
alerts API names changed so we need to update accordingly
alexhuang091 Apr 12, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion grails-app/assets/javascripts/show.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,17 @@ $(document).ready(function() {
relatedRecordReason: relatedRecordReason,
},
function (data) {
// 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";
$.post(OCC_REC.contextPath + actionpath);
}

$('#assertionSubmitProgress').css({'display': 'none'});
$("#submitSuccess").html("Thanks for flagging the problem!");
$("#issueFormSubmit").hide();
$("input:reset").hide();
$("input#cancel").hide();
$("input#close").show();
//retrieve all assertions
$.get(OCC_REC.contextPath + '/assertions/' + OCC_REC.recordUuid, function (data) { // recordUuid=${record.raw.uuid}
Expand Down Expand Up @@ -229,6 +236,18 @@ $(document).ready(function() {
$(el).html(replaceURLWithHTMLLinks(html)); // convert it
});

$('#assertionButton').click(function (e) {
// if myannotation enabled, to retrieve current settings
if (OCC_REC.myAnnotationEnabled) {
// by default off
$("#notifyChangeCheckbox").prop('checked', false);
var getAlerts = OCC_REC.contextPath + "/occurrences/alerts";
$.getJSON(getAlerts, function (data) {
var myAnnotationEnabled = data && data.myannotation && data.myannotation.length > 0;
$("#notifyChangeCheckbox").prop('checked', myAnnotationEnabled);
})
}
})

// bind to form "close" button TODO
$("input#close").on("click", function(e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -725,4 +725,34 @@ class OccurrenceController {

return userPref.expand
}

def getAlerts() {
String userId = authService?.getUserId()
if (userId == null) {
response.status = 404
render ([error: 'userId must be supplied to get alerts'] as JSON)
} else {
render webServicesService.getAlerts(userId) as JSON
}
}

def subscribeMyAnnotation() {
String userId = authService?.getUserId()
if (userId == null) {
response.status = 404
render ([error: 'userId must be supplied to add alert'] as JSON)
} else {
render webServicesService.subscribeMyAnnotation(userId) as JSON
}
}

def unsubscribeMyAnnotation() {
String userId = authService?.getUserId()
if (userId == null) {
response.status = 404
render ([error: 'userId must be supplied to delete alert'] as JSON)
} else {
render webServicesService.unsubscribeMyAnnotation(userId) as JSON
}
}
}
1 change: 1 addition & 0 deletions grails-app/i18n/messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ show.issueform.label01 = Issue type:
show.issueform.label02 = Comment:
show.issueform.label03 = Duplicate Record ID:
show.issueform.label04 = Duplicate Reason:
show.issueform.notifyme = Notify me when records I have annotated are updated
show.issueform.button.submit = Submit
show.issueform.button.cancel = Cancel
show.issueform.button.close = Close
Expand Down
12 changes: 12 additions & 0 deletions grails-app/init/biocache/hubs/BootStrap.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,20 @@ package biocache.hubs
class BootStrap {
def messageSource
def application
def grailsApplication
def grailsUrlMappingsHolder

def init = { servletContext ->

// if my annotation feature turned on, add url mapping to handle add/remove my annotation alert requests
if (grailsApplication.config.getProperty('alerts.myannotation.enabled', Boolean, false)) {
grailsUrlMappingsHolder.addMappings({
"/occurrences/alerts"(controller: 'occurrence', action: [GET: 'getAlerts'])
"/occurrences/subscribeMyAnnotation"(controller: 'occurrence', action: [POST: 'subscribeMyAnnotation'])
"/occurrences/unsubscribeMyAnnotation"(controller: 'occurrence', action: [POST: 'unsubscribeMyAnnotation'])
})
}

messageSource.setBasenames(
"file:///var/opt/atlas/i18n/downloads-plugin/messages",
"file:///opt/atlas/i18n/downloads-plugin/messages",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,21 @@ class WebServicesService {
getJsonElements(url)
}

def getAlerts(String userId) {
def url = "${grailsApplication.config.alerts.baseUrl}" + "/api/alerts/user/" + userId
return getJsonElements(url, "${grailsApplication.config.alerts.apiKey}")
}

def subscribeMyAnnotation(String userId) {
String url = "${grailsApplication.config.alerts.baseUrl}" + "/api/alerts/user/" + userId + "/subscribeMyAnnotation"
postFormData(url, [:], grailsApplication.config.alerts.apiKey as String)
}

def unsubscribeMyAnnotation(String userId) {
String url = "${grailsApplication.config.alerts.baseUrl}" + "/api/alerts/user/" + userId + "/unsubscribeMyAnnotation"
postFormData(url, [:], grailsApplication.config.alerts.apiKey as String)
}

def JSONObject getDuplicateRecordDetails(JSONObject record) {
log.debug "getDuplicateRecordDetails -> ${record?.processed?.occurrence?.associatedOccurrences}"
if (record?.processed?.occurrence?.associatedOccurrences) {
Expand Down
9 changes: 8 additions & 1 deletion grails-app/views/occurrence/_recordSidebar.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,16 @@
<label for="issueComment" style="vertical-align:top;"><g:message code="show.issueform.label02" default="Comment:"/></label>
<textarea name="comment" id="issueComment" style="width:380px;height:150px;" placeholder="Please add a comment here..."></textarea>
</p>

<g:if test="${grailsApplication.config.alerts.myannotation.enabled.toBoolean()}">
<p style="margin-top:30px;">
<label style="width:100%" id="notifyChange"><input type="checkbox" id="notifyChangeCheckbox" name="notifyChange" value="">&nbsp;<g:message code="show.issueform.notifyme" default="Notify me when records I have annotated are updated"/></label>
</p>
</g:if>

<p style="margin-top:20px;">
<input id="issueFormSubmit" type="submit" value="<g:message code="show.issueform.button.submit" default="Submit"/>" class="btn btn-primary" />
<input type="button" value="<g:message code="show.issueform.button.cancel" default="Cancel"/>" class="btn btn-default" onClick="$('#loginOrFlag').modal('hide');"/>
<input type="button" id="cancel" value="<g:message code="show.issueform.button.cancel" default="Cancel"/>" class="btn btn-default" onClick="$('#loginOrFlag').modal('hide');"/>
<input type="button" id="close" value="<g:message code="show.issueform.button.close" default="Close"/>" class="btn btn-default" style="display:none;"/>
<span id="submitSuccess"></span>
</p>
Expand Down
3 changes: 2 additions & 1 deletion grails-app/views/occurrence/show.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@
status="s">'${sds}': '${grailsApplication.config.sensitiveDatasets[sds]}'${s < (sensitiveDatasets.size() - 1) ? ',' : ''}
</g:each>
},
hasGoogleKey: ${grailsApplication.config.google.apikey as Boolean}
hasGoogleKey: ${grailsApplication.config.google.apikey as Boolean},
myAnnotationEnabled: ${(grailsApplication.config.getProperty("alerts.myannotation.enabled", Boolean, false))}
}

var BC_CONF = OCC_REC; // For compatibility with common JS components which require BC_CONF
Expand Down