diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css
index 3581b31..2852c7e 100644
--- a/app/assets/stylesheets/application.css
+++ b/app/assets/stylesheets/application.css
@@ -1,39 +1,43 @@
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any styles
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
* file per style scope.
*
*= require bootstrap.min
*= require_tree .
*= require_self
*/
/* Make sure navbar does not overlay body */
body {
padding-top: 70px;
}
.right {
text-align: right;
margin-right: 0px;
float: right;
}
.graybox {
max-width: 500px;
margin-right: 0;
margin-left: 0;
background-color: #F7F7F9;
margin-bottom: 30px;
}
.graybox form {
padding-top: 30px;
}
+
+#_days_back {
+ margin: auto 10px;
+}
diff --git a/app/controllers/clients_controller.rb b/app/controllers/clients_controller.rb
index 96699fd..46bc189 100644
--- a/app/controllers/clients_controller.rb
+++ b/app/controllers/clients_controller.rb
@@ -1,20 +1,30 @@
class ClientsController < ApplicationController
before_action :set_client, only: :show
# GET /clients
def index
- client_ids = Client.for_user(current_user.id).pluck(:ClientId)
- @clients = Client.where(ClientId: client_ids).includes(:jobs)
- @active_jobs = Job.running.where(ClientId: client_ids).group(:ClientId).count
+ @client_ids = Client.for_user(current_user.id).pluck(:ClientId)
+ @clients = Client.where(ClientId: @client_ids).includes(:jobs)
+ @active_jobs = Job.running.where(ClientId: @client_ids).group(:ClientId).count
@hosts = current_user.hosts.not_baculized
+ get_charts
end
# GET /clients/1
- def show; end
+ def show
+ @client_ids = [@client.id]
+ get_charts
+ end
private
def set_client
@client = Client.for_user(current_user.id).find(params[:id])
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/clients/_client_graphs.html.erb b/app/views/clients/_client_graphs.html.erb
new file mode 100644
index 0000000..eadc1cd
--- /dev/null
+++ b/app/views/clients/_client_graphs.html.erb
@@ -0,0 +1,18 @@
+
+
+
+
+
+ <%= bootstrap_form_tag(url: path, method: :get, 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 %>
+
+
+
+<%= baas_chart('jobs_status', @job_status) %>
+<%= baas_chart('jobs_stats', @job_stats) %>
diff --git a/app/views/clients/index.html.erb b/app/views/clients/index.html.erb
index a69f3e9..a218eff 100644
--- a/app/views/clients/index.html.erb
+++ b/app/views/clients/index.html.erb
@@ -1,51 +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 |
-
-
+
+
+
+
+ Name |
+ FQDN |
+ Port |
+ Password |
+ FileRetention (days) |
+ JobRetention (days) |
+ AutoPrune |
+ Created At |
+
+
+
+ <%= render partial: 'hosts/host', collection: @hosts %>
+
+
+
+<% end %>
-
- <%= render partial: 'hosts/host', collection: @hosts %>
-
-
-
+<%= render partial: 'client_graphs', locals: { path: clients_path } %>
diff --git a/app/views/clients/show.html.erb b/app/views/clients/show.html.erb
index 8d04039..4febfeb 100644
--- a/app/views/clients/show.html.erb
+++ b/app/views/clients/show.html.erb
@@ -1,38 +1,40 @@
<%= notice %>
<% if @client.host %>
<%= link_to 'Manage Client', host_path(@client.host), class: "btn btn-primary", role: "button" %>
<% end %>
<%= @client.name %>
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) } %>