Page Menu
Home
GRNET
Search
Configure Global Search
Log In
Files
F1090550
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Oct 15, 8:41 AM
Size
13 KB
Mime Type
text/x-diff
Expires
Fri, Oct 17, 8:41 AM (1 d, 14 h)
Engine
blob
Format
Raw Data
Handle
279336
Attached To
rARCHIVING archiving
View Options
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 @@
+<p id="notice"><%= notice %></p>
+
+<%= 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) %>
+
+<h2>
+ <%= @client.name %>
+ <small><%= host_status_label(@client.host) %></small>
+</h2>
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' %>
+
+<div class="row">
+ <div class="col-xs-6">
+ <h3>Recent Jobs</h3>
+ </div>
+</div>
+<div class="row">
+ <%= render partial: 'recent_jobs' %>
+</div>
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' %>
+
<div class='row'>
<div class='col-xs-3'>
<h3>Logs</h3>
</div>
<div class="col-xs-12">
<div class="table-responsive">
<table class="table table-striped table-bordered table-condensed">
<thead>
<tr>
<th>LogId</th>
<th>Job</th>
<th>Time</th>
<th>Text</th>
</tr>
</thead>
<tbody>
<%= render partial: 'log', collection: @logs %>
</tbody>
</table>
</div>
</div>
</div>
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 @@
-<p id="notice"><%= notice %></p>
-<% if @client.host %>
- <div class="row right">
- <%= link_to 'Manage Client', 'admin_host_path(@client.host)', class: "btn btn-primary", role: "button" %>
- </div>
-<% end %>
-
-<h2><%= @client.name %></h2>
+<%= render partial: 'header' %>
<div class="row">
<div class="col-xs-4">
<h3>Client Details</h3>
</div>
<div class="col-xs-6">
<h3>Bacula Jobs</h3>
</div>
</div>
<div class="row">
<%= render partial: 'client_details' %>
<div class="col-xs-8">
<div class="row">
<% if @client.host %>
<%= render partial: 'jobs' %>
<% end %>
</div>
- <div class="row">
- <div class="col-xs-6">
- <h3>Recent Jobs</h3>
- </div>
- </div>
- <div class="row">
- <%= render partial: 'recent_jobs' %>
- </div>
</div>
</div>
-
-<br/>
-
-<%= render partial: 'client_graphs', locals: { path: admin_client_path(@client) } %>
-
-<br/>
-
-<%= 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 @@
+<p id="notice"><%= notice %></p>
+<% if @client.host %>
+ <div class="row right">
+ <%= link_to 'Manage Client', host_path(@client.host), class: "btn btn-primary", role: "button" %>
+ </div>
+<% end %>
+
+<%= breadcrumb_with Client: client_path(@client), Jobs: jobs_client_path(@client),
+ Stats: stats_client_path(@client), Logs: logs_client_path(@client) %>
+
+<h2>
+ <%= @client.name %>
+ <small><%= host_status_label(@client.host) %></small>
+</h2>
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 @@
<div class="row right">
<%= link_to 'New Client', new_host_path, class: 'btn btn-primary', role: 'button' %>
</div>
<h1>My Bacula Clients</h1>
<div class="table-responsive">
<table class="table table-striped table-bordered table-condensed">
<thead>
<tr>
<th>Name</th>
<th>Uname</th>
<th>Active Jobs</th>
<th>Last Backup</th>
<th>FileRetention (days)</th>
<th>JobRetention (days)</th>
<th>Space Used</th>
<th>File count</th>
<th>AutoPrune</th>
</tr>
</thead>
<tbody>
<%= render partial: 'client', collection: @clients %>
</tbody>
</table>
</div>
<% if @hosts.any? %>
<h1>My Pending Hosts</h1>
<div class="table-responsive">
<table class="table table-striped table-bordered table-condensed">
<thead>
<tr>
<th>Name</th>
<th>FQDN</th>
<th>Port</th>
<th>Password</th>
<th>FileRetention (days)</th>
<th>JobRetention (days)</th>
<th>AutoPrune</th>
<th>Created At</th>
</tr>
</thead>
<tbody>
<%= render partial: 'hosts/host', collection: @hosts %>
</tbody>
</table>
</div>
<% 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' %>
+
+<div class="row">
+ <div class="col-xs-6">
+ <h3>Recent Jobs</h3>
+ </div>
+</div>
+<div class="row">
+ <%= render partial: 'recent_jobs' %>
+</div>
+
+<%= 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' %>
+
<div class='row'>
<div class='col-xs-3'>
<h3>Logs</h3>
</div>
<div class="col-xs-12">
<div class="table-responsive">
<table class="table table-striped table-bordered table-condensed">
<thead>
<tr>
<th>LogId</th>
<th>Job</th>
<th>Time</th>
<th>Text</th>
</tr>
</thead>
<tbody>
<%= render partial: 'log', collection: @logs %>
</tbody>
</table>
</div>
</div>
</div>
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 @@
-<p id="notice"><%= notice %></p>
-<% if @client.host %>
- <div class="row right">
- <%= link_to 'Manage Client', host_path(@client.host), class: "btn btn-primary", role: "button" %>
- </div>
-<% end %>
-
-<h2><%= @client.name %></h2>
+<%= render partial: 'header' %>
<div class="row">
<div class="col-xs-4">
<h3>Client Details</h3>
</div>
<div class="col-xs-6">
<h3>Bacula Jobs</h3>
</div>
</div>
<div class="row">
<%= render partial: 'client_details' %>
<div class="col-xs-8">
<div class="row">
<%= render partial: 'jobs' %>
</div>
- <div class="row">
- <div class="col-xs-6">
- <h3>Recent Jobs</h3>
- </div>
- </div>
- <div class="row">
- <%= render partial: 'recent_jobs' %>
- </div>
</div>
</div>
<br/>
<%= link_to 'Back to clients', clients_path %>
-
-<%= render partial: 'client_graphs', locals: { path: client_path(@client) } %>
-
-<br/>
-
-<%= 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
Event Timeline
Log In to Comment