-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Paul Kelly
committed
Oct 8, 2010
1 parent
ba09fed
commit 77311f8
Showing
6 changed files
with
94 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,41 @@ | ||
class NetdbsController < ApplicationController | ||
layout 'standard' | ||
def index | ||
@search = Netdb.search params[:search] | ||
@netdbs = @search.paginate(:page => params[:page]) | ||
end | ||
|
||
def new | ||
@netdb = Netdb.new | ||
end | ||
|
||
def create | ||
@netdb = Netdb.new(params[:netdb]) | ||
if @netdb.save | ||
flash[:foreman_notice] = "Successfully created network database" | ||
redirect_to netdbs_url | ||
else | ||
render :action => 'new' | ||
end | ||
end | ||
|
||
def edit | ||
@netdb = Netdb.find(params[:id]) | ||
end | ||
|
||
active_scaffold :netdb do |config| | ||
config.label = "Network Database" | ||
config.actions = [:list,:delete, :search, :create, :show, :update] | ||
config.columns = [:name, :address, :vendor, :servertype] | ||
columns[:servertype].label = "Service" | ||
list.sorting = {:name => 'ASC' } | ||
config.columns[:vendor].form_ui = :select | ||
config.columns[:servertype].form_ui = :select | ||
def update | ||
@netdb = Netdb.find(params[:id]) | ||
if @netdb.update_attributes(params[:netdb]) | ||
flash[:foreman_notice] = "Successfully updated network database" | ||
redirect_to netdbs_url | ||
else | ||
render :action => 'edit' | ||
end | ||
end | ||
|
||
# Deletes require a page update so as to show error messsages | ||
config.delete.link.inline = false | ||
def destroy | ||
@netdb = Netdb.find(params[:id]) | ||
@netdb.destroy | ||
flash[:foreman_notice] = "Successfully destroyed network database" | ||
redirect_to netdbs_url | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<% form_for @netdb do |f| %> | ||
<%= f.error_messages %> | ||
<p> | ||
<%= f.label :name %><br /> | ||
<%= f.text_field :name %> | ||
</p> | ||
<p> | ||
<%= f.label :address %><br /> | ||
<%= f.text_field :address %> | ||
</p> | ||
<p> | ||
<%= f.label :vendor %><br /> | ||
<%= f.collection_select :vendor_id, Vendor.all, :id, :name %> | ||
</p> | ||
<p> | ||
<%= f.label :servertype %><br /> | ||
<%= f.collection_select :servertype_id, Servertype.all, :id, :name %> | ||
</p> | ||
<p><%= f.submit "Submit" %></p> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<% title "Edit network database" %> | ||
|
||
<%= render :partial => 'form' %> | ||
|
||
<p><%= link_to "View all network databases", netdbs_path %></p> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<% title "Network databases" %> | ||
|
||
<table class="list"> | ||
<tr> | ||
<th>Name</th> | ||
<th>Address</th> | ||
<th>Vendor</th> | ||
<th>Service</th> | ||
<th></th> | ||
</tr> | ||
<% for netdb in @netdbs %> | ||
<tr class="<%= cycle("even", "odd") -%>"> | ||
<td><%=link_to h(netdb.name), edit_netdb_path(netdb)%></td> | ||
<td><%=netdb.address%></td> | ||
<td><%=netdb.vendor.name%></td> | ||
<td><%=netdb.servertype.name%></td> | ||
<td align="right"> | ||
<%= link_to "Destroy", netdb, :confirm => "Delete #{netdb.name}?", :method => :delete %> | ||
</td> | ||
</tr> | ||
<% end %> | ||
</table> | ||
<%= page_entries_info @netdbs %> | ||
<%= will_paginate @netdbs %> | ||
|
||
<p><%= link_to "New network database", new_netdb_path %></p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<% title "New Subnet" %> | ||
|
||
<%= render :partial => 'form' %> | ||
|
||
<p><%= link_to "Back to List", subnets_path %></p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
ActionController::Routing::Routes.draw do |map| | ||
map.resources :subnets | ||
map.resources :netdbs | ||
end |