diff --git a/app/assets/javascripts/app/controllers/report.coffee b/app/assets/javascripts/app/controllers/report.coffee index 2fc5d7c96..68e2d4166 100644 --- a/app/assets/javascripts/app/controllers/report.coffee +++ b/app/assets/javascripts/app/controllers/report.coffee @@ -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() diff --git a/app/assets/javascripts/app/views/report/time_picker.jst.eco b/app/assets/javascripts/app/views/report/time_picker.jst.eco index bdd4d30ae..96a17b978 100644 --- a/app/assets/javascripts/app/views/report/time_picker.jst.eco +++ b/app/assets/javascripts/app/views/report/time_picker.jst.eco @@ -2,7 +2,7 @@ <% if @params.timeRange is 'day': %>
<% for item in @timeRangeDay: %> -
<%= item.display %>
+
<%= item.display %>
<% end %>
<% end %> @@ -10,7 +10,7 @@ <% if @params.timeRange is 'day' || @params.timeRange is 'month': %>
<% for item in @timeRangeMonth: %> -
<%= item.display %>
+
<%= item.display %>
<% end %>
<% end %> @@ -18,7 +18,7 @@ <% if @params.timeRange is 'week': %>
<% for item in @timeRangeWeek: %> -
<%= item.display %>
+
<%= item.display %>
<% end %>
<% end %> @@ -26,7 +26,7 @@ <% if @params.timeRange isnt 'realtime': %>
<% for item in @timeRangeYear: %> -
<%= item.display %>
+
<%= item.display %>
<% end %>
<% end %> diff --git a/app/assets/stylesheets/zammad.scss b/app/assets/stylesheets/zammad.scss index a49ed078e..9974648c3 100644 --- a/app/assets/stylesheets/zammad.scss +++ b/app/assets/stylesheets/zammad.scss @@ -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; diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index 35d47a9e5..d76b2471e 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -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, diff --git a/app/models/report.rb b/app/models/report.rb index e754779b8..9d7322ce4 100644 --- a/app/models/report.rb +++ b/app/models/report.rb @@ -1,5 +1,9 @@ class Report + def self.enabled? + !Setting.get('es_url').empty? + end + def self.config config = {} config[:metric] = {}