deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@redhat.com
Subject [PATCH core 3/5] CIMI: Switched to %table from %dl in client app
Date Wed, 29 Feb 2012 13:57:11 GMT
From: Michal Fojtik <mfojtik@redhat.com>


Signed-off-by: Michal fojtik <mfojtik@redhat.com>
---
 clients/cimi/lib/cimi_frontend_helper.rb           |   22 +++++++++
 clients/cimi/public/app.css                        |    4 ++
 clients/cimi/views/cloud_entry_point/index.haml    |   13 ++----
 clients/cimi/views/machine_admins/show.haml        |   25 ++++-------
 .../cimi/views/machine_configurations/index.haml   |   14 ++----
 .../cimi/views/machine_configurations/show.haml    |   21 +++-----
 clients/cimi/views/machine_images/index.haml       |   14 ++----
 clients/cimi/views/machine_images/show.haml        |   18 +++-----
 clients/cimi/views/volumes/index.haml              |   13 ++---
 clients/cimi/views/volumes/show.haml               |   47 +++++++------------
 10 files changed, 85 insertions(+), 106 deletions(-)

diff --git a/clients/cimi/lib/cimi_frontend_helper.rb b/clients/cimi/lib/cimi_frontend_helper.rb
index 5827089..e00a6b1 100644
--- a/clients/cimi/lib/cimi_frontend_helper.rb
+++ b/clients/cimi/lib/cimi_frontend_helper.rb
@@ -84,6 +84,28 @@ module CIMI
         struct_name.class.name.split('_').last
       end
 
+      def row(label, value)
+        haml_tag :tr do
+          haml_tag :th do
+            haml_concat label
+          end
+          haml_tag :td do
+            haml_concat value.nil? ? '' : convert_urls(value)
+          end
+        end
+      end
+
+      def details(title='', &block)
+        haml_tag :table, { :class => 'table table-bordered table-striped' } do
+          haml_tag :caption do
+            haml_tag :h3 do
+              haml_concat title
+            end
+          end unless title.empty?
+          haml_tag :tbody, &block
+        end
+      end
+
     end
   end
 end
diff --git a/clients/cimi/public/app.css b/clients/cimi/public/app.css
index 1c20dfe..74ccfa4 100644
--- a/clients/cimi/public/app.css
+++ b/clients/cimi/public/app.css
@@ -63,3 +63,7 @@ body {
 #toolbar p:first-child {
   text-align : right;
 }
+
+table caption h3 {
+  text-align : left;
+}
diff --git a/clients/cimi/views/cloud_entry_point/index.haml b/clients/cimi/views/cloud_entry_point/index.haml
index 9475b51..189c71a 100644
--- a/clients/cimi/views/cloud_entry_point/index.haml
+++ b/clients/cimi/views/cloud_entry_point/index.haml
@@ -24,12 +24,7 @@
         %a{ :href => "/cimi/#{entity}"}=struct_to_name @entry_point.send(entity.intern)
         =not_implemented(entity)
 
-%h3 Collection details
-
-%dl
-  %dt URI
-  %dd=@entry_point.uri
-  %dt Description
-  %dd=@entry_point.description
-  %dt Created
-  %dd=@entry_point.created
+- details('Collection details') do
+  - row 'URI', @entry_point.uri
+  - row 'Description', @entry_point.description
+  - row 'Created', @entry_point.created
diff --git a/clients/cimi/views/machine_admins/show.haml b/clients/cimi/views/machine_admins/show.haml
index 07602f3..abf8e88 100644
--- a/clients/cimi/views/machine_admins/show.haml
+++ b/clients/cimi/views/machine_admins/show.haml
@@ -18,25 +18,18 @@
   %p
     %form{ :action => "/cimi/machine_admins/#{@machine_admin.name}/delete", :method =>
:post, :style => 'display:inline'}
       %input{ :type => :hidden, :name => '_method', :value => 'delete'}
-      %button{ :class => 'btn danger'} Destroy
+      %button{ :class => 'btn btn-danger'} Destroy
 
 %blockquote
   %p
     A Machine Admin entity contains the information required to create the
     initial administrative super- user of a newly created Machine
 
