Ack to this series - with the new 4/8 in the series

Just few comments, just please remove commented lines in instances tests, and 
also minor nit, could you please change the name of the instance method, since 
its a little confusing.

Other than that looks great,

Cheers

----- Original Message -----
From: [email protected]
To: [email protected]
Sent: Tuesday, December 21, 2010 9:41:19 AM
Subject: [deltacloud-devel] [PATCH aggregator 8/8] New UI - show instance in    
the pane

From: Jan Provaznik <[email protected]>

---
 .../controllers/resources/instances_controller.rb  |   34 ++++++-----
 src/app/views/resources/instances/_properties.haml |   57 ++++++++++++++++++
 src/app/views/resources/instances/show.haml        |   63 +------------------
 3 files changed, 80 insertions(+), 74 deletions(-)
 create mode 100644 src/app/views/resources/instances/_properties.haml

diff --git a/src/app/controllers/resources/instances_controller.rb 
b/src/app/controllers/resources/instances_controller.rb
index f5e4786..abb5ce8 100644
--- a/src/app/controllers/resources/instances_controller.rb
+++ b/src/app/controllers/resources/instances_controller.rb
@@ -1,6 +1,7 @@
 class Resources::InstancesController < ApplicationController
   before_filter :require_user
   before_filter :instance, :only => [:show, :remove_failed, :key, :stop]
+  before_filter :load_instances, :only => [:show, :index]
 
   def new
     @instance = Instance.new(params[:instance])
@@ -77,21 +78,6 @@ class Resources::InstancesController < ApplicationController
   end
 
   def index
-    @header = [
-      {:name => 'VM NAME', :sort_attr => 'name'},
-      {:name => 'STATUS', :sortable => false},
-      {:name => 'TEMPLATE', :sort_attr => 'templates.name'},
-      {:name => 'PUBLIC ADDRESS', :sort_attr => 'public_addresses'},
-      {:name => 'PROVIDER', :sortable => false},
-      {:name => 'CREATED BY', :sort_attr => 'users.last_name'},
-    ]
-
-    pools = Pool.list_for_user(@current_user, Privilege::INSTANCE_MODIFY)
-    @instances = Instance.all(
-      :include => [:template, :owner],
-      :conditions => {:pool_id => pools},
-      :order => (params[:order_field] || 'name') +' '+ (params[:order_dir] || 
'asc')
-    )
   end
 
   def key
@@ -147,4 +133,22 @@ class Resources::InstancesController < 
ApplicationController
       }
     )
   end
+
+  def load_instances
+    @header = [
+      {:name => 'VM NAME', :sort_attr => 'name'},
+      {:name => 'STATUS', :sortable => false},
+      {:name => 'TEMPLATE', :sort_attr => 'templates.name'},
+      {:name => 'PUBLIC ADDRESS', :sort_attr => 'public_addresses'},
+      {:name => 'PROVIDER', :sortable => false},
+      {:name => 'CREATED BY', :sort_attr => 'users.last_name'},
+    ]
+
+    pools = Pool.list_for_user(@current_user, Privilege::INSTANCE_MODIFY)
+    @instances = Instance.all(
+      :include => [:template, :owner],
+      :conditions => {:pool_id => pools},
+      :order => (params[:order_field] || 'name') +' '+ (params[:order_dir] || 
'asc')
+    )
+  end
 end
