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

Expose provider disable for containers providers #1663

Merged
merged 1 commit into from
Aug 17, 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
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@
var providers = data.providers;
if (providers) {
if ($scope.id) {
$scope.providerTypeIconImage = data.providers[0].iconImage;
$scope.providerTypeName = providers[0].typeName;
$scope.providerTypeIconImage = providers[0].iconImage;
$scope.providerStatusIconImage = providers[0].statusIcon;
$scope.isSingleProvider = true;
} else {
$scope.isSingleProvider = false;
Expand Down
19 changes: 19 additions & 0 deletions app/assets/stylesheets/container_providers_dashboard.scss
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,25 @@
opacity: 1;
}

.provider-status-card {
min-height: 132px;

.card-pf-title {
margin-top: 25px;
}

.provider-icon-small {
height: 24px;

&:last-of-type {
display: block;
margin-top: 35px;
text-align: center;
width: 100%;
}
}
}

.provider-card .provider-icon-large {
font-size: 100px;
position: relative;
Expand Down
54 changes: 54 additions & 0 deletions app/controllers/ems_common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@ def button
redirect_to :action => "new" if params[:pressed] == "new"
deleteemss if params[:pressed] == "#{table_name}_delete"
refreshemss if params[:pressed] == "#{table_name}_refresh"
pause_or_resume_emss(:pause => true) if params[:pressed] == "#{table_name}_pause"
pause_or_resume_emss(:resume => true) if params[:pressed] == "#{table_name}_resume"
# scanemss if params[:pressed] == "scan"
tag(model) if params[:pressed] == "#{table_name}_tag"

Expand Down Expand Up @@ -549,6 +551,21 @@ def process_emss(emss, task)
:product => I18n.t('product.name'),
:model => ui_lookup(:table => table_name),
:models => ui_lookup(:tables => table_name)}) if @flash_array.nil?
elsif task == "pause_ems" || task == "resume_ems"
action = task.split("_").first
model.where(:id => emss).order("lower(name)").each do |ems|
id = ems.id
ems_name = ems.name
audit = {:event => "ems_record_#{action}_initiated",
:message => _("[%{name}] Record #{action} initiated") % {:name => ems_name},
:target_id => id,
:target_class => model.to_s,
:userid => session[:userid]}
AuditEvent.success(audit)

ems.disable! if action == "pause"
ems.enable! if action == "resume"
end
else
model.where(:id => emss).order("lower(name)").each do |ems|
id = ems.id
Expand Down Expand Up @@ -679,6 +696,43 @@ def refreshemss
end
end

def call_ems_pause_resume(emss, options)
action = if options[:resume]
"resume"
elsif options[:pause]
"pause"
end

