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> + <%@instances.each {|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' %>
ACK with a caveat inline.
Also, it would be great if it looked and behaved the same way as the pool-specific instance table does now (using the DataTables jquery thingy).
But that can be in another patch and I'm not sure how important it is for now.
Thomas
----- Original Message ----- From: "Mohammed Morsi" mmorsi@redhat.com To: deltacloud-devel@lists.fedorahosted.org Sent: Wednesday, June 2, 2010 9:00:14 PM GMT +01:00 Amsterdam / Berlin / Bern / Rome / Stockholm / Vienna Subject: [deltacloud-devel] [PATCH aggregator] instances index/list view and backend
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> + <%@instances.each {|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>
This outputs something like: #Image:0xb6656808 to the webpage instead of the real image name (e.g. Fedora 10).
+ </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' %>
Tomas Sedovic wrote:
ACK with a caveat inline.
Also, it would be great if it looked and behaved the same way as the pool-specific instance table does now (using the DataTables jquery thingy).
But that can be in another patch and I'm not sure how important it is for now.
Thomas
Actually we probably do want it using the same jquery bits for now, if possible.
Scott
----- Original Message ----- From: "Mohammed Morsi" mmorsi@redhat.com To: deltacloud-devel@lists.fedorahosted.org Sent: Wednesday, June 2, 2010 9:00:14 PM GMT +01:00 Amsterdam / Berlin / Bern / Rome / Stockholm / Vienna Subject: [deltacloud-devel] [PATCH aggregator] instances index/list view and backend
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>
- <%@instances.each {|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>
This outputs something like: #Image:0xb6656808 to the webpage instead of the real image name (e.g. Fedora 10).
</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' %>
On 06/03/2010 02:39 PM, Scott Seago wrote:
Tomas Sedovic wrote:
ACK with a caveat inline.
Also, it would be great if it looked and behaved the same way as the pool-specific instance table does now (using the DataTables jquery thingy).
But that can be in another patch and I'm not sure how important it is for now.
Thomas
Actually we probably do want it using the same jquery bits for now, if possible.
Scott
Sent an updated patch, with the following changes / caveats:
- the DataTables plugin is now used, albeit after much hacking I was unable to get it to populate correctly. Something is going wrong in the DataTables paginated callback which I'm unfamiliar with
- I added the 'PermissionedObject' module to the instance model, which gives us a working Instance.list_by_user(current_user) method. The problem is, is in the DataTable instance query conditions, I'm not sure how to (or even if I can) make use of the list_by_user method (look for the fixme in the patch)
- I didn't expand the Instance::COLUMNS field to include provider / account as it is being used elsewhere and could cause breakage, though the image column should now display the name correctly as that functionality should already be working.
Most likely the current issues are small and can be resolved quickly on IRC tonight/tommorow.
-Mo
On Thu, 2010-06-03 at 16:58 -0400, Mohammed Morsi wrote:
On 06/03/2010 02:39 PM, Scott Seago wrote:
Tomas Sedovic wrote:
ACK with a caveat inline.
Also, it would be great if it looked and behaved the same way as the pool-specific instance table does now (using the DataTables jquery thingy).
But that can be in another patch and I'm not sure how important it is for now.
Thomas
Actually we probably do want it using the same jquery bits for now, if possible.
Scott
Sent an updated patch, with the following changes / caveats:
- the DataTables plugin is now used, albeit after much hacking I was
unable to get it to populate correctly. Something is going wrong in the DataTables paginated callback which I'm unfamiliar with
I'm not sure if this is what you mean, but I noticed that the Actions column is empty. In the poll-specific lists it contains the links to the Reboot|Stop / Start|Destroy actions.
Is it possible to add that to the patch? I'll ACK this if it's not (better than what we have now) but it would be great to have the lists behave the same.
Thomas
- I added the 'PermissionedObject' module to the instance model,
which gives us a working Instance.list_by_user(current_user) method. The problem is, is in the DataTable instance query conditions, I'm not sure how to (or even if I can) make use of the list_by_user method (look for the fixme in the patch)
- I didn't expand the Instance::COLUMNS field to include provider /
account as it is being used elsewhere and could cause breakage, though the image column should now display the name correctly as that functionality should already be working.
Most likely the current issues are small and can be resolved quickly on IRC tonight/tommorow.
-Mo
deltacloud-devel@lists.fedorahosted.org