From 5a4b9823c29fddec450fed7d4eb81b7f76ebdd1f Mon Sep 17 00:00:00 2001 From: Daniel DeLeo Date: Sun, 23 Jan 2011 09:19:15 -0800 Subject: remove recipe versions from run list editor, restyle current run list --- chef-server-webui/app/controllers/application.rb | 10 ++----- chef-server-webui/app/controllers/nodes.rb | 32 +++++++++++----------- chef-server-webui/app/controllers/roles.rb | 24 ++++++++-------- .../app/helpers/application_helper.rb | 26 +++++++++++++++++- chef-server-webui/app/views/nodes/_form.html.erb | 7 ++--- chef-server-webui/app/views/roles/_form.html.erb | 15 +++++----- chef-server-webui/public/stylesheets/chef.css | 28 +++++++++++++++++-- 7 files changed, 91 insertions(+), 51 deletions(-) (limited to 'chef-server-webui') diff --git a/chef-server-webui/app/controllers/application.rb b/chef-server-webui/app/controllers/application.rb index 67866225b9..e1e990b5c3 100644 --- a/chef-server-webui/app/controllers/application.rb +++ b/chef-server-webui/app/controllers/application.rb @@ -259,15 +259,9 @@ class Application < Merb::Controller end end - def get_available_recipes + def list_available_recipes r = Chef::REST.new(Chef::Config[:chef_server_url]) - all_recipes = Array.new - r.get_rest('cookbooks/_recipes').each do |cb, versions| - all_recipes << versions.sort{|x,y| y <=> x }.map do |ver, recipes| - recipes.map{ |rn| rn == "default" ? "#{cb} #{ver}" : "#{cb}::#{rn} #{ver}" } - end - end - all_recipes.flatten.uniq + r.get_rest('cookbooks/_recipes').keys end def convert_newline_to_br(string) diff --git a/chef-server-webui/app/controllers/nodes.rb b/chef-server-webui/app/controllers/nodes.rb index 5888f12b1c..9fe64093d4 100644 --- a/chef-server-webui/app/controllers/nodes.rb +++ b/chef-server-webui/app/controllers/nodes.rb @@ -8,9 +8,9 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,12 +21,12 @@ require 'chef/node' class Nodes < Application - + provides :html - + before :login_required before :require_admin, :only => [:destroy] - + def index begin if session[:environment] @@ -44,20 +44,20 @@ class Nodes < Application end def show - begin + begin @node =Chef::Node.load(params[:id]) rescue => e Chef::Log.error("#{e}\n#{e.backtrace.join("\n")}") @_message = {:error => "Could not load node #{params[:id]}"} @node = Chef::Node.new - end + end render end def new begin @node = Chef::Node.new - @available_recipes = get_available_recipes + @available_recipes = list_available_recipes @available_roles = Chef::Role.list.keys.sort @run_list = @node.run_list render @@ -66,13 +66,13 @@ class Nodes < Application @node_list = Chef::Node.list() @_message = {:error => "Could not load available recipes, roles, or the run list"} render :index - end + end end def edit begin @node = Chef::Node.load(params[:id]) - @available_recipes = get_available_recipes + @available_recipes = list_available_recipes @available_roles = Chef::Role.list.keys.sort @run_list = @node.run_list render @@ -84,11 +84,11 @@ class Nodes < Application @run_list = [] @_message = {:error => "Could not load node #{params[:id]}"} render - end + end end def create - begin + begin @node = Chef::Node.new @node.name params[:name] @node.normal_attrs = Chef::JSON.from_json(params[:attributes]) @@ -99,7 +99,7 @@ class Nodes < Application rescue => e Chef::Log.error("#{e}\n#{e.backtrace.join("\n")}") @node.normal_attrs = Chef::JSON.from_json(params[:attributes]) - @available_recipes = get_available_recipes + @available_recipes = list_available_recipes @available_roles = Chef::Role.list.keys.sort @node.run_list params[:for_node] @run_list = @node.run_list @@ -118,7 +118,7 @@ class Nodes < Application render :show rescue => e Chef::Log.error("#{e}\n#{e.backtrace.join("\n")}") - @available_recipes = get_available_recipes + @available_recipes = list_available_recipes @available_roles = Chef::Role.list.keys.sort @run_list = Chef::RunList.new @run_list.reset!(params[:for_node]) @@ -137,7 +137,7 @@ class Nodes < Application @node_list = Chef::Node.list() @_message = {:error => "Could not delete the node"} render :index - end + end end - + end diff --git a/chef-server-webui/app/controllers/roles.rb b/chef-server-webui/app/controllers/roles.rb index 91083a4692..b8cdb7cc5f 100644 --- a/chef-server-webui/app/controllers/roles.rb +++ b/chef-server-webui/app/controllers/roles.rb @@ -7,9 +7,9 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,7 +24,7 @@ class Roles < Application provides :html before :login_required before :require_admin, :only => [:destroy] - + # GET /roles def index @role_list = begin @@ -33,7 +33,7 @@ class Roles < Application Chef::Log.error("#{e}\n#{e.backtrace.join("\n")}") @_message = {:error => "Could not list roles"} {} - end + end render end @@ -45,14 +45,14 @@ class Roles < Application Chef::Log.error("#{e}\n#{e.backtrace.join("\n")}") @_message = {:error => "Could not load role #{params[:id]}"} Chef::Role.new - end + end render end # GET /roles/new def new begin - @available_recipes = get_available_recipes + @available_recipes = list_available_recipes @role = Chef::Role.new @available_roles = Chef::Role.list.keys.sort @run_list = @role.run_list @@ -65,14 +65,14 @@ class Roles < Application @role_list = Chef::Role.list() @_message = {:error => "Could not load available recipes, roles, or the run list."} render :index - end + end end # GET /roles/:id/edit def edit begin @role = Chef::Role.load(params[:id]) - @available_recipes = get_available_recipes + @available_recipes = list_available_recipes @available_roles = Chef::Role.list.keys.sort @run_list = @role.run_list @environments = @role.env_run_lists.keys @@ -84,7 +84,7 @@ class Roles < Application @available_roles = [] @run_list = [] @_message = {:error => "Could not load role #{params[:id]}, the available recipes, roles, or the run list"} - end + end render end @@ -101,7 +101,7 @@ class Roles < Application redirect(url(:roles), :message => { :notice => "Created Role #{@role.name}" }) rescue => e Chef::Log.error("#{e}\n#{e.backtrace.join("\n")}") - @available_recipes = get_available_recipes + @available_recipes = list_available_recipes @available_roles = Chef::Role.list.keys.sort @role = Chef::Role.new @role.default_attributes(Chef::JSON.from_json(params[:default_attributes])) if params[:default_attributes] != '' @@ -125,7 +125,7 @@ class Roles < Application render :show rescue => e Chef::Log.error("#{e}\n#{e.backtrace.join("\n")}") - @available_recipes = get_available_recipes + @available_recipes = list_available_recipes @available_roles = Chef::Role.list.keys.sort @run_list = Chef::RunList.new.reset!( Array(params[:for_role])) Chef::Log.error(@run_list.inspect) @@ -147,7 +147,7 @@ class Roles < Application @role_list = Chef::Role.list() @_message = {:error => "Could not delete role #{params[:id]}"} render :index - end + end end end diff --git a/chef-server-webui/app/helpers/application_helper.rb b/chef-server-webui/app/helpers/application_helper.rb index c3873bc5a6..10ce6aefb0 100644 --- a/chef-server-webui/app/helpers/application_helper.rb +++ b/chef-server-webui/app/helpers/application_helper.rb @@ -4,12 +4,36 @@ require 'chef-server-webui/version' module Merb module ApplicationHelper + ROLE_STR = "role" + RECIPE_STR = "recipe" + + def chef_version ::ChefServerWebui::VERSION end def class_for_run_list_item(item) - item.type == 'role' ? 'ui-state-highlight' : 'ui-state-default' + case item.type.to_s + when ROLE_STR + 'ui-state-highlight' + when RECIPE_STR + 'ui-state-default' + else + raise ArgumentError, "Cannot generate UI class for #{item.inspect}" + end + end + + def display_run_list_item(item) + case item.type.to_s + when ROLE_STR + item.name + when RECIPE_STR + # webui not sophisticated enough for versioned recipes + # "#{item.name}@#{item.version}" + item.name + else + raise ArgumentError, "can't generate display string for #{item.inspect}" + end end end diff --git a/chef-server-webui/app/views/nodes/_form.html.erb b/chef-server-webui/app/views/nodes/_form.html.erb index 0115ff9577..808d9d750d 100644 --- a/chef-server-webui/app/views/nodes/_form.html.erb +++ b/chef-server-webui/app/views/nodes/_form.html.erb @@ -24,9 +24,8 @@ Available Recipes
@@ -39,7 +38,7 @@
diff --git a/chef-server-webui/app/views/roles/_form.html.erb b/chef-server-webui/app/views/roles/_form.html.erb index 81eaba64c8..440e99a0b6 100644 --- a/chef-server-webui/app/views/roles/_form.html.erb +++ b/chef-server-webui/app/views/roles/_form.html.erb @@ -1,5 +1,5 @@
- <%= form(:action => form_url, :method => :post, :id => form_id, :class => 'form') do -%> + <%= form(:action => form_url, :method => :post, :id => form_id, :class => 'form') do -%> <% unless form_for == 'edit' %>
@@ -31,7 +31,7 @@
    <% @available_recipes.each do |recipe| %> -
  • <%= h(recipe.split(/\s+/).join('@')) -%>
  • +
  • <%= h(recipe) -%>
  • <% end %>
