diff --git a/app/controllers/admin/hosts_controller.rb b/app/controllers/admin/hosts_controller.rb index 0afab20..cb281ce 100644 --- a/app/controllers/admin/hosts_controller.rb +++ b/app/controllers/admin/hosts_controller.rb @@ -1,20 +1,32 @@ class Admin::HostsController < Admin::BaseController - before_action :fetch_host, only: [:verify] + before_action :fetch_host, only: [:verify, :set_quota] # GET /admin/hosts/unverified def unverified @hosts = Host.unverified end # POST /admin/hosts/1/verify def verify @host.verify(current_user.id) redirect_to unverified_admin_hosts_path end + # PUT /admin/hosts/1/set_quota + def set_quota + @host.quota = params[:host][:quota] + 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/clients/show.html.erb b/app/views/admin/clients/show.html.erb index fc79cd3..c488a54 100644 --- a/app/views/admin/clients/show.html.erb +++ b/app/views/admin/clients/show.html.erb @@ -1,46 +1,71 @@ <%= render partial: 'header' %>
+ <%= link_to '#', data: { toggle: 'modal', target: ".js-quota:first"}, + class: "btn btn-default", role: "button" do %> + + Set Quota + <% end %> + <% if @client.host.can_set_inactive? %> <%= link_to 'Disable client', disable_admin_client_path(@client), method: :post, data: { confirm: 'This will disable the client. Are you sure?' }, class: "btn btn-warning", role: "button" %> <% end %> <% if @client.host.can_block? %> <%= link_to 'Lock client', block_admin_client_path(@client), method: :post, data: { confirm: 'This will disable and lock the client. Are you sure?' }, class: "btn btn-warning", role: "button" %> <% end %> <% if @client.host.blocked? %> <%= link_to 'Unlock client', unblock_admin_client_path(@client), method: :post, data: { confirm: 'This will unlock the client. Are you sure?' }, class: "btn btn-warning", role: "button" %> <% end %> <%= link_to 'Remove client', revoke_admin_client_path(@client), method: :delete, data: { confirm: 'This will REMOVE the client from Bacula. Are you sure?' }, class: "btn btn-danger", role: "button" %>

Client Details

Bacula Jobs

<%= render partial: 'client_details' %>
<% if @client.host %> <%= render partial: 'jobs' %> <% end %>
+ + + diff --git a/config/routes.rb b/config/routes.rb index 41a7982..d1c4b6a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,106 +1,107 @@ 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 delete :revoke end collection do get :fetch_vima_hosts, to: 'hosts#fetch_vima_hosts', as: :fetch_vima 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, :edit, :update, :destroy] resources :schedules, only: [:show, :new, :edit, :create, :update, :destroy] 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 end resources :hosts, only: [] do collection do get :unverified end member do post :verify + put :set_quota end end resources :users, only: [:index, :new, :create, :show, :edit, :update] do member do patch :ban patch :unban end end resources :pools, only: [:index, :new, :create] resources :faqs end end