Skip to content

Commit

Permalink
Features:
Browse files Browse the repository at this point in the history
* Add correct delete, edit and show buttons to database instance page
* Implement database instance delete view and change destroy action to allow cancel
* Change sort for database instances to sort by environment, alias
  • Loading branch information
Joakim Bodin committed Mar 12, 2009
1 parent 3ef4854 commit ffb366e
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 10 deletions.
25 changes: 21 additions & 4 deletions app/controllers/db_instances_controller.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class DbInstancesController < ApplicationController
# GET /db_instances # GET /db_instances
# GET /db_instances.xml # GET /db_instances.xml
def index def index
@db_instances = DbInstance.all(:order => 'db_env ASC') @db_instances = DbInstance.all(:order => 'db_env, db_alias ASC')


respond_to do |format| respond_to do |format|
format.html # index.html.erb format.html # index.html.erb
Expand Down Expand Up @@ -71,15 +71,32 @@ def update
end end
end end


# GET /db_instances/1/delete
def delete
@db_instance = DbInstance.find(params[:id])
end

# DELETE /db_instances/1 # DELETE /db_instances/1
# DELETE /db_instances/1.xml # DELETE /db_instances/1.xml
def destroy def destroy
@db_instance = DbInstance.find(params[:id]) @db_instance = DbInstance.find(params[:id])
@db_instance.destroy
if params[:db_instance_delete_cancel]
redirect_to db_instances_path
return
end


respond_to do |format| respond_to do |format|
format.html { redirect_to(db_instances_url) } if @db_instance.destroy
format.xml { head :ok } format.html do
flash[:notice] = "Database Instance '#{@db_instance}' successfully deleted"
redirect_to db_instances_path
end
format.xml { head :ok }
else
format.html { render :action => 'delete' }
format.xml { render :xml => @db_instance.errors, :status => :unprocessable_entity }
end
end end
end end


Expand Down
32 changes: 32 additions & 0 deletions app/views/db_instances/delete.html.erb
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,32 @@
<fieldset>
<legend>Delete Database Instance</legend>

<h3>Are you sure you want to delete this Database Instance?</h3>
<hr class="space" />

<table>
<thead>
<tr>
<th>Alias</th>
<th>Host</th>
<th>Port</th>
<th>Environment</th>
<th>Type</th>
</tr>
</thead>

<tr class="db_instance <%=h @db_instance.db_env %>">
<td><%=h @db_instance.db_alias %></td>
<td><%=h @db_instance.host %></td>
<td><%=h @db_instance.port %></td>
<td><%=h @db_instance.db_env %></td>
<td><%=h @db_instance.db_type %></td>
</tr>
</table>

<% form_for(@db_instance, :url => db_instance_path(@db_instance), :html => {:method => :delete}) do |f| %>
<%= render :partial => 'shared/form_error', :locals => {:f => f} %>
<%= f.submit 'Delete Database Instance' %>
<%= f.submit 'Cancel', :id => 'db_instance_delete_cancel', :name => 'db_instance_delete_cancel' %>
<% end %>
</fieldset>
12 changes: 8 additions & 4 deletions app/views/db_instances/index.html.erb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<th>Port</th> <th>Port</th>
<th>Environment</th> <th>Environment</th>
<th>Type</th> <th>Type</th>
<th colspan="3">Actions</th> <th>Actions</th>
</tr> </tr>
</thead> </thead>


Expand All @@ -17,9 +17,13 @@
<td><%=h db_instance.port %></td> <td><%=h db_instance.port %></td>
<td><%=h db_instance.db_env %></td> <td><%=h db_instance.db_env %></td>
<td><%=h db_instance.db_type %></td> <td><%=h db_instance.db_type %></td>
<td><%= link_to 'Show', db_instance %></td> <td>
<td><%= link_to 'Edit', edit_db_instance_path(db_instance) %></td> <ul class="actions">
<td><%= link_to 'Delete', db_instance, {:confirm => 'Are you sure?', :method => :delete} %></td> <li class="destroy"><%= link_to 'Delete', delete_db_instance_path(db_instance) %></li>
<li><%= link_to 'Show', db_instance_path(db_instance) %></li>
<li><%= link_to 'Edit', edit_db_instance_path(db_instance) %></li>
</ul>
</td>
</tr> </tr>
<% end %> <% end %>
<tr> <tr>
Expand Down
2 changes: 1 addition & 1 deletion config/config.yml
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,5 @@
common: common:
release_version: 1.2.9.3 release_version: 1.2.9.4
release_name: 'Hot Shots' release_name: 'Hot Shots'
vc_type: 'svn' vc_type: 'svn'
vc_uri: '' vc_uri: ''
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,5 @@
ActionController::Routing::Routes.draw do |map| ActionController::Routing::Routes.draw do |map|
map.resources :db_instances map.resources :db_instances, :member => {:delete => :get}


map.resources :apps, :except => [:destroy] do |apps| map.resources :apps, :except => [:destroy] do |apps|
apps.resources :activities, :except => [:destroy] do |activities| apps.resources :activities, :except => [:destroy] do |activities|
Expand Down
File renamed without changes.
7 changes: 7 additions & 0 deletions public/stylesheets/db_instances/delete.css
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,7 @@
fieldset {
border: 1px solid #AB3E1D;
}

fieldset legend {
color: #AB3E1D;
}

0 comments on commit ffb366e

Please sign in to comment.