mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-29 18:52:22 +01:00
display custom aggregations in front statistics
This commit is contained in:
parent
53dd54b175
commit
9d599a14e5
@ -55,6 +55,9 @@ Application.Controllers.controller "StatisticsController", ["$scope", "$state",
|
||||
## total of the stat field for non simple types
|
||||
$scope.sumStat = 0
|
||||
|
||||
## Results of custom aggregations for the current type
|
||||
$scope.customAggs = {}
|
||||
|
||||
## default: results are not sorted
|
||||
$scope.sorting =
|
||||
ca: 'none'
|
||||
@ -337,6 +340,7 @@ Application.Controllers.controller "StatisticsController", ["$scope", "$state",
|
||||
$scope.sumCA = 0
|
||||
$scope.averageAge = 0
|
||||
$scope.sumStat = 0
|
||||
$scope.customAggs = {}
|
||||
$scope.totalHits = null
|
||||
$scope.searchDate = new Date()
|
||||
custom = buildCustomFilterQuery()
|
||||
@ -350,6 +354,9 @@ Application.Controllers.controller "StatisticsController", ["$scope", "$state",
|
||||
$scope.averageAge = Math.round(res.aggregations.average_age.value * 100) / 100
|
||||
$scope.sumStat = res.aggregations.total_stat.value
|
||||
$scope.scrollId = res._scroll_id
|
||||
for custom in $scope.type.active.custom_aggregations
|
||||
$scope.customAggs[custom.field] = res.aggregations[custom.field].value
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -235,6 +235,7 @@
|
||||
<li ng-show="selectedIndex.ca">{{ 'revenue_' | translate }} {{sumCA | currency}}</li>
|
||||
<li>{{ 'average_age' | translate }} {{averageAge}} {{ 'years_old' | translate }}</li>
|
||||
<li ng-if="!type.active.simple">{{ 'total' | translate }} {{type.active.label}} : {{sumStat}}</li>
|
||||
<li ng-repeat="custom in type.active.custom_aggregations">{{ custom.field | translate }} : {{customAggs[custom.field]}}</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
@ -5,6 +5,9 @@ json.array!(@statistics) do |s|
|
||||
end
|
||||
json.types s.statistic_types do |t|
|
||||
json.extract! t, :id, :key, :label, :graph, :simple
|
||||
json.custom_aggregations t.statistic_custom_aggregations do |c|
|
||||
json.extract! c, :id, :field
|
||||
end
|
||||
json.subtypes t.statistic_sub_types do |st|
|
||||
json.extract! st, :id, :key, :label
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user