Skip to content

Commit

Permalink
Merge pull request #983 from martinpovolny/ems_dashboard_refresh
Browse files Browse the repository at this point in the history
Fix ems refresh from Dashboard view (includes RBAC)
  • Loading branch information
mzazrivec authored Apr 11, 2017
2 parents ee4bbb4 + 792da4d commit f1b42a7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 25 deletions.
44 changes: 19 additions & 25 deletions app/controllers/ems_common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,9 @@ def set_record_vars(ems, mode = nil)
end

def process_emss(emss, task)
emss, emss_out_region = filter_ids_in_region(emss, "Provider")
emss, _emss_out_region = filter_ids_in_region(emss, "Provider")
assert_rbac(model, emss)

return if emss.empty?

if task == "refresh_ems"
Expand Down Expand Up @@ -979,44 +981,36 @@ def scanemss
end
end

def call_ems_refresh(emss)
process_emss(emss, "refresh_ems") unless emss.empty?
return if @flash_array.present?

add_flash(n_("Refresh initiated for %{count} %{model} from the %{product} Database",
"Refresh initiated for %{count} %{models} from the %{product} Database", emss.length) %
{:count => emss.length,
:product => I18n.t('product.name'),
:model => ui_lookup(:table => @table_name),
:models => ui_lookup(:tables => @table_name)})
end

# Refresh VM states for all selected or single displayed ems(s)
def refreshemss
assert_privileges(params[:pressed])
emss = []
if @lastaction == "show_list" # showing a list, scan all selected emss
if @lastaction == "show_list"
emss = find_checked_items
if emss.empty?
add_flash(_("No %{model} were selected for refresh") % {:model => ui_lookup(:table => @table_name)}, :error)
end
process_emss(emss, "refresh_ems") unless emss.empty?
add_flash(n_("Refresh initiated for %{count} %{model} from the %{product} Database",
"Refresh initiated for %{count} %{models} from the %{product} Database", emss.length) %
{:count => emss.length,
:product => I18n.t('product.name'),
:model => ui_lookup(:table => @table_name),
:models => ui_lookup(:tables => @table_name)}) if @flash_array.nil?
call_ems_refresh(emss)
show_list
@refresh_partial = "layouts/gtl"
else # showing 1 ems, scan it
else
if params[:id].nil? || model.find_by_id(params[:id]).nil?
add_flash(_("%{record} no longer exists") % {:record => ui_lookup(:table => @table_name)}, :error)
else
emss.push(params[:id])
call_ems_refresh([params[:id]])
end
process_emss(emss, "refresh_ems") unless emss.empty?
add_flash(n_("Refresh initiated for %{count} %{model} from the %{product} Database",
"Refresh initiated for %{count} %{models} from the %{product} Database", emss.length) %
{:count => emss.length,
:product => I18n.t('product.name'),
:model => ui_lookup(:table => @table_name),
:models => ui_lookup(:tables => @table_name)}) if @flash_array.nil?
params[:display] = @display
show
if ["vms", "hosts", "storages"].include?(@display)
@refresh_partial = "layouts/gtl"
else
@refresh_partial = "main"
end
end
end

Expand Down
1 change: 1 addition & 0 deletions app/views/ems_infra/_show_dashboard.html.haml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.container-fluid.container-tiles-pf.ems-infra-dashboard.miq-dashboard-view{"ng-controller" => "emsInfraDashboardController as dashboard"}
= render :partial => "layouts/flash_msg"
.row.row-tile-pf
.col-xs-12.col-sm-12.col-md-2
.provider-card{"pf-card" => "",
Expand Down

0 comments on commit f1b42a7

Please sign in to comment.