geoblacklight_admin 0.5.0 → 0.6.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 +4 -4
- data/README.md +24 -11
- data/Rakefile +83 -47
- data/app/assets/javascripts/geoblacklight_admin/chosen.js +1 -0
- data/app/assets/stylesheets/geoblacklight_admin/_core.scss +24 -0
- data/app/assets/stylesheets/geoblacklight_admin/modules/_nav.scss +0 -5
- data/app/assets/stylesheets/geoblacklight_admin/modules/_tables.scss +1 -1
- data/app/controllers/admin/admin_controller.rb +16 -0
- data/app/controllers/admin/advanced_search_controller.rb +7 -1
- data/app/controllers/admin/assets_controller.rb +47 -32
- data/app/controllers/admin/bookmarks_controller.rb +17 -5
- data/app/controllers/admin/bulk_actions_controller.rb +32 -1
- data/app/controllers/admin/document_accesses_controller.rb +38 -0
- data/app/controllers/admin/document_assets_controller.rb +47 -89
- data/app/controllers/admin/document_distributions_controller.rb +172 -0
- data/app/controllers/admin/documents_controller.rb +43 -57
- data/app/controllers/admin/elements_controller.rb +24 -0
- data/app/controllers/admin/form_elements_controller.rb +33 -0
- data/app/controllers/admin/ids_controller.rb +6 -0
- data/app/controllers/admin/import_documents_controller.rb +11 -1
- data/app/controllers/admin/imports_controller.rb +34 -4
- data/app/controllers/admin/mappings_controller.rb +15 -0
- data/app/controllers/admin/notifications_controller.rb +27 -0
- data/app/controllers/admin/reference_types_controller.rb +106 -0
- data/app/controllers/admin/search_controller.rb +7 -0
- data/app/controllers/admin/users_controller.rb +10 -0
- data/app/helpers/asset_helper.rb +6 -0
- data/app/helpers/bulk_actions_helper.rb +10 -1
- data/app/helpers/document_helper.rb +36 -0
- data/app/helpers/geoblacklight_admin_helper.rb +88 -8
- data/app/helpers/mappings_helper.rb +26 -0
- data/app/indexers/document_indexer.rb +22 -2
- data/app/javascript/channels/consumer.js +6 -0
- data/app/javascript/channels/export_channel.js +30 -0
- data/app/javascript/channels/index.js +3 -0
- data/app/javascript/controllers/results_controller.js +14 -0
- data/app/javascript/index.js +8 -2
- data/app/jobs/bulk_action_revert_document_job.rb +4 -12
- data/app/jobs/bulk_action_run_document_job.rb +2 -10
- data/app/jobs/export_job.rb +35 -8
- data/app/jobs/geoblacklight_admin/delete_thumbnail_job.rb +19 -0
- data/app/jobs/geoblacklight_admin/remove_parent_dct_references_uri_job.rb +16 -0
- data/app/jobs/geoblacklight_admin/set_parent_dct_references_uri_job.rb +17 -0
- data/app/jobs/geoblacklight_admin/store_image_job.rb +22 -0
- data/app/jobs/import_document_job.rb +1 -4
- data/app/jobs/import_run_job.rb +1 -1
- data/app/models/admin/bookmark.rb +1 -1
- data/app/models/asset.rb +20 -0
- data/app/models/bulk_action.rb +2 -1
- data/app/models/bulk_actions/change_publication_state.rb +0 -25
- data/app/models/bulk_actions/delete_thumbnails.rb +6 -0
- data/app/models/bulk_actions/draft_document.rb +6 -0
- data/app/models/bulk_actions/harvest_thumbnails.rb +6 -0
- data/app/models/bulk_actions/publish_document.rb +6 -0
- data/app/models/bulk_actions/unpublish_document.rb +6 -0
- data/app/models/document/geom_validator.rb +8 -0
- data/app/models/document/reference.rb +65 -65
- data/app/models/document.rb +129 -72
- data/app/models/document_distribution.rb +145 -0
- data/app/models/element.rb +2 -0
- data/app/models/geoblacklight_admin/schema.rb +10 -2
- data/app/models/import/csv_duplicates_validator.rb +2 -0
- data/app/models/import/csv_header_validator.rb +3 -1
- data/app/models/import_btaa_aardvark.rb +2 -2
- data/app/models/import_document_state_machine.rb +1 -0
- data/app/models/import_gblv1.rb +2 -2
- data/app/models/reference_type.rb +40 -0
- data/app/models/user.rb +4 -2
- data/app/services/export_csv_document_distributions_service.rb +61 -0
- data/app/services/geoblacklight_admin/image_service/iiif_manifest.rb +39 -43
- data/app/services/geoblacklight_admin/image_service/tms.rb +0 -8
- data/app/services/geoblacklight_admin/image_service.rb +1 -1
- data/app/services/geoblacklight_admin/item_viewer.rb +4 -4
- data/app/views/admin/bookmarks/index.html.erb +19 -14
- data/app/views/admin/bulk_actions/show.html.erb +1 -1
- data/app/views/admin/document_accesses/import.html.erb +6 -2
- data/app/views/admin/document_assets/_assets_table.html.erb +49 -0
- data/app/views/admin/document_assets/_form.html.erb +2 -3
- data/app/views/admin/document_assets/index.html.erb +1 -47
- data/app/views/admin/document_distributions/_document_distribution.html.erb +39 -0
- data/app/views/admin/document_distributions/_document_distribution.json.jbuilder +2 -0
- data/app/views/admin/document_distributions/_form.html.erb +34 -0
- data/app/views/admin/document_distributions/destroy_all.html.erb +82 -0
- data/app/views/admin/document_distributions/edit.html.erb +12 -0
- data/app/views/admin/document_distributions/import.html.erb +80 -0
- data/app/views/admin/document_distributions/index.html.erb +143 -0
- data/app/views/admin/document_distributions/index.json.jbuilder +1 -0
- data/app/views/admin/document_distributions/new.html.erb +11 -0
- data/app/views/admin/document_distributions/show.html.erb +10 -0
- data/app/views/admin/document_distributions/show.json.jbuilder +1 -0
- data/app/views/admin/documents/_document.html.erb +1 -3
- data/app/views/admin/documents/_form.html.erb +2 -4
- data/app/views/admin/documents/_form_control.html.erb +5 -2
- data/app/views/admin/documents/_form_nav.html.erb +14 -5
- data/app/views/admin/documents/_form_nav_kithe.html.erb +4 -1
- data/app/views/admin/documents/_json_aardvark.jbuilder +1 -1
- data/app/views/admin/documents/_json_gbl_v1.jbuilder +1 -1
- data/app/views/admin/documents/_result_selected_options.html.erb +5 -2
- data/app/views/admin/documents/admin.html.erb +5 -5
- data/app/views/admin/documents/features/_document_references.html.erb +23 -0
- data/app/views/admin/documents/features/_multiple_download_links.html.erb +29 -26
- data/app/views/admin/ids/fetch.json.jbuilder +0 -2
- data/app/views/admin/ids/index.json.jbuilder +0 -2
- data/app/views/admin/imports/_form.html.erb +1 -1
- data/app/views/admin/imports/show.html.erb +1 -1
- data/app/views/admin/layouts/application.html.erb +4 -2
- data/app/views/admin/mappings/index.html.erb +1 -1
- data/app/views/admin/notifications/_notification.html.haml +29 -28
- data/app/views/admin/reference_types/_form.html.erb +25 -0
- data/app/views/admin/reference_types/_reference_type.html.erb +52 -0
- data/app/views/admin/reference_types/_reference_type.json.jbuilder +2 -0
- data/app/views/admin/reference_types/edit.html.erb +12 -0
- data/app/views/admin/reference_types/index.html.erb +52 -0
- data/app/views/admin/reference_types/index.json.jbuilder +1 -0
- data/app/views/admin/reference_types/new.html.erb +11 -0
- data/app/views/admin/reference_types/show.html.erb +3 -0
- data/app/views/admin/reference_types/show.json.jbuilder +1 -0
- data/app/views/admin/shared/_footer.html.erb +5 -2
- data/app/views/admin/shared/_js_behaviors.html.erb +2 -3
- data/app/views/admin/shared/_navbar.html.erb +9 -2
- data/app/views/admin/users/index.html.erb +0 -1
- data/app/views/catalog/_show_gbl_admin.html.erb +1 -1
- data/config/initializers/defaults.yml +310 -0
- data/config/initializers/rails_config.rb +8 -0
- data/config/locales/documents.en.yml +14 -0
- data/config/routes.rb +30 -5
- data/db/import_references_schema_support.numbers +0 -0
- data/db/migrate/20230316183001_add_geoblacklight_admin_gem.rb +0 -12
- data/db/migrate/20241009200524_create_admin_reference_types.rb +13 -0
- data/db/migrate/20241010161420_create_document_references.rb +14 -0
- data/db/migrate/20241120238823_rename_references_to_distributions.rb +5 -0
- data/db/seeds.rb +5 -0
- data/db/seeds_elements.csv +1 -1
- data/db/seeds_elements.numbers +0 -0
- data/db/seeds_reference_types.csv +29 -0
- data/db/seeds_reference_types.numbers +0 -0
- data/db/structure.sql +1 -38
- data/lib/compose.yml +31 -0
- data/lib/generators/geoblacklight_admin/config_generator.rb +53 -12
- data/lib/generators/geoblacklight_admin/install_generator.rb +8 -0
- data/lib/generators/geoblacklight_admin/templates/btaa_sample_records.csv +5 -0
- data/lib/generators/geoblacklight_admin/templates/config/database.yml +1 -1
- data/lib/generators/geoblacklight_admin/templates/config/initializers/devise.rb +0 -2
- data/lib/generators/geoblacklight_admin/templates/config/initializers/mime_types.rb +1 -0
- data/lib/generators/geoblacklight_admin/templates/demo-app/Dockerfile +31 -0
- data/lib/generators/geoblacklight_admin/templates/demo-app/compose.yml +42 -0
- data/lib/generators/geoblacklight_admin/templates/demo-app/start-server.sh +21 -0
- data/lib/geoblacklight_admin/engine.rb +4 -0
- data/lib/geoblacklight_admin/rake_task.rb +2 -0
- data/lib/geoblacklight_admin/tasks/distributions.rake +69 -0
- data/lib/geoblacklight_admin/tasks/images.rake +1 -0
- data/lib/geoblacklight_admin/tasks/solr.rake +31 -0
- data/lib/geoblacklight_admin/version.rb +1 -1
- data/lib/geoblacklight_admin.rb +4 -0
- metadata +137 -53
- data/app/helpers/import_documents_helper.rb +0 -5
- data/app/javascript/entrypoints/engine.js +0 -8
- data/config/locales/devise_invitable.en.yml +0 -31
- data/lib/generators/geoblacklight_admin/templates/devise/invitations/edit.html.erb +0 -15
- data/lib/generators/geoblacklight_admin/templates/devise/invitations/new.html.erb +0 -15
- data/lib/generators/geoblacklight_admin/templates/devise/mailer/invitation_instructions.html.erb +0 -11
- data/lib/generators/geoblacklight_admin/templates/devise/mailer/invitation_instructions.text.erb +0 -11
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fb7dfdea7cb8626ae4e65999624310642a89c81cea03a8d0e58a5649c080091b
|
|
4
|
+
data.tar.gz: e08e45d57f47e372d574e7cce41e1babd93697741a1261a22dcf816e07a0b74b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b7e2504e7f0fb46e55e0ba3359577a4d6e90842afa5c6be608e79a52d2b278ec39fe24812b68d8ca6d950ff2ef7842905550bb2a1354ba012f82f8b6349da154
|
|
7
|
+
data.tar.gz: d913fe08b848b6b9a2f2cd730570cecbb1f0e98157540b967306fc903ee7433bdae04a422b7d0b06c20678103bd30440bfaa939b04369c9b9f100bdd55611a65
|
data/README.md
CHANGED
|
@@ -8,9 +8,9 @@ GeoBlacklight Admin is a [GeoBlacklight](https://github.com/geoblacklight/geobla
|
|
|
8
8
|
|
|
9
9
|
## Requirements
|
|
10
10
|
|
|
11
|
-
* Rails v7
|
|
11
|
+
* Rails v7 (not v8)
|
|
12
12
|
* Blacklight v7 (not v8)
|
|
13
|
-
* GeoBlacklight v4
|
|
13
|
+
* GeoBlacklight v4 (not v5)
|
|
14
14
|
* @geoblacklight/frontend v4 (NPM package)
|
|
15
15
|
* Solr v8.4+
|
|
16
16
|
* PostgreSQL (not MySQL-based DBs)
|
|
@@ -28,12 +28,19 @@ You need a PostgreSQL database to use this project.
|
|
|
28
28
|
|
|
29
29
|
### Install Template
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
#### 1. Create your geoblacklight_admin_development PostgreSQL database
|
|
32
32
|
|
|
33
33
|
```bash
|
|
34
|
-
|
|
34
|
+
psql postgres
|
|
35
|
+
CREATE DATABASE geoblacklight_admin_development;
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
#### 2. Bootstrap a new GeoBlacklight + GBL Admin application using the template script:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
rails _7.2.2_ new gbl_admin -m https://raw.githubusercontent.com/geobtaa/geoblacklight_admin/develop/template.rb
|
|
35
42
|
cd gbl_admin
|
|
36
|
-
bundle exec rake
|
|
43
|
+
bundle exec rake geoblacklight:server
|
|
37
44
|
```
|
|
38
45
|
|
|
39
46
|
You have now generated the .internal_test_app and populated the Elements / FormElements tables for OMG Aardvark support.
|
|
@@ -44,7 +51,7 @@ You have now generated the .internal_test_app and populated the Elements / FormE
|
|
|
44
51
|
2. Click on the "Sign in" link
|
|
45
52
|
3. Enter email: admin@geoblacklight.org and password: 123456
|
|
46
53
|
4. Click on the "GBL Admin" link
|
|
47
|
-
5. Import some CSV (test/fixtures/files/btaa_sample_records.csv)
|
|
54
|
+
5. Import some CSV data (test/fixtures/files/btaa_sample_records.csv)
|
|
48
55
|
|
|
49
56
|
-----
|
|
50
57
|
|
|
@@ -55,9 +62,15 @@ For Developer documentation see [doc/developer.md](./docs/development.md)
|
|
|
55
62
|
## License
|
|
56
63
|
The gem is available as open source under the terms of the [Apache 2.0 License](https://opensource.org/license/apache-2-0).
|
|
57
64
|
|
|
58
|
-
|
|
59
|
-
## TODOs
|
|
65
|
+
## TODOs / Roadmap
|
|
60
66
|
* ~~Send GBLADMIN JavaScript pack to NPM like Blacklight~~
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
67
|
+
* ~~Improve test coverage~~
|
|
68
|
+
* ~~Fix CI test runner~~
|
|
69
|
+
* ~~Debug Rails 7.2 support (remove devise_invitable, see [#915](https://github.com/scambra/devise_invitable/issues/915))~~
|
|
70
|
+
* ~~Separate dct_references_s support into a separate model~~
|
|
71
|
+
* ~~Import/Export dct_references_s outside of the main document model~~
|
|
72
|
+
* Migrate our GBL API controllers to just RSolr-based models
|
|
73
|
+
* DRY up Gem dependencies and Engine routing
|
|
74
|
+
* Gazetteer: Add GeoNames support
|
|
75
|
+
* Gazetteer: Add Who's On First support
|
|
76
|
+
* Remove any remaining GEOMG references
|
data/Rakefile
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require "rubygems"
|
|
4
4
|
require "rails"
|
|
5
|
+
require "database_cleaner/active_record"
|
|
5
6
|
|
|
6
7
|
require "bundler/setup"
|
|
7
8
|
|
|
@@ -13,15 +14,12 @@ load "rails/tasks/statistics.rake"
|
|
|
13
14
|
|
|
14
15
|
require "bundler/gem_tasks"
|
|
15
16
|
|
|
16
|
-
require "solr_wrapper"
|
|
17
|
-
|
|
18
17
|
require "rspec/core/rake_task"
|
|
19
18
|
RSpec::Core::RakeTask.new(:spec)
|
|
20
19
|
|
|
21
20
|
require "rubocop/rake_task"
|
|
22
21
|
RuboCop::RakeTask.new(:rubocop)
|
|
23
22
|
|
|
24
|
-
require "solr_wrapper/rake_task"
|
|
25
23
|
require "engine_cart/rake_task"
|
|
26
24
|
require "geoblacklight_admin/version"
|
|
27
25
|
require "rake/testtask"
|
|
@@ -40,66 +38,104 @@ end
|
|
|
40
38
|
task default: :test
|
|
41
39
|
|
|
42
40
|
desc "Run test suite"
|
|
43
|
-
task ci
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
task :ci do
|
|
42
|
+
# Reset the database if the test app exists
|
|
43
|
+
if File.exist? EngineCart.destination
|
|
44
|
+
within_test_app do
|
|
45
|
+
system "bundle exec rake db:reset"
|
|
46
|
+
end
|
|
49
47
|
end
|
|
50
48
|
|
|
51
|
-
#
|
|
52
|
-
Rake::Task["geoblacklight:
|
|
53
|
-
end
|
|
49
|
+
# Start docker
|
|
50
|
+
Rake::Task["geoblacklight:admin:docker:start"].invoke
|
|
54
51
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
task :coverage do
|
|
58
|
-
ENV["COVERAGE"] = "true"
|
|
59
|
-
# Rake::Task["spec"].invoke
|
|
60
|
-
Rake::Task["test"].invoke
|
|
61
|
-
end
|
|
52
|
+
# Create the test rails app
|
|
53
|
+
Rake::Task["geoblacklight:admin:generate"].invoke
|
|
62
54
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
# Intentionally Empty Block
|
|
66
|
-
end
|
|
55
|
+
# Run Minitest tests with Coverage
|
|
56
|
+
Rake::Task["geoblacklight:admin:coverage"].invoke
|
|
67
57
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
system "bundle exec rake db:seed"
|
|
72
|
-
system "bundle exec rake geoblacklight:downloads:mkdir"
|
|
73
|
-
end
|
|
74
|
-
end
|
|
75
|
-
end
|
|
58
|
+
# Stop docker
|
|
59
|
+
Rake::Task["geoblacklight:admin:docker:stop"].invoke
|
|
60
|
+
end
|
|
76
61
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
62
|
+
namespace :geoblacklight do
|
|
63
|
+
namespace :admin do
|
|
64
|
+
desc "Run GeoBlacklight Admin and Solr with seed data for interactive development"
|
|
65
|
+
task :server, [:rails_server_args] do |_t, args|
|
|
66
|
+
if File.exist? EngineCart.destination
|
|
67
|
+
within_test_app do
|
|
68
|
+
system "bundle update"
|
|
69
|
+
end
|
|
70
|
+
else
|
|
71
|
+
Rake::Task["engine_cart:generate"].invoke
|
|
82
72
|
end
|
|
83
|
-
else
|
|
84
|
-
Rake::Task["engine_cart:generate"].invoke
|
|
85
|
-
end
|
|
86
73
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
dir: File.join(File.expand_path(".", File.dirname(__FILE__)),
|
|
90
|
-
"solr", "conf")) do
|
|
91
|
-
Rake::Task["geoblacklight:internal:seed"].invoke
|
|
74
|
+
system "docker compose up -d"
|
|
75
|
+
Rake::Task["geoblacklight:admin:internal:seed"].invoke
|
|
92
76
|
|
|
77
|
+
begin
|
|
93
78
|
within_test_app do
|
|
94
|
-
puts "\nSolr server running: http://localhost
|
|
95
|
-
puts "\
|
|
79
|
+
puts "\nSolr server running: http://localhost:8983/solr/#/blacklight-core"
|
|
80
|
+
puts "\nPostgreSQL server running: http://localhost:5555"
|
|
96
81
|
puts " "
|
|
97
82
|
begin
|
|
98
|
-
|
|
83
|
+
system "bundle exec rails s #{args[:rails_server_args]}"
|
|
99
84
|
rescue Interrupt
|
|
100
85
|
puts "Shutting down..."
|
|
101
86
|
end
|
|
102
87
|
end
|
|
88
|
+
ensure
|
|
89
|
+
system "docker compose down"
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
desc "Run tests with coverage"
|
|
94
|
+
task :coverage do
|
|
95
|
+
ENV["COVERAGE"] = "true"
|
|
96
|
+
Rake::Task["test"].invoke
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
desc "Create the test rails app"
|
|
100
|
+
task generate: ["engine_cart:generate"] do
|
|
101
|
+
# system "bundle exec rake db:reset"
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
namespace :internal do
|
|
105
|
+
task seed: ["engine_cart:generate"] do
|
|
106
|
+
within_test_app do
|
|
107
|
+
system "Settings.reload!"
|
|
108
|
+
system "bundle exec rake db:reset"
|
|
109
|
+
system "bundle exec rake db:seed"
|
|
110
|
+
system "bundle exec rake geoblacklight:downloads:mkdir"
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
desc "Run Solr and seed with sample data"
|
|
116
|
+
task :solr do
|
|
117
|
+
if File.exist? EngineCart.destination
|
|
118
|
+
within_test_app do
|
|
119
|
+
system "bundle update"
|
|
120
|
+
end
|
|
121
|
+
else
|
|
122
|
+
Rake::Task["engine_cart:generate"].invoke
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
namespace :docker do
|
|
127
|
+
desc "Start docker and seed with sample data"
|
|
128
|
+
task :start do
|
|
129
|
+
system "docker compose up -d"
|
|
130
|
+
Rake::Task["geoblacklight:admin:internal:seed"].invoke
|
|
131
|
+
puts "\nSolr server running: http://localhost:8983/solr/#/blacklight-core"
|
|
132
|
+
puts "\nPostgreSQL server running: http://localhost:5555"
|
|
133
|
+
puts " "
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
desc "Stop docker"
|
|
137
|
+
task :stop do
|
|
138
|
+
system "docker compose down"
|
|
103
139
|
end
|
|
104
140
|
end
|
|
105
141
|
end
|
|
@@ -45,10 +45,34 @@ footer.gbl-admin {
|
|
|
45
45
|
box-shadow: inset 0 0 0 50vw rgba(0, 0, 0, 0.8);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
main#gbl-admin {
|
|
49
|
+
min-height: 75vh;
|
|
50
|
+
margin-top: 0rem;
|
|
51
|
+
}
|
|
52
|
+
|
|
48
53
|
main.container-fluid {
|
|
49
54
|
margin-top: 5rem;
|
|
50
55
|
}
|
|
51
56
|
|
|
52
57
|
.navbar-brand.gbl-admin {
|
|
53
58
|
background: none;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
kbd {
|
|
62
|
+
background-color:aliceblue;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
a.btn.btn-gbl-admin {
|
|
66
|
+
color: black;
|
|
67
|
+
border-color: #ffc107;
|
|
68
|
+
margin: 1rem 0;
|
|
69
|
+
|
|
70
|
+
&:visited {
|
|
71
|
+
color: black;
|
|
72
|
+
background-color: #ffc107;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
div.dropdown-menu.show {
|
|
77
|
+
z-index: 2000;
|
|
54
78
|
}
|
|
@@ -1,18 +1,34 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
# The Admin module contains controllers for the admin section of the application.
|
|
3
4
|
module Admin
|
|
5
|
+
# AdminController is the base controller for all admin-related controllers.
|
|
6
|
+
# It includes necessary modules and provides authentication for admin users.
|
|
4
7
|
class AdminController < ApplicationController
|
|
8
|
+
# Includes Devise helpers for authentication.
|
|
5
9
|
include Devise::Controllers::Helpers
|
|
10
|
+
# Includes Pagy for pagination.
|
|
6
11
|
include ::Pagy::Backend
|
|
12
|
+
# Sets the layout for the admin section.
|
|
7
13
|
layout "admin/layouts/application"
|
|
8
14
|
|
|
15
|
+
# Before any action, ensure the user is authenticated as an admin.
|
|
9
16
|
before_action :authenticate_admin!
|
|
17
|
+
before_action :set_action_cable_identifier
|
|
10
18
|
|
|
11
19
|
protected
|
|
12
20
|
|
|
21
|
+
# Authenticates the user and checks if they are an admin.
|
|
22
|
+
# Redirects to a specified location with a forbidden status if the user is not an admin.
|
|
13
23
|
def authenticate_admin!
|
|
14
24
|
authenticate_user!
|
|
15
25
|
redirect_to :somewhere, status: :forbidden unless current_user.admin?
|
|
16
26
|
end
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
def set_action_cable_identifier
|
|
31
|
+
cookies.encrypted[:user_id] = current_user&.id
|
|
32
|
+
end
|
|
17
33
|
end
|
|
18
34
|
end
|
|
@@ -76,7 +76,7 @@ module Admin
|
|
|
76
76
|
# config.index.record_display_type = 'format'
|
|
77
77
|
|
|
78
78
|
config.index.title_field = Settings.FIELDS.TITLE
|
|
79
|
-
config.index.document_presenter_class = Geoblacklight::DocumentPresenter
|
|
79
|
+
config.index.document_presenter_class = ::Geoblacklight::DocumentPresenter
|
|
80
80
|
|
|
81
81
|
# solr field configuration for document/show views
|
|
82
82
|
|
|
@@ -380,5 +380,11 @@ module Admin
|
|
|
380
380
|
end
|
|
381
381
|
end
|
|
382
382
|
end
|
|
383
|
+
|
|
384
|
+
private
|
|
385
|
+
|
|
386
|
+
def advanced_search_params
|
|
387
|
+
params.permit(:advanced_search)
|
|
388
|
+
end
|
|
383
389
|
end
|
|
384
390
|
end
|
|
@@ -1,11 +1,33 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
# Admin::AssetsController
|
|
4
|
+
#
|
|
5
|
+
# This controller handles the management of assets within the admin namespace.
|
|
6
|
+
# It provides actions to list, show, edit, update, and destroy assets.
|
|
7
|
+
# Additionally, it supports attaching files to assets.
|
|
8
|
+
#
|
|
9
|
+
# Actions:
|
|
10
|
+
# - index: Lists all assets with optional search functionality.
|
|
11
|
+
# - show: Displays a specific asset.
|
|
12
|
+
# - edit: Provides a form to edit an asset.
|
|
13
|
+
# - update: Updates an asset with new data.
|
|
14
|
+
# - destroy: Deletes an asset.
|
|
15
|
+
# - display_attach_form: Displays a form to attach files to an asset.
|
|
16
|
+
# - attach_files: Attaches files to an asset based on provided JSON data.
|
|
17
|
+
#
|
|
18
|
+
# Private Methods:
|
|
19
|
+
# - parent_id_via_friendly_id: Finds a document's ID using its friendlier_id.
|
|
20
|
+
# - set_asset: Finds and sets an asset based on the provided ID.
|
|
21
|
+
# - asset_params: Permits only trusted parameters for asset updates.
|
|
22
|
+
# - date_check?: Checks if a value can be converted to a date.
|
|
4
23
|
module Admin
|
|
5
24
|
class AssetsController < Admin::AdminController
|
|
6
25
|
before_action :set_asset, only: %i[show edit update destroy]
|
|
7
26
|
|
|
8
|
-
# GET /
|
|
27
|
+
# GET /admin/asset_files
|
|
28
|
+
#
|
|
29
|
+
# Lists all assets. Supports searching by ID, friendlier_id, title, or parent_id.
|
|
30
|
+
# If a date is provided as a search query, it filters assets created on that date.
|
|
9
31
|
def index
|
|
10
32
|
scope = Asset
|
|
11
33
|
search_query = params[:q].strip if params[:q].present?
|
|
@@ -29,37 +51,24 @@ module Admin
|
|
|
29
51
|
end
|
|
30
52
|
|
|
31
53
|
# GET /assets/1 or /assets/1.json
|
|
54
|
+
#
|
|
55
|
+
# Displays a specific asset.
|
|
32
56
|
def show
|
|
33
57
|
end
|
|
34
58
|
|
|
35
|
-
# GET /assets/new
|
|
36
|
-
def new
|
|
37
|
-
@asset = Asset.new
|
|
38
|
-
end
|
|
39
|
-
|
|
40
59
|
# GET /assets/1/edit
|
|
60
|
+
#
|
|
61
|
+
# Provides a form to edit an asset.
|
|
41
62
|
def edit
|
|
42
63
|
end
|
|
43
64
|
|
|
44
|
-
# POST /assets or /assets.json
|
|
45
|
-
def create
|
|
46
|
-
@asset = Asset.new(asset_params)
|
|
47
|
-
|
|
48
|
-
respond_to do |format|
|
|
49
|
-
if @asset.save
|
|
50
|
-
format.html { redirect_to admin_asset_url(@asset), notice: "Asset was successfully created." }
|
|
51
|
-
format.json { render :show, status: :created, location: @asset }
|
|
52
|
-
else
|
|
53
|
-
format.html { render :new, status: :unprocessable_entity }
|
|
54
|
-
format.json { render json: @asset.errors, status: :unprocessable_entity }
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
|
|
59
65
|
# PATCH/PUT /assets/1 or /assets/1.json
|
|
66
|
+
#
|
|
67
|
+
# Updates an asset with new data. If successful, redirects to the asset's page.
|
|
68
|
+
# Otherwise, re-renders the edit form with errors.
|
|
60
69
|
def update
|
|
61
70
|
respond_to do |format|
|
|
62
|
-
if @asset.update(asset_params)
|
|
71
|
+
if @asset.update(asset_params.merge!(parent_id: parent_id_via_friendly_id(asset_params[:parent_id])))
|
|
63
72
|
format.html { redirect_to admin_asset_url(@asset.id), notice: "Asset was successfully updated." }
|
|
64
73
|
format.json { render :show, status: :ok, location: @asset }
|
|
65
74
|
else
|
|
@@ -70,6 +79,8 @@ module Admin
|
|
|
70
79
|
end
|
|
71
80
|
|
|
72
81
|
# DELETE /assets/1 or /assets/1.json
|
|
82
|
+
#
|
|
83
|
+
# Deletes an asset and redirects to the assets list with a success notice.
|
|
73
84
|
def destroy
|
|
74
85
|
@asset.destroy
|
|
75
86
|
|
|
@@ -80,14 +91,16 @@ module Admin
|
|
|
80
91
|
end
|
|
81
92
|
|
|
82
93
|
# /assets/display_attach_form
|
|
94
|
+
#
|
|
95
|
+
# Displays a form to attach files to an asset.
|
|
83
96
|
def display_attach_form
|
|
84
97
|
end
|
|
85
98
|
|
|
86
|
-
# Receives json hashes for direct uploaded files in params[:files],
|
|
87
|
-
# and id in params[:id] (friendlier_id)
|
|
88
|
-
# creates filesets for them and attach.
|
|
89
|
-
#
|
|
90
99
|
# POST /assets/ingest
|
|
100
|
+
#
|
|
101
|
+
# Receives JSON hashes for direct uploaded files in params[:files],
|
|
102
|
+
# and id in params[:id] (friendlier_id). Creates filesets for them and attaches.
|
|
103
|
+
# Redirects to the assets list with a success notice.
|
|
91
104
|
def attach_files
|
|
92
105
|
# @parent = Document.find_by_friendlier_id!(params[:id])
|
|
93
106
|
|
|
@@ -116,23 +129,25 @@ module Admin
|
|
|
116
129
|
redirect_to admin_assets_url, notice: "Files attached successfully."
|
|
117
130
|
end
|
|
118
131
|
|
|
119
|
-
def sort
|
|
120
|
-
Asset.sort_assets(params[:id_list])
|
|
121
|
-
render body: nil
|
|
122
|
-
end
|
|
123
|
-
|
|
124
132
|
private
|
|
125
133
|
|
|
134
|
+
# Finds a document's ID using its friendlier_id.
|
|
135
|
+
def parent_id_via_friendly_id(friendlier_id)
|
|
136
|
+
Document.find_by_friendlier_id(friendlier_id)&.id
|
|
137
|
+
end
|
|
138
|
+
|
|
126
139
|
# Use callbacks to share common setup or constraints between actions.
|
|
140
|
+
# Finds and sets an asset based on the provided ID.
|
|
127
141
|
def set_asset
|
|
128
142
|
@asset = Asset.find(params[:id])
|
|
129
143
|
end
|
|
130
144
|
|
|
131
145
|
# Only allow a list of trusted parameters through.
|
|
132
146
|
def asset_params
|
|
133
|
-
params.require(:asset)
|
|
147
|
+
params.require(:asset).permit(:parent_id, :thumbnail)
|
|
134
148
|
end
|
|
135
149
|
|
|
150
|
+
# Checks if a value can be converted to a date.
|
|
136
151
|
def date_check?(val)
|
|
137
152
|
val.to_date
|
|
138
153
|
rescue Date::Error
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
# Admin::BookmarksController
|
|
4
|
+
# This controller handles the management of bookmarks for the admin interface.
|
|
5
|
+
# It allows for listing, creating, and destroying bookmarks associated with the current user.
|
|
4
6
|
module Admin
|
|
5
7
|
class BookmarksController < Admin::AdminController
|
|
6
|
-
before_action :set_document,
|
|
7
|
-
only: %i[create destroy]
|
|
8
|
+
before_action :set_document, only: %i[create destroy]
|
|
8
9
|
|
|
9
10
|
# GET /bookmarks
|
|
10
11
|
# GET /bookmarks.json
|
|
12
|
+
# Lists all bookmarks for the current user, filtered by document type "Kithe::Model".
|
|
13
|
+
# Responds with HTML or CSV format.
|
|
11
14
|
def index
|
|
12
15
|
@pagy, @bookmarks = pagy(current_user.bookmarks.where(document_type: "Kithe::Model"))
|
|
13
16
|
|
|
@@ -20,15 +23,18 @@ module Admin
|
|
|
20
23
|
|
|
21
24
|
# POST /bookmarks
|
|
22
25
|
# POST /bookmarks.json
|
|
26
|
+
# Creates a new bookmark for the current user and the specified document.
|
|
27
|
+
# If successful, redirects to the bookmarks index with a success notice.
|
|
28
|
+
# Otherwise, renders the index with an error status.
|
|
23
29
|
def create
|
|
24
30
|
@bookmark = Admin::Bookmark.find_or_create_by(user: current_user, document: @document)
|
|
25
31
|
|
|
26
32
|
respond_to do |format|
|
|
27
33
|
if @bookmark.save
|
|
28
|
-
format.html { redirect_to
|
|
34
|
+
format.html { redirect_to admin_bookmarks_url, notice: "Bookmark was successfully created." }
|
|
29
35
|
format.js
|
|
30
36
|
else
|
|
31
|
-
format.html { render :
|
|
37
|
+
format.html { render :index, status: :unprocessable_entity }
|
|
32
38
|
format.json { render json: @bookmark.errors, status: :unprocessable_entity }
|
|
33
39
|
end
|
|
34
40
|
end
|
|
@@ -36,17 +42,20 @@ module Admin
|
|
|
36
42
|
|
|
37
43
|
# DELETE /bookmarks/1
|
|
38
44
|
# DELETE /bookmarks/1.json
|
|
45
|
+
# Destroys the bookmark for the current user and the specified document.
|
|
46
|
+
# Redirects to the bookmarks index with a success notice.
|
|
39
47
|
def destroy
|
|
40
48
|
Admin::Bookmark.destroy_by(user: current_user, document: @document)
|
|
41
49
|
|
|
42
50
|
respond_to do |format|
|
|
43
|
-
format.html { redirect_to
|
|
51
|
+
format.html { redirect_to admin_bookmarks_url, notice: "Bookmark was successfully destroyed." }
|
|
44
52
|
format.js
|
|
45
53
|
end
|
|
46
54
|
end
|
|
47
55
|
|
|
48
56
|
private
|
|
49
57
|
|
|
58
|
+
# Sets the document based on the friendlier_id parameter.
|
|
50
59
|
def set_document
|
|
51
60
|
@document = Document.find_by(friendlier_id: params["document"])
|
|
52
61
|
end
|
|
@@ -56,6 +65,9 @@ module Admin
|
|
|
56
65
|
params.fetch(:bookmark, {})
|
|
57
66
|
end
|
|
58
67
|
|
|
68
|
+
# Collects bookmarks into a CSV format.
|
|
69
|
+
# @param bookmarks [Array<Bookmark>] the bookmarks to be converted to CSV
|
|
70
|
+
# @return [String] the generated CSV data
|
|
59
71
|
def collect_csv(bookmarks)
|
|
60
72
|
CSV.generate(headers: true) do |csv|
|
|
61
73
|
csv << GeoblacklightAdmin::Schema.instance.importable_fields.map { |k, _v| k.to_s }
|
|
@@ -1,34 +1,52 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
# Admin::BulkActionsController
|
|
4
|
+
#
|
|
5
|
+
# This controller manages bulk actions within the admin interface.
|
|
6
|
+
# It provides actions to list, show, create, update, destroy, run, and revert bulk actions.
|
|
4
7
|
module Admin
|
|
5
8
|
class BulkActionsController < Admin::AdminController
|
|
6
9
|
before_action :set_bulk_action, only: %i[show edit update destroy run revert]
|
|
7
10
|
|
|
8
11
|
# GET /bulk_actions
|
|
9
12
|
# GET /bulk_actions.json
|
|
13
|
+
#
|
|
14
|
+
# Lists all bulk actions, paginated.
|
|
15
|
+
# @return [Array<BulkAction>] List of bulk actions
|
|
10
16
|
def index
|
|
11
17
|
@pagy, @bulk_actions = pagy(BulkAction.all.order(created_at: :desc), items: 20)
|
|
12
18
|
end
|
|
13
19
|
|
|
14
20
|
# GET /bulk_actions/1
|
|
15
21
|
# GET /bulk_actions/1.json
|
|
22
|
+
#
|
|
23
|
+
# Shows a specific bulk action and its associated documents.
|
|
24
|
+
# @return [BulkAction] The requested bulk action
|
|
16
25
|
def show
|
|
17
26
|
@pagy, @documents = pagy(@bulk_action.documents, items: 30)
|
|
18
27
|
@bulk_action.check_run_state
|
|
19
28
|
end
|
|
20
29
|
|
|
21
30
|
# GET /bulk_actions/new
|
|
31
|
+
#
|
|
32
|
+
# Initializes a new bulk action with a given scope.
|
|
33
|
+
# @return [BulkAction] A new bulk action instance
|
|
22
34
|
def new
|
|
23
35
|
@bulk_action = BulkAction.new(scope: params[:scope])
|
|
24
36
|
end
|
|
25
37
|
|
|
26
38
|
# GET /bulk_actions/1/edit
|
|
39
|
+
#
|
|
40
|
+
# Prepares a bulk action for editing.
|
|
41
|
+
# @return [BulkAction] The bulk action to be edited
|
|
27
42
|
def edit
|
|
28
43
|
end
|
|
29
44
|
|
|
30
45
|
# POST /bulk_actions
|
|
31
46
|
# POST /bulk_actions.json
|
|
47
|
+
#
|
|
48
|
+
# Creates a new bulk action.
|
|
49
|
+
# @return [BulkAction] The created bulk action
|
|
32
50
|
def create
|
|
33
51
|
@bulk_action = BulkAction.new(bulk_action_params)
|
|
34
52
|
|
|
@@ -47,6 +65,9 @@ module Admin
|
|
|
47
65
|
|
|
48
66
|
# PATCH/PUT /bulk_actions/1
|
|
49
67
|
# PATCH/PUT /bulk_actions/1.json
|
|
68
|
+
#
|
|
69
|
+
# Updates an existing bulk action.
|
|
70
|
+
# @return [BulkAction] The updated bulk action
|
|
50
71
|
def update
|
|
51
72
|
respond_to do |format|
|
|
52
73
|
if @bulk_action.update(bulk_action_params)
|
|
@@ -63,6 +84,9 @@ module Admin
|
|
|
63
84
|
|
|
64
85
|
# DELETE /bulk_actions/1
|
|
65
86
|
# DELETE /bulk_actions/1.json
|
|
87
|
+
#
|
|
88
|
+
# Deletes a bulk action.
|
|
89
|
+
# @return [void]
|
|
66
90
|
def destroy
|
|
67
91
|
@bulk_action.destroy
|
|
68
92
|
respond_to do |format|
|
|
@@ -71,12 +95,16 @@ module Admin
|
|
|
71
95
|
end
|
|
72
96
|
end
|
|
73
97
|
|
|
98
|
+
# Runs a bulk action.
|
|
99
|
+
# @return [void]
|
|
74
100
|
def run
|
|
75
101
|
@bulk_action.run!
|
|
76
102
|
# @bulk_action.state_machine.transition_to!(:queued)
|
|
77
103
|
redirect_to admin_bulk_action_url(@bulk_action), notice: "Bulk action is running. Check back soon for results."
|
|
78
104
|
end
|
|
79
105
|
|
|
106
|
+
# Reverts a bulk action.
|
|
107
|
+
# @return [void]
|
|
80
108
|
def revert
|
|
81
109
|
@bulk_action.revert!
|
|
82
110
|
@bulk_action.state_machine.transition_to!(:queued)
|
|
@@ -87,13 +115,16 @@ module Admin
|
|
|
87
115
|
private
|
|
88
116
|
|
|
89
117
|
# Use callbacks to share common setup or constraints between actions.
|
|
118
|
+
# Finds and sets the bulk action based on the provided ID.
|
|
119
|
+
# @return [BulkAction] The found bulk action
|
|
90
120
|
def set_bulk_action
|
|
91
121
|
@bulk_action = BulkAction.find(params[:id])
|
|
92
122
|
end
|
|
93
123
|
|
|
94
124
|
# Only allow a list of trusted parameters through.
|
|
125
|
+
# @return [ActionController::Parameters] The permitted parameters
|
|
95
126
|
def bulk_action_params
|
|
96
|
-
params.
|
|
127
|
+
params.require(:bulk_action).permit(:name, :scope, :request, :field_name, :field_value)
|
|
97
128
|
end
|
|
98
129
|
end
|
|
99
130
|
end
|