diff --git a/app/controllers/admin/hosts_controller.rb b/app/controllers/admin/hosts_controller.rb
index e5c3c1d..70f45ff 100644
--- a/app/controllers/admin/hosts_controller.rb
+++ b/app/controllers/admin/hosts_controller.rb
@@ -1,62 +1,67 @@
class Admin::HostsController < Admin::BaseController
before_action :fetch_host, only: [:verify, :reject, :set_quota]
# GET /admin/hosts/unverified
def unverified
@hosts = Host.unverified
end
+ # GET /admin/hosts/pending
+ def pending
+ @hosts = Host.where(verified: true).not_baculized
+ end
+
# GET /admin/hosts/rejected
def rejected
@hosts = RejectedHost.order(created_at: :desc)
end
# POST /admin/hosts/1/verify
def verify
@host.verify(current_user.id)
redirect_to unverified_admin_hosts_path
end
# POST /admin/hosts/1/reject
def reject
msg = 'You need to provide a reason' if params[:reason].blank?
msg = 'Host is already verified' if @host.verified?
if msg.blank?
if @host.reject(current_user.id, params[:reason])
flash[:success] = 'Client rejected'
else
flash[:error] = 'Something went wrong'
end
else
flash[:error] = msg
end
redirect_to unverified_admin_hosts_path
end
# PUT /admin/hosts/1/set_quota
def set_quota
@host.quota = case params[:unit]
when 'MB'
params[:quota].to_i * ConfigurationSetting::MEGA_BYTES
when 'GB'
params[:quota].to_i * ConfigurationSetting::GIGA_BYTES
when 'TB'
params[:quota].to_i * ConfigurationSetting::TERA_BYTES
end
if @host.save
flash[:success] = 'Changes saved'
else
flash[:error] = 'Changes not saved'
end
redirect_to admin_client_path(@host.client)
end
private
def fetch_host
@host = Host.find(params[:id])
end
end
diff --git a/app/views/admin/hosts/_host.html.erb b/app/views/admin/hosts/_host.html.erb
index 6356ca7..7a5c4cb 100644
--- a/app/views/admin/hosts/_host.html.erb
+++ b/app/views/admin/hosts/_host.html.erb
@@ -1,16 +1,20 @@
<%= host.name %> |
<%= host.fqdn %> |
<%= host.first_user.display_name %> |
<%= host.port %> |
<%= I18n.l(host.created_at, format: :long) %> |
- <%= link_to 'Verify', verify_admin_host_path(host), method: :post,
- class: "btn btn-success", role: "button",
- data: { confirm: "Client #{host.name} will be ready to be dispatched to Bacula" }
- %>
- <%= link_to 'Reject', '#', class: "btn btn-danger", role: "button",
- data: { toggle: 'modal', target: '#reject-modal',
- id: host.id, name: host.name } %>
+ <% if host.verified? %>
+ <%= host.try(:verifier).try(:username) || 'None' %>
+ <% else %>
+ <%= link_to 'Verify', verify_admin_host_path(host), method: :post,
+ class: "btn btn-success", role: "button",
+ data: { confirm: "Client #{host.name} will be ready to be dispatched to Bacula" }
+ %>
+ <%= link_to 'Reject', '#', class: "btn btn-danger", role: "button",
+ data: { toggle: 'modal', target: '#reject-modal',
+ id: host.id, name: host.name } %>
+ <% end %>
|
diff --git a/app/views/admin/hosts/pending.html.erb b/app/views/admin/hosts/pending.html.erb
new file mode 100644
index 0000000..77365e1
--- /dev/null
+++ b/app/views/admin/hosts/pending.html.erb
@@ -0,0 +1,24 @@
+Pending Clients
+
+<% if @hosts.empty? %>
+ There are no clients waiting for configuration
+<% else %>
+
+
+
+
+ Name |
+ FQDN |
+ User |
+ Port |
+ Created At |
+ Approved By |
+
+
+
+
+ <%= render partial: 'host', collection: @hosts %>
+
+
+
+<% end %>
diff --git a/app/views/shared/_admin.html.erb b/app/views/shared/_admin.html.erb
index 367d2c1..18be359 100644
--- a/app/views/shared/_admin.html.erb
+++ b/app/views/shared/_admin.html.erb
@@ -1,61 +1,65 @@
<%= content_tag(:li, active_class(admin_path)) do %>
<%= link_to 'Admin', admin_path %>
<% end %>
<%= content_tag(:li, active_class(admin_clients_path)) do %>
<%= link_to 'Clients', admin_clients_path %>
<% end %>
<%= content_tag(:li,
{ class: ['dropdown',
active_class([obsolete_admin_clients_path,
unverified_admin_hosts_path,
+ pending_admin_hosts_path,
rejected_admin_hosts_path])[:class]].join(' ')}) do %>
Inactive Clients
<%#= content_tag(:li, active_class(unverified_admin_hosts_path, true)) do %>
<%#= link_to 'Unverified Clients', unverified_admin_hosts_path %>
<% end %>
<%= content_tag(:li, { class: "dropdown #{active_class(admin_users_path)[:class]}" }) do %>
Users
<% end %>
<%= content_tag(:li, active_class(admin_faqs_path)) do %>
<%= link_to 'FAQ', admin_faqs_path %>
<% end %>
<%= content_tag(:li, active_class(admin_pools_path)) do %>
<%= link_to 'Pools', admin_pools_path %>
<% end %>
<%= content_tag(:li, active_class(admin_settings_path)) do %>
<%= link_to 'Settings', admin_settings_path %>
<% end %>
diff --git a/config/routes.rb b/config/routes.rb
index 82f3dbb..d461f67 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,136 +1,137 @@
Rails.application.routes.draw do
root 'application#index'
get 'faq' => 'application#faq'
post 'grnet' => 'application#grnet'
get 'institutional' => 'application#institutional'
match 'vima', to: 'application#vima', :via => [:get, :post]
get 'logout' => 'application#logout'
resources :clients, only: [:index, :show] do
member do
get :jobs
get :logs
get :stats
post :stats
get :users
get :restore
post :run_restore
post :restore_selected
delete :remove_user
end
collection do
post :index
end
end
resources :clients, only: [], param: :client_id do
member do
get :tree
end
end
resources :invitations, only: [:create]
get '/invitations/:host_id/:verification_code/accept' => 'invitations#accept',
as: :accept_invitation
resources :hosts, only: [:new, :create, :show, :edit, :update, :destroy] do
member do
post :submit_config
post :disable
post :regenerate_token
delete :revoke
get :fd_config
end
collection do
get :fetch_vima_hosts, to: 'hosts#fetch_vima_hosts', as: :fetch_vima
end
resources :simple_configs, only: [:new, :create]
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, :edit, :update, :destroy]
resources :schedules, only: [:show, :new, :edit, :create, :update, :destroy]
end
resources :users, only: :show do
member do
patch :generate_token
end
end
namespace :admin do
match '/', to: 'base#index', via: [:get, :post]
get '/login' => 'base#login', as: :login
resources :settings, only: [:index, :new, :create, :edit, :update] do
member do
delete :reset
end
end
resources :clients, only: [:index, :show] do
member do
get :jobs
get :logs
get :stats
post :stats
get :configuration
post :disable
post :block
post :unblock
delete :revoke
end
collection do
get :obsolete
end
end
resources :hosts, only: [] do
collection do
get :unverified
get :rejected
+ get :pending
end
member do
post :verify
post :reject
put :set_quota
end
end
resources :users, only: [:index, :new, :create, :show, :edit, :update] do
member do
patch :ban
patch :unban
patch :revoke_admin
patch :grant_admin
end
end
resources :pools, only: [:index, :new, :create]
resources :faqs
end
namespace :api, defaults: { format: :json } do
scope module: :v1, constraints: ApiVersion.new(version: 1, default: true) do
resources :clients, only: [:index, :show] do
member do
post :backup
post :restore
end
end
end
end
end