Got macs working
This commit is contained in:
parent
998558cd30
commit
04764af983
|
@ -5,7 +5,10 @@ require "optparse"
|
|||
#require "rubygems"
|
||||
|
||||
def index
|
||||
@macs = Mac.all
|
||||
@active_macs = Mac.where(:active => true, :hidden => false)
|
||||
@active_macs += Mac.where(:active => true, :hidden => nil)
|
||||
@hidden_macs = Mac.where(:active => true, :hidden => true)
|
||||
@inactive_macs = Mac.where(:active => false)
|
||||
end
|
||||
|
||||
# GET /macs/1
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class Mac < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
attr_accessible :active, :ip, :mac, :refreshed, :since, :user_id
|
||||
attr_accessible :active, :ip, :mac, :refreshed, :since, :hidden, :note, :user_id
|
||||
end
|
||||
|
|
|
@ -13,12 +13,20 @@
|
|||
|
||||
<div class="field">
|
||||
<%= f.label :user_id, "User" %><br />
|
||||
<%= collection_select(:mac, :user_id, @users, :id, :name) %>
|
||||
<%= collection_select(:mac, :user_id, @users, :id, :name, :include_blank => true) %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :mac, "Mac" %><br />
|
||||
<%= f.label :mac %><br />
|
||||
<%= f.text_field :mac %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :note %><br />
|
||||
<%= f.text_field :note %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :hidden %><br />
|
||||
<%= f.check_box :hidden %>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<%= f.submit %>
|
||||
</div>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<h2>What machines are on our network?</h2>
|
||||
<% @macs.each do |mac| %>
|
||||
<% @active_macs.each do |mac| %>
|
||||
<%= mac.user.name unless mac.user.blank? %>
|
||||
<%= mac.mac if mac.user.blank? %> <!--
|
||||
<%= mac.since %>,
|
||||
|
@ -7,3 +7,23 @@
|
|||
<%= mac.active %>--> |
|
||||
<%= link_to 'Edit', edit_mac_path(mac) %> <br/>
|
||||
<% end %>
|
||||
<hr>
|
||||
<% @hidden_macs.each do |mac| %>
|
||||
<%= mac.user.name unless mac.user.blank? %>
|
||||
<%= mac.mac if mac.user.blank? %>
|
||||
(<%= mac.note %>) <!--
|
||||
<%= mac.since %>,
|
||||
<%= mac.refreshed %>,
|
||||
<%= mac.active %>--> |
|
||||
<%= link_to 'Edit', edit_mac_path(mac) %> <br/>
|
||||
<% end %>
|
||||
<hr>
|
||||
<% @inactive_macs.each do |mac| %>
|
||||
<%= mac.user.name unless mac.user.blank? %>
|
||||
<%= mac.mac if mac.user.blank? %>
|
||||
(<%= mac.note %>) <!--
|
||||
<%= mac.since %>,
|
||||
<%= mac.refreshed %>,
|
||||
<%= mac.active %>--> |
|
||||
<%= link_to 'Edit', edit_mac_path(mac) %> <br/>
|
||||
<% end %>
|
||||
|
|
|
@ -8,5 +8,20 @@
|
|||
<%= @mac.mac %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Note:</b>
|
||||
<%= @mac.note %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Hidden:</b>
|
||||
<%= @mac.hidden %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>IP:</b>
|
||||
<%= @mac.ip %>
|
||||
</p>
|
||||
|
||||
<%= link_to 'Edit', edit_mac_path(@mac) %> |
|
||||
<%= link_to 'Back', macs_path %>
|
||||
|
|
6
db/migrate/20130201042646_add_properties_to_macs.rb
Normal file
6
db/migrate/20130201042646_add_properties_to_macs.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
class AddPropertiesToMacs < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :macs, :hidden, :boolean
|
||||
add_column :macs, :note, :string
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20130201022153) do
|
||||
ActiveRecord::Schema.define(:version => 20130201042646) do
|
||||
|
||||
create_table "cards", :force => true do |t|
|
||||
t.string "card_number"
|
||||
|
@ -52,6 +52,8 @@ ActiveRecord::Schema.define(:version => 20130201022153) do
|
|||
t.boolean "active"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.boolean "hidden"
|
||||
t.string "note"
|
||||
end
|
||||
|
||||
add_index "macs", ["user_id"], :name => "index_macs_on_user_id"
|
||||
|
|
Loading…
Reference in New Issue
Block a user