[Ovirt-devel] [PATCH server] Minor bug fixes and enhancements.

Jason Guiditta jguiditt at redhat.com
Tue Feb 3 20:51:22 UTC 2009


* Fixed weird css issue with popup for 'add storage server'.
* Fixed bug in edit_items method of HardwareController. It
was looking for a param that was not always present.
* Made the storage tree in main content area of storage tab
a subscriber to the STORAGE_VOLUME channel, set a couple places
to publish events to that channel. This means it will now update
when a new storage item is added.

Signed-off-by: Jason Guiditta <jguiditt at redhat.com>
---
 src/app/controllers/hardware_controller.rb |    5 +++--
 src/app/controllers/storage_controller.rb  |    3 ++-
 src/app/models/hardware_pool.rb            |    2 +-
 src/app/views/hardware/move.rhtml          |    3 ++-
 src/app/views/hardware/show_storage.rhtml  |    3 ++-
 src/public/javascripts/ovirt.js            |   21 ++++++++++-----------
 src/public/javascripts/ovirt.tree.js       |    4 ++--
 src/public/stylesheets/ovirt-tree/tree.css |    2 +-
 8 files changed, 23 insertions(+), 20 deletions(-)

diff --git a/src/app/controllers/hardware_controller.rb b/src/app/controllers/hardware_controller.rb
index 0f9cceb..3caf024 100644
--- a/src/app/controllers/hardware_controller.rb
+++ b/src/app/controllers/hardware_controller.rb
@@ -299,7 +299,7 @@ class HardwareController < PoolController
     resource_ids = resource_ids_str.split(",").collect {|x| x.to_i}
 
     # if user doesn't have modify permission on both source and destination
-    unless @pool.can_modify(@user) and Pool.find(params[:target_pool_id]).can_modify(@user)
+    unless @pool.can_modify(@user) and Pool.find(target_pool_id).can_modify(@user)
         render :json => { :success => false,
                :alert => "Cannot #{item_action.to_s} #{item_class.table_name.humanize} without admin permissions on both pools" }
         return
