geoblacklight_admin 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.editorconfig +18 -0
- data/.gitignore +75 -0
- data/.standard.yml +4 -0
- data/Gemfile +59 -0
- data/LICENSE +21 -0
- data/README.md +84 -0
- data/Rakefile +72 -0
- data/app/assets/images/.keep +0 -0
- data/app/assets/images/aerial_photo.jpg +0 -0
- data/app/assets/images/archive-solid.svg +1 -0
- data/app/assets/images/bookmark-regular.svg +1 -0
- data/app/assets/images/bookmark-solid.svg +1 -0
- data/app/assets/images/btaa-logo.jpg +0 -0
- data/app/assets/images/cloud-download-alt-solid.svg +1 -0
- data/app/assets/images/file-import-solid.svg +1 -0
- data/app/assets/images/trash-alt-solid.svg +1 -0
- data/app/assets/javascripts/geoblacklight_admin/chosen.js +4 -0
- data/app/assets/javascripts/geoblacklight_admin/date_range_picker.js +173 -0
- data/app/assets/javascripts/geoblacklight_admin/datepicker.js +22 -0
- data/app/assets/javascripts/geoblacklight_admin/elements.js +38 -0
- data/app/assets/javascripts/geoblacklight_admin/exports.js +3 -0
- data/app/assets/javascripts/geoblacklight_admin/fields.js +11 -0
- data/app/assets/javascripts/geoblacklight_admin/geoblacklight_admin.js +2 -0
- data/app/assets/javascripts/geoblacklight_admin/inputmask.js +4 -0
- data/app/assets/javascripts/geoblacklight_admin/locale.js +5 -0
- data/app/assets/javascripts/geoblacklight_admin/sortable.js +2544 -0
- data/app/assets/javascripts/geoblacklight_admin/tooltips.js +3 -0
- data/app/assets/javascripts/geoblacklight_admin/truncate.js +4 -0
- data/app/assets/javascripts/geoblacklight_admin.js +40 -0
- data/app/assets/stylesheets/geoblacklight_admin/_core.scss +47 -0
- data/app/assets/stylesheets/geoblacklight_admin/modules/_autocomplete.scss +32 -0
- data/app/assets/stylesheets/geoblacklight_admin/modules/_blazer.scss +3 -0
- data/app/assets/stylesheets/geoblacklight_admin/modules/_code.scss +3 -0
- data/app/assets/stylesheets/geoblacklight_admin/modules/_datepicker.scss +477 -0
- data/app/assets/stylesheets/geoblacklight_admin/modules/_elements.scss +3 -0
- data/app/assets/stylesheets/geoblacklight_admin/modules/_forms.scss +28 -0
- data/app/assets/stylesheets/geoblacklight_admin/modules/_icons.scss +15 -0
- data/app/assets/stylesheets/geoblacklight_admin/modules/_nav.scss +9 -0
- data/app/assets/stylesheets/geoblacklight_admin/modules/_tables.scss +4 -0
- data/app/assets/stylesheets/geoblacklight_admin/modules/_toasts.scss +7 -0
- data/app/assets/stylesheets/geoblacklight_admin/modules/_visibility.scss +3 -0
- data/app/assets/stylesheets/geoblacklight_admin/settings/_variables.scss +1 -0
- data/app/channels/export_channel.rb +12 -0
- data/app/controllers/admin/admin_controller.rb +16 -0
- data/app/controllers/admin/advanced_search_controller.rb +365 -0
- data/app/controllers/admin/api_controller.rb +386 -0
- data/app/controllers/admin/bookmarks_controller.rb +68 -0
- data/app/controllers/admin/bulk_actions_controller.rb +94 -0
- data/app/controllers/admin/concerns/.keep +0 -0
- data/app/controllers/admin/concerns/upload_util.rb +8 -0
- data/app/controllers/admin/document_accesses_controller.rb +125 -0
- data/app/controllers/admin/document_assets_controller.rb +198 -0
- data/app/controllers/admin/document_downloads_controller.rb +127 -0
- data/app/controllers/admin/documents_controller.rb +219 -0
- data/app/controllers/admin/elements_controller.rb +81 -0
- data/app/controllers/admin/form_elements_controller.rb +81 -0
- data/app/controllers/admin/ids_controller.rb +379 -0
- data/app/controllers/admin/import_documents_controller.rb +18 -0
- data/app/controllers/admin/imports_controller.rb +105 -0
- data/app/controllers/admin/mappings_controller.rb +95 -0
- data/app/controllers/admin/notifications_controller.rb +51 -0
- data/app/controllers/admin/search_controller.rb +10 -0
- data/app/controllers/admin/users_controller.rb +10 -0
- data/app/helpers/bulk_actions_helper.rb +9 -0
- data/app/helpers/document_helper.rb +60 -0
- data/app/helpers/form_input_helper.rb +73 -0
- data/app/helpers/geoblacklight_admin_helper.rb +118 -0
- data/app/helpers/import_documents_helper.rb +5 -0
- data/app/helpers/mappings_helper.rb +27 -0
- data/app/indexers/document_indexer.rb +34 -0
- data/app/jobs/bulk_action_revert_document_job.rb +49 -0
- data/app/jobs/bulk_action_revert_job.rb +25 -0
- data/app/jobs/bulk_action_run_document_job.rb +42 -0
- data/app/jobs/bulk_action_run_job.rb +27 -0
- data/app/jobs/export_job.rb +72 -0
- data/app/jobs/export_json_job.rb +120 -0
- data/app/jobs/import_document_job.rb +25 -0
- data/app/jobs/import_run_job.rb +33 -0
- data/app/models/active_storage_attachment.rb +5 -0
- data/app/models/active_storage_blob.rb +5 -0
- data/app/models/api_search_builder.rb +12 -0
- data/app/models/application_record.rb +6 -0
- data/app/models/blacklight_api.rb +93 -0
- data/app/models/blacklight_api_facets.rb +15 -0
- data/app/models/blacklight_api_ids.rb +103 -0
- data/app/models/bookmark.rb +17 -0
- data/app/models/bulk_action.rb +88 -0
- data/app/models/bulk_action_document.rb +22 -0
- data/app/models/bulk_action_document_state_machine.rb +16 -0
- data/app/models/bulk_action_document_transition.rb +19 -0
- data/app/models/bulk_action_state_machine.rb +16 -0
- data/app/models/bulk_action_transition.rb +26 -0
- data/app/models/concerns/.keep +0 -0
- data/app/models/document/bbox_validator.rb +70 -0
- data/app/models/document/controlled_lists.rb +104 -0
- data/app/models/document/date_range_validator.rb +63 -0
- data/app/models/document/geom_validator.rb +117 -0
- data/app/models/document/reference.rb +107 -0
- data/app/models/document.rb +264 -0
- data/app/models/document_access.rb +35 -0
- data/app/models/document_download.rb +35 -0
- data/app/models/document_state_machine.rb +14 -0
- data/app/models/document_transition.rb +26 -0
- data/app/models/element.rb +90 -0
- data/app/models/form_control.rb +2 -0
- data/app/models/form_element.rb +19 -0
- data/app/models/form_feature.rb +2 -0
- data/app/models/form_group.rb +2 -0
- data/app/models/form_header.rb +2 -0
- data/app/models/geoblacklight_admin/field_mappings_btaa_aardvark.rb +379 -0
- data/app/models/geoblacklight_admin/field_mappings_gblv1.rb +344 -0
- data/app/models/geoblacklight_admin/iso_language_codes.rb +515 -0
- data/app/models/geoblacklight_admin/schema.rb +194 -0
- data/app/models/geoblacklight_admin.rb +3 -0
- data/app/models/import/csv_duplicates_validator.rb +36 -0
- data/app/models/import/csv_header_validator.rb +24 -0
- data/app/models/import.rb +186 -0
- data/app/models/import_btaa.rb +91 -0
- data/app/models/import_btaa_aardvark.rb +109 -0
- data/app/models/import_document.rb +34 -0
- data/app/models/import_document_state_machine.rb +12 -0
- data/app/models/import_document_transition.rb +19 -0
- data/app/models/import_gblv1.rb +92 -0
- data/app/models/import_state_machine.rb +16 -0
- data/app/models/import_transition.rb +26 -0
- data/app/models/mapping.rb +10 -0
- data/app/models/notification.rb +9 -0
- data/app/models/user.rb +26 -0
- data/app/notifications/export_notification.rb +30 -0
- data/app/services/export_csv_document_access_links_service.rb +47 -0
- data/app/services/export_csv_document_downloads_service.rb +47 -0
- data/app/services/export_csv_service.rb +44 -0
- data/app/services/export_json_service.rb +35 -0
- data/app/services/zip_file_generator.rb +56 -0
- data/app/views/admin/advanced_search/facets.json.jbuilder +80 -0
- data/app/views/admin/advanced_search/index.json.jbuilder +90 -0
- data/app/views/admin/api/_field.json.jbuilder +10 -0
- data/app/views/admin/api/fetch.json.jbuilder +86 -0
- data/app/views/admin/api/index.json.jbuilder +90 -0
- data/app/views/admin/bookmarks/_bookmark.json.jbuilder +4 -0
- data/app/views/admin/bookmarks/create.js.erb +7 -0
- data/app/views/admin/bookmarks/destroy.js.erb +7 -0
- data/app/views/admin/bookmarks/index.html.erb +21 -0
- data/app/views/admin/bookmarks/index.json.jbuilder +3 -0
- data/app/views/admin/bulk_actions/_bulk_action.json.jbuilder +4 -0
- data/app/views/admin/bulk_actions/_form.html.erb +17 -0
- data/app/views/admin/bulk_actions/edit.html.erb +6 -0
- data/app/views/admin/bulk_actions/index.html.erb +54 -0
- data/app/views/admin/bulk_actions/index.json.jbuilder +3 -0
- data/app/views/admin/bulk_actions/new.html.erb +5 -0
- data/app/views/admin/bulk_actions/show.html.erb +100 -0
- data/app/views/admin/bulk_actions/show.json.jbuilder +3 -0
- data/app/views/admin/devise/confirmations/new.html.erb +16 -0
- data/app/views/admin/devise/invitations/edit.html.erb +15 -0
- data/app/views/admin/devise/invitations/new.html.erb +15 -0
- data/app/views/admin/devise/mailer/invitation_instructions.html.erb +11 -0
- data/app/views/admin/devise/mailer/invitation_instructions.text.erb +11 -0
- data/app/views/admin/devise/passwords/edit.html.erb +26 -0
- data/app/views/admin/devise/passwords/new.html.erb +16 -0
- data/app/views/admin/devise/registrations/edit.html.erb +35 -0
- data/app/views/admin/devise/registrations/new.html.erb +30 -0
- data/app/views/admin/devise/sessions/new.html.erb +28 -0
- data/app/views/admin/devise/shared/_links.html.erb +27 -0
- data/app/views/admin/devise/unlocks/new.html.erb +16 -0
- data/app/views/admin/document_accesses/_document_access.json.jbuilder +4 -0
- data/app/views/admin/document_accesses/_form.html.erb +17 -0
- data/app/views/admin/document_accesses/destroy_all.html.erb +70 -0
- data/app/views/admin/document_accesses/edit.html.erb +5 -0
- data/app/views/admin/document_accesses/import.html.erb +70 -0
- data/app/views/admin/document_accesses/index.html.erb +74 -0
- data/app/views/admin/document_accesses/index.json.jbuilder +3 -0
- data/app/views/admin/document_accesses/new.html.erb +6 -0
- data/app/views/admin/document_accesses/show.html.erb +19 -0
- data/app/views/admin/document_accesses/show.json.jbuilder +3 -0
- data/app/views/admin/document_assets/display_attach_form.html.erb +44 -0
- data/app/views/admin/document_assets/index.html.erb +65 -0
- data/app/views/admin/document_downloads/_document_download.json.jbuilder +4 -0
- data/app/views/admin/document_downloads/_form.html.erb +15 -0
- data/app/views/admin/document_downloads/destroy_all.html.erb +70 -0
- data/app/views/admin/document_downloads/edit.html.erb +6 -0
- data/app/views/admin/document_downloads/import.html.erb +74 -0
- data/app/views/admin/document_downloads/index.html.erb +70 -0
- data/app/views/admin/document_downloads/index.json.jbuilder +3 -0
- data/app/views/admin/document_downloads/new.html.erb +5 -0
- data/app/views/admin/document_downloads/show.html.erb +24 -0
- data/app/views/admin/document_downloads/show.json.jbuilder +3 -0
- data/app/views/admin/documents/_document.html.erb +29 -0
- data/app/views/admin/documents/_document_bookmark.html.erb +17 -0
- data/app/views/admin/documents/_document_fields.html.erb +24 -0
- data/app/views/admin/documents/_form.html.erb +49 -0
- data/app/views/admin/documents/_form_control.html.erb +86 -0
- data/app/views/admin/documents/_form_group.html.erb +1 -0
- data/app/views/admin/documents/_form_header.html.erb +1 -0
- data/app/views/admin/documents/_form_nav.html.erb +21 -0
- data/app/views/admin/documents/_json_aardvark.jbuilder +47 -0
- data/app/views/admin/documents/_json_btaa_aardvark.jbuilder +16 -0
- data/app/views/admin/documents/_json_gbl_v1.jbuilder +32 -0
- data/app/views/admin/documents/_result_facets.html.erb +35 -0
- data/app/views/admin/documents/_result_pagination.html.erb +21 -0
- data/app/views/admin/documents/_result_selected_options.html.erb +54 -0
- data/app/views/admin/documents/_result_selection_options.html.erb +10 -0
- data/app/views/admin/documents/_result_toggle.html.erb +13 -0
- data/app/views/admin/documents/edit.html.erb +7 -0
- data/app/views/admin/documents/features/_assets.html.erb +3 -0
- data/app/views/admin/documents/features/_institutional_access_links.html.erb +3 -0
- data/app/views/admin/documents/features/_multiple_download_links.html.erb +27 -0
- data/app/views/admin/documents/fetch.json_aardvark.jbuilder +9 -0
- data/app/views/admin/documents/fetch.json_btaa_aardvark.jbuilder +9 -0
- data/app/views/admin/documents/fetch.json_gbl_v1.jbuilder +9 -0
- data/app/views/admin/documents/index.html.erb +49 -0
- data/app/views/admin/documents/index.json_aardvark.jbuilder +9 -0
- data/app/views/admin/documents/index.json_btaa_aardvark.jbuilder +9 -0
- data/app/views/admin/documents/index.json_gbl_v1.jbuilder +9 -0
- data/app/views/admin/documents/show.json_aardvark.jbuilder +3 -0
- data/app/views/admin/documents/show.json_btaa_aardvark.jbuilder +3 -0
- data/app/views/admin/documents/show.json_gbl_v1.jbuilder +3 -0
- data/app/views/admin/documents/versions.html.erb +110 -0
- data/app/views/admin/elements/_element.json.jbuilder +2 -0
- data/app/views/admin/elements/_form.html.erb +45 -0
- data/app/views/admin/elements/edit.html.erb +6 -0
- data/app/views/admin/elements/index.html.erb +68 -0
- data/app/views/admin/elements/index.json.jbuilder +1 -0
- data/app/views/admin/elements/new.html.erb +5 -0
- data/app/views/admin/elements/show.html.erb +121 -0
- data/app/views/admin/elements/show.json.jbuilder +1 -0
- data/app/views/admin/form_elements/_form.html.erb +46 -0
- data/app/views/admin/form_elements/_form_element.json.jbuilder +2 -0
- data/app/views/admin/form_elements/edit.html.erb +6 -0
- data/app/views/admin/form_elements/index.html.erb +49 -0
- data/app/views/admin/form_elements/index.json.jbuilder +1 -0
- data/app/views/admin/form_elements/new.html.erb +5 -0
- data/app/views/admin/form_elements/show.html.erb +19 -0
- data/app/views/admin/form_elements/show.json.jbuilder +1 -0
- data/app/views/admin/ids/fetch.json.jbuilder +86 -0
- data/app/views/admin/ids/index.json.jbuilder +41 -0
- data/app/views/admin/import_documents/show.html.haml +20 -0
- data/app/views/admin/imports/_form.html.erb +27 -0
- data/app/views/admin/imports/_import.json.jbuilder +4 -0
- data/app/views/admin/imports/_show_failed_tab.html.erb +37 -0
- data/app/views/admin/imports/_show_success_tab.html.erb +31 -0
- data/app/views/admin/imports/edit.html.erb +8 -0
- data/app/views/admin/imports/index.html.erb +56 -0
- data/app/views/admin/imports/index.json.jbuilder +3 -0
- data/app/views/admin/imports/new.html.erb +7 -0
- data/app/views/admin/imports/show.html.erb +123 -0
- data/app/views/admin/imports/show.json.jbuilder +3 -0
- data/app/views/admin/layouts/application.html.erb +30 -0
- data/app/views/admin/layouts/blazer/application.html.erb +23 -0
- data/app/views/admin/layouts/mailer.html.erb +13 -0
- data/app/views/admin/layouts/mailer.text.erb +1 -0
- data/app/views/admin/mappings/_form.html.erb +17 -0
- data/app/views/admin/mappings/_mapping.json.jbuilder +4 -0
- data/app/views/admin/mappings/edit.html.erb +6 -0
- data/app/views/admin/mappings/index.html.erb +37 -0
- data/app/views/admin/mappings/index.json.jbuilder +3 -0
- data/app/views/admin/mappings/new.html.erb +5 -0
- data/app/views/admin/mappings/show.html.erb +27 -0
- data/app/views/admin/mappings/show.json.jbuilder +3 -0
- data/app/views/admin/notifications/_notification.html.haml +31 -0
- data/app/views/admin/notifications/index.html.erb +54 -0
- data/app/views/admin/notifications/update.js.erb +7 -0
- data/app/views/admin/search/index.html.erb +38 -0
- data/app/views/admin/shared/_flash_messages.html.erb +5 -0
- data/app/views/admin/shared/_footer.html.erb +56 -0
- data/app/views/admin/shared/_js_behaviors.html.erb +147 -0
- data/app/views/admin/shared/_navbar.html.erb +78 -0
- data/app/views/admin/shared/_navbar_blazer.html.erb +42 -0
- data/app/views/admin/shared/_schema_timestamp.html.erb +16 -0
- data/app/views/admin/shared/_toast.html.erb +13 -0
- data/app/views/admin/users/index.html.erb +21 -0
- data/config/authorities/formats.yml +25 -0
- data/config/authorities/languages.yml +50 -0
- data/config/authorities/resource_type.yml +82 -0
- data/config/blazer.yml +79 -0
- data/config/gbl_v1_schema.json +118 -0
- data/config/geomg_aardvark_schema.json +211 -0
- data/config/geomg_schema.json +123 -0
- data/config/locales/devise.en.yml +65 -0
- data/config/locales/devise_invitable.en.yml +31 -0
- data/config/locales/documents.en.yml +189 -0
- data/config/locales/en.yml +51 -0
- data/config/locales/geoblacklight.en.yml +178 -0
- data/config/locales/simple_form.en.yml +31 -0
- data/config/routes.rb +162 -0
- data/db/migrate/20230316183001_add_geoblacklight_admin.rb +399 -0
- data/db/seeds.rb +26 -0
- data/db/seeds_elements.csv +56 -0
- data/db/seeds_elements.numbers +0 -0
- data/db/seeds_form_elements.csv +71 -0
- data/db/seeds_form_elements.numbers +0 -0
- data/db/structure.sql +816 -0
- data/geoblacklight_admin.gemspec +67 -0
- data/lib/generators/geoblacklight_admin/config_generator.rb +336 -0
- data/lib/generators/geoblacklight_admin/example_docs_generator.rb +18 -0
- data/lib/generators/geoblacklight_admin/helpers_generator.rb +18 -0
- data/lib/generators/geoblacklight_admin/install_generator.rb +60 -0
- data/lib/generators/geoblacklight_admin/jobs_generator.rb +21 -0
- data/lib/generators/geoblacklight_admin/models_generator.rb +23 -0
- data/lib/generators/geoblacklight_admin/templates/.env.development.example +28 -0
- data/lib/generators/geoblacklight_admin/templates/.solr_wrapper.yml +7 -0
- data/lib/generators/geoblacklight_admin/templates/_user_util_links.html.erb +30 -0
- data/lib/generators/geoblacklight_admin/templates/config/database.yml +18 -0
- data/lib/generators/geoblacklight_admin/templates/config/geomg_aardvark_schema.json +211 -0
- data/lib/generators/geoblacklight_admin/templates/config/initializers/geoblacklight_admin.rb +25 -0
- data/lib/generators/geoblacklight_admin/templates/config/initializers/kithe.rb +31 -0
- data/lib/generators/geoblacklight_admin/templates/config/initializers/pagy.rb +158 -0
- data/lib/generators/geoblacklight_admin/templates/config/initializers/statesman.rb +7 -0
- data/lib/generators/geoblacklight_admin/templates/javascript/channels/consumer.js +6 -0
- data/lib/generators/geoblacklight_admin/templates/javascript/channels/export_channel.js +30 -0
- data/lib/generators/geoblacklight_admin/templates/javascript/channels/index.js +5 -0
- data/lib/generators/geoblacklight_admin/templates/javascript/controllers/application_controller.js +17 -0
- data/lib/generators/geoblacklight_admin/templates/javascript/controllers/document_controller.js +26 -0
- data/lib/generators/geoblacklight_admin/templates/javascript/controllers/index.js +10 -0
- data/lib/generators/geoblacklight_admin/templates/javascript/controllers/results_controller.js +310 -0
- data/lib/generators/geoblacklight_admin/templates/javascript/packs/application.js +23 -0
- data/lib/generators/geoblacklight_admin/templates/javascript/src/js/admin/qa_autocomplete.js +1134 -0
- data/lib/generators/geoblacklight_admin/templates/package.json +32 -0
- data/lib/generators/geoblacklight_admin/templates/solr/README-geoblacklight-solr-development.txt +3 -0
- data/lib/generators/geoblacklight_admin/templates/solr/conf/_rest_managed.json +3 -0
- data/lib/generators/geoblacklight_admin/templates/solr/conf/admin-extra.html +31 -0
- data/lib/generators/geoblacklight_admin/templates/solr/conf/core.properties +5 -0
- data/lib/generators/geoblacklight_admin/templates/solr/conf/elevate.xml +36 -0
- data/lib/generators/geoblacklight_admin/templates/solr/conf/mapping-ISOLatin1Accent.txt +246 -0
- data/lib/generators/geoblacklight_admin/templates/solr/conf/protwords.txt +21 -0
- data/lib/generators/geoblacklight_admin/templates/solr/conf/schema.xml +229 -0
- data/lib/generators/geoblacklight_admin/templates/solr/conf/scripts.conf +24 -0
- data/lib/generators/geoblacklight_admin/templates/solr/conf/solrconfig.xml +266 -0
- data/lib/generators/geoblacklight_admin/templates/solr/conf/spellings.txt +2 -0
- data/lib/generators/geoblacklight_admin/templates/solr/conf/stopwords.txt +58 -0
- data/lib/generators/geoblacklight_admin/templates/solr/conf/stopwords_en.txt +58 -0
- data/lib/generators/geoblacklight_admin/templates/solr/conf/synonyms.txt +43 -0
- data/lib/generators/geoblacklight_admin/templates/solr/conf/xslt/example.xsl +132 -0
- data/lib/generators/geoblacklight_admin/templates/solr/conf/xslt/example_atom.xsl +67 -0
- data/lib/generators/geoblacklight_admin/templates/solr/conf/xslt/example_rss.xsl +66 -0
- data/lib/generators/geoblacklight_admin/templates/solr/conf/xslt/luke.xsl +337 -0
- data/lib/generators/geoblacklight_admin/templates/solr/snapshots/.keep +0 -0
- data/lib/generators/geoblacklight_admin/views_generator.rb +19 -0
- data/lib/geoblacklight_admin/engine.rb +20 -0
- data/lib/geoblacklight_admin/version.rb +5 -0
- data/lib/geoblacklight_admin.rb +7 -0
- data/lib/tasks/.keep +0 -0
- data/lib/tasks/geoblacklight_admin.rake +209 -0
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +35 -0
- data/template.rb +16 -0
- metadata +1037 -0
@@ -0,0 +1,379 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'blacklight/catalog'
|
5
|
+
|
6
|
+
# Admin::IdsController
|
7
|
+
module Admin
|
8
|
+
class IdsController < Admin::AdminController
|
9
|
+
include BlacklightAdvancedSearch::Controller
|
10
|
+
include BlacklightRangeLimit::ControllerOverride
|
11
|
+
include Blacklight::Catalog
|
12
|
+
|
13
|
+
configure_blacklight do |config|
|
14
|
+
# special search builder / fails
|
15
|
+
config.search_builder_class = ApiSearchBuilder
|
16
|
+
|
17
|
+
# default advanced config values
|
18
|
+
config.advanced_search ||= Blacklight::OpenStructWithHashAccess.new
|
19
|
+
|
20
|
+
# Blacklight update to 7.0.0
|
21
|
+
config.add_results_document_tool(:bookmark, partial: 'bookmark_control', if: :render_bookmarks_control?)
|
22
|
+
|
23
|
+
config.add_results_collection_tool(:sort_widget)
|
24
|
+
config.add_results_collection_tool(:per_page_widget)
|
25
|
+
config.add_results_collection_tool(:view_type_group)
|
26
|
+
|
27
|
+
config.add_show_tools_partial(:bookmark, partial: 'bookmark_control', if: :render_bookmarks_control?)
|
28
|
+
config.add_show_tools_partial(:email, callback: :email_action, validator: :validate_email_params)
|
29
|
+
config.add_show_tools_partial(:sms, if: :render_sms_action?, callback: :sms_action, validator: :validate_sms_params)
|
30
|
+
|
31
|
+
config.add_nav_action(:bookmark, partial: 'blacklight/nav/bookmark', if: :render_bookmarks_control?)
|
32
|
+
# Blacklight update to 7.0.0
|
33
|
+
|
34
|
+
# Advanced config values
|
35
|
+
config.advanced_search ||= Blacklight::OpenStructWithHashAccess.new
|
36
|
+
config.advanced_search[:url_key] ||= 'advanced'
|
37
|
+
config.advanced_search[:query_parser] ||= 'edismax'
|
38
|
+
config.advanced_search[:form_solr_parameters] ||= {}
|
39
|
+
config.advanced_search[:form_solr_parameters]['facet.field'] ||= [Settings.FIELDS.PROVIDER, Settings.FIELDS.B1G_CODE, Settings.FIELDS.MEMBER_OF, Settings.FIELDS.IS_PART_OF, Settings.FIELDS.RESOURCE_CLASS, Settings.FIELDS.RESOURCE_TYPE, Settings.FIELDS.SUBJECT, Settings.FIELDS.THEME, Settings.FIELDS.FORMAT, Settings.FIELDS.SUPPRESSED, Settings.FIELDS.B1G_CHILD_RECORD, Settings.FIELDS.GEOREFERENCED]
|
40
|
+
config.advanced_search[:form_solr_parameters]['facet.query'] ||= ''
|
41
|
+
config.advanced_search[:form_solr_parameters]['facet.limit'] ||= -1
|
42
|
+
config.advanced_search[:form_solr_parameters]['facet.sort'] ||= 'index'
|
43
|
+
|
44
|
+
# Map views
|
45
|
+
config.view.mapview.partials = [:index]
|
46
|
+
config.view['split'].title = "List view"
|
47
|
+
config.view['mapview'].title = "Map view"
|
48
|
+
|
49
|
+
config.raw_endpoint.enabled = true
|
50
|
+
|
51
|
+
## Default parameters to send to solr for all search-like requests. See also SolrHelper#solr_search_params
|
52
|
+
config.default_solr_params = {
|
53
|
+
:start => 0,
|
54
|
+
'q.alt' => '*:*',
|
55
|
+
'bf' => ["if(exists(#{Settings.FIELDS.B1G_CHILD_RECORD}),0,100)^0.5"],
|
56
|
+
'admin.api' => true
|
57
|
+
}
|
58
|
+
|
59
|
+
config.default_per_page = 1000 # Works!
|
60
|
+
|
61
|
+
## Default parameters to send on single-document requests to Solr. These settings are the Blackligt defaults (see SolrHelper#solr_doc_params) or
|
62
|
+
## parameters included in the Blacklight-jetty document requestHandler.
|
63
|
+
#
|
64
|
+
config.default_document_solr_params = {
|
65
|
+
:qt => 'document',
|
66
|
+
:q => "{!raw f=#{Settings.FIELDS.B1G_GEOMG_ID} v=$id}"
|
67
|
+
}
|
68
|
+
|
69
|
+
# config.search_builder_class = Geoblacklight::SearchBuilder
|
70
|
+
|
71
|
+
# solr field configuration for search results/index views
|
72
|
+
# config.index.show_link = 'title_display'
|
73
|
+
# config.index.record_display_type = 'format'
|
74
|
+
|
75
|
+
config.index.title_field = Settings.FIELDS.TITLE
|
76
|
+
config.index.document_presenter_class = Geoblacklight::DocumentPresenter
|
77
|
+
|
78
|
+
# solr field configuration for document/show views
|
79
|
+
|
80
|
+
config.show.display_type_field = 'format'
|
81
|
+
|
82
|
+
# Custom GeoBlacklight fields which currently map to GeoBlacklight-Schema
|
83
|
+
# v0.3.2
|
84
|
+
config.wxs_identifier_field = Settings.FIELDS.WXS_IDENTIFIER
|
85
|
+
|
86
|
+
# solr fields that will be treated as facets by the blacklight application
|
87
|
+
# The ordering of the field names is the order of the display
|
88
|
+
#
|
89
|
+
# Setting a limit will trigger Blacklight's 'more' facet values link.
|
90
|
+
# * If left unset, then all facet values returned by solr will be displayed.
|
91
|
+
# * If set to an integer, then "f.somefield.facet.limit" will be added to
|
92
|
+
# solr request, with actual solr request being +1 your configured limit --
|
93
|
+
# you configure the number of items you actually want _displayed_ in a page.
|
94
|
+
# * If set to 'true', then no additional parameters will be sent to solr,
|
95
|
+
# but any 'sniffed' request limit parameters will be used for paging, with
|
96
|
+
# paging at requested limit -1. Can sniff from facet.limit or
|
97
|
+
# f.specific_field.facet.limit solr request params. This 'true' config
|
98
|
+
# can be used if you set limits in :default_solr_params, or as defaults
|
99
|
+
# on the solr side in the request handler itself. Request handler defaults
|
100
|
+
# sniffing requires solr requests to be made with "echoParams=all", for
|
101
|
+
# app code to actually have it echo'd back to see it.
|
102
|
+
#
|
103
|
+
# :show may be set to false if you don't want the facet to be drawn in the
|
104
|
+
# facet bar
|
105
|
+
# config.add_facet_field 'format', :label => 'Format'
|
106
|
+
# config.add_facet_field 'pub_date', :label => 'Publication Year', :single => true
|
107
|
+
# config.add_facet_field 'subject_topic_facet', :label => 'Topic', :limit => 20
|
108
|
+
# config.add_facet_field 'language_facet', :label => 'Language', :limit => true
|
109
|
+
# config.add_facet_field 'lc_1letter_facet', :label => 'Call Number'
|
110
|
+
# config.add_facet_field 'subject_geo_facet', :label => 'Region'
|
111
|
+
# config.add_facet_field 'solr_bbox', :fq => "solr_bbox:IsWithin(-88,26,-79,36)", :label => 'Spatial'
|
112
|
+
|
113
|
+
# config.add_facet_field 'example_pivot_field', :label => 'Pivot Field', :pivot => ['format', 'language_facet']
|
114
|
+
|
115
|
+
## FACETS
|
116
|
+
#
|
117
|
+
# Date Range Filter
|
118
|
+
config.add_facet_field 'date_created_drsim', :label => 'Date Created', :show => false
|
119
|
+
|
120
|
+
# Date Created
|
121
|
+
config.add_facet_field 'time_period', label: 'Date Created', query: {
|
122
|
+
'today' => { label: 'Today', fq: "date_created_drsim:[#{Date.today.beginning_of_day.to_time.strftime('%Y-%m-%dT%H:%M:%S')} TO #{Date.today.end_of_day.to_time.strftime('%Y-%m-%dT%H:%M:%S')}]"},
|
123
|
+
'this_week' => { label: 'This week', fq: "date_created_drsim:[#{(Date.today.end_of_day - 1.week).to_time.strftime('%Y-%m-%dT%H:%M:%S')} TO #{Date.today.end_of_day.to_time.strftime('%Y-%m-%dT%H:%M:%S')}]"},
|
124
|
+
'this_month' => { label: 'This month', fq: "date_created_drsim:[#{(Date.today.end_of_day - 1.month).to_time.strftime('%Y-%m-%dT%H:%M:%S')} TO #{Date.today.end_of_day.to_time.strftime('%Y-%m-%dT%H:%M:%S')}]"},
|
125
|
+
'last_month' => { label: 'Last month', fq: "date_created_drsim:[#{(Date.today.end_of_day - 2.months).to_time.strftime('%Y-%m-%dT%H:%M:%S')} TO #{(Date.today.end_of_day - 1.month).to_time.strftime('%Y-%m-%dT%H:%M:%S')}]"},
|
126
|
+
'this_quarter' => { label: 'This quarter', fq: "date_created_drsim:[#{(Date.today.end_of_day - 3.months).to_time.strftime('%Y-%m-%dT%H:%M:%S')} TO #{(Date.today.end_of_day).to_time.strftime('%Y-%m-%dT%H:%M:%S')}]"},
|
127
|
+
'this_year' => { label: 'This year', fq: "date_created_drsim:[#{(Date.today.end_of_day - 1.year).to_time.strftime('%Y-%m-%dT%H:%M:%S')} TO #{(Date.today.end_of_day).to_time.strftime('%Y-%m-%dT%H:%M:%S')}]"}
|
128
|
+
}
|
129
|
+
|
130
|
+
# Publication State
|
131
|
+
config.add_facet_field Settings.FIELDS.B1G_PUBLICATION_STATE, show: false
|
132
|
+
|
133
|
+
# Resouce Class
|
134
|
+
config.add_facet_field Settings.FIELDS.RESOURCE_CLASS, show: false
|
135
|
+
|
136
|
+
# Contributor
|
137
|
+
config.add_facet_field Settings.FIELDS.PROVIDER, show: false
|
138
|
+
|
139
|
+
# Accrual Method
|
140
|
+
config.add_facet_field Settings.FIELDS.B1G_ACCRUAL_METHOD, show: false
|
141
|
+
|
142
|
+
# Public/Restricted
|
143
|
+
config.add_facet_field Settings.FIELDS.ACCESS_RIGHTS, show: false
|
144
|
+
|
145
|
+
# ADVANCED SEARCH
|
146
|
+
#
|
147
|
+
# Code
|
148
|
+
config.add_facet_field Settings.FIELDS.B1G_CODE, label: 'Code', limit: 1000
|
149
|
+
|
150
|
+
# Is Part Of
|
151
|
+
config.add_facet_field Settings.FIELDS.IS_PART_OF, label: 'Is Part Of', limit: 1000
|
152
|
+
|
153
|
+
# Member Of
|
154
|
+
config.add_facet_field Settings.FIELDS.MEMBER_OF, label: 'Member Of', limit: 1000
|
155
|
+
|
156
|
+
# Resource Type
|
157
|
+
config.add_facet_field Settings.FIELDS.RESOURCE_TYPE, label: 'Resource Type', limit: 1000
|
158
|
+
|
159
|
+
# Subject
|
160
|
+
config.add_facet_field Settings.FIELDS.SUBJECT, label: 'Subject', limit: 1000
|
161
|
+
|
162
|
+
# Theme
|
163
|
+
config.add_facet_field Settings.FIELDS.THEME, label: 'Theme', limit: 1000
|
164
|
+
|
165
|
+
# Format
|
166
|
+
config.add_facet_field Settings.FIELDS.FORMAT, label: 'Format', limit: 1000
|
167
|
+
|
168
|
+
# Suppressed
|
169
|
+
config.add_facet_field Settings.FIELDS.SUPPRESSED, label: 'Suppressed'
|
170
|
+
|
171
|
+
# Child Record
|
172
|
+
config.add_facet_field Settings.FIELDS.B1G_CHILD_RECORD, label: 'Child Record'
|
173
|
+
|
174
|
+
# Georeferenced
|
175
|
+
config.add_facet_field Settings.FIELDS.GEOREFERENCED, label: 'Georeferenced'
|
176
|
+
|
177
|
+
# Have BL send all facet field names to Solr, which has been the default
|
178
|
+
# previously. Simply remove these lines if you'd rather use Solr request
|
179
|
+
# handler defaults, or have no facets.
|
180
|
+
# config.add_facet_fields_to_solr_request!
|
181
|
+
|
182
|
+
# solr fields to be displayed in the index (search results) view
|
183
|
+
# The ordering of the field names is the order of the display
|
184
|
+
# config.add_index_field 'title_display', :label => 'Title:'
|
185
|
+
# config.add_index_field 'title_vern_display', :label => 'Title:'
|
186
|
+
# config.add_index_field 'author_display', :label => 'Author:'
|
187
|
+
# config.add_index_field 'author_vern_display', :label => 'Author:'
|
188
|
+
# config.add_index_field 'format', :label => 'Format:'
|
189
|
+
# config.add_index_field 'language_facet', :label => 'Language:'
|
190
|
+
# config.add_index_field 'published_display', :label => 'Published:'
|
191
|
+
# config.add_index_field 'published_vern_display', :label => 'Published:'
|
192
|
+
# config.add_index_field 'lc_callnum_display', :label => 'Call number:'
|
193
|
+
|
194
|
+
# config.add_index_field Settings.FIELDS.TITLE, :label => 'Title:'
|
195
|
+
# config.add_index_field Settings.FIELDS.B1G_GEOMG_ID, :label => 'Identifier:'
|
196
|
+
# config.add_index_field Settings.FIELDS.PROVIDER, :label => 'Institution:'
|
197
|
+
# config.add_index_field Settings.FIELDS.ACCESS_RIGHTS, :label => 'Access:'
|
198
|
+
# config.add_index_field Settings.FIELDS.SUBJECT, :label => 'Keywords:'
|
199
|
+
# config.add_index_field Settings.FIELDS.CENTROID, :label => 'Centroid:'
|
200
|
+
# config.add_index_field Settings.FIELDS.INDEX_YEAR
|
201
|
+
# config.add_index_field Settings.FIELDS.CREATOR
|
202
|
+
# config.add_index_field Settings.FIELDS.DESCRIPTION, helper_method: :snippit
|
203
|
+
# config.add_index_field Settings.FIELDS.PUBLISHER
|
204
|
+
# config.add_index_field Settings.FIELDS.SUPPRESSED, :label => 'Suppressed:'
|
205
|
+
|
206
|
+
# solr fields to be displayed in the show (single result) view
|
207
|
+
# The ordering of the field names is the order of the display
|
208
|
+
#
|
209
|
+
# item_prop: [String] property given to span with Schema.org item property
|
210
|
+
# link_to_facet: [Boolean] that can be passed to link to a facet search
|
211
|
+
# helper_method: [Symbol] method that can be used to render the value
|
212
|
+
# config.add_show_field Settings.FIELDS.CREATOR, label: 'Creator', itemprop: 'creator'
|
213
|
+
# config.add_show_field Settings.FIELDS.DESCRIPTION, label: 'Description', itemprop: 'description', helper_method: :render_value_as_truncate_abstract
|
214
|
+
# config.add_show_field Settings.FIELDS.PUBLISHER, label: 'Publisher', itemprop: 'publisher', link_to_facet: true
|
215
|
+
# config.add_show_field Settings.FIELDS.SPATIAL_COVERAGE, label: 'Place', itemprop: 'spatial', link_to_facet: true, helper_method: :render_placenames_as_truncate_abstract
|
216
|
+
# config.add_show_field Settings.FIELDS.SUBJECT, label: 'Subject', itemprop: 'keywords', link_to_facet: true
|
217
|
+
# config.add_show_field Settings.FIELDS.RESOURCE_TYPE, label: 'Type', itemprop: 'keywords', link_to_facet: true
|
218
|
+
# config.add_show_field Settings.FIELDS.DATE_ISSUED, label: 'Date # Published', itemprop: 'keywords', link_to_facet: true
|
219
|
+
# config.add_show_field Settings.FIELDS.TEMPORAL_COVERAGE, label: 'Temporal Coverage', itemprop: 'temporal'
|
220
|
+
# config.add_show_field Settings.FIELDS.PROVIDER, label: 'Contributed by', link_to_facet: true
|
221
|
+
# config.add_show_field Settings.FIELDS.RIGHTS, label: 'Access Rights'
|
222
|
+
|
223
|
+
# "fielded" search configuration. Used by pulldown among other places.
|
224
|
+
# For supported keys in hash, see rdoc for Blacklight::SearchFields
|
225
|
+
#
|
226
|
+
# Search fields will inherit the :qt solr request handler from
|
227
|
+
# config[:default_solr_parameters], OR can specify a different one
|
228
|
+
# with a :qt key/value. Below examples inherit, except for subject
|
229
|
+
# that specifies the same :qt as default for our own internal
|
230
|
+
# testing purposes.
|
231
|
+
#
|
232
|
+
# The :key is what will be used to identify this BL search field internally,
|
233
|
+
# as well as in URLs -- so changing it after deployment may break bookmarked
|
234
|
+
# urls. A display label will be automatically calculated from the :key,
|
235
|
+
# or can be specified manually to be different.
|
236
|
+
|
237
|
+
# This one uses all the defaults set by the solr request handler. Which
|
238
|
+
# solr request handler? The one set in config[:default_solr_parameters][:qt],
|
239
|
+
# since we aren't specifying it otherwise.
|
240
|
+
|
241
|
+
config.add_search_field('all_fields') do |field|
|
242
|
+
field.include_in_advanced_search = false
|
243
|
+
field.label = 'All Fields'
|
244
|
+
end
|
245
|
+
|
246
|
+
config.add_search_field('keyword') do |field|
|
247
|
+
field.include_in_simple_select = false
|
248
|
+
field.qt = 'search'
|
249
|
+
field.label = 'Keyword'
|
250
|
+
field.solr_local_parameters = {
|
251
|
+
qf: '$qf',
|
252
|
+
pf: '$pf'
|
253
|
+
}
|
254
|
+
end
|
255
|
+
|
256
|
+
config.add_search_field('title') do |field|
|
257
|
+
field.include_in_simple_select = false
|
258
|
+
field.qt = 'search'
|
259
|
+
field.label = 'Title'
|
260
|
+
field.solr_local_parameters = {
|
261
|
+
qf: '$title_qf',
|
262
|
+
pf: '$title_pf'
|
263
|
+
}
|
264
|
+
end
|
265
|
+
|
266
|
+
config.add_search_field('placename') do |field|
|
267
|
+
field.include_in_simple_select = false
|
268
|
+
field.qt = 'search'
|
269
|
+
field.label = 'Place'
|
270
|
+
field.solr_local_parameters = {
|
271
|
+
qf: '$placename_qf',
|
272
|
+
pf: '$placename_pf'
|
273
|
+
}
|
274
|
+
end
|
275
|
+
|
276
|
+
config.add_search_field('publisher') do |field|
|
277
|
+
field.include_in_simple_select = false
|
278
|
+
field.qt = 'search'
|
279
|
+
field.label = 'Publisher/Creator'
|
280
|
+
field.solr_local_parameters = {
|
281
|
+
qf: '$publisher_qf',
|
282
|
+
pf: '$publisher_pf'
|
283
|
+
}
|
284
|
+
end
|
285
|
+
|
286
|
+
# "sort results by" select (pulldown)
|
287
|
+
# label in pulldown is followed by the name of the SOLR field to sort by and
|
288
|
+
# whether the sort is ascending or descending (it must be asc or desc
|
289
|
+
# except in the relevancy case).
|
290
|
+
config.add_sort_field 'score desc, dct_title_sort asc', :label => 'relevance'
|
291
|
+
config.add_sort_field "#{Settings.FIELDS.INDEX_YEAR} desc, dct_title_sort asc", :label => 'year'
|
292
|
+
config.add_sort_field 'dct_title_sort asc', :label => 'title'
|
293
|
+
|
294
|
+
# If there are more than this many search results, no spelling ("did you
|
295
|
+
# mean") suggestion is offered.
|
296
|
+
config.spell_max = 5
|
297
|
+
|
298
|
+
# Custom tools for GeoBlacklight
|
299
|
+
config.add_show_tools_partial :more_details, partial: 'more_details', if: proc { |_context, _config, options| options[:document] && (!options[:document].references.nil? & !options[:document].references.url.nil?)}
|
300
|
+
config.add_show_tools_partial :metadata, if: proc { |_context, _config, options| options[:document] && (Settings.METADATA_SHOWN & options[:document].references.refs.map(&:type).map(&:to_s)).any? }
|
301
|
+
config.add_show_tools_partial :web_services, if: proc { |_context, _config, options| options[:document] && (Settings.WEBSERVICES_SHOWN & options[:document].references.refs.map(&:type).map(&:to_s)).any? }
|
302
|
+
config.add_show_tools_partial :exports, partial: 'exports', if: proc { |_context, _config, options| options[:document] }
|
303
|
+
config.add_show_tools_partial :data_dictionary, partial: 'data_dictionary', if: proc { |_context, _config, options| options[:document] && options[:document].data_dictionary_download.present?}
|
304
|
+
config.add_show_tools_partial(:citation)
|
305
|
+
config.add_show_tools_partial(:access_links, partial: 'access_links', if: proc { |_context, _config, options| options[:document] && options[:document].access_links.present?})
|
306
|
+
|
307
|
+
# Remove nav actions
|
308
|
+
config.add_nav_action(:bookmark, partial: 'blacklight/nav/bookmark', if: false)
|
309
|
+
|
310
|
+
# Remove show tools
|
311
|
+
config.show.partials.delete(:show_header)
|
312
|
+
config.show.partials.delete(:show)
|
313
|
+
|
314
|
+
config.show.display_type_field = 'format'
|
315
|
+
config.show.partials << 'show_header'
|
316
|
+
config.show.partials << 'show_default_viewer_container'
|
317
|
+
config.show.partials << 'show_default_viewer_information'
|
318
|
+
config.show.partials << 'show_default_attribute_table'
|
319
|
+
config.show.partials << 'show'
|
320
|
+
|
321
|
+
|
322
|
+
config.show.document_actions.delete(:email)
|
323
|
+
config.show.document_actions.delete(:bookmark)
|
324
|
+
config.show.document_actions.delete(:sms)
|
325
|
+
|
326
|
+
# Configure basemap provider for GeoBlacklight maps (uses https only basemap
|
327
|
+
# providers with open licenses)
|
328
|
+
# Valid basemaps include:
|
329
|
+
# 'mapquest' http://developer.mapquest.com/web/products/open/map
|
330
|
+
# 'positron' http://cartodb.com/basemaps/
|
331
|
+
# 'darkMatter' http://cartodb.com/basemaps/
|
332
|
+
config.basemap_provider = 'esri'
|
333
|
+
config.max_per_page = 100000
|
334
|
+
|
335
|
+
# Configuration for autocomplete suggestor
|
336
|
+
config.autocomplete_enabled = true
|
337
|
+
config.autocomplete_path = 'suggest'
|
338
|
+
end
|
339
|
+
|
340
|
+
# Administrative view of document
|
341
|
+
# - Sidecar Image
|
342
|
+
# - URIs
|
343
|
+
def admin
|
344
|
+
deprecated_response, @document = search_service.fetch(params[:id])
|
345
|
+
end
|
346
|
+
|
347
|
+
# Administrative view for array of document ids
|
348
|
+
# - bookmarks
|
349
|
+
def fetch
|
350
|
+
@response, deprecated_document_list = search_service.fetch(params[:id])
|
351
|
+
|
352
|
+
respond_to do |format|
|
353
|
+
format.json do
|
354
|
+
@presenter = Blacklight::JsonPresenter.new(@response,
|
355
|
+
blacklight_config)
|
356
|
+
end
|
357
|
+
end
|
358
|
+
end
|
359
|
+
|
360
|
+
# Administrative view of adv search facets
|
361
|
+
def advanced_search_facets
|
362
|
+
# We want to find the facets available for the current search, but:
|
363
|
+
# * IGNORING current query (add in facets_for_advanced_search_form filter)
|
364
|
+
# * IGNORING current advanced search facets (remove add_advanced_search_to_solr filter)
|
365
|
+
@response, _ = search_service.search_results do |search_builder|
|
366
|
+
search_builder.except(:add_advanced_search_to_solr).append(:facets_for_advanced_search_form)
|
367
|
+
end
|
368
|
+
|
369
|
+
@response
|
370
|
+
|
371
|
+
respond_to do |format|
|
372
|
+
format.json do
|
373
|
+
@presenter = Blacklight::JsonPresenter.new(@response,
|
374
|
+
blacklight_config)
|
375
|
+
end
|
376
|
+
end
|
377
|
+
end
|
378
|
+
end
|
379
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Admin::ImportDocumentsController
|
4
|
+
module Admin
|
5
|
+
class ImportDocumentsController < Admin::AdminController
|
6
|
+
before_action :set_import_document, only: %i[show]
|
7
|
+
|
8
|
+
def show
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
# Use callbacks to share common setup or constraints between actions.
|
14
|
+
def set_import_document
|
15
|
+
@import_document = ImportDocument.find(params[:id])
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Admin::ImportsController
|
4
|
+
module Admin
|
5
|
+
class ImportsController < Admin::AdminController
|
6
|
+
before_action :set_import, only: %i[show edit update destroy run]
|
7
|
+
|
8
|
+
# GET /imports
|
9
|
+
# GET /imports.json
|
10
|
+
def index
|
11
|
+
@pagy, @imports = pagy(Import.all.order("created_at DESC"), items: 20)
|
12
|
+
end
|
13
|
+
|
14
|
+
# GET /imports/1
|
15
|
+
# GET /imports/1.json
|
16
|
+
def show
|
17
|
+
@pagy_failed, @import_failed_documents = pagy(@import.import_documents.not_in_state(:success), items: 100)
|
18
|
+
@pagy_success, @import_success_documents = pagy(@import.import_documents.in_state(:success), items: 100)
|
19
|
+
end
|
20
|
+
|
21
|
+
# GET /imports/new
|
22
|
+
def new
|
23
|
+
@import = Import.new
|
24
|
+
end
|
25
|
+
|
26
|
+
# GET /imports/1/edit
|
27
|
+
def edit
|
28
|
+
end
|
29
|
+
|
30
|
+
# POST /imports
|
31
|
+
# POST /imports.json
|
32
|
+
def create
|
33
|
+
@import = Import.new(import_params)
|
34
|
+
|
35
|
+
respond_to do |format|
|
36
|
+
if @import.save
|
37
|
+
format.html { redirect_to admin_import_mappings_path(@import), notice: "Import was successful. Please set your import mapping rules." }
|
38
|
+
format.json { render :show, status: :created, location: @import }
|
39
|
+
else
|
40
|
+
format.html { render :new }
|
41
|
+
format.json { render json: @import.errors, status: :unprocessable_entity }
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# PATCH/PUT /imports/1
|
47
|
+
# PATCH/PUT /imports/1.json
|
48
|
+
def update
|
49
|
+
respond_to do |format|
|
50
|
+
if @import.update(import_params)
|
51
|
+
format.html { redirect_to admin_import_path(@import), notice: "Import was successfully updated." }
|
52
|
+
format.json { render :show, status: :ok, location: @import }
|
53
|
+
else
|
54
|
+
format.html { render :edit }
|
55
|
+
format.json { render json: @import.errors, status: :unprocessable_entity }
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# DELETE /imports/1
|
61
|
+
# DELETE /imports/1.json
|
62
|
+
def destroy
|
63
|
+
@import.destroy
|
64
|
+
respond_to do |format|
|
65
|
+
format.html { redirect_to admin_imports_url, notice: "Import was successfully destroyed." }
|
66
|
+
format.json { head :no_content }
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def run
|
71
|
+
@import.run!
|
72
|
+
redirect_to admin_import_url(@import), notice: "Import is running. Check back soon for results."
|
73
|
+
end
|
74
|
+
|
75
|
+
private
|
76
|
+
|
77
|
+
# Use callbacks to share common setup or constraints between actions.
|
78
|
+
def set_import
|
79
|
+
@import = Import.find(params[:id])
|
80
|
+
end
|
81
|
+
|
82
|
+
# Never trust parameters from the scary internet, only allow the white list through.
|
83
|
+
|
84
|
+
def permittable_params
|
85
|
+
%i[type name filename source description row_count encoding content_type extension validity validation_result csv_file run]
|
86
|
+
end
|
87
|
+
|
88
|
+
def import_params
|
89
|
+
# Handle STI key
|
90
|
+
key = (params.keys & %w[import import_btaa import_btaa_aardvark import_gblv1])[0]
|
91
|
+
params.require(key).permit(
|
92
|
+
permittable_params,
|
93
|
+
mappings_attributes: %i[
|
94
|
+
id
|
95
|
+
source_header
|
96
|
+
destination_field
|
97
|
+
delimited
|
98
|
+
transformation_method
|
99
|
+
import_id
|
100
|
+
],
|
101
|
+
headers: []
|
102
|
+
)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Admin::MappingsController
|
4
|
+
module Admin
|
5
|
+
class MappingsController < Admin::AdminController
|
6
|
+
before_action :set_import
|
7
|
+
before_action :set_mapping, only: %i[show edit update destroy]
|
8
|
+
|
9
|
+
# GET /import/:id/mappings
|
10
|
+
# GET /import/:id/mappings.json
|
11
|
+
def index
|
12
|
+
@mappings = Mapping.where(import_id: @import)
|
13
|
+
|
14
|
+
# Build mappings unless we already have
|
15
|
+
@import.mappings.build if @import.mappings.blank?
|
16
|
+
end
|
17
|
+
|
18
|
+
# GET /mappings/1
|
19
|
+
# GET /mappings/1.json
|
20
|
+
def show
|
21
|
+
@import = Import.find(params[:import_id])
|
22
|
+
end
|
23
|
+
|
24
|
+
# GET /mappings/new
|
25
|
+
def new
|
26
|
+
@mapping = Mapping.new
|
27
|
+
end
|
28
|
+
|
29
|
+
# GET /mappings/1/edit
|
30
|
+
def edit
|
31
|
+
end
|
32
|
+
|
33
|
+
# POST /mappings
|
34
|
+
# POST /mappings.json
|
35
|
+
def create
|
36
|
+
@mapping = Mapping.new(mapping_params)
|
37
|
+
|
38
|
+
respond_to do |format|
|
39
|
+
if @mapping.save
|
40
|
+
format.html { redirect_to import_mapping_path(@import, @mapping), notice: "Mapping was successfully created." }
|
41
|
+
format.json { render :show, status: :created, location: @mapping }
|
42
|
+
else
|
43
|
+
format.html { render :new }
|
44
|
+
format.json { render json: @mapping.errors, status: :unprocessable_entity }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# PATCH/PUT /mappings/1
|
50
|
+
# PATCH/PUT /mappings/1.json
|
51
|
+
def update
|
52
|
+
respond_to do |format|
|
53
|
+
if @mapping.update(mapping_params)
|
54
|
+
format.html { redirect_to import_mappings_path(@mapping.import), notice: "Mapping was successfully updated." }
|
55
|
+
format.json { render :show, status: :ok, location: @mapping }
|
56
|
+
else
|
57
|
+
format.html { render :edit }
|
58
|
+
format.json { render json: @mapping.errors, status: :unprocessable_entity }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# DELETE /mappings/1
|
64
|
+
# DELETE /mappings/1.json
|
65
|
+
def destroy
|
66
|
+
@mapping.destroy
|
67
|
+
respond_to do |format|
|
68
|
+
format.html { redirect_to import_mappings_url(@import), notice: "Mapping was successfully destroyed." }
|
69
|
+
format.json { head :no_content }
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
private
|
74
|
+
|
75
|
+
# Use callbacks to share common setup or constraints between actions.
|
76
|
+
def set_import
|
77
|
+
@import = Import.find(params[:import_id])
|
78
|
+
end
|
79
|
+
|
80
|
+
def set_mapping
|
81
|
+
@mapping = Mapping.find(params[:id])
|
82
|
+
end
|
83
|
+
|
84
|
+
# Only allow a list of trusted parameters through.
|
85
|
+
def mapping_params
|
86
|
+
params.require(:mapping).permit(
|
87
|
+
:source_header,
|
88
|
+
:destination_field,
|
89
|
+
:delimited,
|
90
|
+
:transformation_method,
|
91
|
+
:import_id
|
92
|
+
)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Admin::NotificationsController
|
4
|
+
module Admin
|
5
|
+
class NotificationsController < Admin::AdminController
|
6
|
+
before_action :set_notification, only: %i[update destroy]
|
7
|
+
|
8
|
+
def index
|
9
|
+
@pagy, @notifications = pagy(current_user.notifications.order(created_at: :desc), items: 20)
|
10
|
+
end
|
11
|
+
|
12
|
+
def update
|
13
|
+
case params[:read]
|
14
|
+
when "0"
|
15
|
+
@notification.update(read_at: nil)
|
16
|
+
@toast = "Notification marked unread."
|
17
|
+
when "1"
|
18
|
+
@notification.update(read_at: Time.zone.now)
|
19
|
+
@toast = "Notification marked read."
|
20
|
+
end
|
21
|
+
|
22
|
+
respond_to do |format|
|
23
|
+
format.html { redirect_to admin_notifications_url }
|
24
|
+
format.js
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def destroy
|
29
|
+
@notification.file.purge
|
30
|
+
@notification.destroy
|
31
|
+
respond_to do |format|
|
32
|
+
format.html { redirect_to admin_notifications_url, notice: "Notification was successfully destroyed." }
|
33
|
+
format.json { head :no_content }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def batch
|
38
|
+
return unless params[:read] == "all"
|
39
|
+
|
40
|
+
current_user.notifications.mark_as_read!
|
41
|
+
flash[:success] = "All notifications marked as read."
|
42
|
+
redirect_to admin_notifications_url
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def set_notification
|
48
|
+
@notification = Notification.find(params[:id])
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|