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