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

Fix ems refresh from Dashboard view (includes RBAC) #983

Merged
merged 5 commits into from
Apr 11, 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
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