@@ -326,7 +326,8 @@ class HardwareController < PoolController
 
     if success
       render :json => { :success => true,
-        :alert => "#{item_action.to_s} #{item_class.table_name.humanize} successful." }
+        :alert => "#{item_action.to_s} #{item_class.table_name.humanize} successful.",
+        :storage => @pool.storage_tree({:filter_unavailable => false, :include_used => true, :state => item_action.to_s})}
     else
       render :json => { :success => false,
          :alert => "#{item_action.to_s} #{item_class.table_name.humanize} failed" +
diff --git a/src/app/controllers/storage_controller.rb b/src/app/controllers/storage_controller.rb
index 7f69efa..98ba0f6 100644
--- a/src/app/controllers/storage_controller.rb
+++ b/src/app/controllers/storage_controller.rb
@@ -126,7 +126,8 @@ class StorageController < ApplicationController
       respond_to do |format|
         format.json { render :json => { :object => "storage_pool",
             :success => true,
-            :alert => "Storage Pool was successfully created." } }
+            :alert => "Storage Pool was successfully created.",
+            :new_pool => @storage_pool.storage_tree_element({:filter_unavailable => false, :state => 'new'})} }
         format.xml { render :xml => @storage_pool,
             :status => :created,
             :location => storage_pool_url(@storage_pool)
diff --git a/src/app/models/hardware_pool.rb b/src/app/models/hardware_pool.rb
index b72d485..7015854 100644
--- a/src/app/models/hardware_pool.rb
+++ b/src/app/models/hardware_pool.rb
@@ -60,7 +60,7 @@ class HardwarePool < Pool
     end
   end
 
-  def move_storage(storage_pool_ids, target_pool_id) 
+  def move_storage(storage_pool_ids, target_pool_id)
     storage_pools = StoragePool.find(:all, :conditions => "id in (#{storage_pool_ids.join(', ')})")
     transaction do
       storage_pools.each do |storage_pool|
diff --git a/src/app/views/hardware/move.rhtml b/src/app/views/hardware/move.rhtml
index 3bcb8bb..6ada86d 100644
--- a/src/app/views/hardware/move.rhtml
+++ b/src/app/views/hardware/move.rhtml
@@ -9,6 +9,7 @@
       $(document).ready(function(){
         $('#move_tree').tree({
           content: {"pools" : <%=  @pools %>},
+          template: 'move_template',
           clickHandler: move_<%= @resource_type %>,
           cacheContent: false
         });
@@ -42,7 +43,7 @@ $('#move_to_new_pool').click(function(){
 </script>
 <ul id="move_tree" class="ovirt-tree"></ul>
 
-<textarea id="tree_template" style="display:none;">
+<textarea id="move_template" style="display:none;">
 {macro htmlList(list, id, isFullList)}
   {if isFullList}
   <ul style="display:none;">
diff --git a/src/app/views/hardware/show_storage.rhtml b/src/app/views/hardware/show_storage.rhtml
index 07f5625..8d09577 100644
--- a/src/app/views/hardware/show_storage.rhtml
+++ b/src/app/views/hardware/show_storage.rhtml
@@ -62,7 +62,8 @@ ${htmlList(pools, id)}
   $(document).ready(function(){
     $('#storage_tree').tree({
       content: {"pools" : <%=  @storage_tree%>},
-      clickHandler: storage_select
+      clickHandler: storage_select,
+      channel: 'STORAGE_VOLUME'
     });
   });
   function add_storage_to_smart_pool(smart_pool)
diff --git a/src/public/javascripts/ovirt.js b/src/public/javascripts/ovirt.js
index 19e41c2..c24df16 100644
--- a/src/public/javascripts/ovirt.js
+++ b/src/public/javascripts/ovirt.js
@@ -60,14 +60,14 @@ function add_storage(url)
     if (validate_selected(storage, "storage pool")) {
       $.post(url,
              { resource_ids: storage.toString() },
-              function(data,status){;
-                $(document).trigger('close.facebox');
-                // FIXME: this always reloads the tab for now
-	        grid = $("#storage_grid");
-                if (grid.size()>0 && grid != null) {
-                  grid.flexReload();
-                } else {
-                   $tabs.tabs("load",$tabs.data('selected.tabs'));
+              function(data,status){
+                if (data.success) {
+                  $(document).trigger('close.facebox');
+                  if ($("#storage_tree").size() > 0) {
+                    $('ul.ovirt-tree').trigger('STORAGE_VOLUME', [response.storage]);
+                  } else {
+                    $tabs.tabs("load",$tabs.data('selected.tabs'));
+                  }
                 }
 		if (data.alert) {
 		  $.jGrowl(data.alert);
@@ -206,9 +206,8 @@ function afterStoragePool(response, status){
     ajax_validation(response, status);
     if (response.success) {
       $(document).trigger('close.facebox');
-      grid = $("#storage_grid");
-      if (grid.size()>0 && grid != null) {
-        grid.flexReload();
+      if ($("#storage_tree").size() > 0) {
+        $('ul.ovirt-tree').trigger('STORAGE_VOLUME', [response.new_pool]);
       } else {
         $tabs.tabs("load",$tabs.data('selected.tabs'));
       }
diff --git a/src/public/javascripts/ovirt.tree.js b/src/public/javascripts/ovirt.tree.js
index 1b1d0c8..ff58c5d 100644
--- a/src/public/javascripts/ovirt.tree.js
+++ b/src/public/javascripts/ovirt.tree.js
@@ -100,7 +100,7 @@ function processChildren(list, templateObj){
                 walkTree: function(list, lookup, self) {
                     $.each(list, function(n,obj){
                         lookup.push(obj);
-                        if (obj.children.length > 0) self.walkTree(obj.children, lookup, self);
+                        if (obj.children && obj.children.length > 0) self.walkTree(obj.children, lookup, self);
                     });
                     return lookup;
                 },
@@ -179,7 +179,7 @@ function processChildren(list, templateObj){
                       var self = this;
                       $.each(matchedItems, function(n,obj){
                         var existingObj = [];
-                        if(obj.children.length >0) {
+                        if(obj.children && obj.children.length >0) {
                           existingObj = $.grep(obj.children,function(value) {return value.ui_object == data.ui_object;});
                         }
                         if (existingObj.length === 0){
diff --git a/src/public/stylesheets/ovirt-tree/tree.css b/src/public/stylesheets/ovirt-tree/tree.css
index 3ee0fcc..441ae83 100644
--- a/src/public/stylesheets/ovirt-tree/tree.css
+++ b/src/public/stylesheets/ovirt-tree/tree.css
@@ -66,7 +66,7 @@
     background: url('../../images/minus.gif') no-repeat left;
 }
 
-.current {
+.ovirt-tree .current {
     background-color: #698FA6;
     color:#000000;
     width: 100%;
-- 
1.5.6.6




More information about the ovirt-devel mailing list