From 2560edc5cc305e3a3cc4137b05948a0dc2edf143 Mon Sep 17 00:00:00 2001 From: lpichler Date: Mon, 30 Oct 2017 13:56:46 +0100 Subject: [PATCH] Make Metering reports like a Chargeback reports in views --- app/controllers/report_controller/reports/editor.rb | 4 ++-- app/views/report/_form_filter_chargeback.html.haml | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/controllers/report_controller/reports/editor.rb b/app/controllers/report_controller/reports/editor.rb index f18ce3f9a69..bbd23c5ebb1 100644 --- a/app/controllers/report_controller/reports/editor.rb +++ b/app/controllers/report_controller/reports/editor.rb @@ -186,7 +186,7 @@ def build_edit_screen build_tabs get_time_profiles # Get time profiles list (global and user specific) - cb_entities_by_provider if Chargeback.db_is_chargeback?(@edit[:new][:model]) && [ChargebackContainerImage, ChargebackContainerProject].include?(@edit[:new][:model].safe_constantize) + cb_entities_by_provider if Chargeback.db_is_chargeback?(@edit[:new][:model]) && [ChargebackContainerImage, ChargebackContainerProject, MeteringContainerImage, MeteringContainerProject].include?(@edit[:new][:model].safe_constantize) case @sb[:miq_tab].split("_")[1] when "1" # Select columns @edit[:models] ||= reportable_models @@ -1328,7 +1328,7 @@ def set_form_vars @edit[:new][:cb_interval_size] = options[:interval_size] @edit[:new][:cb_end_interval_offset] = options[:end_interval_offset] @edit[:new][:cb_groupby] = options[:groupby] - cb_entities_by_provider if [ChargebackContainerImage, ChargebackContainerProject].include?(@rpt.db.safe_constantize) + cb_entities_by_provider if [ChargebackContainerImage, ChargebackContainerProject, MeteringContainerImage, MeteringContainerProject].include?(@rpt.db.safe_constantize) end # Only show chargeback users choice if an admin diff --git a/app/views/report/_form_filter_chargeback.html.haml b/app/views/report/_form_filter_chargeback.html.haml index ac3d3d5d222..dd567d632ed 100644 --- a/app/views/report/_form_filter_chargeback.html.haml +++ b/app/views/report/_form_filter_chargeback.html.haml @@ -1,5 +1,5 @@ - url = url_for_only_path(:action => 'form_field_changed', :id => (@edit[:rpt_id] || 'new')) -- if @edit[:new][:model] == "ChargebackVm" +- if @edit[:new][:model] == "ChargebackVm" || @edit[:new][:model] == "MeteringVm" %h3 = _('Chargeback Resources') .form-horizontal @@ -32,11 +32,11 @@ = _('Show Costs by') .col-md-8 - opts = [["<#{_('Choose')}>", nil]] - - if @edit[:new][:model] == "ChargebackContainerProject" + - if @edit[:new][:model] == "ChargebackContainerProject" || @edit[:new][:model] == "MeteringContainerProject" - opts += [[ui_lookup(:model => @edit[:new][:cb_model]), "entity"], ["%s Tag" % current_tenant.name, "tag"]] - - elsif @edit[:new][:model] == "ChargebackVm" + - elsif @edit[:new][:model] == "ChargebackVm" || @edit[:new][:model] == "MeteringVm" - opts += [[_('Owner'), "owner"], ["%{tenant_name} Tag" % {:tenant_name => current_tenant.name}, "tag"], [_('Tenant'), "tenant"]] - - elsif @edit[:new][:model] == "ChargebackContainerImage" + - elsif @edit[:new][:model] == "ChargebackContainerImage" || @edit[:new][:model] == "MeteringContainerImage" - opts += [[ui_lookup(:model => @edit[:new][:cb_model]), "entity"]] - else - opts += [[_('Owner'), "owner"], ["%{tenant_name} Tag" % {:tenant_name => current_tenant.name}, "tag"], [_(@edit[:new][:cb_model].to_s), "entity"]] @@ -134,8 +134,8 @@ = _('Group by') .col-md-8 - opts = [["#{_('Date')}", "date"], ["#{_(@edit[:new][:cb_model])}", "vm"]] - - opts += [["#{_('Tag')}", "tag"]] unless @edit[:new][:model] == "ChargebackContainerImage" - - opts += [["#{_('Project')}", "project"], [_('Label'), 'label']] if @edit[:new][:model] == "ChargebackContainerImage" + - opts += [["#{_('Tag')}", "tag"]] unless @edit[:new][:model] == "ChargebackContainerImage" || @edit[:new][:model] == "MeteringContainerImage" + - opts += [["#{_('Project')}", "project"], [_('Label'), 'label']] if @edit[:new][:model] == "ChargebackContainerImage" || @edit[:new][:model] == "MeteringContainerImage" = select_tag("cb_groupby", options_for_select(opts, @edit[:new][:cb_groupby]), :class => "selectpicker")