---
src/app/controllers/portal_pool_controller.rb | 12 +++++++++++
src/app/views/portal_pool/accounts.html.erb | 27 +++++++++++++++++++++++-
src/public/stylesheets/dcloud.css | 4 +++
3 files changed, 41 insertions(+), 2 deletions(-)
diff --git a/src/app/controllers/portal_pool_controller.rb b/src/app/controllers/portal_pool_controller.rb
index ff1df67..5e5ec5e 100644
--- a/src/app/controllers/portal_pool_controller.rb
+++ b/src/app/controllers/portal_pool_controller.rb
@@ -36,6 +36,18 @@ class PortalPoolController < ApplicationController
@pool = PortalPool.find(params[:id])
end
+ def remove_accounts
+ pool_id = params[:id]
+ cloud_accounts = params[:cloud_account_ids]
+
+ unless pool_id.nil? || cloud_accounts.nil? || cloud_accounts.size < 1
+ cloud_accounts = cloud_accounts.join(',')
+ PoolAccount.delete_all(["portal_pool_id = ? AND cloud_account_id IN (#{cloud_accounts})", pool_id])
+ end
+
+ redirect_to :action => 'accounts'
+ end
+
def new
@portal_pool = PortalPool.new
@account = CloudAccount.new
diff --git a/src/app/views/portal_pool/accounts.html.erb b/src/app/views/portal_pool/accounts.html.erb
index b02b124..c7871cf 100644
--- a/src/app/views/portal_pool/accounts.html.erb
+++ b/src/app/views/portal_pool/accounts.html.erb
@@ -1,9 +1,10 @@
<% if @pool.cloud_accounts.size == 0 %>
<h1>There are no accounts to display</h1>
<% else %>
- <table>
+ <table id="pool_accounts">
<thead>
<tr>
+ <th/>
<th scope="col">Provider</th>
<th scope="col">Username</th>
</tr>
@@ -11,6 +12,7 @@
<tbody>
<%(a)pool.cloud_accounts.each {|account| %>
<tr>
+ <td><input type="checkbox" id="cloud_account_<%=account.id%>" class="cloud_account_id" /></td>
<td><%= account.provider.name %></td>
<td><%= account.username %></td>
</tr>
@@ -18,4 +20,25 @@
</tbody>
</table>
<% end %>
-<%= link_to "Add an account", {:controller => "cloud_account", :action => "new", :pools => [@pool.id]}, :class => "actionlink" %>
+<%= link_to "Add an account", {}, :id => 'add_account_link', :class => 'actionlink' %>
+<%= link_to "Remove Accounts", {}, :id => 'remove_account_link', :class => 'actionlink' %>
+
+
+<script type="text/javascript">
+ $('#add_account_link').bind('click', function(e){
+ });
+
+ $('#remove_account_link').bind('click', function(e){
+ c = confirm("remove account?");
+ if(c){
+ cloud_account_ids = new Array();
+ $('.cloud_account_id:checked').each(function(index){
+ cloud_account_ids[index] = this.id.substring(14, this.id.length);
+ });
+ $.post("<%= url_for :action => 'remove_accounts' %>", {'id' : '<%= @pool.id %>', 'cloud_account_ids[]' : cloud_account_ids});
+ return true;
+ }
+ return false;
+ });
+</script>
+
diff --git a/src/public/stylesheets/dcloud.css b/src/public/stylesheets/dcloud.css
index e2f47aa..95edf5f 100644
--- a/src/public/stylesheets/dcloud.css
+++ b/src/public/stylesheets/dcloud.css
@@ -264,3 +264,7 @@ ul#providers li ul li a:hover {
.instance_action_list li.first {
border-left: none;
}
+
+#pool_accounts th:first-child {
+ width: 20px;
+}
--
1.6.2.5