navigating to http://localhost:3000/instance/ when running deltacloud
locally now brings the user to a list of instances in pools which
they have the instance_view permission on
---
src/app/controllers/instance_controller.rb | 5 +++++
src/app/views/dashboard/summary.haml | 2 ++
src/app/views/instance/_list.html.erb | 24 ++++++++++++++++++++++++
src/app/views/instance/index.html.erb | 3 +--
4 files changed, 32 insertions(+), 2 deletions(-)
create mode 100644 src/app/views/instance/_list.html.erb
diff --git a/src/app/controllers/instance_controller.rb
b/src/app/controllers/instance_controller.rb
index c898691..c1c56e9 100644
--- a/src/app/controllers/instance_controller.rb
+++ b/src/app/controllers/instance_controller.rb
@@ -25,6 +25,11 @@ class InstanceController < ApplicationController
before_filter :require_user
def index
+ @instances = current_user.permissions.all.find_all { |perm|
+ !perm.role.privileges.all.find { |priv|
+ priv.name == Privilege::INSTANCE_VIEW
+ }.nil? && perm.permission_object_type == "Pool"
+ }.collect { |perm| perm.permission_object.instances }.flatten
end
# Right now this is essentially a duplicate of PoolController#show,
diff --git a/src/app/views/dashboard/summary.haml
b/src/app/views/dashboard/summary.haml
index 4eeb58b..b64ffb5 100644
--- a/src/app/views/dashboard/summary.haml
+++ b/src/app/views/dashboard/summary.haml
@@ -38,6 +38,8 @@
Create a Template
%a{:href => url_for(:controller => "users", :action => "new")}
Create a User
+ %a{:href => url_for(:controller => "instance", :action => "index")}
+ View Instances
- else
%a{:href => url_for(:controller => "", :action => "")}
Launch Instances
diff --git a/src/app/views/instance/_list.html.erb
b/src/app/views/instance/_list.html.erb
new file mode 100644
index 0000000..66f6eeb
--- /dev/null
+++ b/src/app/views/instance/_list.html.erb
@@ -0,0 +1,24 @@
+<% if @instances.size == 0 %>
+<h1>There are no instances to display</h1>
+<% else %>
+ <table>
+ <thead>
+ <tr>
+ <th scope="col">Name</th>
+ <th scope="col">Pool</th>
+ <th scope="col">Hardware Profile</th>
+ <th scope="col">Image</th>
+ </tr>
+ </thead>
+ <tbody>
+ <%[email protected] {|instance| %>
+ <tr>
+ <td><%= instance.name %></td>
+ <td><%= instance.pool.name if instance.pool %></td>
+ <td><%= instance.hardware_profile.name if instance.hardware_profile
%></td>
+ <td><%= instance.image if instance.image %></td>
+ </tr>
+ <% } %>
+ </tbody>
+ </table>
+<% end %>
diff --git a/src/app/views/instance/index.html.erb
b/src/app/views/instance/index.html.erb
index a632f6c..c19c3fa 100644
--- a/src/app/views/instance/index.html.erb
+++ b/src/app/views/instance/index.html.erb
@@ -1,2 +1 @@
-<h1>Instance#index</h1>
-<p>Find me in app/views/instance/index.html.erb</p>
+<%= render :partial => 'list' %>
--
1.6.2.5
_______________________________________________
deltacloud-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/deltacloud-devel