diff --git a/src/app/views/resources/instances/_properties.haml 
b/src/app/views/resources/instances/_properties.haml
new file mode 100644
index 0000000..6f8120e
--- /dev/null
+++ b/src/app/views/resources/instances/_properties.haml
@@ -0,0 +1,57 @@
+%ul
+  %li
+    = label_tag :name, 'Name'
+    %span= @instance.name
+  %li
+    = label_tag :status, 'Status'
+    %span= @instance.state
+  %li
+    = label_tag :public_addresses, 'Public Addresses'
+    %span= @instance.public_addresses
+  %li
+    = label_tag :private_addresses, 'Private Addresses'
+    %span= @instance.private_addresses
+  %li
+    = label_tag :operating_system, 'Operating system'
+    %span= "#[email protected]} 
#[email protected]_version}"
+  %li
+    = label_tag :provider, 'Provider'
+    %span= @instance.cloud_account.provider.name if @instance.cloud_account
+  %li
+    = label_tag :base_template, 'Base Template'
+    %span= @instance.template.name
+  %li
+    = label_tag :architecture, 'Architecture'
+    %span= @instance.hardware_profile.architecture.value
+  %li
+    = label_tag :memory, 'Memory'
+    %span= @instance.hardware_profile.memory.value
+  %li
+    = label_tag :storage, 'Storage'
+    %span= @instance.hardware_profile.storage.value
+  %li
+    = label_tag :instantiation_time, 'Instantiation Time'
+    %span= @instance.created_at.strftime("%d-%b-%Y %H:%M:%S")
+  %li
+    = label_tag :uptime, 'Uptime'
+    %span= @instance.total_state_time(@instance.state)
+  %li
+    = label_tag :current_alerts, 'Current Alerts'
+    %span= 0
+  %li
+    = label_tag :console_connection, 'Console Connection'
+    %span= 'via SSH'
+  - unless @instance.instance_key_id.nil?
+    %li
+      = label_tag :instance_key, 'SSH key'
+      %span= link_to("Download", key_resources_instance_path(@instance))
+  %li
+    = label_tag :owner, 'Owner'
+    %span= "#[email protected]_name} #[email protected]_name}"
+  %li
+    = label_tag :shared_to, 'Shared to'
+    %span= "N/A"
+  - if @instance.state == Instance::STATE_ERROR
+    %li
+      = label_tag :error, 'Error'
+      %span= @instance.last_error
diff --git a/src/app/views/resources/instances/show.haml 
b/src/app/views/resources/instances/show.haml
index deb1a49..05eeedd 100644
--- a/src/app/views/resources/instances/show.haml
+++ b/src/app/views/resources/instances/show.haml
@@ -1,60 +1,5 @@
-%h2 Instance Details
-%ul
-  %li
-    = label_tag :name, 'Name'
-    %span= @instance.name
-  %li
-    = label_tag :status, 'Status'
-    %span= @instance.state
-  %li
-    = label_tag :public_addresses, 'Public Addresses'
-    %span= @instance.public_addresses
-  %li
-    = label_tag :private_addresses, 'Private Addresses'
-    %span= @instance.private_addresses
-  %li
-    = label_tag :operating_system, 'Operating system'
-    %span= "#[email protected]} 
#[email protected]_version}"
-  %li
-    = label_tag :provider, 'Provider'
-    %span= @instance.cloud_account.provider.name if @instance.cloud_account
-  %li
-    = label_tag :base_template, 'Base Template'
-    %span= @instance.template.name
-  %li
-    = label_tag :architecture, 'Architecture'
-    %span= @instance.hardware_profile.architecture.value
-  %li
-    = label_tag :memory, 'Memory'
-    %span= @instance.hardware_profile.memory.value
-  %li
-    = label_tag :storage, 'Storage'
-    %span= @instance.hardware_profile.storage.value
-  %li
-    = label_tag :instantiation_time, 'Instantiation Time'
-    %span= @instance.created_at.strftime("%d-%b-%Y %H:%M:%S")
-  %li
-    = label_tag :uptime, 'Uptime'
-    %span= @instance.total_state_time(@instance.state)
-  %li
-    = label_tag :current_alerts, 'Current Alerts'
-    %span= 0
-  %li
-    = label_tag :console_connection, 'Console Connection'
-    %span= 'via SSH'
-  - unless @instance.instance_key_id.nil?
-    %li
-      = label_tag :instance_key, 'SSH key'
-      %span= link_to("Download", key_resources_instance_path(@instance))
-  %li
-    = label_tag :owner, 'Owner'
-    %span= "#[email protected]_name} #[email protected]_name}"
-  %li
-    = label_tag :shared_to, 'Shared to'
-    %span= "N/A"
-  - if @instance.state == Instance::STATE_ERROR
-    %li
-      = label_tag :error, 'Error'
-      %span= @instance.last_error
+- content_for :list do
+  = render :partial => 'list'
 
-= link_to 'Back', resources_instances_path, :class => 'button'
+- content_for :details do
+  = render :partial => 'layouts/details_pane'
-- 
1.7.2.3

_______________________________________________
deltacloud-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/deltacloud-devel
_______________________________________________
deltacloud-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/deltacloud-devel

Reply via email to