Skip to content

Commit

Permalink
Merge branch 'develop' into feature/hcat
Browse files Browse the repository at this point in the history
  • Loading branch information
jack-brinkman authored Apr 22, 2024
2 parents ec5e42a + 6d07101 commit ef340df
Show file tree
Hide file tree
Showing 23 changed files with 396 additions and 111 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ dependencies {

if (!Boolean.valueOf(inplace)) {
implementation "org.grails.plugins:ala-map-plugin:3.0.1"
implementation "org.grails.plugins:ecodata-client-plugin:6.1.3"
implementation "org.grails.plugins:ecodata-client-plugin:6.2"
}

testCompileOnly "org.grails:grails-test-mixins:3.3.0"
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
biocollectVersion=6.8-REFASSESS-SNAPSHOT
biocollectVersion=6.8-LOGIN-SNAPSHOT
grailsVersion=5.1.9
grailsGradlePluginVersion=5.1.5
assetPipelineVersion=3.3.4
Expand Down
1 change: 1 addition & 0 deletions grails-app/assets/javascripts/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ function attachViewModelToFileUpload(uploadUrl, documentViewModel, uiSelector, p
$(uiSelector).fileupload({
url:uploadUrl,
pasteZone: null,
dropZone: null,
formData:function(form) {
return [{name:'document', value:documentViewModel.toJSONString()}]
},
Expand Down
49 changes: 49 additions & 0 deletions grails-app/assets/javascripts/i18n.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright (C) 2019 Atlas of Living Australia
* All Rights Reserved.
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* Created by Temi on 15/11/19.
*/

(function() {
var messages = {},
deffer = $.Deferred();
$.get({
url: fcConfig.i18nURL,
cache: true
}).done(function (data) {
messages = data;
deffer.resolve();
}).fail(function () {
deffer.reject();
});

$i18n = function(key, defaultValue) {
if (messages[key] !== undefined) {
return messages[key];
} else {
return defaultValue || key;
}
};

$i18nAsync = function(key, defaultValue, callback) {
if (callback) {
deffer.done(function () {
callback($i18n(key, defaultValue));
}).fail(function () {
callback($i18n(key, defaultValue));
})
}
}

})();
54 changes: 50 additions & 4 deletions grails-app/assets/javascripts/knockout-custom-bindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ ko.bindingHandlers.stagedImageUpload = {
$(element).fileupload({
url: config.url,
pasteZone: null,
dropZone: null,
autoUpload: true
}).on('fileuploadadd', function (e, data) {
complete(false);
Expand Down Expand Up @@ -703,11 +704,11 @@ ko.bindingHandlers.fileUploadNoImage = {

var defaults = {autoUpload: true};
var settings = {
pasteZone: null
pasteZone: null,
dropZone: null
};
$.extend(settings, defaults, options());
$(element).fileupload(settings
).on('fileuploadadd', function (e, data) {
$(element).fileupload(settings).on('fileuploadadd', function (e, data) {
window.incrementAsyncCounter && window.incrementAsyncCounter();
}).on('fileuploaddone', function (e, data) {
window.decreaseAsyncCounter && window.decreaseAsyncCounter();
Expand Down Expand Up @@ -1148,4 +1149,49 @@ ko.bindingHandlers.debug = {
console.log(element);
console.log(ko.toJS(valueAccessor()));
}
};
};


/**
* This binding requires i18n.js to be loaded. It also requires fcConfig.i18nURL to be set.
* Params can be a string or an object. If string, it is treated as key and translated to text. Object parameter has the
* following properties:
* @contentType can be 'text' or 'html' (default is 'text')
* @key is the key to be translated
* @defaultValue is the default value to be used if the key is not found
*
* Usage examples:
* <div data-bind="i18n: 'g.cancel'"></div>
* <div data-bind="i18n: {key: 'record.edit.verificationStatusTypes.help', contentType: 'html', defaultValue: '<b>simple help</b>'}"></div>
*
*/
ko.bindingHandlers.i18n = {
init: function (element, valueAccessor, allBindings, viewModel, bindingContext) {
var value = valueAccessor();
value = ko.unwrap(value);
var contentType = value && value.contentType || 'text'

// $i18nAsync is required to be defined
if(typeof $i18nAsync === 'undefined')
return

if( typeof value === 'string') {
$i18nAsync(value, '',function(text) {
$(element).text(text);
});
}
else if (typeof value === 'object') {
$i18nAsync(value.key, value.defaultValue,function(text) {
switch (contentType) {
default:
case 'text':
$(element).text(text);
break;
case 'html':
$(element).html(text);
break;
}
});
}
}
}
2 changes: 2 additions & 0 deletions grails-app/assets/javascripts/outputs.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ ko.bindingHandlers.photoPointUpload = {
$(element).fileupload({
url:config.url,
pasteZone: null,
dropZone: null,
autoUpload:true
}).on('fileuploadadd', function(e, data) {
complete(false);
Expand Down Expand Up @@ -360,6 +361,7 @@ ko.bindingHandlers.fileUploadWithProgress = {
$(element).fileupload({
url: config.url,
pasteZone: null,
dropZone: null,
autoUpload: true
}).on('fileuploadadd', function (e, data) {
complete(false);
Expand Down
21 changes: 10 additions & 11 deletions grails-app/conf/application.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ environments {
temp.dir = "/data/biocollect/temp"
// system level config
server.port = 8087
serverURL = "http://devt.ala.org.au:8087"
serverURL = "http://localhost:8087"
biocollect.system.email.replyTo = "biocollect-dev<no-reply>@ala.org.au"
sender = "[email protected]"
debugUI = true
Expand All @@ -36,11 +36,10 @@ environments {
}

test {
spring.autoconfigure.exclude="au.org.ala.ws.security.AlaWsSecurityConfiguration"
debugUI = false
loggerLevel = "DEBUG"
server.port = "8087"
grails.host = "http://devt.ala.org.au"
grails.host = "http://localhost"
serverName = "${grails.host}:${server.port}"
grails.serverURL = serverName
server.serverURL = serverName
Expand All @@ -51,8 +50,8 @@ environments {
grails.config.locations = []
security.oidc.discoveryUri = "http://localhost:${wiremock.port}/cas/oidc/.well-known"
security.oidc.allowUnsignedIdTokens = true
def casBaseUrl = "http://devt.ala.org.au:${wiremock.port}"

def casBaseUrl = "http://localhost:${wiremock.port}"
ehcache.directory = './ehcache'
security.cas.appServerName=serverName
security.cas.contextPath=
security.cas.casServerName="${casBaseUrl}"
Expand All @@ -61,17 +60,17 @@ environments {
security.cas.loginUrl="${security.cas.casServerUrlPrefix}/login"
security.cas.casLoginUrl="${security.cas.casServerUrlPrefix}/login"
security.cas.logoutUrl="${security.cas.casServerUrlPrefix}/logout"
userDetails.api.url = "${casBaseUrl}/userdetails/userDetails/"
security.jwt.discoveryUri="${casBaseUrl}/cas/oidc/.well-known"
userDetails.url = "${casBaseUrl}/userdetails/userDetails/"
userDetailsSingleUrl = "${userDetails.Url}getUserDetails"
userDetailsUrl = "${userDetatails.url}getUserListFull"
userDetailsSingleUrl = "${userDetails.url}getUserDetails"
logging.dir = '.'
upload.images.path = '/tmp'
upload.images.url = grails.serverURL+'/image/'
ecodata.baseUrl = 'http://devt.ala.org.au:8080/'
ecodata.baseURL = 'http://devt.ala.org.au:8080'
ecodata.service.url = 'http://devt.ala.org.au:8080/ws'
pdfgen.baseURL = "http://devt.ala.org.au:${wiremock.port}/"
ecodata.baseUrl = 'http://localhost:8080/'
ecodata.baseURL = 'http://localhost:8080'
ecodata.service.url = 'http://localhost:8080/ws'
pdfgen.baseURL = "http://localhost:${wiremock.port}/"
api_key='testapikey'
grails.cache.config = {
diskStore {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class HomeController {
def settingService
def metadataService
def userService
CommonService commonService

@PreAuthorise(accessLevel = 'alaAdmin', redirectController = "admin")
@SSO
Expand Down Expand Up @@ -61,6 +62,13 @@ class HomeController {
def works() {
}

def i18n() {
if (request.isGet()) {
Map props = commonService.i18n(request.locale)
render props as JSON
}
}

/**
* The purpose of this method is to enable the display of the spatial object corresponding to a selected
* value from a geographic facet (e.g. to display the polygon representing NSW on the map if the user has
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ class ActivityService {
webService.doDelete(grailsApplication.config.ecodata.service.url + '/activity/' + id)
}

def bulkDelete(List ids, boolean destory) {
def bulkDelete(List ids, boolean destroy = false) {
String url = grailsApplication.config.ecodata.service.url + '/activityBulkDelete'
if(destory)
if(destroy)
url += '?destroy=true'
webService.doPost(url, [ids: ids])
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package au.org.ala.biocollect.merit
import grails.converters.JSON
import grails.web.mapping.LinkGenerator
import grails.web.servlet.mvc.GrailsParameterMap
import org.springframework.context.MessageSource

import javax.servlet.http.HttpServletRequest
import javax.xml.bind.DatatypeConverter
Expand All @@ -13,6 +14,7 @@ class CommonService {
UserService userService

LinkGenerator grailsLinkGenerator
MessageSource messageSource

List ignores = ["action","controller"]

Expand Down Expand Up @@ -92,4 +94,7 @@ class CommonService {
queryParams
}

def i18n(Locale locale) {
messageSource.getMergedProperties(locale)?.properties
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,10 @@ class SettingService {
}

def loadHubConfig(hub) {

def defaultHub = grailsApplication.config.getProperty('app.default.hub', String, 'default')
if (!hub) {
hub = grailsApplication.config.app.default.hub?:'default'
hub = cookieService.getCookie(LAST_ACCESSED_HUB)
hub = hub ?: defaultHub
}
else {
// Hub value in multiple places like url path and in parameter causes Array to be passed instead of String.
Expand Down Expand Up @@ -131,7 +132,10 @@ class SettingService {
)
}

cookieService.setCookie(LAST_ACCESSED_HUB, settings?.urlPath, -1 /* -1 means the cookie expires when the browser is closed */)
// Do not set cookie value to default hub since it overwrites genuine hub selection when calls are made with default hub.
// This usually happens when calls are made without hub parameter like downloading images.
if (settings?.urlPath != defaultHub)
cookieService.setCookie(LAST_ACCESSED_HUB, settings?.urlPath, -1 /* -1 means the cookie expires when the browser is closed */, '/')
GrailsWebRequest.lookup().params.hub = settings?.urlPath
SettingService.setHubConfig(settings)
}
Expand Down
Loading

0 comments on commit ef340df

Please sign in to comment.