summaryrefslogtreecommitdiff
path: root/chef-server-webui
diff options
context:
space:
mode:
authorsdelano <stephen@opscode.com>2010-08-25 12:34:01 -0700
committerSeth Falcon <seth@opscode.com>2010-11-01 10:44:49 -0700
commit70ba60c8516254066472a8fbe1315dc6b17a8fbf (patch)
tree62b3bc2bbe800250e7602472fba95b8926491ce0 /chef-server-webui
parent0c73903a8105329c944ad16b576a9ec0315c13fc (diff)
downloadchef-70ba60c8516254066472a8fbe1315dc6b17a8fbf.tar.gz
filter nodes by environment in webui
Diffstat (limited to 'chef-server-webui')
-rw-r--r--chef-server-webui/app/controllers/nodes.rb9
-rw-r--r--chef-server-webui/app/views/cookbooks/index.html.haml2
-rw-r--r--chef-server-webui/app/views/nodes/index.html.haml15
-rw-r--r--chef-server-webui/config/router.rb2
4 files changed, 22 insertions, 6 deletions
diff --git a/chef-server-webui/app/controllers/nodes.rb b/chef-server-webui/app/controllers/nodes.rb
index f2b9cbb30e..9cbcc11555 100644
--- a/chef-server-webui/app/controllers/nodes.rb
+++ b/chef-server-webui/app/controllers/nodes.rb
@@ -28,10 +28,13 @@ class Nodes < Application
before :require_admin, :only => [:destroy]
def index
+ @environments = Chef::Environment.list.keys.sort
begin
- node_hash = Chef::Node.list
- require 'pp'
- pp node_hash
+ if params[:environment_id]
+ node_hash = Chef::Node.list_by_environment(params[:environment_id])
+ else
+ node_hash = Chef::Node.list
+ end
@node_list = node_hash.keys.sort
rescue => e
Chef::Log.error("#{e}\n#{e.backtrace.join("\n")}")
diff --git a/chef-server-webui/app/views/cookbooks/index.html.haml b/chef-server-webui/app/views/cookbooks/index.html.haml
index 39cee76d2c..f4139cb927 100644
--- a/chef-server-webui/app/views/cookbooks/index.html.haml
+++ b/chef-server-webui/app/views/cookbooks/index.html.haml
@@ -2,7 +2,7 @@
.block#block-tables
.content
%h2.title
- = Cookbooks
+ Cookbooks
%select{:name => "choice", :onchange => "jump(this)", :size => "1"}
%option{:value => ""} Environments
%option{:value => ""} ------------
diff --git a/chef-server-webui/app/views/nodes/index.html.haml b/chef-server-webui/app/views/nodes/index.html.haml
index 021993af59..ef2708d612 100644
--- a/chef-server-webui/app/views/nodes/index.html.haml
+++ b/chef-server-webui/app/views/nodes/index.html.haml
@@ -1,6 +1,14 @@
+%script{:type=>"text/javascript", :src => "/javascripts/drop_down_menu.js"}
.block#block-tables
.content
- %h2.title Node List
+ %h2.title
+ Node List
+ %select{:name => "choice", :onchange => "jump(this)", :size => "1"}
+ %option{:value => ""} Environments
+ %option{:value => ""} ------------
+ %option{:value => url(:nodes)} All
+ - @environments.each do |environment|
+ %option{:value => url(:nodes_by_environment, :environment_id => environment), :selected => params[:environment_id] == environment}= environment
.inner
= partial('navigation', :active => 'index')
.content
@@ -12,7 +20,10 @@
%th.last &nbsp;
- even = false
- if @node_list.empty?
- %td{:colspan => 4}= "You appear to have no nodes - try connecting one, or creating or editing a #{link_to('client', url(:clients))}"
+ - if params[:environment_id]
+ %td{:colspan => 4}= "The environment #{params[:environment_id]} has no nodes"
+ - else
+ %td{:colspan => 4}= "You have no nodes - try connecting one, or creating or editing a #{link_to('node', url(:nodes))}"
- else
- @node_list.each do |node|
%tr{:class => even ? "even": "odd" }
diff --git a/chef-server-webui/config/router.rb b/chef-server-webui/config/router.rb
index beb304f4a3..845364c9c5 100644
--- a/chef-server-webui/config/router.rb
+++ b/chef-server-webui/config/router.rb
@@ -19,6 +19,8 @@
Merb::Router.prepare do
resources :nodes, :id => /[^\/]+/
+ match("/nodes/_environments/:environment_id").to(:controller => "nodes", :action => "index").name(:nodes_by_environment)
+
resources :clients, :id => /[^\/]+/
resources :roles
resources :environments do |e|