diff options
| -rw-r--r-- | app/assets/javascripts/files.coffee | 3 | ||||
| -rw-r--r-- | app/assets/stylesheets/files.scss | 3 | ||||
| -rw-r--r-- | app/controllers/agents/files_controller.rb | 25 | ||||
| -rw-r--r-- | app/helpers/files_helper.rb | 2 | ||||
| -rw-r--r-- | app/views/agents/files/index.json.jbuilder | 4 | ||||
| -rw-r--r-- | app/views/agents/files/show.json.jbuilder | 3 | ||||
| -rw-r--r-- | app/views/agents/index.html.erb | 3 | ||||
| -rw-r--r-- | config/routes.rb | 1 |
8 files changed, 43 insertions, 1 deletions
diff --git a/app/assets/javascripts/files.coffee b/app/assets/javascripts/files.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/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/ diff --git a/app/assets/stylesheets/files.scss b/app/assets/stylesheets/files.scss new file mode 100644 index 0000000..febd8a7 --- /dev/null +++ b/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/ diff --git a/app/controllers/agents/files_controller.rb b/app/controllers/agents/files_controller.rb new file mode 100644 index 0000000..9afd766 --- /dev/null +++ b/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 diff --git a/app/helpers/files_helper.rb b/app/helpers/files_helper.rb new file mode 100644 index 0000000..e9da4f6 --- /dev/null +++ b/app/helpers/files_helper.rb @@ -0,0 +1,2 @@ +module FilesHelper +end diff --git a/app/views/agents/files/index.json.jbuilder b/app/views/agents/files/index.json.jbuilder new file mode 100644 index 0000000..6551a44 --- /dev/null +++ b/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 diff --git a/app/views/agents/files/show.json.jbuilder b/app/views/agents/files/show.json.jbuilder new file mode 100644 index 0000000..88011e6 --- /dev/null +++ b/app/views/agents/files/show.json.jbuilder @@ -0,0 +1,3 @@ +if @file + json.extract! @file, :fingerprint, :state +end diff --git a/app/views/agents/index.html.erb b/app/views/agents/index.html.erb index 3a6b738..a1021ed 100644 --- a/app/views/agents/index.html.erb +++ b/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> diff --git a/config/routes.rb b/config/routes.rb index eeddcac..ae0a4cb 100644 --- a/config/routes.rb +++ b/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 |
