summaryrefslogtreecommitdiff
path: root/app/views
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2015-02-03 21:30:13 -0700
committermo khan <mo@mokhan.ca>2015-02-03 21:30:13 -0700
commit2085d8aecbfb095bbf9989a56dd74dc89f1d2a3e (patch)
tree45ab2811e6eb29364dfb526e21727735bbd7e11b /app/views
parentbab5e66e261774700eb3ad515eb929fc85991a69 (diff)
add association from agents to events.
Diffstat (limited to 'app/views')
-rw-r--r--app/views/agents/_form.html.erb21
-rw-r--r--app/views/agents/edit.html.erb6
-rw-r--r--app/views/agents/index.html.erb28
-rw-r--r--app/views/agents/index.json.jbuilder4
-rw-r--r--app/views/agents/new.html.erb5
-rw-r--r--app/views/agents/show.html.erb9
-rw-r--r--app/views/agents/show.json.jbuilder1
-rw-r--r--app/views/events/_form.html.erb2
-rw-r--r--app/views/events/index.html.erb4
-rw-r--r--app/views/events/new.html.erb2
10 files changed, 78 insertions, 4 deletions
diff --git a/app/views/agents/_form.html.erb b/app/views/agents/_form.html.erb
new file mode 100644
index 0000000..fe9d10e
--- /dev/null
+++ b/app/views/agents/_form.html.erb
@@ -0,0 +1,21 @@
+<%= form_for(@agent) do |f| %>
+ <% if @agent.errors.any? %>
+ <div id="error_explanation">
+ <h2><%= pluralize(@agent.errors.count, "error") %> prohibited this agent from being saved:</h2>
+
+ <ul>
+ <% @agent.errors.full_messages.each do |message| %>
+ <li><%= message %></li>
+ <% end %>
+ </ul>
+ </div>
+ <% end %>
+
+ <div class="field">
+ <%= f.label :hostname %><br>
+ <%= f.text_field :hostname %>
+ </div>
+ <div class="actions">
+ <%= f.submit %>
+ </div>
+<% end %>
diff --git a/app/views/agents/edit.html.erb b/app/views/agents/edit.html.erb
new file mode 100644
index 0000000..bed9b23
--- /dev/null
+++ b/app/views/agents/edit.html.erb
@@ -0,0 +1,6 @@
+<h1>Editing Agent</h1>
+
+<%= render 'form' %>
+
+<%= link_to 'Show', @agent %> |
+<%= link_to 'Back', agents_path %>
diff --git a/app/views/agents/index.html.erb b/app/views/agents/index.html.erb
new file mode 100644
index 0000000..48a36e2
--- /dev/null
+++ b/app/views/agents/index.html.erb
@@ -0,0 +1,28 @@
+<p id="notice"><%= notice %></p>
+
+<h1>Listing Agents</h1>
+
+<table>
+ <thead>
+ <tr>
+ <th>Hostname</th>
+ <th colspan="4"></th>
+ </tr>
+ </thead>
+
+ <tbody>
+ <% @agents.each do |agent| %>
+ <tr>
+ <td><%= agent.hostname %></td>
+ <td><%= link_to 'Events', agent_events_path(agent) %></td>
+ <td><%= link_to 'Show', agent %></td>
+ <td><%= link_to 'Edit', edit_agent_path(agent) %></td>
+ <td><%= link_to 'Destroy', agent, method: :delete, data: { confirm: 'Are you sure?' } %></td>
+ </tr>
+ <% end %>
+ </tbody>
+</table>
+
+<br>
+
+<%= link_to 'New Agent', new_agent_path %>
diff --git a/app/views/agents/index.json.jbuilder b/app/views/agents/index.json.jbuilder
new file mode 100644
index 0000000..65f6f60
--- /dev/null
+++ b/app/views/agents/index.json.jbuilder
@@ -0,0 +1,4 @@
+json.array!(@agents) do |agent|
+ json.extract! agent, :id, :hostname
+ json.url agent_url(agent, format: :json)
+end
diff --git a/app/views/agents/new.html.erb b/app/views/agents/new.html.erb
new file mode 100644
index 0000000..782236f
--- /dev/null
+++ b/app/views/agents/new.html.erb
@@ -0,0 +1,5 @@
+<h1>New Agent</h1>
+
+<%= render 'form' %>
+
+<%= link_to 'Back', agents_path %>
diff --git a/app/views/agents/show.html.erb b/app/views/agents/show.html.erb
new file mode 100644
index 0000000..0e7a061
--- /dev/null
+++ b/app/views/agents/show.html.erb
@@ -0,0 +1,9 @@
+<p id="notice"><%= notice %></p>
+
+<p>
+ <strong>Hostname:</strong>
+ <%= @agent.hostname %>
+</p>
+
+<%= link_to 'Edit', edit_agent_path(@agent) %> |
+<%= link_to 'Back', agents_path %>
diff --git a/app/views/agents/show.json.jbuilder b/app/views/agents/show.json.jbuilder
new file mode 100644
index 0000000..f156cb0
--- /dev/null
+++ b/app/views/agents/show.json.jbuilder
@@ -0,0 +1 @@
+json.extract! @agent, :id, :hostname, :created_at, :updated_at
diff --git a/app/views/events/_form.html.erb b/app/views/events/_form.html.erb
index a803510..2215f6c 100644
--- a/app/views/events/_form.html.erb
+++ b/app/views/events/_form.html.erb
@@ -1,4 +1,4 @@
-<%= form_for(@event) do |f| %>
+<%= form_for([@agent, @event]) do |f| %>
<% if @event.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@event.errors.count, "error") %> prohibited this event from being saved:</h2>
diff --git a/app/views/events/index.html.erb b/app/views/events/index.html.erb
index 02fb2cb..bf0480c 100644
--- a/app/views/events/index.html.erb
+++ b/app/views/events/index.html.erb
@@ -18,7 +18,7 @@
<td><%= event.name %></td>
<td><%= event.data %></td>
<td><%= event.created_at %></td>
- <td><%= link_to 'Destroy', event, method: :delete, data: { confirm: 'Are you sure?' } %></td>
+ <td><%= link_to 'Destroy', [@agent, event], method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
@@ -26,4 +26,4 @@
<br>
-<%= link_to 'New Event', new_event_path %>
+<%= link_to 'New Event', new_agent_event_path(@agent) %>
diff --git a/app/views/events/new.html.erb b/app/views/events/new.html.erb
index 86707c1..1c0b206 100644
--- a/app/views/events/new.html.erb
+++ b/app/views/events/new.html.erb
@@ -2,4 +2,4 @@
<%= render 'form' %>
-<%= link_to 'Back', events_path %>
+<%= link_to 'Back', agent_events_path(@agent) %>