Skip to content

Commit

Permalink
Merge pull request #270 from isimluk/vm-chargeback-tab
Browse files Browse the repository at this point in the history
Introduce Vm/Chargeback tab [ui-part]
  • Loading branch information
martinpovolny committed Jan 30, 2017
2 parents a9c11d9 + 6158340 commit b7b59b0
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/application_controller/explorer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def x_history
'guest_restart' => :s1, 'retire_now' => :s1, 'snapshot_revert' => :s1,
'start' => :s1, 'stop' => :s1, 'suspend' => :s1,
'reset' => :s1, 'terminate' => :s1, 'pause' => :s1,
'shelve' => :s1, 'shelve_offload' => :s1,
'shelve' => :s1, 'shelve_offload' => :s1, 'chargeback' => :s1,

# group 2
'clone' => :s2, 'compare' => :s2, 'drift' => :s2,
Expand Down
26 changes: 26 additions & 0 deletions app/controllers/mixins/chargeback_preview.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module ChargebackPreview
extend ActiveSupport::Concern

def vm_chargeback
@sb[:action] ||= 'chargeback'
@vm = @record = identify_record(params[:id], VmOrTemplate)

if params[:task_id]
miq_task = MiqTask.find(params[:task_id])
if !miq_task.results_ready?
add_flash(_("Report preview generation returned: Status [%{status}] Message [%{message}]") %
{:status => miq_task.status, :message => miq_task.message}, :error)
else
rr = miq_task.miq_report_result
@html = report_build_html_table(rr.report_results, rr.html_rows.join)
@refresh_partial = 'vm_common/chargeback'
miq_task.destroy
end
else
rpt = perf_get_chart_rpt('vm_chargeback')
rpt.db_options[:options][:entity_id] = @vm.id
# TODO: Use user's timezone
initiate_wait_for_task(:task_id => rpt.async_generate_table(:userid => session[:userid]))
end
end
end
5 changes: 5 additions & 0 deletions app/controllers/vm_common.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module VmCommon
extend ActiveSupport::Concern
include ActionView::Helpers::JavaScriptHelper
include ChargebackPreview

# handle buttons pressed on the button bar
def button
Expand Down Expand Up @@ -1663,6 +1664,10 @@ def set_right_cell_vars
header = _("Editing %{vm_or_template} \"%{name}\"") %
{:name => name, :vm_or_template => ui_lookup(:table => table)}
action = "edit_vm"
when 'chargeback'
partial = @refresh_partial
header = _('Chargeback preview for "%{vm_name}"') % { :vm_name => name }
action = 'vm_chargeback'
when "evm_relationship"
partial = "vm_common/evm_relationship"
header = _("Edit %{product} Server Relationship for %{vm_or_template} \"%{name}\"") %
Expand Down
6 changes: 6 additions & 0 deletions app/helpers/application_helper/toolbar/x_vm_center.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,12 @@ class ApplicationHelper::Toolbar::XVmCenter < ApplicationHelper::Toolbar::Basic
N_('Timelines'),
:url_parms => "?display=timeline",
:klass => ApplicationHelper::Button::VmTimeline),
button(
:vm_chargeback,
'product product-report fa-lg',
N_('Show Chargeback preview'),
N_('Chargeback Preview')
),
]
),
])
Expand Down
2 changes: 2 additions & 0 deletions app/views/vm_common/_chargeback.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
= render :partial => 'layouts/flash_msg'
= render :partial => 'layouts/report_html'

0 comments on commit b7b59b0

Please sign in to comment.