Fixed isse#384 - Click on "Reports" leads to Error 500.
This commit is contained in:
parent
9d47559cf6
commit
cbcd1bc129
5 changed files with 31 additions and 11 deletions
|
@ -12,6 +12,12 @@ class Index extends App.ControllerContent
|
|||
processData: true
|
||||
success: (data) =>
|
||||
@stopLoading()
|
||||
if data.error
|
||||
@renderScreenError(
|
||||
detail: data.error
|
||||
objectName: 'Report'
|
||||
)
|
||||
return
|
||||
@config = data.config
|
||||
App.Collection.load(type: 'ReportProfile', data: data.profiles)
|
||||
@render()
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<% if @params.timeRange is 'day': %>
|
||||
<div class="btn-group btn-group--full" role="group" aria-label="">
|
||||
<% for item in @timeRangeDay: %>
|
||||
<div class="btn btn--text js-timePickerDay<%- ' is-selected' if @params.day is item.value %>" data-id="<%= @params.timeRange %>" data-type="<%= item.value %>"><%= item.display %></div>
|
||||
<div class="btn btn--textLarge js-timePickerDay<%- ' is-selected' if @params.day is item.value %>" data-id="<%= @params.timeRange %>" data-type="<%= item.value %>"><%= item.display %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
@ -10,7 +10,7 @@
|
|||
<% if @params.timeRange is 'day' || @params.timeRange is 'month': %>
|
||||
<div class="btn-group btn-group--full" role="group" aria-label="">
|
||||
<% for item in @timeRangeMonth: %>
|
||||
<div class="btn btn--text js-timePickerMonth<%- ' is-selected' if @params.month is item.value %>" data-id="<%= @params.timeRange %>" data-type="<%= item.value %>"><%= item.display %></div>
|
||||
<div class="btn btn--textLarge js-timePickerMonth<%- ' is-selected' if @params.month is item.value %>" data-id="<%= @params.timeRange %>" data-type="<%= item.value %>"><%= item.display %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
@ -18,7 +18,7 @@
|
|||
<% if @params.timeRange is 'week': %>
|
||||
<div class="btn-group btn-group--full" role="group" aria-label="">
|
||||
<% for item in @timeRangeWeek: %>
|
||||
<div class="btn btn--text js-timePickerWeek<%- ' is-selected' if @params.week is item.value %>" data-id="<%= @params.timeRange %>" data-type="<%= item.value %>"><%= item.display %></div>
|
||||
<div class="btn btn--textLarge js-timePickerWeek<%- ' is-selected' if @params.week is item.value %>" data-id="<%= @params.timeRange %>" data-type="<%= item.value %>"><%= item.display %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
@ -26,7 +26,7 @@
|
|||
<% if @params.timeRange isnt 'realtime': %>
|
||||
<div class="btn-group btn-group--full" role="group" aria-label="">
|
||||
<% for item in @timeRangeYear: %>
|
||||
<div class="btn btn--text js-timePickerYear<%- ' is-selected' if @params.year is item.value %>" data-id="<%= @params.timeRange %>" data-type="<%= item.value %>"><%= item.display %></div>
|
||||
<div class="btn btn--textLarge js-timePickerYear<%- ' is-selected' if @params.year is item.value %>" data-id="<%= @params.timeRange %>" data-type="<%= item.value %>"><%= item.display %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
|
@ -553,6 +553,11 @@ pre code.hljs {
|
|||
}
|
||||
}
|
||||
|
||||
&.btn--textLarge {
|
||||
@extend .btn--text;
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
&.btn--quad {
|
||||
padding: 10px 12px 9px;
|
||||
|
||||
|
@ -673,7 +678,7 @@ pre code.hljs {
|
|||
margin-left: 0;
|
||||
}
|
||||
|
||||
.btn--text {
|
||||
.btn--text, .btn--textLarge {
|
||||
padding: 6px 10px 5px; /* reporting main.eco */
|
||||
display: inline-block;
|
||||
border-radius: 3px;
|
||||
|
|
|
@ -7,6 +7,12 @@ class ReportsController < ApplicationController
|
|||
|
||||
# GET /api/reports/config
|
||||
def reporting_config
|
||||
if !Report.enabled?
|
||||
render json: {
|
||||
error: 'Elasticsearch need to be configured!',
|
||||
}
|
||||
return
|
||||
end
|
||||
render json: {
|
||||
config: Report.config,
|
||||
profiles: Report::Profile.list,
|
||||
|
@ -138,17 +144,16 @@ class ReportsController < ApplicationController
|
|||
range = 'hour'
|
||||
elsif params[:timeRange] == 'week'
|
||||
start = Date.commercial(params[:year], params[:week]).iso8601
|
||||
stop = Date.parse(start).end_of_week
|
||||
stop = Date.parse(start).end_of_week.iso8601
|
||||
range = 'week'
|
||||
elsif params[:timeRange] == 'month'
|
||||
start = Date.parse("#{params[:year]}-#{params[:month]}-01}").iso8601
|
||||
stop = Date.parse(start).end_of_month
|
||||
stop = Date.parse(start).end_of_month.iso8601
|
||||
range = 'day'
|
||||
else
|
||||
start = "#{params[:year]}-01-01"
|
||||
stop_date = Date.parse(start).end_of_month
|
||||
stop = "#{stop_date.year}-#{stop_date.month}-#{stop_date.day}"
|
||||
range = 'month'
|
||||
start = "#{params[:year]}-01-01"
|
||||
stop = Date.parse("#{params[:year]}-12-31").iso8601
|
||||
range = 'month'
|
||||
end
|
||||
{
|
||||
profile: profile,
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
class Report
|
||||
|
||||
def self.enabled?
|
||||
!Setting.get('es_url').empty?
|
||||
end
|
||||
|
||||
def self.config
|
||||
config = {}
|
||||
config[:metric] = {}
|
||||
|
|
Loading…
Reference in a new issue