From 72c98ccdcea2232876c2984900cc8e42f202bebc Mon Sep 17 00:00:00 2001 From: Jack Brinkman Date: Wed, 27 Mar 2024 15:33:52 +1000 Subject: [PATCH] Fixed image uploading for assessment records, switched knockout-core reference to common.js --- .../assets/javascripts/knockout-core.js | 1 - .../ReferenceAssessmentController.groovy | 39 +++++++++++++------ grails-app/views/staticPage/index.gsp | 2 +- 3 files changed, 29 insertions(+), 13 deletions(-) delete mode 100644 grails-app/assets/javascripts/knockout-core.js diff --git a/grails-app/assets/javascripts/knockout-core.js b/grails-app/assets/javascripts/knockout-core.js deleted file mode 100644 index 513bb3424..000000000 --- a/grails-app/assets/javascripts/knockout-core.js +++ /dev/null @@ -1 +0,0 @@ -//= require knockout/3.4.0/knockout-3.4.0.js \ No newline at end of file diff --git a/grails-app/controllers/au/org/ala/biocollect/ReferenceAssessmentController.groovy b/grails-app/controllers/au/org/ala/biocollect/ReferenceAssessmentController.groovy index 6a1084fa3..5c5821be3 100644 --- a/grails-app/controllers/au/org/ala/biocollect/ReferenceAssessmentController.groovy +++ b/grails-app/controllers/au/org/ala/biocollect/ReferenceAssessmentController.groovy @@ -8,12 +8,29 @@ import java.time.Instant class ReferenceAssessmentController { UserService userService - ProjectService projectService ProjectActivityService projectActivityService ActivityService activityService private def createAssessmentRecordFromReference(Object referenceActivity, Object assessProjectActivity) { + def refDoc = referenceActivity.documents[0] + def assessPhoto = [ + licence: refDoc["licence"], + notes: refDoc["notes"], + filesize: refDoc["filesize"], + staged: true, + url: grailsApplication.config.serverURL + refDoc["url"], + filename: refDoc["filename"], + attribution: referenceActivity.outputs[0].data["imageAttribution"], + name: refDoc["name"], + documentId: '', + contentType: refDoc["contentType"], + dateTaken: refDoc["dateTaken"], + formattedSize: refDoc["formattedSize"], + thumbnailUrl: grailsApplication.config.serverURL + refDoc["thumbnailUrl"], + status: "active" + ] + def assessActivity = [ outputs: [ [ @@ -25,7 +42,8 @@ class ReferenceAssessmentController { lowerConditionBound: "0", overallConditionBestEstimate: "0", mvgGroup: referenceActivity.outputs[0].data.vegetationStructureGroup, - huchinsonGroup: referenceActivity.outputs[0].data.huchinsonGroup + huchinsonGroup: referenceActivity.outputs[0].data.huchinsonGroup, + sitePhoto: [assessPhoto] ], name: assessProjectActivity["pActivityFormName"] ] @@ -112,13 +130,6 @@ class ReferenceAssessmentController { // Combine the two lists refActivities = priorityRecords + otherRecords -// if (true) { -// response.status = 200 -// result = [message: 'Test!'] -// render result as JSON -// return -// } - // Ensure there are reference records after filtering if (refActivities.size() == 0) { response.status = 400 @@ -129,7 +140,11 @@ class ReferenceAssessmentController { def assessProjectActivity = projectActivityService.get(config.assessment.projectActivityId) def assessActivities = [] - for (int projectIndex = 0; projectIndex < min(config.assessment.maxRecordsToCreate, refActivities.size()); projectIndex++) { + for ( + int projectIndex = 0; + projectIndex < Math.min(config.assessment.maxRecordsToCreate, refActivities.size()); + projectIndex++ + ) { assessActivities.push( createAssessmentRecordFromReference( refActivities[projectIndex], @@ -138,6 +153,8 @@ class ReferenceAssessmentController { ) } - render assessActivities as JSON + response.status = 200 + result = [message: "Found ${assessActivities.size()} images for assessment, please standby..."] + render result as JSON } } diff --git a/grails-app/views/staticPage/index.gsp b/grails-app/views/staticPage/index.gsp index 6f81d9dac..5a34d5931 100644 --- a/grails-app/views/staticPage/index.gsp +++ b/grails-app/views/staticPage/index.gsp @@ -21,7 +21,7 @@ - +