-%dl
-  %dt URI
-  %dd
-    %a{ :href => @machine_admin.uri }=@machine_admin.uri
-  %dt Description
-  %dd=@machine_admin.description
-  %dt Created
-  %dd=@machine_admin.created
-  %dt Username
-  %dd=boolean_span_for @machine_admin.username
-  %dt Password
-  %dd=boolean_span_for @machine_admin.password
-  %dt Key
-  %dd
-    %pre=boolean_span_for @machine_admin.key
+- details 'MachineAdmin Details' do
+  - row 'URI', @machine_admin.uri
+  - row 'Description', @machine_admin.description
+  - row 'Created', @machine_admin.created
+  - row 'Username', boolean_span_for(@machine_admin.username)
+  - row 'Password', boolean_span_for(@machine_admin.password)
+  - row 'Key', '<pre>'+boolean_span_for(@machine_admin.key)+'</pre>'
+
diff --git a/clients/cimi/views/machine_configurations/index.haml b/clients/cimi/views/machine_configurations/index.haml
index cd9bb4d..0f9e8b3 100644
--- a/clients/cimi/views/machine_configurations/index.haml
+++ b/clients/cimi/views/machine_configurations/index.haml
@@ -19,17 +19,13 @@
     Machine Configuration entities within a Provider. This entity can be used to
     locate and create Machine Configurations.
 
+%h3 MachineConfigurationCollection
 %ul
   - @machine_configurations.machine_configurations.each do |conf|
     %li
       %a{ :href => "/cimi/machine_configurations/#{conf.href.split('/').last}"}=conf.href.split('/').last
 
-%h3 Collection details
-
-%dl
-  %dt URI
-  %dd=@machine_configurations.uri
-  %dt Description
-  %dd=@machine_configurations.description
-  %dt Created
-  %dd=@machine_configurations.created
+- details('Collection details') do
+  - row 'URI', @machine_configurations.uri
+  - row 'Description', @machine_configurations.description
+  - row 'Created', @machine_configurations.created
diff --git a/clients/cimi/views/machine_configurations/show.haml b/clients/cimi/views/machine_configurations/show.haml
index 387de62..7eff926 100644
--- a/clients/cimi/views/machine_configurations/show.haml
+++ b/clients/cimi/views/machine_configurations/show.haml
@@ -23,16 +23,11 @@
     Instance. Machine Configurations are created by Providers and MAY, at the
     Providers discretion, be created by Consumers.
 
-%dl
-  %dt URI
-  %dd
-    %a{ :href => @machine_configuration.uri }=@machine_configuration.uri
-  %dt Description
-  %dd=@machine_configuration.description
-  %dt CPU
-  %dd=@machine_configuration.cpu
-  %dt Memory
-  %dd=[@machine_configuration.memory[:quantity], @machine_configuration.memory[:units]].join('&nbsp;')
-  %dt Disks
-  - @machine_configuration.disks.each do |disk|
-    %dd=[disk.capacity.quantity, disk.capacity.units].join('&nbsp;')
+- details('MachineConfiguration details') do
+  - row 'URI', @machine_configuration.uri
+  - row 'Description', @machine_configuration.description
+  - row 'Created', @machine_configuration.created
+  - row '# of CPU', @machine_configuration.cpu
+  - row 'Memory (RAM)', [@machine_configuration.memory[:quantity], @machine_configuration.memory[:units]].join('&nbsp;')
+  - row 'Storage (disks)', @machine_configuration.disks.map { |d| [ d.capacity.quantity,
d.capacity.units ].join('&nbsp;') }.join(',')
+
diff --git a/clients/cimi/views/machine_images/index.haml b/clients/cimi/views/machine_images/index.haml
index c8d9c86..defad9a 100644
--- a/clients/cimi/views/machine_images/index.haml
+++ b/clients/cimi/views/machine_images/index.haml
@@ -19,17 +19,13 @@
     entities within a Provider. This entity can be used to locate and create
     Machine Images.
 
+%h3 MachineImageCollection
 %ul
   - @machine_images.machine_images.each do |image|
     %li
       %a{ :href => "/cimi/machine_images/#{image.href.split('/').last}"}=image.href.split('/').last
 
