Commit 3371919
Changed files (8)
app
assets
javascripts
stylesheets
controllers
agents
helpers
views
agents
config
app/assets/javascripts/files.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://coffeescript.org/
app/assets/stylesheets/files.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the files controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
app/controllers/agents/files_controller.rb
@@ -0,0 +1,25 @@
+module Agents
+ class FilesController < ApplicationController
+ before_action :load_agent
+ before_action do
+ request.format = :json
+ end
+
+ def index
+ end
+
+ def show
+ @file = Disposition.find_by(fingerprint: params[:id])
+ Publisher.publish("queries", {
+ fingerprint: params[:id],
+ data: params
+ })
+ end
+
+ private
+
+ def load_agent
+ Agent.find(params[:agent_id])
+ end
+ end
+end
app/helpers/files_helper.rb
@@ -0,0 +1,2 @@
+module FilesHelper
+end
app/views/agents/files/index.json.jbuilder
@@ -0,0 +1,4 @@
+json.array!(@files) do |file|
+ json.extract! agent, :fingerprint, :state
+ json.url agent_file_url([agent, file], format: :json)
+end
app/views/agents/files/show.json.jbuilder
@@ -0,0 +1,3 @@
+if @file
+ json.extract! @file, :fingerprint, :state
+end
app/views/agents/index.html.erb
@@ -9,7 +9,7 @@
<thead>
<tr>
<th>Hostname</th>
- <th colspan="4"></th>
+ <th colspan="5"></th>
</tr>
</thead>
<tbody>
@@ -17,6 +17,7 @@
<tr>
<td><%= agent.hostname %></td>
<td><%= link_to 'Events', agent_events_path(agent) %></td>
+ <td><%= link_to 'Files', agent_files_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>
config/routes.rb
@@ -1,6 +1,7 @@
Rails.application.routes.draw do
resources :agents do
resources :events, only: [:index, :new, :create, :destroy], controller: 'agents/events'
+ resources :files, only: [:index, :show], controller: 'agents/files'
end
resources :dispositions