Skip to content

Commit

Permalink
First cut of org dashboard #3387
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisala committed Dec 18, 2024
1 parent f72cb38 commit cc501b4
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 3 deletions.
7 changes: 6 additions & 1 deletion grails-app/assets/javascripts/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function OrganisationServicesViewModel(serviceIds, allServices, outputTargets, p
target.serviceId = ko.observable(service ? service.id : null);
target.scoreId = ko.observable(score ? score.scoreId : null);

var decimalPlaces = _.isNumber(score.decimalPlaces) ? score.decimalPlaces : 2;
var decimalPlaces = _.isNumber(score && score.decimalPlaces) ? score.decimalPlaces : 2;
target.target = ko.observable().extend({numericString: decimalPlaces});
target.targetDate = ko.observable().extend({simpleDate:false});

Expand Down Expand Up @@ -210,6 +210,11 @@ function OrganisationServicesViewModel(serviceIds, allServices, outputTargets, p
});

target.scoreId.subscribe(function () {
var score = target.scoreId() ? target.score() : null;
if (score) {
var decimalPlaces = _.isNumber(score && score.decimalPlaces) ? score.decimalPlaces : 2;
target.target = ko.observable().extend({numericString: decimalPlaces});
}
target.updateTargets();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,14 @@ class OrganisationController {
Map availableReportCategories = null
List services = null
List targetPeriods = null
List dashboardData = null
if (adminVisible) {
dashboardReports += [name:'announcements', label:'Announcements']
availableReportCategories = settingService.getJson(SettingPageType.ORGANISATION_REPORT_CONFIG)
services = organisationService.findApplicableServices(organisation, metadataService.getProjectServices())
targetPeriods = organisationService.generateTargetPeriods(organisation)
List scores = services.collect{it.scores}.flatten()
dashboardData = organisationService.scoresForOrganisation(organisation, scores?.collect{it.scoreId}, !hasEditorAccess)
}
boolean showTargets = userService.userIsSiteAdmin() && services && targetPeriods

Expand Down Expand Up @@ -110,7 +113,7 @@ class OrganisationController {
[about : [label: 'About', visible: true, stopBinding: false, type:'tab', default:!reportingVisible, displayedPrograms:projectGroups.displayedPrograms, servicesDashboard:[visible:true]],
projects : [label: 'Reporting', template:"/shared/projectListByProgram", visible: reportingVisible, stopBinding:true, default:reportingVisible, type: 'tab', reports:organisation.reports, adHocReportTypes:adHocReportTypes, reportOrder:reportOrder, hideDueDate:true, displayedPrograms:projectGroups.displayedPrograms, reportsFirst:true, declarationType:SettingPageType.RDP_REPORT_DECLARATION],
sites : [label: 'Sites', visible: reportingVisible, type: 'tab', stopBinding:true, projectCount:organisation.projects?.size()?:0, showShapefileDownload:adminVisible],
dashboard : [label: 'Dashboard', visible: reportingVisible, stopBinding:true, type: 'tab', template:'/shared/dashboard', reports:dashboardReports],
dashboard : [label: 'Dashboard', visible: reportingVisible, stopBinding:true, type: 'tab', template:'dashboard', reports:dashboardReports, dashboardData:dashboardData],
admin : [label: 'Admin', visible: adminVisible, type: 'tab', template:'admin', showEditAnnoucements:showEditAnnoucements, availableReportCategories:availableReportCategories, targetPeriods:targetPeriods, services: services, showTargets:showTargets]]

}
Expand Down Expand Up @@ -200,7 +203,7 @@ class OrganisationController {
}

List existingLinks = links?.findResults { it.documentId }
List toDeleteLinks = originalOrganisation?.links?.findAll { !existingLinks.contains(it.documentId) }
List toDeleteLinks = originalOrganisation?.links?.findAll { !existingLinks?.contains(it.documentId) }
// delete any links that were removed.
if (toDeleteLinks && !result.error) {
toDeleteLinks.each { link ->
Expand Down
17 changes: 17 additions & 0 deletions grails-app/services/au/org/ala/merit/OrganisationService.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,23 @@ class OrganisationService {
scoreIds.collectEntries{ String scoreId ->[(scoreId):result.results?.find{it.scoreId == scoreId}?.result?.result ?: 0]}
}

List scoresForOrganisation(Map organisation, List<String> scoreIds, boolean approvedOnly = true) {

String url = grailsApplication.config.getProperty('ecodata.baseUrl')+"organisation/organisationMetrics/"+organisation.organisationId
Map params = [approvedOnly: approvedOnly, scoreIds: scoreIds]

Map result = webService.doPost(url, params)

List scores = result?.resp?.collect { Map score ->
Map target = organisation?.custom?.details?.services?.targets?.find { it.scoreId == score.scoreId }
score.target = target?.target
score
}

scores

}


/**
* Filter services to those supported by organisation.
Expand Down
10 changes: 10 additions & 0 deletions grails-app/views/organisation/_dashboard.gsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<g:if test="${dashboardData}">
<div class="dashboard-section" style="padding:10px; margin-top:10px;">
<h3 class="serviceTitle">Indigenous workforce and procurement</h3>
<g:each in="${dashboardData}" var="score">
<fc:renderScore score="${score}" includeInvoiced="false"></fc:renderScore>
</g:each>
</div>
</g:if>

<g:render template="/shared/dashboard"></g:render>

0 comments on commit cc501b4

Please sign in to comment.