-%h3 Collection details
-
-%dl
-  %dt URI
-  %dd=@machine_images.uri
-  %dt Description
-  %dd=@machine_images.description
-  %dt Created
-  %dd=@machine_images.created
+- details('Collection details') do
+  - row 'URI', @machine_images.uri
+  - row 'Description', @machine_images.description
+  - row 'Created', @machine_images.created
diff --git a/clients/cimi/views/machine_images/show.haml b/clients/cimi/views/machine_images/show.haml
index b3c4120..af5ba91 100644
--- a/clients/cimi/views/machine_images/show.haml
+++ b/clients/cimi/views/machine_images/show.haml
@@ -22,15 +22,9 @@
     (OVF) package) necessary for hardware virtualized resources to create a
     Machine Instance
 
-%dl
-  %dt URI
-  %dd
-    %a{ :href => @machine_image.uri }=@machine_image.uri
-  %dt Description
-  %dd=@machine_image.description
-  %dt Created
-  %dd=@machine_image.created
-  %dt Image Location
-  %dd=@machine_image.image_location.href
-  %dt Image Data
-  %dd=@machine_image.image_data
+- details 'MachineImage details' do
+  - row 'URI', @machine_image.uri
+  - row 'Description', @machine_image.description
+  - row 'Created', @machine_image.created
+  - row 'Image Location', @machine_image.image_location.href
+  - row 'Image Data', @machine_image.image_data
diff --git a/clients/cimi/views/volumes/index.haml b/clients/cimi/views/volumes/index.haml
index de37597..08a5cc1 100644
--- a/clients/cimi/views/volumes/index.haml
+++ b/clients/cimi/views/volumes/index.haml
@@ -19,17 +19,14 @@
     entities within a Provider. This entity can be used to locate and create
     volumes.
 
+%h3 VolumesCollection
 %ul
   - @volumes.volumes.each do |volume|
     %li
       %a{ :href => "/cimi/volumes/#{volume.href.split('/').last}"}=volume.href.split('/').last
 
-%h3 Collection details
+- details 'Collection details' do
+  - row 'URI', @volumes.uri
+  - row 'Description', @volumes.description
+  - row 'Created', @volumes.created
 
-%dl
-  %dt URI
-  %dd=@volumes.uri
-  %dt Description
-  %dd=@volumes.description
-  %dt Created
-  %dd=@volumes.created
diff --git a/clients/cimi/views/volumes/show.haml b/clients/cimi/views/volumes/show.haml
index 0352d52..ae477db 100644
--- a/clients/cimi/views/volumes/show.haml
+++ b/clients/cimi/views/volumes/show.haml
@@ -18,34 +18,21 @@
 
 %blockquote
   %p
-    This entity represents a
-    volume Instance
+    This entity represents a volume Instance
+
+- details 'Volume details' do
+  - row 'URI', @volume.uri
+  - row 'Description', @volume.description
+  - row 'Created', @volume.created
+  - row 'Bootable?', boolean_span_for(@volume.bootable)
+  - row 'Support snapshots?', boolean_span_for(@volume.supports_snapshots)
+  - row 'Guest Interface', boolean_span_for(@volume.guest_interface)
+
+- details 'Volume Snapshots' do
+  - @volume.snapshots.each_with_index do |s, i|
+    - row "##{i}", s.ref
+
+- details 'Volume Meters' do
+  - @volume.meters.each_with_index do |m, i|
+    - row "##{i}", m.ref
 
-%dl
-  %dt URI
-  %dd
-    %a{ :href => @volume.uri }=@volume.uri
-  %dt Description
-  %dd=@volume.description
-  %dt Created
-  %dd=@volume.created
-  %dt Bootable
-  %dd=boolean_span_for @volume.bootable
-  %dt Support Snapshots
-  %dd=boolean_span_for @volume.supports_snapshots
-  %dt Guest Interface
-  %dd=boolean_span_for @volume.guest_interface
-  %dt Snapshots
-  %dd
-    - if @volume.snapshots.empty?
-      %span.label No snapshots
-    - else
-      - @volume.snapshots.each do |snapshot|
-        %dd=snapshot.ref
-  %dt Meters
-  %dd
-    - if @volume.meters.empty?
-      %span.label No meters
-    - else
-      - @volume.meters.each do |meters|
-        %dd=meters.ref
-- 
1.7.9.1


Mime
View raw message