mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-29 18:52:22 +01:00
fix type key transmission
This commit is contained in:
parent
0f7f2c256a
commit
8e968f7813
@ -288,8 +288,10 @@ Application.Controllers.controller "StatisticsController", ["$scope", "$state",
|
|||||||
query: ->
|
query: ->
|
||||||
custom = buildCustomFilterQuery()
|
custom = buildCustomFilterQuery()
|
||||||
buildElasticDataQuery($scope.type.active.key, custom, $scope.agePicker.start, $scope.agePicker.end, moment($scope.datePickerStart.selected), moment($scope.datePickerEnd.selected), $scope.sorting)
|
buildElasticDataQuery($scope.type.active.key, custom, $scope.agePicker.start, $scope.agePicker.end, moment($scope.datePickerStart.selected), moment($scope.datePickerEnd.selected), $scope.sorting)
|
||||||
key: ->
|
index: ->
|
||||||
key: $scope.selectedIndex.es_type_key
|
key: $scope.selectedIndex.es_type_key
|
||||||
|
type: ->
|
||||||
|
key: $scope.type.active.key
|
||||||
|
|
||||||
$uibModal.open options
|
$uibModal.open options
|
||||||
.result['finally'](null).then (info)->
|
.result['finally'](null).then (info)->
|
||||||
@ -529,8 +531,8 @@ Application.Controllers.controller "StatisticsController", ["$scope", "$state",
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
Application.Controllers.controller 'ExportStatisticsController', [ '$scope', '$uibModalInstance', 'dates', 'query', 'key', 'CSRF'
|
Application.Controllers.controller 'ExportStatisticsController', [ '$scope', '$uibModalInstance', 'dates', 'query', 'index', 'type', 'CSRF'
|
||||||
, ($scope, $uibModalInstance, dates, query, key, CSRF) ->
|
, ($scope, $uibModalInstance, dates, query, index, type, CSRF) ->
|
||||||
|
|
||||||
## Retrieve Anti-CSRF tokens from cookies
|
## Retrieve Anti-CSRF tokens from cookies
|
||||||
CSRF.setMetaTags()
|
CSRF.setMetaTags()
|
||||||
@ -542,7 +544,10 @@ Application.Controllers.controller 'ExportStatisticsController', [ '$scope', '$u
|
|||||||
$scope.query = JSON.stringify(query)
|
$scope.query = JSON.stringify(query)
|
||||||
|
|
||||||
## API URL where the form will be posted
|
## API URL where the form will be posted
|
||||||
$scope.actionUrl = '/stats/'+key.key+'/export'
|
$scope.actionUrl = '/stats/'+index.key+'/export'
|
||||||
|
|
||||||
|
## Key of the current search' statistic type
|
||||||
|
$scope.typeKey = type.key
|
||||||
|
|
||||||
## Form action on the above URL
|
## Form action on the above URL
|
||||||
$scope.method = "post"
|
$scope.method = "post"
|
||||||
@ -601,7 +606,7 @@ Application.Controllers.controller 'ExportStatisticsController', [ '$scope', '$u
|
|||||||
$scope.actionUrl = '/stats/global/export'
|
$scope.actionUrl = '/stats/global/export'
|
||||||
$scope.query = JSON.stringify(query)
|
$scope.query = JSON.stringify(query)
|
||||||
else
|
else
|
||||||
$scope.actionUrl = '/stats/'+key.key+'/export'
|
$scope.actionUrl = '/stats/'+index.key+'/export'
|
||||||
$scope.query = JSON.stringify(
|
$scope.query = JSON.stringify(
|
||||||
"query":
|
"query":
|
||||||
"bool":
|
"bool":
|
||||||
@ -616,7 +621,7 @@ Application.Controllers.controller 'ExportStatisticsController', [ '$scope', '$u
|
|||||||
)
|
)
|
||||||
|
|
||||||
##
|
##
|
||||||
# Callback to close the modal, telling the caller to start the export with the selected parameters
|
# Callback to close the modal, telling the caller what is exported
|
||||||
##
|
##
|
||||||
$scope.exportData = ->
|
$scope.exportData = ->
|
||||||
info =
|
info =
|
||||||
|
@ -66,6 +66,7 @@
|
|||||||
<form role=form" ng-submit="exportData()" name="exportForm" method="post" action="{{ actionUrl }}" class="inline">
|
<form role=form" ng-submit="exportData()" name="exportForm" method="post" action="{{ actionUrl }}" class="inline">
|
||||||
<input name="authenticity_token" type="hidden" ng-value="csrfToken"/>
|
<input name="authenticity_token" type="hidden" ng-value="csrfToken"/>
|
||||||
<input name="_method" type="hidden" ng-value="method"/>
|
<input name="_method" type="hidden" ng-value="method"/>
|
||||||
|
<input name="type_key" type="hidden" ng-value="typeKey"/>
|
||||||
<input name="body" type="hidden" ng-value="query"/>
|
<input name="body" type="hidden" ng-value="query"/>
|
||||||
<input type="submit" class="btn btn-info" value="{{ 'export' | translate }}" formtarget="_blank"/>
|
<input type="submit" class="btn btn-info" value="{{ 'export' | translate }}" formtarget="_blank"/>
|
||||||
</form>
|
</form>
|
||||||
|
@ -19,6 +19,7 @@ class API::StatisticsController < API::ApiController
|
|||||||
authorize :statistic, :#{path}?
|
authorize :statistic, :#{path}?
|
||||||
|
|
||||||
query = MultiJson.load(params[:body])
|
query = MultiJson.load(params[:body])
|
||||||
|
type_key = params[:type_key]
|
||||||
|
|
||||||
@results = Elasticsearch::Model.client.search({index: 'stats', type: '#{path}', scroll: '30s', body: query})
|
@results = Elasticsearch::Model.client.search({index: 'stats', type: '#{path}', scroll: '30s', body: query})
|
||||||
scroll_id = @results['_scroll_id']
|
scroll_id = @results['_scroll_id']
|
||||||
@ -31,7 +32,6 @@ class API::StatisticsController < API::ApiController
|
|||||||
ids = @results['hits']['hits'].map { |u| u['_source']['userId'] }
|
ids = @results['hits']['hits'].map { |u| u['_source']['userId'] }
|
||||||
@users = User.includes(:profile).where(:id => ids)
|
@users = User.includes(:profile).where(:id => ids)
|
||||||
|
|
||||||
type_key = query['query']['bool']['must'][0]['term']['type'].to_s
|
|
||||||
@index = StatisticIndex.find_by(es_type_key: '#{path}')
|
@index = StatisticIndex.find_by(es_type_key: '#{path}')
|
||||||
@type = StatisticType.find_by(key: type_key, statistic_index_id: @index.id)
|
@type = StatisticType.find_by(key: type_key, statistic_index_id: @index.id)
|
||||||
@subtypes = @type.statistic_sub_types
|
@subtypes = @type.statistic_sub_types
|
||||||
|
@ -49,7 +49,7 @@ wb.add_worksheet(name: @index.label) do |sheet|
|
|||||||
field_data = hit['_source'][f.key]
|
field_data = hit['_source'][f.key]
|
||||||
case f.data_type
|
case f.data_type
|
||||||
when 'date'
|
when 'date'
|
||||||
data.push Date::strptime(field_data,'%Y-%m-%d')
|
data.push Date::strptime(field_data, '%Y-%m-%d')
|
||||||
styles.push date
|
styles.push date
|
||||||
types.push :date
|
types.push :date
|
||||||
when 'list'
|
when 'list'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user