diff --git a/app/controllers/admin/settings_controller.rb b/app/controllers/admin/settings_controller.rb new file mode 100644 index 0000000..d605dfa --- /dev/null +++ b/app/controllers/admin/settings_controller.rb @@ -0,0 +1,31 @@ +class Admin::SettingsController < Admin::BaseController + # GET /admin/settings + def index + @settings = ConfigurationSetting.last || ConfigurationSetting.new + end + + # GET /admin/settings/1 + def show + end + + # GET /admin/settings/new + def new + @setting = ConfigurationSetting.new + end + + # GET /admin/settings/1/edit + def edit + end + + # POST /admin/settings + def create + end + + # PATCH /admin/settings/1/update + def update + end + + # DELETE /admin/settings/1/delete + def destroy + end +end diff --git a/app/helpers/settings_helper.rb b/app/helpers/settings_helper.rb new file mode 100644 index 0000000..e1020bb --- /dev/null +++ b/app/helpers/settings_helper.rb @@ -0,0 +1,29 @@ +module SettingsHelper + # Creates an html table for the given attributes + # + # @example table_for( a: 1, b: 2 ) + #
+ # + # + # + # + # + # + # + # + # + #
A1
B2
+ #
+ # + # @param attributes[Hash] + # @returns [String] Html table + def table_for(attributes) + content_tag(:div, class: 'table-responsive') do + content_tag(:table, class: 'table table-striped table-bordered table-condensed') do + attributes.map { |key, value| + "#{key.to_s.titleize}#{value}" + }.inject { |result, element| result.concat(element) }.html_safe + end + end + end +end diff --git a/app/views/admin/settings/index.html.erb b/app/views/admin/settings/index.html.erb new file mode 100644 index 0000000..6fc37b5 --- /dev/null +++ b/app/views/admin/settings/index.html.erb @@ -0,0 +1,25 @@ +

Settings

+ +<% if !@settings.persisted? %> + +<% end %> + +
+
+

Client Settings

+
+
+

Job Settings

+
+
+ +
+
+ <%= table_for(ConfigurationSetting.current_job_settings) %> +
+
+ <%= table_for(ConfigurationSetting.current_client_settings) %> +
+
diff --git a/app/views/shared/_nav.html.erb b/app/views/shared/_nav.html.erb index cc1a16f..bef50e4 100644 --- a/app/views/shared/_nav.html.erb +++ b/app/views/shared/_nav.html.erb @@ -1,44 +1,47 @@ diff --git a/config/routes.rb b/config/routes.rb index 8dae782..140cbf4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,59 +1,61 @@ Rails.application.routes.draw do root 'clients#index' resources :clients, only: [:index, :show] do member do get :jobs get :logs get :stats post :stats end collection do post :index 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 match '/', to: 'base#index', via: [:get, :post] + resources :settings + resources :clients, only: [:index, :show] do member do get :jobs get :logs get :stats post :stats get :configuration end end resources :hosts, only: [:show] do collection do get :unverified end member do post :verify end end end end