@@ -44,18 +44,19 @@
    - <% @run_list.each do |entry| %> -
  • <%=h "#{entry.name} #{entry.version}"-%>
  • + <% @run_list.each do |item| %> +
  • <%=h display_run_list_item(item)-%>
  • <% end %>
Active Run List for <%= h(@current_env) -%> -
-
    +
    +
    PREPROD
    +
      <% @role.run_list_for(@current_env).each do |item| %> -
    • <%= h(item) -%>
    • +
    • <%= h(item) -%>
    • <% end %>
    diff --git a/chef-server-webui/public/stylesheets/chef.css b/chef-server-webui/public/stylesheets/chef.css index 57aa09130d..3a214bb4c2 100644 --- a/chef-server-webui/public/stylesheets/chef.css +++ b/chef-server-webui/public/stylesheets/chef.css @@ -17,6 +17,10 @@ .ruby .expr { color: #227; } .ruby .escape { color: #277; } +.todo{ + color:red; +} + .files { padding-left: 20px; } @@ -63,17 +67,29 @@ div.runListEditorColumn { float:left; } +div#current_run_list_display_container{ + margin-left:20px; +} + span#environment_run_list_selection_control{ float:right; margin-right:10px; } -span.runListEditorLabel{ +span.runListEditorLabel, div#activeRunListName{ font-size: 1.2em; + font-weight: bold; +} + +span.runListEditorLabel{ padding: 1px 0 3px 0; margin: 0; display: inline-block; - font-weight: bold; +} + +div#activeRunListName{ + padding:2px; + text-align:center; } div.runListAvailableItemContainer, div.runListContainer { @@ -98,7 +114,6 @@ ul.runListAvailableItemList, ul.runListItemList { width:100%; list-style-type: none; margin: 0px; - background: #eee; } ul.runListItemList{ @@ -113,6 +128,13 @@ li.runListItem{ cursor:pointer; } +li.displayRunListItem{ + padding: 5px 5px 5px 5px; + margin: 0px 5px 0px 5px; + width: 93%; + border-bottom:1px solid #eee; +} + div.clear { clear: left; } -- cgit v1.2.1