diff --git a/app/controllers/admin/base_controller.rb b/app/controllers/admin/base_controller.rb index 051c184..f4276de 100644 --- a/app/controllers/admin/base_controller.rb +++ b/app/controllers/admin/base_controller.rb @@ -1,31 +1,36 @@ class Admin::BaseController < ApplicationController before_action :require_admin, except: [:login] # GET /admin # POST /admin def index @client_ids = Client.pluck(:ClientId) get_charts @global_stats = GlobalStats.new.stats + + @jobs = Job.includes(:file_set, :logs, :client). + where('EndTime > ?', days_ago.days.ago). + order(EndTime: :desc) + render 'admin/index' end # GET /admin/login def login render 'admin/login' end protected def get_charts @job_status = ChartGenerator.job_statuses(@client_ids, days_ago) @job_stats = ChartGenerator.job_stats(@client_ids, days_ago - 1) end def require_admin return if current_user.try(:has_admin_access?) flash[:alert] = 'You need to log in first' redirect_to admin_login_path end end diff --git a/app/views/admin/index.html.erb b/app/views/admin/index.html.erb index b1f74d3..cc42608 100644 --- a/app/views/admin/index.html.erb +++ b/app/views/admin/index.html.erb @@ -1,12 +1,14 @@ <div class="row"> <div class="col-xs-4 text-right right"> <%= bootstrap_form_tag(url: admin_path, method: :post, layout: :inline) do |f| %> <%= f.select(:days_back, [['1 week', 7], ['2 weeks', 14], ['1 month', 30]], selected: params[:days_back]) %> <%= f.submit 'See Stats', class: "btn btn-primary" %> <% end %> </div> </div> <br /> <%= render partial: 'clients/client_graphs', locals: { path: admin_path } %> + +<%= render partial: 'admin/jobs/jobs' %> diff --git a/app/views/admin/jobs/_jobs.html.erb b/app/views/admin/jobs/_jobs.html.erb new file mode 100644 index 0000000..83b8838 --- /dev/null +++ b/app/views/admin/jobs/_jobs.html.erb @@ -0,0 +1,9 @@ +<div class="row"> + <div class="col-xs-6"> + <h3>Recent Jobs <small>(<%= @jobs.count %>)</small></h3> + </div> +</div> + +<div class="row"> + <%= render partial: 'admin/jobs/recent_jobs' %> +</div> diff --git a/app/views/admin/jobs/_recent_job.html.erb b/app/views/admin/jobs/_recent_job.html.erb new file mode 100644 index 0000000..bac4d3c --- /dev/null +++ b/app/views/admin/jobs/_recent_job.html.erb @@ -0,0 +1,15 @@ +<tr class="<%= success_class(recent_job.job_status) %>"> + <td><%= recent_job.name %></td> + <td><%= recent_job.client.name %></td> + <td><%= recent_job.job_id %></td> + <td><%= recent_job.level_human %></td> + <td><%= recent_job.fileset %></td> + <td><%= recent_job.start_time_formatted %></td> + <td><%= recent_job.end_time_formatted %></td> + <td><%= recent_job.duration %></td> + <td><%= number_to_human_size(recent_job.job_bytes) %></td> + <td><%= number_by_magnitude(recent_job.job_files) %></td> + <td><%= recent_job.status_human %></td> + <td><%= recent_job.encryption %></td> + <td><%= recent_job.compression %></td> +</tr> diff --git a/app/views/admin/jobs/_recent_jobs.html.erb b/app/views/admin/jobs/_recent_jobs.html.erb new file mode 100644 index 0000000..07df9d7 --- /dev/null +++ b/app/views/admin/jobs/_recent_jobs.html.erb @@ -0,0 +1,26 @@ +<div class="col-xs-12"> + <div class="table-responsive"> + <table class="table table-striped table-bordered table-condensed"> + <thead> + <tr> + <th>Name</th> + <th>Client</th> + <th>JobId</th> + <th>Level</th> + <th>Fileset</th> + <th>Started At</th> + <th>Finished At</th> + <th>Duration</th> + <th>Bytes</th> + <th>Files</th> + <th>Status</th> + <th>Encryption</th> + <th>Compression</th> + </tr> + </thead> + <tbody> + <%= render partial: 'admin/jobs/recent_job', collection: @jobs %> + </tbody> + </table> + </div> +</div>