barkest_core 1.5.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/Gemfile +22 -0
- data/Gemfile.lock +254 -0
- data/MIT-LICENSE +20 -0
- data/README.md +364 -0
- data/Rakefile +37 -0
- data/app/assets/fonts/barkest_core/ArchivoNarrow-Bold.ttf +0 -0
- data/app/assets/fonts/barkest_core/ArchivoNarrow-BoldItalic.ttf +0 -0
- data/app/assets/fonts/barkest_core/ArchivoNarrow-Italic.ttf +0 -0
- data/app/assets/fonts/barkest_core/ArchivoNarrow-Regular.ttf +0 -0
- data/app/assets/images/barkest_core/.keep +0 -0
- data/app/assets/images/barkest_core/barcode-B.svg +181 -0
- data/app/assets/javascripts/barkest_core/.keep +0 -0
- data/app/assets/javascripts/barkest_core/application.js +22 -0
- data/app/assets/javascripts/barkest_core/bootstrap-datepicker.js +1800 -0
- data/app/assets/javascripts/barkest_core/field_init.js +7 -0
- data/app/assets/javascripts/barkest_core/jquery.doubleScroll.js +112 -0
- data/app/assets/javascripts/barkest_core/masked_edit.js +25 -0
- data/app/assets/javascripts/barkest_core/system_status.js.erb +201 -0
- data/app/assets/stylesheets/barkest_core/.keep +0 -0
- data/app/assets/stylesheets/barkest_core/application.css +17 -0
- data/app/assets/stylesheets/barkest_core/custom.css.scss +264 -0
- data/app/assets/stylesheets/barkest_core/datepicker3.css +790 -0
- data/app/controllers/.keep +0 -0
- data/app/controllers/access_groups_controller.rb +74 -0
- data/app/controllers/account_activations_controller.rb +29 -0
- data/app/controllers/application_controller.rb +5 -0
- data/app/controllers/barkest_core/application_controller_base.rb +113 -0
- data/app/controllers/barkest_core/engine_controller_base.rb +15 -0
- data/app/controllers/barkest_core/testsub_controller.rb +21 -0
- data/app/controllers/contact_controller.rb +32 -0
- data/app/controllers/log_view_controller.rb +31 -0
- data/app/controllers/password_resets_controller.rb +126 -0
- data/app/controllers/sessions_controller.rb +64 -0
- data/app/controllers/status_controller.rb +150 -0
- data/app/controllers/system_config_controller.rb +238 -0
- data/app/controllers/system_update_controller.rb +164 -0
- data/app/controllers/test_access_controller.rb +44 -0
- data/app/controllers/test_report_controller.rb +75 -0
- data/app/controllers/users_controller.rb +218 -0
- data/app/helpers/.keep +0 -0
- data/app/helpers/barkest_core/application_helper.rb +134 -0
- data/app/helpers/barkest_core/form_helper.rb +469 -0
- data/app/helpers/barkest_core/html_helper.rb +70 -0
- data/app/helpers/barkest_core/misc_helper.rb +68 -0
- data/app/helpers/barkest_core/pdf_helper.rb +180 -0
- data/app/helpers/barkest_core/recaptcha_helper.rb +115 -0
- data/app/helpers/barkest_core/sessions_helper.rb +94 -0
- data/app/helpers/barkest_core/status_helper.rb +118 -0
- data/app/helpers/barkest_core/users_helper.rb +32 -0
- data/app/mailers/.keep +0 -0
- data/app/mailers/application_mailer.rb +5 -0
- data/app/mailers/barkest_core/application_mailer_base.rb +30 -0
- data/app/mailers/barkest_core/contact_form.rb +20 -0
- data/app/mailers/barkest_core/user_mailer.rb +44 -0
- data/app/models/.keep +0 -0
- data/app/models/access_group.rb +121 -0
- data/app/models/access_group_group_member.rb +13 -0
- data/app/models/access_group_user_member.rb +11 -0
- data/app/models/barkest_core/auth_config.rb +95 -0
- data/app/models/barkest_core/authorize_failure.rb +7 -0
- data/app/models/barkest_core/contact_message.rb +37 -0
- data/app/models/barkest_core/database_config.rb +223 -0
- data/app/models/barkest_core/db_table.rb +21 -0
- data/app/models/barkest_core/email_config.rb +132 -0
- data/app/models/barkest_core/global_status.rb +267 -0
- data/app/models/barkest_core/log_entry.rb +101 -0
- data/app/models/barkest_core/log_view_options.rb +51 -0
- data/app/models/barkest_core/ms_sql_db_definition.rb +441 -0
- data/app/models/barkest_core/ms_sql_definition.rb +221 -0
- data/app/models/barkest_core/ms_sql_function.rb +423 -0
- data/app/models/barkest_core/not_logged_in.rb +7 -0
- data/app/models/barkest_core/pdf_table_builder.rb +407 -0
- data/app/models/barkest_core/self_update_config.rb +37 -0
- data/app/models/barkest_core/user_alert.rb +29 -0
- data/app/models/barkest_core/user_alert_generators.rb +58 -0
- data/app/models/barkest_core/user_manager.rb +404 -0
- data/app/models/barkest_core/work_path.rb +74 -0
- data/app/models/disable_user.rb +18 -0
- data/app/models/ldap_access_group.rb +15 -0
- data/app/models/system_config.rb +99 -0
- data/app/models/user.rb +405 -0
- data/app/models/user_login_history.rb +11 -0
- data/app/views/.keep +0 -0
- data/app/views/access_groups/_form.html.erb +19 -0
- data/app/views/access_groups/edit.html.erb +2 -0
- data/app/views/access_groups/index.html.erb +32 -0
- data/app/views/access_groups/new.html.erb +2 -0
- data/app/views/access_groups/show.html.erb +4 -0
- data/app/views/barkest_core/contact_form/contact.html.erb +16 -0
- data/app/views/barkest_core/contact_form/contact.text.erb +13 -0
- data/app/views/barkest_core/testsub/_links.html.erb +5 -0
- data/app/views/barkest_core/testsub/page1.html.erb +3 -0
- data/app/views/barkest_core/testsub/page2.html.erb +2 -0
- data/app/views/barkest_core/testsub/page3.html.erb +2 -0
- data/app/views/barkest_core/user_mailer/account_activation.html.erb +7 -0
- data/app/views/barkest_core/user_mailer/account_activation.text.erb +6 -0
- data/app/views/barkest_core/user_mailer/invalid_password_reset.html.erb +3 -0
- data/app/views/barkest_core/user_mailer/invalid_password_reset.text.erb +5 -0
- data/app/views/barkest_core/user_mailer/password_reset.html.erb +8 -0
- data/app/views/barkest_core/user_mailer/password_reset.text.erb +7 -0
- data/app/views/contact/index.html.erb +24 -0
- data/app/views/layouts/_footer_copyright.html.erb +1 -0
- data/app/views/layouts/_menu_admin.html.erb +5 -0
- data/app/views/layouts/_menu_anon.html.erb +0 -0
- data/app/views/layouts/_menu_auth.html.erb +3 -0
- data/app/views/layouts/_menu_footer.html.erb +1 -0
- data/app/views/layouts/_nav_logo.html.erb +1 -0
- data/app/views/layouts/application.html.erb +2 -0
- data/app/views/layouts/barkest_core/_application.html.erb +24 -0
- data/app/views/layouts/barkest_core/_footer.html.erb +18 -0
- data/app/views/layouts/barkest_core/_header.html.erb +38 -0
- data/app/views/layouts/barkest_core/_html_mailer.html.erb +11 -0
- data/app/views/layouts/barkest_core/_menu_account.html.erb +14 -0
- data/app/views/layouts/barkest_core/_menu_sample.html.erb +1 -0
- data/app/views/layouts/barkest_core/_messages.html.erb +4 -0
- data/app/views/layouts/barkest_core/_shim.html.erb +4 -0
- data/app/views/layouts/barkest_core/_subheader.html.erb +1 -0
- data/app/views/layouts/barkest_core/_text_mailer.text.erb +4 -0
- data/app/views/layouts/mailer.html.erb +1 -0
- data/app/views/layouts/mailer.text.erb +1 -0
- data/app/views/log_view/index.html.erb +100 -0
- data/app/views/password_resets/edit.html.erb +20 -0
- data/app/views/password_resets/new.html.erb +14 -0
- data/app/views/sessions/new.html.erb +27 -0
- data/app/views/shared/_error_messages.html.erb +29 -0
- data/app/views/shared/_generic_user_alert.html.erb +4 -0
- data/app/views/status/current.html.erb +34 -0
- data/app/views/status/test.html.erb +50 -0
- data/app/views/system_config/index.html.erb +25 -0
- data/app/views/system_config/show_auth.html.erb +28 -0
- data/app/views/system_config/show_database.html.erb +36 -0
- data/app/views/system_config/show_email.html.erb +21 -0
- data/app/views/system_config/show_self_update.html.erb +13 -0
- data/app/views/system_update/index.html.erb +31 -0
- data/app/views/system_update/new.html.erb +2 -0
- data/app/views/test_access/allow_anon.html.erb +2 -0
- data/app/views/test_access/require_admin.html.erb +2 -0
- data/app/views/test_access/require_group_x.html.erb +2 -0
- data/app/views/test_access/require_user.html.erb +2 -0
- data/app/views/test_report/index.csv.csvrb +23 -0
- data/app/views/test_report/index.html.erb +6 -0
- data/app/views/test_report/index.pdf.prawn +50 -0
- data/app/views/test_report/index.xlsx.axlsx +28 -0
- data/app/views/users/_user.html.erb +57 -0
- data/app/views/users/_user_details.html.erb +15 -0
- data/app/views/users/_user_details_for_list.html.erb +1 -0
- data/app/views/users/_user_form.html.erb +13 -0
- data/app/views/users/disable_confirm.html.erb +19 -0
- data/app/views/users/edit.html.erb +15 -0
- data/app/views/users/index.html.erb +9 -0
- data/app/views/users/new.html.erb +10 -0
- data/app/views/users/show.html.erb +46 -0
- data/bin/rails +12 -0
- data/config/routes.rb +3 -0
- data/db/migrate/20160617172539_create_access_groups.rb +10 -0
- data/db/migrate/20160617172725_create_users.rb +26 -0
- data/db/migrate/20160617172833_create_user_login_histories.rb +12 -0
- data/db/migrate/20160622151720_create_access_group_user_members.rb +9 -0
- data/db/migrate/20160622151925_create_access_group_group_members.rb +9 -0
- data/db/migrate/20160701005706_create_ldap_access_groups.rb +11 -0
- data/db/migrate/20161108155029_create_system_configs.rb +11 -0
- data/db/seeds/barkest_core_01_create_users.rb +42 -0
- data/db/seeds.rb +53 -0
- data/lib/barkest_core/concerns/association_with_defaults.rb +55 -0
- data/lib/barkest_core/concerns/boolean_parser.rb +88 -0
- data/lib/barkest_core/concerns/date_parser.rb +181 -0
- data/lib/barkest_core/concerns/email_tester.rb +55 -0
- data/lib/barkest_core/concerns/encrypted_fields.rb +156 -0
- data/lib/barkest_core/concerns/named_model.rb +73 -0
- data/lib/barkest_core/concerns/number_parser.rb +145 -0
- data/lib/barkest_core/concerns/utc_conversion.rb +60 -0
- data/lib/barkest_core/engine.rb +105 -0
- data/lib/barkest_core/extensions/active_record_extensions.rb +120 -0
- data/lib/barkest_core/extensions/application_configuration_extensions.rb +38 -0
- data/lib/barkest_core/extensions/application_extensions.rb +50 -0
- data/lib/barkest_core/extensions/axlsx_extenstions.rb +157 -0
- data/lib/barkest_core/extensions/fixture_set_extensions.rb +107 -0
- data/lib/barkest_core/extensions/generator_extensions.rb +271 -0
- data/lib/barkest_core/extensions/main_app_extensions.rb +35 -0
- data/lib/barkest_core/extensions/prawn_document_extensions.rb +367 -0
- data/lib/barkest_core/extensions/prawn_table_extensions.rb +131 -0
- data/lib/barkest_core/extensions/router_extensions.rb +106 -0
- data/lib/barkest_core/extensions/simple_formatter_extensions.rb +66 -0
- data/lib/barkest_core/extensions/test_case_extensions.rb +348 -0
- data/lib/barkest_core/extensions/time_extensions.rb +164 -0
- data/lib/barkest_core/handlers/csv_handler.rb +30 -0
- data/lib/barkest_core/version.rb +3 -0
- data/lib/barkest_core.rb +324 -0
- data/lib/generators/barkest/install_generator.rb +102 -0
- data/lib/generators/barkest_core/actions/01_patch_application_controller.rb +55 -0
- data/lib/generators/barkest_core/actions/02_patch_application_mailer.rb +56 -0
- data/lib/generators/barkest_core/actions/03_patch_assets.rb +62 -0
- data/lib/generators/barkest_core/actions/04_patch_layouts.rb +36 -0
- data/lib/generators/barkest_core/actions/05_patch_routes.rb +93 -0
- data/lib/generators/barkest_core/actions/06_patch_seeds.rb +60 -0
- data/lib/generators/barkest_core/actions/07_copy_migrations.rb +51 -0
- data/lib/generators/barkest_core/actions/08_configure_database.rb +52 -0
- data/lib/generators/barkest_core/actions/09_configure_secrets.rb +29 -0
- data/lib/generators/barkest_core/actions/99_patch_gitignore.rb +57 -0
- data/lib/generators/barkest_core/install_generator.rb +17 -0
- data/test/barkest_core_test.rb +83 -0
- data/test/controllers/access_groups_controller_test.rb +53 -0
- data/test/controllers/contact_controller_test.rb +10 -0
- data/test/controllers/sessions_controller_test.rb +10 -0
- data/test/controllers/users_controller_test.rb +10 -0
- data/test/dummy/.gitignore +10 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/images/.keep +0 -0
- data/test/dummy/app/assets/javascripts/application.js +14 -0
- data/test/dummy/app/assets/stylesheets/application.css +16 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/controllers/concerns/.keep +0 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/mailers/.keep +0 -0
- data/test/dummy/app/mailers/application_mailer.rb +3 -0
- data/test/dummy/app/models/.keep +0 -0
- data/test/dummy/app/models/concerns/.keep +0 -0
- data/test/dummy/app/views/layouts/application.html.erb +1 -0
- data/test/dummy/app/views/layouts/mailer.html.erb +1 -0
- data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/test/dummy/app/views/system_config/show_fake.html.erb +3 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +29 -0
- data/test/dummy/config/application.rb +27 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +47 -0
- data/test/dummy/config/environments/production.rb +79 -0
- data/test/dummy/config/environments/test.rb +44 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/db_updater_ext.rb +33 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/sys_config_ext.rb +12 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +60 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/db/schema.rb +95 -0
- data/test/dummy/db/seeds/barkest_core_01_create_users.rb +42 -0
- data/test/dummy/db/seeds.rb +51 -0
- data/test/dummy/lib/assets/.keep +0 -0
- data/test/dummy/log/.keep +0 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/sql/my_test_view.sql +3 -0
- data/test/fixtures/access_groups.yml +21 -0
- data/test/fixtures/users.yml +71 -0
- data/test/helpers/barkest_core/sessions_helper_test.rb +22 -0
- data/test/integration/access_group_mgmt_test.rb +33 -0
- data/test/integration/access_test.rb +24 -0
- data/test/integration/account_activations_access_test.rb +12 -0
- data/test/integration/contact_test.rb +98 -0
- data/test/integration/extra_partial_test.rb +41 -0
- data/test/integration/log_view_access_test.rb +12 -0
- data/test/integration/password_resets_test.rb +101 -0
- data/test/integration/reports_test.rb +53 -0
- data/test/integration/status_access_test.rb +27 -0
- data/test/integration/system_config_access_test.rb +24 -0
- data/test/integration/system_update_access_test.rb +19 -0
- data/test/integration/users_access_test.rb +34 -0
- data/test/integration/users_edit_test.rb +178 -0
- data/test/integration/users_index_test.rb +62 -0
- data/test/integration/users_login_test.rb +67 -0
- data/test/integration/users_signup_test.rb +54 -0
- data/test/mailers/.keep +0 -0
- data/test/mailers/barkest_core/contact_form_test.rb +28 -0
- data/test/mailers/barkest_core/user_mailer_test.rb +43 -0
- data/test/mailers/previews/barkest_core/contact_form_preview.rb +17 -0
- data/test/mailers/previews/barkest_core/user_mailer_preview.rb +26 -0
- data/test/models/access_group_group_member_test.rb +28 -0
- data/test/models/access_group_test.rb +114 -0
- data/test/models/access_group_user_member_test.rb +28 -0
- data/test/models/barkest_core/auth_config_test.rb +57 -0
- data/test/models/barkest_core/bool_parser_test.rb +28 -0
- data/test/models/barkest_core/contact_message_test.rb +61 -0
- data/test/models/barkest_core/database_config_test.rb +33 -0
- data/test/models/barkest_core/date_parser_test.rb +110 -0
- data/test/models/barkest_core/email_config_test.rb +57 -0
- data/test/models/barkest_core/global_status_test.rb +50 -0
- data/test/models/barkest_core/ms_sql_db_updater_test.rb +115 -0
- data/test/models/barkest_core/ms_sql_definition_test.rb +102 -0
- data/test/models/barkest_core/ms_sql_function_test.rb +131 -0
- data/test/models/barkest_core/number_parser_test.rb +29 -0
- data/test/models/barkest_core/self_update_config_test.rb +29 -0
- data/test/models/barkest_core/user_alert_test.rb +19 -0
- data/test/models/barkest_core/user_manager_test.rb +34 -0
- data/test/models/barkest_core/work_path_test.rb +26 -0
- data/test/models/disable_user_test.rb +27 -0
- data/test/models/generic_time_test.rb +66 -0
- data/test/models/ldap_access_group_test.rb +31 -0
- data/test/models/pdf_table_builder_test.rb +6 -0
- data/test/models/system_config_test.rb +78 -0
- data/test/models/user_login_history_test.rb +37 -0
- data/test/models/user_test.rb +130 -0
- data/test/test_helper.rb +63 -0
- metadata +798 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
##
|
|
2
|
+
# A simple controller providing the login and logout methods for the application.
|
|
3
|
+
class SessionsController < ApplicationController
|
|
4
|
+
|
|
5
|
+
before_action :require_anon, only: [ :new, :create ]
|
|
6
|
+
|
|
7
|
+
##
|
|
8
|
+
# Shows the login form.
|
|
9
|
+
#
|
|
10
|
+
def new
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
##
|
|
14
|
+
# Attempts to login a user. To successfully log in, a user must be activated and enabled.
|
|
15
|
+
#
|
|
16
|
+
# A disabled user is treated the same as a non-existent user or an invalid password,
|
|
17
|
+
# a generic message stating invalid email or password is shown.
|
|
18
|
+
# An non-activated user is given a message indicating their account is not yet active.
|
|
19
|
+
#
|
|
20
|
+
# Upon successfuly login, the user is redirected back to where they came from or to the
|
|
21
|
+
# root url.
|
|
22
|
+
#
|
|
23
|
+
def create
|
|
24
|
+
if (@user = BarkestCore::UserManager.authenticate(params[:session][:email], params[:session][:password], request.remote_ip))
|
|
25
|
+
if @user.activated?
|
|
26
|
+
# log the user in.
|
|
27
|
+
log_in @user
|
|
28
|
+
params[:session][:remember_me] == '1' ? remember(@user) : forget(@user)
|
|
29
|
+
|
|
30
|
+
# show alerts on login.
|
|
31
|
+
session[:show_alerts] = true
|
|
32
|
+
|
|
33
|
+
redirect_back_or @user
|
|
34
|
+
else
|
|
35
|
+
flash[:safe_warning] = 'Your account has not yet been activated.<br/>Check your email for the activation link.'
|
|
36
|
+
redirect_to root_url
|
|
37
|
+
end
|
|
38
|
+
else
|
|
39
|
+
# deny login.
|
|
40
|
+
flash.now[:danger] = 'Invalid email or password.'
|
|
41
|
+
render 'new'
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
##
|
|
46
|
+
# Logs out any currently logged in user session.
|
|
47
|
+
#
|
|
48
|
+
# This will not raise errors if a user is not logged in and will redirect to the
|
|
49
|
+
# root url when finished.
|
|
50
|
+
#
|
|
51
|
+
def destroy
|
|
52
|
+
log_out if logged_in?
|
|
53
|
+
redirect_to root_url
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
private
|
|
57
|
+
|
|
58
|
+
def require_anon
|
|
59
|
+
if logged_in?
|
|
60
|
+
flash[:danger] = 'You are already logged in.'
|
|
61
|
+
redirect_to root_url
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
|
|
2
|
+
##
|
|
3
|
+
# A fairly simple system status controller.
|
|
4
|
+
#
|
|
5
|
+
# The status system revolves around the GlobalStatus class and the WorkPath#system_status_file contents.
|
|
6
|
+
# When a long running process acquires a lock with the GlobalStatus, then it can update the status freely
|
|
7
|
+
# until it releases the lock. This controller simply checks the GlobalStatus lock and reads the
|
|
8
|
+
# WorkPath#system_status_file contents to construct the object that gets returned to the client.
|
|
9
|
+
#
|
|
10
|
+
# See the methods below for more information on how this works.
|
|
11
|
+
#
|
|
12
|
+
class StatusController < ApplicationController
|
|
13
|
+
|
|
14
|
+
before_action :check_for_user
|
|
15
|
+
|
|
16
|
+
##
|
|
17
|
+
# Gets the current system status from the beginning of the system status log.
|
|
18
|
+
#
|
|
19
|
+
# Status is returned as a JSON object to be consumed by Javascript.
|
|
20
|
+
#
|
|
21
|
+
# error::
|
|
22
|
+
# The +error+ field alerts the consumer to any application error that may have occurred.
|
|
23
|
+
#
|
|
24
|
+
# locked::
|
|
25
|
+
# The +locked+ field lets the consumer know whether the system is currently busy with a
|
|
26
|
+
# long running task.
|
|
27
|
+
#
|
|
28
|
+
# status::
|
|
29
|
+
# The +status+ field gives the main status for the system at the time of the request.
|
|
30
|
+
#
|
|
31
|
+
# percentage::
|
|
32
|
+
# The +percentage+ field gives the progress for the current system status.
|
|
33
|
+
# If blank, there is no reported progress and the consumer should hide the progress bar.
|
|
34
|
+
# If set to '-', and +locked+ is false, then the consumer should decide whether
|
|
35
|
+
# to show the percentage (100%) or keep the progress bar hidden.
|
|
36
|
+
# If set to an integer between 0 and 100, then the consumer should show the progress bar
|
|
37
|
+
# with the specified percentage.
|
|
38
|
+
#
|
|
39
|
+
# contents::
|
|
40
|
+
# The +contents+ field contains the status log file up to this point.
|
|
41
|
+
# Requests to #first will contain the entire log file, whereas subsequent requests to
|
|
42
|
+
# #more will contain any data added to the log file since #first or #more was last
|
|
43
|
+
# requested. The consumer should append the +contents+ field to its existing log to
|
|
44
|
+
# reconstruct the log data in entirety.
|
|
45
|
+
# If +error+ is true, then this will contain the error message and should be treated
|
|
46
|
+
# differently from the successful requests.
|
|
47
|
+
def first
|
|
48
|
+
self.start_position = 0
|
|
49
|
+
build_status
|
|
50
|
+
render json: @status.to_json
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
##
|
|
54
|
+
# Gets any status changes since the last call to +first+ or +more+.
|
|
55
|
+
#
|
|
56
|
+
# Status is returned as a JSON object to be consumed by Javascript.
|
|
57
|
+
#
|
|
58
|
+
# See #first for a description of the JSON object returned.
|
|
59
|
+
def more
|
|
60
|
+
build_status
|
|
61
|
+
render json: @status.to_json
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
##
|
|
65
|
+
# Shows the dedicated status reporting page.
|
|
66
|
+
#
|
|
67
|
+
# This action should not be invoked directly, instead use the StatusHelper#show_system_status helper
|
|
68
|
+
# method with the long running code as a block.
|
|
69
|
+
def current
|
|
70
|
+
@inital_status = BarkestCore::GlobalStatus.current[:message]
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
##
|
|
74
|
+
# Shows the status testing page.
|
|
75
|
+
#
|
|
76
|
+
# This page provides five examples of how to implement status display.
|
|
77
|
+
def test
|
|
78
|
+
flag = (params[:flag] || 'menu').underscore.to_sym
|
|
79
|
+
|
|
80
|
+
if flag != :menu
|
|
81
|
+
show_system_status(
|
|
82
|
+
url_on_completion: status_test_url,
|
|
83
|
+
completion_button: 'Test Again',
|
|
84
|
+
main_status: 'Running test process'
|
|
85
|
+
) do |status|
|
|
86
|
+
sleep 0.5
|
|
87
|
+
|
|
88
|
+
File.open(BarkestCore::WorkPath.system_status_file, 'wt') do |f|
|
|
89
|
+
2.times do |i|
|
|
90
|
+
f.write("Before loop status message ##{i+1}.\n")
|
|
91
|
+
f.flush
|
|
92
|
+
sleep 0.1
|
|
93
|
+
end
|
|
94
|
+
sleep 0.5
|
|
95
|
+
|
|
96
|
+
status.set_percentage(0) if flag == :with_progress
|
|
97
|
+
15.times do |t|
|
|
98
|
+
c = (t % 2 == 1) ? 3 : 5
|
|
99
|
+
c.times do |i|
|
|
100
|
+
f.write("Pass ##{t+1} status message ##{i+1}.\n")
|
|
101
|
+
f.flush
|
|
102
|
+
sleep 0.1
|
|
103
|
+
end
|
|
104
|
+
status.set_percentage((t * 100) / 15) if flag == :with_progress
|
|
105
|
+
sleep 0.5
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
private
|
|
113
|
+
|
|
114
|
+
def check_for_user
|
|
115
|
+
authorize! true
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def start_position
|
|
119
|
+
session[:system_status_position] || 0
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def start_position=(value)
|
|
123
|
+
session[:system_status_position] = value
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def build_status
|
|
127
|
+
start = start_position
|
|
128
|
+
|
|
129
|
+
cur = BarkestCore::GlobalStatus.current
|
|
130
|
+
@status = { error: false, locked: cur[:locked], status: cur[:message], percentage: cur[:percent] }
|
|
131
|
+
|
|
132
|
+
begin
|
|
133
|
+
raise StandardError.new('No system status.') unless File.exist?(BarkestCore::WorkPath.system_status_file)
|
|
134
|
+
|
|
135
|
+
File.open(BarkestCore::WorkPath.system_status_file, 'r') do |f|
|
|
136
|
+
@status[:contents] = f.read
|
|
137
|
+
end
|
|
138
|
+
if start > 0 && @status[:contents].length >= start
|
|
139
|
+
@status[:contents] = @status[:contents][start..-1]
|
|
140
|
+
end
|
|
141
|
+
start += @status[:contents].length
|
|
142
|
+
rescue Exception => err
|
|
143
|
+
@status[:contents] = err.message
|
|
144
|
+
@status[:error] = true
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
self.start_position = start
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
end
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
|
|
2
|
+
##
|
|
3
|
+
# This controller makes it easy to edit the system configuration for email, authentication,
|
|
4
|
+
# and additional database connections.
|
|
5
|
+
#
|
|
6
|
+
# Extend this class and add additional configuration items if needed.
|
|
7
|
+
# New configuration items should be added as paired methods.
|
|
8
|
+
#
|
|
9
|
+
# # GET: /system_config/my_config_item
|
|
10
|
+
# def show_my_config_item
|
|
11
|
+
# ...
|
|
12
|
+
# end
|
|
13
|
+
#
|
|
14
|
+
# # POST: /system_config/my_config_item
|
|
15
|
+
# def update_my_config_item
|
|
16
|
+
# ...
|
|
17
|
+
# end
|
|
18
|
+
#
|
|
19
|
+
# If the config item requires an ID parameter, use the requires_id helper.
|
|
20
|
+
# requires_id :my_config_item
|
|
21
|
+
#
|
|
22
|
+
class SystemConfigController < ApplicationController
|
|
23
|
+
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
def self.id_config_types
|
|
27
|
+
@id_config_types ||= {}
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
protected
|
|
31
|
+
|
|
32
|
+
##
|
|
33
|
+
# Sets a config type to require an id parameter.
|
|
34
|
+
def self.requires_id(config_type, id_provider)
|
|
35
|
+
config_type = config_type.to_s.to_sym
|
|
36
|
+
raise 'provider cannot be nil' unless id_provider
|
|
37
|
+
id_config_types[config_type] = id_provider
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
public
|
|
41
|
+
|
|
42
|
+
before_action :require_admin
|
|
43
|
+
before_action :validate_db_id, only: [ :show_database, :update_database ]
|
|
44
|
+
|
|
45
|
+
##
|
|
46
|
+
# GET /system_config
|
|
47
|
+
def index
|
|
48
|
+
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
##
|
|
52
|
+
# POST /system_config/restart
|
|
53
|
+
def restart
|
|
54
|
+
BarkestCore.request_restart
|
|
55
|
+
redirect_to system_config_url
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
##
|
|
59
|
+
# GET /system_config/auth
|
|
60
|
+
def show_auth
|
|
61
|
+
@auth_params = BarkestCore::AuthConfig.new(BarkestCore.auth_config)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
##
|
|
65
|
+
# POST /system_config/auth
|
|
66
|
+
def update_auth
|
|
67
|
+
@auth_params = get_auth_params
|
|
68
|
+
|
|
69
|
+
if @auth_params.valid?
|
|
70
|
+
if @auth_params.save
|
|
71
|
+
flash[:safe_success] = 'The configuration has been saved.<br>The app will need to be restarted to use the new configuration.'
|
|
72
|
+
redirect_to system_config_url
|
|
73
|
+
else
|
|
74
|
+
flash.now[:danger] = 'Failed to save the configuration.'
|
|
75
|
+
render 'show_auth'
|
|
76
|
+
end
|
|
77
|
+
else
|
|
78
|
+
render 'show_auth'
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
##
|
|
83
|
+
# GET /system_config/email
|
|
84
|
+
def show_email
|
|
85
|
+
@email_config = BarkestCore::EmailConfig.new(BarkestCore.email_config)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
##
|
|
89
|
+
# POST /system_config/email
|
|
90
|
+
def update_email
|
|
91
|
+
@email_config = get_email_params
|
|
92
|
+
|
|
93
|
+
if @email_config.valid?
|
|
94
|
+
if @email_config.save
|
|
95
|
+
flash[:safe_success] = 'The configuration has been saved.<br>The app will need to be restarted to use the new configuration.'
|
|
96
|
+
redirect_to system_config_url
|
|
97
|
+
else
|
|
98
|
+
flash.now[:danger] = 'Failed to save the configuration.'
|
|
99
|
+
render 'show_email'
|
|
100
|
+
end
|
|
101
|
+
else
|
|
102
|
+
render 'show_email'
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
requires_id :database, '::BarkestCore::DatabaseConfig.registered'
|
|
107
|
+
|
|
108
|
+
##
|
|
109
|
+
# GET /system_config/database/db_name
|
|
110
|
+
def show_database
|
|
111
|
+
@db_config = BarkestCore::DatabaseConfig.new(@db_id, BarkestCore.db_config(@db_id, nil, false))
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
##
|
|
115
|
+
# POST /system_config/database/db_name
|
|
116
|
+
def update_database
|
|
117
|
+
@db_config = get_db_params
|
|
118
|
+
|
|
119
|
+
if @db_config.valid?
|
|
120
|
+
if @db_config.save
|
|
121
|
+
flash[:safe_success] = 'The configuration has been saved.<br>The app will need to be restarted to use the new configuration.'
|
|
122
|
+
redirect_to system_config_url
|
|
123
|
+
else
|
|
124
|
+
flash.now[:danger] = 'Failed to save the configuration.'
|
|
125
|
+
render 'show_database'
|
|
126
|
+
end
|
|
127
|
+
else
|
|
128
|
+
render 'show_database'
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
##
|
|
133
|
+
# GET /system_config/self_update
|
|
134
|
+
def show_self_update
|
|
135
|
+
@config = BarkestCore::SelfUpdateConfig.load
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
##
|
|
139
|
+
# POST /system_config/self_update
|
|
140
|
+
def update_self_update
|
|
141
|
+
@config = get_self_update_params
|
|
142
|
+
|
|
143
|
+
if @config.valid?
|
|
144
|
+
if @config.save
|
|
145
|
+
flash[:success] = 'The configuration has been saved.'
|
|
146
|
+
redirect_to system_config_url
|
|
147
|
+
else
|
|
148
|
+
flash[:danger] = 'Failed to save the configuration.'
|
|
149
|
+
render 'show_self_update'
|
|
150
|
+
end
|
|
151
|
+
else
|
|
152
|
+
render 'show_self_update'
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
##
|
|
157
|
+
# Gets all known configuration items.
|
|
158
|
+
def self.get_config_items
|
|
159
|
+
ret = {}
|
|
160
|
+
rex = /^(show|update)_/
|
|
161
|
+
|
|
162
|
+
id_config_types.each { |item, provider| ret[item] = { require_id: true, id_provider: provider } }
|
|
163
|
+
|
|
164
|
+
self.instance_methods.sort.each do |meth|
|
|
165
|
+
meth = meth.to_s
|
|
166
|
+
if rex.match(meth)
|
|
167
|
+
action,_,item = meth.partition('_')
|
|
168
|
+
action = action.to_sym
|
|
169
|
+
item = item.to_sym
|
|
170
|
+
ret[item] ||= {}
|
|
171
|
+
ret[item][action] = true
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
ret.keep_if{ |_,v| v[:show] && v[:update] }
|
|
176
|
+
|
|
177
|
+
ret.each do |k,v|
|
|
178
|
+
ret[k][:route_name] = :"system_config_#{k}"
|
|
179
|
+
ret[k][:path_helper] = :"system_config_#{k}_path"
|
|
180
|
+
ret[k][:url_helper] = :"system_config_#{k}_url"
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
ret
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
private
|
|
187
|
+
|
|
188
|
+
def require_admin
|
|
189
|
+
authorize! true
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
def get_auth_params
|
|
193
|
+
BarkestCore::AuthConfig.new(params.require(:barkest_core_auth_config).permit(
|
|
194
|
+
:enable_db_auth, :enable_ldap_auth, :ldap_host, :ldap_port, :ldap_base_dn, :ldap_ssl,
|
|
195
|
+
:ldap_browse_user, :ldap_browse_password, :ldap_auto_activate, :ldap_system_admin_groups
|
|
196
|
+
))
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
def get_email_params
|
|
200
|
+
BarkestCore::EmailConfig.new(params.require(:barkest_core_email_config).permit(
|
|
201
|
+
:config_mode, :default_sender, :default_recipient, :default_hostname,
|
|
202
|
+
:address, :port, :authentication, :ssl, :enable_starttls_auto,
|
|
203
|
+
:user_name, :password
|
|
204
|
+
))
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
def get_db_params
|
|
208
|
+
BarkestCore::DatabaseConfig.new(@db_id, params.require(:barkest_core_database_config).permit(
|
|
209
|
+
:adapter, :host, :port, :timeout, :pool, :reconnect, :username, :password,
|
|
210
|
+
:encoding, :database,
|
|
211
|
+
:extra_1_name, :extra_1_type, :extra_1_value, :extra_1_label,
|
|
212
|
+
:extra_2_name, :extra_2_type, :extra_2_value, :extra_2_label,
|
|
213
|
+
:extra_3_name, :extra_3_type, :extra_3_value, :extra_3_label,
|
|
214
|
+
:extra_4_name, :extra_4_type, :extra_4_value, :extra_4_label,
|
|
215
|
+
:extra_5_name, :extra_5_type, :extra_5_value, :extra_5_label,
|
|
216
|
+
:update_username, :update_password
|
|
217
|
+
))
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
def get_self_update_params
|
|
221
|
+
BarkestCore::SelfUpdateConfig.new(params.require(:barkest_core_self_update_config).permit(:host, :port, :user, :password))
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
def validate_db_id
|
|
225
|
+
@db_id = params[:id].to_s.downcase
|
|
226
|
+
if @db_id.blank?
|
|
227
|
+
flash[:danger] = 'Database ID must be specified.'
|
|
228
|
+
redirect_to system_config_url
|
|
229
|
+
elsif @db_id == 'barkest_core'
|
|
230
|
+
flash[:danger] = 'Database ID cannot be barkest_core.'
|
|
231
|
+
redirect_to system_config_url
|
|
232
|
+
elsif BarkestCore.db_config_is_file_based?(@db_id)
|
|
233
|
+
flash[:danger] = "Configuration for #{@db_id} is stored in database.yml."
|
|
234
|
+
redirect_to system_config_url
|
|
235
|
+
end
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
end
|