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

Moved Timelines & Utilization buttons to summary screen from list view. #5738

Merged
merged 1 commit into from
Dec 16, 2015
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
52 changes: 19 additions & 33 deletions app/controllers/container_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ class ContainerController < ApplicationController
after_action :set_session_data

CONTAINER_X_BUTTON_ALLOWED_ACTIONS = {
'container_delete' => :container_delete,
'container_edit' => :container_edit,
'container_tag' => :container_tag
'container_delete' => :container_delete,
'container_edit' => :container_edit,
'container_tag' => :container_tag,
'container_timeline' => :show_timeline,
'container_perf' => :show
}

def button
Expand Down Expand Up @@ -53,15 +55,20 @@ def x_button

# Container show selected, redirect to proper controller
def show
record = Container.find_by_id(from_cid(params[:id]))
unless @explorer
tree_node_id = TreeBuilder.build_node_id(record)
redirect_to :controller => "container",
:action => "explorer",
:id => tree_node_id
return
return if perfmenu_click?
@sb[:action] = params[:display]
@display = params[:display] || "main" unless control_selected?

identify_container(params[:id])
if @display == "performance"
@showtype = "performance"
perf_gen_init_options
@refresh_partial = "layouts/performance"
end
redirect_to :action => 'show', :controller => record.class.base_model.to_s.underscore, :id => record.id

redirect_to :action => 'show',
:controller => @record.class.base_model.to_s.underscore,
:id => @record.id unless @display == "performance"
end

def show_timeline
Expand All @@ -84,17 +91,6 @@ def show_list
end

def explorer
@display = params[:display] || "main" unless control_selected?
@record = Container.find_by_id(from_cid(params[:id]))
show_timeline if @display == "timeline"
if @display == "performance"
@showtype = "performance"
drop_breadcrumb(
:name => "#{@record.name} Capacity & Utilization",
:url => "/container/show/#{@record.id}?display=#{@display}&refresh=n"
)
perf_gen_init_options # Initialize perf chart options, charts will be generated async
end
@explorer = true
@lastaction = "explorer"

Expand Down Expand Up @@ -135,17 +131,7 @@ def explorer

params.merge!(session[:exp_parms]) if session[:exp_parms] # Grab any explorer parm overrides
session.delete(:exp_parms)

if @display == "timeline"
show_timeline
elsif @display != "performance"
if @record.nil?
self.x_node = "root"
@showtype = ""
end
get_node_info(x_node)
end

get_node_info(x_node)
@in_a_form = false
render :layout => "application"
end
Expand Down
17 changes: 17 additions & 0 deletions product/toolbars/container_center_tb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,20 @@
:url_parms: 'main_div'
:text: 'Edit Tags'
:title: 'Edit Tags for this #{ui_lookup(:table=>"container")}'
- :name: container_monitoring
:items:
- :buttonSelect: container_monitoring_choice
:image: monitoring
:title: Monitoring
:text: Monitoring
:items:
- :button: container_timeline
:image: timeline
:text: "Timelines"
:title: "Show Timelines for this Container"
:url_parms: '?display=timeline'
- :button: container_perf
:image: capacity
:text: "Utilization"
:title: "Show Capacity & Utilization data for this Container"
:url_parms: '?display=performance'
22 changes: 2 additions & 20 deletions product/toolbars/containers_center_tb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,8 @@
- :button: container_tag
:image: tag
:text: 'Edit Tags'
:title: 'Edit Tags for this #{ui_lookup(:table=>"container")}'
:title: 'Edit Tags for selected #{ui_lookup(:tables=>"container")}'
:url_parms: 'main_div'
:enabled: 'false'
:onwhen: '1+'
- :name: container_monitoring
:items:
- :buttonSelect: container_monitoring_choice
:image: monitoring
:title: Monitoring
:text: Monitoring
:items:
- :button: container_timeline
:image: timeline
:text: "Timelines"
:title: "Show Timelines for this Container"
:url: '/explorer'
:url_parms: '?display=timeline'
- :button: container_perf
:image: capacity
:text: "Utilization"
:title: "Show Capacity & Utilization data for this Container"
:url: '/explorer'
:url_parms: '?display=performance'

38 changes: 38 additions & 0 deletions spec/controllers/container_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,42 @@
expect(assigns(:edit)).to be_nil
end
end

context "#x_button" do
before(:each) do
ems = FactoryGirl.create(:ems_kubernetes)
container_project = ContainerProject.create(:ext_management_system => ems)
container_group = ContainerGroup.create(:ext_management_system => ems,
:container_project => container_project)
@ct = FactoryGirl.create(:container,
:name => "container-01",
:container_group => container_group
)
controller.stub(:x_node).and_return("cnt_#{controller.to_cid(@ct.id)}")
controller.instance_variable_set(:@record, @ct)
FactoryGirl.create(:ems_event, :container_id => @ct.id)
end

after(:each) do
expect(response.status).to eq(200)
end

it "renders timeline views" do
post :x_button,
:pressed => "container_timeline",
:id => @ct.id,
:display => 'timeline'
response.should render_template('layouts/_tl_show')
response.should render_template('layouts/_tl_detail')
end

it "renders utilization views" do
post :x_button,
:pressed => "container_perf",
:id => @ct.id,
:display => 'performance'
response.should render_template('layouts/_perf_options')
response.should render_template('layouts/_perf_charts')
end
end
end