Skip to content

Commit

Permalink
Fixed image uploading for assessment records, switched knockout-core …
Browse files Browse the repository at this point in the history
…reference to common.js
  • Loading branch information
jack-brinkman committed Mar 27, 2024
1 parent 71732c1 commit 72c98cc
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
1 change: 0 additions & 1 deletion grails-app/assets/javascripts/knockout-core.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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: [
[
Expand All @@ -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"]
]
Expand Down Expand Up @@ -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
Expand All @@ -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],
Expand All @@ -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
}
}
2 changes: 1 addition & 1 deletion grails-app/views/staticPage/index.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<head>
<meta name="layout" content="${mobile ? "mobile" : "bs4"}"/>
<title></title>
<asset:javascript src="knockout-core.js"/>
<asset:javascript src="common.js"/>
</head>

<body>
Expand Down

0 comments on commit 72c98cc

Please sign in to comment.