diff --git a/app/controllers/admin/clients_controller.rb b/app/controllers/admin/clients_controller.rb
index 9d8ce6e..3d9ccfa 100644
--- a/app/controllers/admin/clients_controller.rb
+++ b/app/controllers/admin/clients_controller.rb
@@ -1,38 +1,51 @@
class Admin::ClientsController < Admin::BaseController
- before_action :fetch_client, only: [:show]
+ before_action :fetch_client, only: [:show, :jobs, :logs, :stats]
+ before_action :fetch_logs, only: [:logs]
# Shows all available clients
#
# GET /admin/clients
def index
@clients = Client.includes(:jobs).all
@client_ids = @clients.map(&:id)
fetch_jobs_info
end
# Shows a specific client
#
# GET /admin/clients/1
def show
- @client_ids = [@client.id]
- get_logs
+ get_charts
+ end
+
+ # GET /admin/clients/1/jobs
+ def jobs; end
+
+ # GET /admin/clients/1/logs
+ def logs
+ end
+
+ # GET /admin/clients/1/stats
+ # POST /admin/clients/1/stats
+ def stats
get_charts
end
private
# Fetches the client based on the given id
def fetch_client
@client = Client.find(params[:id])
+ @client_ids = [@client.id]
end
def fetch_jobs_info
@stats = JobStats.new
end
def get_charts
days_ago = params.fetch(:days_back, 7).to_i rescue 7
@job_status = ChartGenerator.job_statuses(@client_ids, days_ago)
@job_stats = ChartGenerator.job_stats(@client_ids, days_ago - 1)
end
end
diff --git a/app/controllers/clients_controller.rb b/app/controllers/clients_controller.rb
index b23777c..c30aa6c 100644
--- a/app/controllers/clients_controller.rb
+++ b/app/controllers/clients_controller.rb
@@ -1,35 +1,45 @@
class ClientsController < ApplicationController
- before_action :set_client, only: :show
- before_action :fetch_logs
+ before_action :set_client, only: [:show, :jobs, :logs, :stats]
+ before_action :fetch_logs, only: [:logs]
# GET /clients
def index
@client_ids = Client.for_user(current_user.id).pluck(:ClientId)
@clients = Client.where(ClientId: @client_ids).includes(:jobs)
@hosts = current_user.hosts.not_baculized
fetch_jobs_info
get_charts
end
# GET /clients/1
def show
- @client_ids = [@client.id]
+ end
+
+ # GET /clients/1/jobs
+ def jobs; end
+
+ # GET /clients/1/logs
+ def logs; end
+
+ # GET /clients/1/stats
+ def stats
get_charts
end
private
def set_client
@client = Client.for_user(current_user.id).find(params[:id])
+ @client_ids = [@client.id]
end
def fetch_jobs_info
@stats = JobStats.new(@client_ids)
end
def get_charts
days_ago = params.fetch(:days_back, 7).to_i rescue 7
@job_status = ChartGenerator.job_statuses(@client_ids, days_ago)
@job_stats = ChartGenerator.job_stats(@client_ids, days_ago - 1)
end
end
diff --git a/app/views/admin/clients/_header.html.erb b/app/views/admin/clients/_header.html.erb
new file mode 100644
index 0000000..a19da88
--- /dev/null
+++ b/app/views/admin/clients/_header.html.erb
@@ -0,0 +1,11 @@
+
<%= notice %>
+
+<%= breadcrumb_with Client: admin_client_path(@client),
+ Jobs: jobs_admin_client_path(@client),
+ Stats: stats_admin_client_path(@client),
+ Logs: logs_admin_client_path(@client) %>
+
+
+ <%= @client.name %>
+ <%= host_status_label(@client.host) %>
+
diff --git a/app/views/admin/clients/jobs.html.erb b/app/views/admin/clients/jobs.html.erb
new file mode 100644
index 0000000..f26a259
--- /dev/null
+++ b/app/views/admin/clients/jobs.html.erb
@@ -0,0 +1,10 @@
+<%= render partial: 'header' %>
+
+
+
+ <%= render partial: 'recent_jobs' %>
+
diff --git a/app/views/clients/_logs.html.erb b/app/views/admin/clients/logs.html.erb
similarity index 93%
rename from app/views/clients/_logs.html.erb
rename to app/views/admin/clients/logs.html.erb
index adcfe45..a87cdac 100644
--- a/app/views/clients/_logs.html.erb
+++ b/app/views/admin/clients/logs.html.erb
@@ -1,23 +1,25 @@
+<%= render partial: 'header' %>
+
Logs
LogId |
Job |
Time |
Text |
<%= render partial: 'log', collection: @logs %>
diff --git a/app/views/admin/clients/show.html.erb b/app/views/admin/clients/show.html.erb
index f30a0c7..97d3079 100644
--- a/app/views/admin/clients/show.html.erb
+++ b/app/views/admin/clients/show.html.erb
@@ -1,44 +1,21 @@
-<%= notice %>
-<% if @client.host %>
-
- <%= link_to 'Manage Client', 'admin_host_path(@client.host)', class: "btn btn-primary", role: "button" %>
-
-<% end %>
-
-<%= @client.name %>
+<%= render partial: 'header' %>
Client Details
Bacula Jobs
<%= render partial: 'client_details' %>
<% if @client.host %>
<%= render partial: 'jobs' %>
<% end %>
-
-
- <%= render partial: 'recent_jobs' %>
-
-
-
-
-<%= render partial: 'client_graphs', locals: { path: admin_client_path(@client) } %>
-
-
-
-<%= render partial: 'logs' %>
diff --git a/app/views/admin/clients/stats.html.erb b/app/views/admin/clients/stats.html.erb
new file mode 100644
index 0000000..839490a
--- /dev/null
+++ b/app/views/admin/clients/stats.html.erb
@@ -0,0 +1,3 @@
+<%= render partial: 'header' %>
+
+<%= render partial: 'client_graphs', locals: { path: stats_admin_client_path(@client) } %>
diff --git a/app/views/clients/_header.html.erb b/app/views/clients/_header.html.erb
new file mode 100644
index 0000000..dd13fd9
--- /dev/null
+++ b/app/views/clients/_header.html.erb
@@ -0,0 +1,14 @@
+<%= notice %>
+<% if @client.host %>
+
+ <%= link_to 'Manage Client', host_path(@client.host), class: "btn btn-primary", role: "button" %>
+
+<% end %>
+
+<%= breadcrumb_with Client: client_path(@client), Jobs: jobs_client_path(@client),
+ Stats: stats_client_path(@client), Logs: logs_client_path(@client) %>
+
+
+ <%= @client.name %>
+ <%= host_status_label(@client.host) %>
+
diff --git a/app/views/clients/index.html.erb b/app/views/clients/index.html.erb
index e948e59..a218eff 100644
--- a/app/views/clients/index.html.erb
+++ b/app/views/clients/index.html.erb
@@ -1,54 +1,53 @@
<%= link_to 'New Client', new_host_path, class: 'btn btn-primary', role: 'button' %>
My Bacula Clients
Name |
Uname |
Active Jobs |
Last Backup |
FileRetention (days) |
JobRetention (days) |
Space Used |
File count |
AutoPrune |
<%= render partial: 'client', collection: @clients %>
<% if @hosts.any? %>
My Pending Hosts
Name |
FQDN |
Port |
Password |
FileRetention (days) |
JobRetention (days) |
AutoPrune |
Created At |
<%= render partial: 'hosts/host', collection: @hosts %>
<% end %>
<%= render partial: 'client_graphs', locals: { path: clients_path } %>
-<%= render partial: 'logs' %>
diff --git a/app/views/clients/jobs.html.erb b/app/views/clients/jobs.html.erb
new file mode 100644
index 0000000..a22efeb
--- /dev/null
+++ b/app/views/clients/jobs.html.erb
@@ -0,0 +1,12 @@
+<%= render partial: 'header' %>
+
+
+
+ <%= render partial: 'recent_jobs' %>
+
+
+<%= link_to 'Back to clients', clients_path %>
diff --git a/app/views/admin/clients/_logs.html.erb b/app/views/clients/logs.html.erb
similarity index 93%
rename from app/views/admin/clients/_logs.html.erb
rename to app/views/clients/logs.html.erb
index adcfe45..a87cdac 100644
--- a/app/views/admin/clients/_logs.html.erb
+++ b/app/views/clients/logs.html.erb
@@ -1,23 +1,25 @@
+<%= render partial: 'header' %>
+
Logs
LogId |
Job |
Time |
Text |
<%= render partial: 'log', collection: @logs %>
diff --git a/app/views/clients/show.html.erb b/app/views/clients/show.html.erb
index d134858..2cf3ecc 100644
--- a/app/views/clients/show.html.erb
+++ b/app/views/clients/show.html.erb
@@ -1,44 +1,23 @@
-<%= notice %>
-<% if @client.host %>
-
- <%= link_to 'Manage Client', host_path(@client.host), class: "btn btn-primary", role: "button" %>
-
-<% end %>
-
-<%= @client.name %>
+<%= render partial: 'header' %>
Client Details
Bacula Jobs
<%= render partial: 'client_details' %>
<%= render partial: 'jobs' %>
-
-
- <%= render partial: 'recent_jobs' %>
-
<%= link_to 'Back to clients', clients_path %>
-
-<%= render partial: 'client_graphs', locals: { path: client_path(@client) } %>
-
-
-
-<%= render partial: 'logs' %>
diff --git a/app/views/clients/stats.html.erb b/app/views/clients/stats.html.erb
new file mode 100644
index 0000000..e050a62
--- /dev/null
+++ b/app/views/clients/stats.html.erb
@@ -0,0 +1,4 @@
+<%= render partial: 'header' %>
+
+<%= render partial: 'client_graphs', locals: { path: stats_client_path(@client) } %>
+
diff --git a/config/routes.rb b/config/routes.rb
index d2fd087..91af38a 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,30 +1,43 @@
Rails.application.routes.draw do
root 'clients#index'
- resources :clients, only: [:index, :show]
+ resources :clients, only: [:index, :show] do
+ member do
+ get :jobs
+ get :logs
+ get :stats
+ end
+ end
resources :hosts, only: [:new, :create, :show, :edit, :update, :destroy] do
member do
post :submit_config
get :restore
post :run_restore
delete :revoke
end
resources :jobs, only: [:new, :create, :show, :edit, :update, :destroy] do
member do
patch :toggle_enable
post :backup_now
end
end
resources :filesets, only: [:show, :new, :create, :destroy]
resources :schedules, only: [:show, :new, :edit, :create, :update, :destroy]
end
namespace :admin do
get '/' => 'base#index'
- resources :clients, only: [:index, :show]
+ resources :clients, only: [:index, :show] do
+ member do
+ get :jobs
+ get :logs
+ get :stats
+ post :stats
+ end
+ end
end
end
diff --git a/spec/routing/client_routing_spec.rb b/spec/routing/client_routing_spec.rb
index 728caae..3fde0a8 100644
--- a/spec/routing/client_routing_spec.rb
+++ b/spec/routing/client_routing_spec.rb
@@ -1,16 +1,31 @@
require 'spec_helper'
describe ClientsController do
it 'routes /clients' do
expect(get('/clients')).to route_to(controller: 'clients', action: 'index')
end
it 'routes GET /' do
expect(get('/')).to route_to(controller: 'clients', action: 'index')
end
it 'routes GET /clients/1' do
expect(get('/clients/1')).to route_to(controller: 'clients', action: 'show', id: '1')
end
+
+ it 'routes GET /clients/1/stats' do
+ expect(get('/clients/1/stats')).
+ to route_to(controller: 'clients', action: 'stats', id: '1')
+ end
+
+ it 'routes GET /clients/1/logs' do
+ expect(get('/clients/1/logs')).
+ to route_to(controller: 'clients', action: 'logs', id: '1')
+ end
+
+ it 'routes GET /clients/1/jobs' do
+ expect(get('/clients/1/jobs')).
+ to route_to(controller: 'clients', action: 'jobs', id: '1')
+ end
end