[Ovirt-devel] [Patch] move tree popup widget for moving hosts and storage

Hugh O. Brock hbrock at redhat.com
Mon May 19 16:30:23 UTC 2008


On Fri, May 16, 2008 at 05:02:02PM -0400, Scott Seago wrote:
> >From 1ebce4238a6381d6fd513ed8753803164cef18b0 Mon Sep 17 00:00:00 2001
> From: Scott Seago <sseago at kodiak.boston.redhat.com>
> Date: Fri, 16 May 2008 16:52:58 -0400
> Subject: [PATCH] first pass at move popup. Still not migrated to storage, 
> and the 'new hardware pool' bits need to be hooked up.
>
>
> Signed-off-by: Scott Seago <sseago at kodiak.boston.redhat.com>
> ---
> wui/src/app/controllers/hardware_controller.rb     |   28 +-
> wui/src/app/controllers/resources_controller.rb    |    2 +-
> wui/src/app/models/pool.rb                         |   28 +-
> wui/src/app/views/hardware/move.rhtml              |   43 +
> wui/src/app/views/hardware/new.html.erb            |   76 +-
> wui/src/app/views/hardware/show_hosts.rhtml        |   12 +-
> wui/src/app/views/hardware/show_storage.rhtml      |    2 +-
> wui/src/app/views/layouts/_tree.rhtml              |    2 +-
> wui/src/app/views/layouts/redux.rhtml              |   10 +-
> wui/src/app/views/user/_grid.rhtml                 |    2 +-
> wui/src/public/images/Untitled-4.gif               |  Bin 0 -> 13123 bytes
> wui/src/public/images/addstoragepool.png           |  Bin 0 -> 1069 bytes
> wui/src/public/images/btn_move.png                 |  Bin 0 -> 1531 bytes
> wui/src/public/images/btn_moveto_newhost.png       |  Bin 0 -> 2878 bytes
> wui/src/public/images/btn_moveto_newpool.png       |  Bin 0 -> 2731 bytes
> wui/src/public/images/icon_addvm.png               |  Bin 0 -> 1242 bytes
> wui/src/public/images/icon_selection_add.gif       |  Bin 0 -> 13127 bytes
> wui/src/public/images/icon_selection_remove.gif    |  Bin 0 -> 13117 bytes
> .../public/images/icon_selection_showdetail.gif    |  Bin 0 -> 13124 bytes
> wui/src/public/images/loading.gif                  |  Bin 0 -> 2767 bytes
> wui/src/public/images/slider-bg-1.png              |  Bin 0 -> 204 bytes
> wui/src/public/images/slider-bg-2.png              |  Bin 0 -> 326 bytes
> wui/src/public/images/slider-handle.gif            |  Bin 0 -> 176 bytes
> wui/src/public/javascripts/facebox.js              |    1 +
> .../jquery-treeview/jquery.treeview.async.js       |   19 +-
> wui/src/public/javascripts/jquery.cookie.js        |   92 +
> wui/src/public/javascripts/jquery.js               | 3533 
> ++++++++++++++++++++
> wui/src/public/javascripts/ui.core.js              |  237 ++
> wui/src/public/javascripts/ui.slider.js            |  386 +++
> wui/src/public/stylesheets/facebox.css             |    8 +
> wui/src/public/stylesheets/layout.css              |  138 +-
> 31 files changed, 4525 insertions(+), 94 deletions(-)
> create mode 100644 wui/src/app/views/hardware/move.rhtml
> create mode 100644 wui/src/public/images/Untitled-4.gif
> create mode 100644 wui/src/public/images/addstoragepool.png
> create mode 100644 wui/src/public/images/btn_move.png
> create mode 100644 wui/src/public/images/btn_moveto_newhost.png
> create mode 100644 wui/src/public/images/btn_moveto_newpool.png
> create mode 100644 wui/src/public/images/icon_addvm.png
> create mode 100644 wui/src/public/images/icon_selection_add.gif
> create mode 100644 wui/src/public/images/icon_selection_remove.gif
> create mode 100644 wui/src/public/images/icon_selection_showdetail.gif
> create mode 100755 wui/src/public/images/loading.gif
> create mode 100755 wui/src/public/images/slider-bg-1.png
> create mode 100755 wui/src/public/images/slider-bg-2.png
> create mode 100755 wui/src/public/images/slider-handle.gif
> create mode 100644 wui/src/public/javascripts/jquery.cookie.js
> create mode 100755 wui/src/public/javascripts/jquery.js
> create mode 100755 wui/src/public/javascripts/ui.core.js
> create mode 100755 wui/src/public/javascripts/ui.slider.js
>
> diff --git a/wui/src/app/controllers/hardware_controller.rb 
> b/wui/src/app/controllers/hardware_controller.rb
> index 599d881..0365931 100644
> --- a/wui/src/app/controllers/hardware_controller.rb
> +++ b/wui/src/app/controllers/hardware_controller.rb
> @@ -37,22 +37,30 @@ class HardwareController < ApplicationController
>     end
>   end
>   -  def json
> +  def json_view_tree
> +    json_tree_internal(Permission::PRIV_VIEW, false)
> +  end
> +  def json_move_tree
> +    json_tree_internal(Permission::PRIV_MODIFY, true)
> +  end
> +  def json_tree_internal(privilege, filter_vm_pools)
>     id = params[:id]
>     if id
>       @pool = Pool.find(id)
>       set_perms(@pool)
> -      unless @can_view
> -        flash[:notice] = 'You do not have permission to view this hardware 
> pool: redirecting to top level'
> +      unless @pool.has_privilege(@user, privilege)
> +        flash[:notice] = 'You do not have permission to access this 
> hardware pool: redirecting to top level'
>         redirect_to :controller => "dashboard"
>         return
>       end
>     end
>     if @pool
>       pools = @pool.children
> +      pools = Pool.select_hardware_pools(pools) if filter_vm_pools
>       open_list = []
>     else
>       pools = Pool.list_for_user(get_login_user,Permission::PRIV_VIEW)
> +      pools = Pool.select_hardware_pools(pools) if filter_vm_pools
>       current_id = params[:current_id]
>       if current_id
>         current_pool = Pool.find(current_id)
> @@ -62,7 +70,7 @@ class HardwareController < ApplicationController
>       end
>     end
>
> -    render :json => Pool.nav_json(pools, open_list)
> +    render :json => Pool.nav_json(pools, open_list, filter_vm_pools)
>   end
>
>   def show_vms
> @@ -107,7 +115,7 @@ class HardwareController < ApplicationController
>
>   def users_json
>     json_list(@pool.permissions,
> -              [:id, :user, :user_role])
> +              [:id, :uid, :user_role])
>   end
>
>   def storage_pools_json
> @@ -127,6 +135,12 @@ class HardwareController < ApplicationController
>               [:display_name, :size_in_gb, :get_type_label])
>   end
>
> +  def move
> +    pre_modify
> +    @resource_type = params[:resource_type]
> +    render :layout => 'popup'    +  end
> +
>   def new
>     @pools = @pool.self_and_like_siblings
>   end
> @@ -174,7 +188,7 @@ class HardwareController < ApplicationController
>   # for hosts that aren't currently empty
>   def move_hosts
>     target_pool_id = params[:target_pool_id]
> -    host_ids_str = params[:host_ids]
> +    host_ids_str = params[:resource_ids]
>     host_ids = host_ids_str.split(",").collect {|x| x.to_i}
>         @pool.transaction do
> @@ -209,7 +223,7 @@ class HardwareController < ApplicationController
>   # for storage that aren't currently empty
>   def move_storage
>     target_pool_id = params[:target_pool_id]
> -    storage_pool_ids_str = params[:storage_pool_ids]
> +    storage_pool_ids_str = params[:resource_ids]
>     storage_pool_ids = storage_pool_ids_str.split(",").collect {|x| x.to_i}
>         @pool.transaction do
> diff --git a/wui/src/app/controllers/resources_controller.rb 
> b/wui/src/app/controllers/resources_controller.rb
> index 68e3abe..5056f09 100644
> --- a/wui/src/app/controllers/resources_controller.rb
> +++ b/wui/src/app/controllers/resources_controller.rb
> @@ -79,7 +79,7 @@ class ResourcesController < ApplicationController
>
>   def users_json
>     json_list(@vm_resource_pool.permissions,
> -              [:id, :user, :user_role])
> +              [:id, :uid, :user_role])
>   end
>
>   def new

Not replaying the entire patch since it is huge, but 

ACK

looks a good start.

--Hugh




More information about the ovirt-devel mailing list