process_emss(emss, "#{action}_ems") unless emss.empty?
return if @flash_array.present?
add_flash(n_("#{action.capitalize} initiated for %{count} %{model} from the %{product} Database",
"#{action.capitalize} 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

def pause_or_resume_emss(options)
assert_privileges(params[:pressed])
if @lastaction == "show_list"
emss = find_checked_items
if emss.empty?
add_flash(_("No %{model} were selected for pause") % {:model => ui_lookup(:table => table_name)}, :error)
end
call_ems_pause_resume(emss, options)
show_list
@refresh_partial = "layouts/gtl"
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
call_ems_pause_resume([params[:id]], options)
end
params[:display] = @display
end
end

# true, if any of the given fields are either missing from or blank in hash
def any_blank_fields?(hash, fields)
fields = [fields] unless fields.kind_of? Array
Expand Down
1 change: 1 addition & 0 deletions app/controllers/mixins/dashboard_view_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def show_dashboard
@lastaction = "show_dashboard"
drop_breadcrumb(:name => @record.name + _(" (Dashboard)"), :url => show_link(@record))
@sb[:summary_mode] = 'dashboard' unless @sb[:summary_mode] == 'dashboard'
add_flash(_("Warning: This provider is paused, no data is currently collected from it."), :warning) unless @record.enabled?
render :action => "show_dashboard"
end
end
Expand Down
15 changes: 15 additions & 0 deletions app/helpers/application_helper/toolbar/ems_container_center.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,21 @@ class ApplicationHelper::Toolbar::EmsContainerCenter < ApplicationHelper::Toolba
'pficon pficon-edit fa-lg',
t = N_('Edit this Containers Provider'),
t,),
button(
:ems_container_resume,
'pficon pficon-trend-up fa-lg',
t = N_('Resume this Containers Provider'),
t,
:confirm => N_("Resume this Containers Provider?"),
:enabled => proc { !@record.enabled? }),
button(
:ems_container_pause,
'pficon pficon-trend-down fa-lg',
t = N_('Pause this Containers Provider'),
t,
:confirm => N_("Warning: While this provider is paused no data will be collected from it. " \
"This may cause gaps in inventory, metrics and events!"),
:enabled => proc { @record.enabled? }),
button(
:ems_container_delete,
'pficon pficon-delete fa-lg',
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/application_helper/toolbar_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def apply_common_props(button, input)
)

button[:enabled] = input[:enabled]
%i(title text confirm).each do |key|
%i(title text confirm enabled).each do |key|
unless input[key].blank?
button[key] = button.localized(key, input[key])
end
Expand Down
3 changes: 2 additions & 1 deletion app/helpers/ems_container_helper/textual_summary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module EmsContainerHelper::TextualSummary
include TextualMixins::TextualRefreshStatus
include TextualMixins::TextualAuthenticationsStatus
include TextualMixins::TextualMetricsStatus
include TextualMixins::TextualDataCollectionState
#
# Groups
#
Expand All @@ -23,7 +24,7 @@ def textual_group_relationships
def textual_group_status
TextualGroup.new(
_("Status"),
textual_authentications_status + %i(authentications_status metrics_status refresh_status refresh_date)
textual_authentications_status + %i(authentications_status metrics_status refresh_status refresh_date data_collection_state)
)
end

Expand Down
12 changes: 12 additions & 0 deletions app/helpers/textual_mixins/textual_data_collection_state.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module TextualMixins::TextualDataCollectionState
def textual_data_collection_state
state = @record.enabled?
h = {:label => _("Data Collection"), :value => state ? _("Running") : _("Paused")}
h[:image] = if state
"svg/currentstate-on.svg"
else
"svg/currentstate-paused.svg"
end
h
end
end
14 changes: 12 additions & 2 deletions app/services/container_dashboard_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,19 @@ def providers
end

def build_provider_status(provider_type)
provider_status_icon = if @ems.present?
if @ems.enabled?
icons[:StatusOn][:icon]
else
icons[:StatusPaused][:icon]
end
end

{
:count => 0,
:iconImage => icons[provider_type][:icon]
:count => 0,
:typeName => _(provider_type.to_s),
:iconImage => icons[provider_type][:icon],
:statusIcon => provider_status_icon
}
end

Expand Down
5 changes: 4 additions & 1 deletion app/services/ui_service_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ def icons
:Openshift => {:type => "image", :icon => provider_icon(:Openshift)},
:Openstack => {:type => "image", :icon => provider_icon(:Openstack)},
:Redhat => {:type => "image", :icon => provider_icon(:Redhat)},
:Vmware => {:type => "image", :icon => provider_icon(:Vmware)}
:Vmware => {:type => "image", :icon => provider_icon(:Vmware)},

:StatusPaused => {:type => "image", :icon => ActionController::Base.helpers.image_path("svg/currentstate-paused.svg")},
:StatusOn => {:type => "image", :icon => ActionController::Base.helpers.image_path("svg/currentstate-on.svg")}
}
end

Expand Down
9 changes: 5 additions & 4 deletions app/views/ems_container/_show_dashboard.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
= render :partial => "layouts/flash_msg"
.row.row-tile-pf
.col-xs-12.col-sm-12.col-md-2
.provider-card{"pf-card" => "",
"show-top-border" => "true",
"ng-if" => "isSingleProvider"}
%img.provider-icon-large{"ng-src" =>"{{providerTypeIconImage}}"}
.card-pf.card-pf-accented.card-pf-aggregate-status.provider-status-card
%h2.card-pf-title
%img.provider-icon-small{"ng-src" =>"{{providerTypeIconImage}}"}
{{providerTypeName}}
%img.provider-icon-small{"ng-src" =>"{{providerStatusIconImage}}"}
%div{:layout => "tall",
"pf-aggregate-status-card" => "",
"show-top-border" => "true",
Expand Down