Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce Vm/Chargeback tab [ui-part] #270

Merged
merged 1 commit into from
Jan 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1662,6 +1663,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'