geoblacklight_admin 0.1.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +58 -59
  3. data/Rakefile +25 -10
  4. data/app/assets/javascripts/geoblacklight_admin.js +1 -1
  5. data/app/assets/stylesheets/geoblacklight_admin/_core.scss +1 -1
  6. data/app/assets/stylesheets/geoblacklight_admin/modules/_forms.scss +108 -0
  7. data/app/controllers/admin/document_accesses_controller.rb +3 -3
  8. data/app/controllers/admin/document_assets_controller.rb +1 -1
  9. data/app/controllers/admin/documents_controller.rb +22 -13
  10. data/app/controllers/admin/search_controller.rb +2 -1
  11. data/app/controllers/admin/users_controller.rb +1 -1
  12. data/app/indexers/document_indexer.rb +1 -1
  13. data/app/jobs/export_job.rb +7 -5
  14. data/app/jobs/export_json_bulk_job.rb +94 -0
  15. data/app/jobs/export_json_job.rb +14 -12
  16. data/app/models/blacklight_api.rb +6 -6
  17. data/app/models/blacklight_api_facets.rb +7 -2
  18. data/app/models/blacklight_api_ids.rb +3 -4
  19. data/app/models/bulk_action.rb +1 -1
  20. data/app/models/document/date_range_validator.rb +1 -1
  21. data/app/models/document.rb +1 -1
  22. data/app/models/document_access.rb +4 -2
  23. data/app/models/document_download.rb +4 -2
  24. data/app/models/import_document.rb +18 -1
  25. data/app/views/admin/bulk_actions/index.html.erb +2 -2
  26. data/app/views/admin/document_accesses/destroy_all.html.erb +1 -1
  27. data/app/views/admin/document_assets/display_attach_form.html.erb +3 -3
  28. data/app/views/admin/document_assets/index.html.erb +3 -3
  29. data/app/views/admin/document_downloads/destroy_all.html.erb +1 -1
  30. data/app/views/admin/document_downloads/import.html.erb +1 -1
  31. data/app/views/admin/documents/_form_nav.html.erb +3 -1
  32. data/app/views/admin/documents/_json_file.jbuilder +14 -0
  33. data/app/views/admin/documents/_result_selected_options.html.erb +4 -2
  34. data/app/views/admin/documents/fetch.json_file.jbuilder +9 -0
  35. data/app/views/admin/documents/index.json_file.jbuilder +9 -0
  36. data/app/views/admin/elements/index.html.erb +1 -1
  37. data/app/views/admin/form_elements/index.html.erb +1 -1
  38. data/app/views/admin/shared/_js_behaviors.html.erb +1 -1
  39. data/app/views/admin/shared/_navbar.html.erb +9 -9
  40. data/app/views/admin/shared/_toast.html.erb +1 -1
  41. data/app/views/admin/users/index.html.erb +1 -1
  42. data/config/locales/documents.en.yml +3 -0
  43. data/db/migrate/20230316183001_add_geoblacklight_admin_gem.rb +1 -0
  44. data/db/seeds.rb +0 -1
  45. data/db/seeds_elements.csv +56 -55
  46. data/db/seeds_elements.numbers +0 -0
  47. data/db/seeds_form_elements.csv +65 -64
  48. data/db/seeds_form_elements.numbers +0 -0
  49. data/lib/generators/geoblacklight_admin/config_generator.rb +33 -77
  50. data/lib/generators/geoblacklight_admin/install_generator.rb +1 -9
  51. data/lib/generators/geoblacklight_admin/templates/config/geomg_aardvark_schema.json +12 -6
  52. data/lib/generators/geoblacklight_admin/templates/config/initializers/devise.rb +315 -0
  53. data/lib/generators/geoblacklight_admin/templates/config/initializers/geoblacklight_admin.rb +12 -0
  54. data/lib/generators/geoblacklight_admin/templates/config/initializers/kithe.rb +2 -0
  55. data/lib/generators/geoblacklight_admin/templates/config/initializers/mime_types.rb +15 -0
  56. data/lib/generators/geoblacklight_admin/templates/config/initializers/pagy.rb +2 -0
  57. data/lib/generators/geoblacklight_admin/templates/config/initializers/shrine.rb +12 -0
  58. data/lib/generators/geoblacklight_admin/templates/config/initializers/simple_form.rb +178 -0
  59. data/lib/generators/geoblacklight_admin/templates/config/initializers/simple_form_bootstrap.rb +365 -0
  60. data/lib/generators/geoblacklight_admin/templates/config/settings.yml +74 -22
  61. data/lib/generators/geoblacklight_admin/templates/javascript/controllers/results_controller.js +10 -0
  62. data/lib/generators/geoblacklight_admin/templates/package.json +2 -0
  63. data/lib/generators/geoblacklight_admin/templates/solr/conf/schema.xml +3 -3
  64. data/lib/generators/geoblacklight_admin/views_generator.rb +2 -2
  65. data/lib/geoblacklight_admin/version.rb +1 -1
  66. data/lib/tasks/geoblacklight_admin.rake +6 -6
  67. metadata +31 -24
  68. data/app/controllers/admin/concerns/upload_util.rb +0 -10
  69. data/lib/generators/geoblacklight_admin/example_docs_generator.rb +0 -18
  70. /data/{app/views/admin → lib/generators/geoblacklight_admin/templates}/devise/confirmations/new.html.erb +0 -0
  71. /data/{app/views/admin → lib/generators/geoblacklight_admin/templates}/devise/invitations/edit.html.erb +0 -0
  72. /data/{app/views/admin → lib/generators/geoblacklight_admin/templates}/devise/invitations/new.html.erb +0 -0
  73. /data/{app/views/admin → lib/generators/geoblacklight_admin/templates}/devise/mailer/invitation_instructions.html.erb +0 -0
  74. /data/{app/views/admin → lib/generators/geoblacklight_admin/templates}/devise/mailer/invitation_instructions.text.erb +0 -0
  75. /data/{app/views/admin → lib/generators/geoblacklight_admin/templates}/devise/passwords/edit.html.erb +0 -0
  76. /data/{app/views/admin → lib/generators/geoblacklight_admin/templates}/devise/passwords/new.html.erb +0 -0
  77. /data/{app/views/admin → lib/generators/geoblacklight_admin/templates}/devise/registrations/edit.html.erb +0 -0
  78. /data/{app/views/admin → lib/generators/geoblacklight_admin/templates}/devise/registrations/new.html.erb +0 -0
  79. /data/{app/views/admin → lib/generators/geoblacklight_admin/templates}/devise/sessions/new.html.erb +0 -0
  80. /data/{app/views/admin → lib/generators/geoblacklight_admin/templates}/devise/shared/_links.html.erb +0 -0
  81. /data/{app/views/admin → lib/generators/geoblacklight_admin/templates}/devise/unlocks/new.html.erb +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7684e47be28824d2066af09187c41a5f443cf3ead2ea32d83c22c7bb1b254c2d
4
- data.tar.gz: d444226fbbacfcc2b344e595c8920758e0a75b7981c7202041063fd26d89fec1
3
+ metadata.gz: 387d4164b7cdadef3906c3370163e6057ab2ef8004b11d9de847d634afca62bd
4
+ data.tar.gz: 3102dad801555d0de37e6dd9588cc427661fb5c45772b82a3ddf9baece1f51a2
5
5
  SHA512:
6
- metadata.gz: 89901b678a8a2e240d63297a8a23ecce61e24c15d2e622b333710dcc4ad4d976ec205b583b1abf4373fb398962812895599650864ddb170137c01ca00f2f756d
7
- data.tar.gz: c07f011ff04015800cec00397e7bbf65ef33a8e0511e56e300930dfe1eb9d2c110148666e805f863e7bfc18aa7fe311887f9abc5c5839387a5afb0dbcd0f2d4f
6
+ metadata.gz: e0f33cd2c6fa0c7f9ea40d8616e80cac819636c4319280adf20442637533f8177b87825273aa70ca1371c865fc14c4871fd98d79443b432a2df3b7ce369f8ccf
7
+ data.tar.gz: 2228cf2c8b4fd7c838397f0a9d6fec9a4f8a3f39614df84cdb7245776a665323aa7af7217bb61e658c5b23a5a09c95e78ac41c767c41afdfd7f4b85a0bf8a193
data/README.md CHANGED
@@ -1,13 +1,14 @@
1
1
  # geoblacklight_admin
2
2
 
3
- GeoBlacklight Admin is a [GeoBlacklight](https://github.com/geoblacklight/geoblacklight) plugin, built on [Kithe](https://github.com/sciencehistory/kithe), that provides a complex web-form for editing documents and an CSV-based import/export workflow for OpenGeoMetadata's [Aardvark schema](https://opengeometadata.org/ogm-aardvark/). It's a Rubygem port of the Big Ten Academic Alliance's production workflow tool [GEOMG](https://github.com/geobtaa/geomg).
3
+ ![CI](https://github.com/geobtaa/geoblacklight_admin/actions/workflows/ci.yml/badge.svg)
4
4
 
5
- ## Warning: Pre-Alpha
5
+ GeoBlacklight Admin is a [GeoBlacklight](https://github.com/geoblacklight/geoblacklight) plugin, built on [Kithe](https://github.com/sciencehistory/kithe), that provides a complex web-form for editing documents and an CSV-based import/export workflow for OpenGeoMetadata's [Aardvark schema](https://opengeometadata.org/ogm-aardvark/). GBL Admin is based on the Big Ten Academic Alliance's production workflow tool [GEOMG](https://github.com/geobtaa/geomg).
6
6
 
7
- > :warning: This gem is not ready for public adoption yet, but hopefully someday soon (Late Summer 2023?). Feel free to kick the tires if you are curious and know GeoBlacklight's codebase/stack well.
7
+ [![GeoBlackliht Admin](https://raw.githubusercontent.com/geobtaa/geoblacklight_admin/develop/docs/gbl_admin_screenshot.png)](https://youtu.be/lWjcr-Ow228 "GeoBlacklight Admin")
8
8
 
9
9
  ## Requirements
10
10
 
11
+ * Rails v6.1 (not v7 yet)
11
12
  * Blacklight v7 (not v8)
12
13
  * GeoBlacklight v4 (not v3)
13
14
  * Solr v8.4+
@@ -15,43 +16,26 @@ GeoBlacklight Admin is a [GeoBlacklight](https://github.com/geoblacklight/geobla
15
16
  * Redis (for Sidekiq)
16
17
  * OpenGeoMetadata's Aardvark Schema
17
18
 
18
- ## Install Notes
19
+ ## Installation
19
20
 
20
- ### Terminal 1 - Drop/Create application PG database
21
- ```bash
22
- psql postgres
23
- DROP DATABASE geoblacklight_development;
24
- CREATE DATABASE geoblacklight_development;
25
- ```
26
-
27
- ### Terminal 2 - Bundle and run generator
28
- ```bash
29
- bundle install
30
- bundle exec rake engine_cart:generate
31
- ```
21
+ ### PostgreSQL
32
22
 
33
- When the .internal_test_app is built, edit `geoblacklight_admin_helper.rb`, and uncomment this Pagy include. Why including Pagy here breaks the entire generator build is beyond me...
23
+ You need a PostgreSQL database to use this project.
34
24
 
35
- ```bash
36
- # @TODO:
37
- # Cannot generate app if uncommented...
38
- # Uncomment after app is generated to fix view errors
39
- # include ::Pagy::Frontend
40
- ```
25
+ * Homebrew: https://wiki.postgresql.org/wiki/Homebrew
26
+ * Docker: https://www.docker.com/blog/how-to-use-the-postgres-docker-official-image/
41
27
 
42
- ### Terminal 2 - Seed and spin up server
43
- ```bash
44
- cd .internal_test_app
45
- bundle exec rake db:seed
28
+ ### Install Template
46
29
 
47
- # JS was breaking in dev mode, had to add the yarn package below - EWL 6/5/23
48
- yarn add @babel/plugin-proposal-private-methods --dev
30
+ Use Ruby v3.2 and Rails v6.1.7.4 to bootstrap a new GeoBlacklight + GBL Admin application using the template script:
49
31
 
50
- # Run the app server
32
+ ```bash
33
+ rails _6.1.7.4_ new gbl_admin -m https://raw.githubusercontent.com/geobtaa/geoblacklight_admin/develop/template.rb
34
+ cd gbl_admin
51
35
  bundle exec rake gbl_admin:server
52
36
  ```
53
37
 
54
- You're now done generating the test app and populating the Elements / FormElements tables with the basic Aardvark controls.
38
+ You have now generated the .internal_test_app and populated the Elements / FormElements tables for OMG Aardvark support.
55
39
 
56
40
  ### View App in Browser
57
41
 
@@ -59,12 +43,48 @@ You're now done generating the test app and populating the Elements / FormElemen
59
43
  2. Click on the "Sign in" link
60
44
  3. Enter email: admin@geoblacklight.org and password: 123456
61
45
  4. Click on the "GBL Admin" link
62
- 5. Import some CSV
46
+ 5. Import some CSV (test/fixtures/files/btaa_sample_records.csv)
63
47
 
64
48
  -----
65
49
 
66
- ### TODOs - Running list of things to accomplish
50
+ ## Run Project for Local Development
51
+ Drop and recreate databases (or engine_cart:generate will fail)
67
52
 
53
+ ### Drop/Create application PG database
54
+ ```bash
55
+ psql postgres
56
+ DROP DATABASE geoblacklight_development;
57
+ CREATE DATABASE geoblacklight_development;
58
+ ```
59
+
60
+ ```bash
61
+ cd project root
62
+ bundle install
63
+ bundle exec rake engine_cart:regenerate
64
+ ```
65
+
66
+ ### Run Solr
67
+ ```bash
68
+ bin/rails geoblacklight:solr
69
+ ```
70
+
71
+ ### Run App
72
+ ```bash
73
+ cd .internal_test_app
74
+ bundle exec rails server
75
+ ```
76
+
77
+ ### Lint App
78
+ ```bash
79
+ standardrb .
80
+ ```
81
+
82
+ ### Test App
83
+ ```bash
84
+ RAILS_ENV=test bundle exec rails test
85
+ ```
86
+
87
+ ## TODOs
68
88
  * ~~SolrWrapper - Add persist option~~
69
89
  * ~~BlacklightApi returns not auth'd message (not requiring auth for now (not sensitive data))~~
70
90
  * ~~Facet links need /admin nesting~~
@@ -78,31 +98,10 @@ You're now done generating the test app and populating the Elements / FormElemen
78
98
  * ~~Routes - Get devise user~~
79
99
  * ~~No route matches [GET] "/users/sign_out"~~
80
100
  * ~~Bookmarks need to be Admin::Bookmarks~~
81
- * GitHub Actions / CI integration
82
- * Port the GEOMG test suite
101
+ * ~~GitHub Actions / CI integration~~
102
+ * ~~Port the GEOMG test suite~~
103
+ * ~~Project gem dependency injection redundancy...~~
104
+ * DRY up Engine routing
83
105
  * Remove legacy GEOMG / B1G everywhere...
84
106
  * Send GBLADMIN JavaScript pack to NPM like Blacklight
85
- * Project gem dependency injection redundancy...
86
- * Likely a lot more polish to be uncovered...
87
-
88
-
89
- # To Run Project
90
- drop and create databases (or engine_cart will fail)
91
- cd project root
92
- bundle exec rake engine_cart:regenerate
93
-
94
- ## Run Solr
95
- bin/rails geoblacklight:solr
96
-
97
- ## Run App
98
- cd .internal_test_app
99
- bundle exec rails server
100
-
101
- ## Test App
102
- bundle exec rails test
103
- cd .internal_test_app
104
- rake db:seed
105
- rake geomg:solr:reindex
106
-
107
- # @TODO: Add chosen.js css
108
- # @TODO: Fix missing select form-control class
107
+ * Likely some more polish to be uncovered...
data/Rakefile CHANGED
@@ -24,14 +24,6 @@ RuboCop::RakeTask.new(:rubocop)
24
24
  require "solr_wrapper/rake_task"
25
25
  require "engine_cart/rake_task"
26
26
  require "geoblacklight_admin/version"
27
-
28
- desc "Run test suite"
29
- task "ci" do
30
- ENV["RAILS_ENV"] = "test"
31
- system("RAILS_ENV=test bundle exec rake test") || false
32
- # system("RAILS_ENV=test bundle exec rake geomg:solr:reindex") || false
33
- end
34
-
35
27
  require "rake/testtask"
36
28
 
37
29
  # Searches for files ending in _test.rb in the test directory
@@ -45,12 +37,35 @@ end
45
37
  # Will use test as defaut task if rake is run by itself
46
38
  task default: :test
47
39
 
40
+ desc "Run test suite"
41
+ task ci: ["geoblacklight:generate"] do
42
+ within_test_app do
43
+ system "RAILS_ENV=test bin/rails db:migrate"
44
+ system "RAILS_ENV=test rake db:seed"
45
+ system "RAILS_ENV=test rails webpacker:compile"
46
+ end
47
+
48
+ # Run RSpec tests with Coverage
49
+ Rake::Task["geoblacklight:coverage"].invoke
50
+ end
51
+
48
52
  namespace :geoblacklight do
53
+ desc "Run tests with coverage"
54
+ task :coverage do
55
+ ENV["COVERAGE"] = "true"
56
+ # Rake::Task["spec"].invoke
57
+ Rake::Task["test"].invoke
58
+ end
59
+
60
+ desc "Create the test rails app"
61
+ task generate: ["engine_cart:generate"] do
62
+ # Intentionally Empty Block
63
+ end
64
+
49
65
  namespace :internal do
50
66
  task seed: ["engine_cart:generate"] do
51
67
  within_test_app do
52
- # @TODO - Seed Elements / FormElements
53
- # system "bundle exec rake gbl_admin:seed"
68
+ system "bundle exec rake db:seed"
54
69
  system "bundle exec rake geoblacklight:downloads:mkdir"
55
70
  end
56
71
  end
@@ -13,7 +13,7 @@
13
13
 
14
14
  //= require jquery3
15
15
  //= require rails-ujs
16
- //= require cocoon
16
+ //= require @nathanvda/cocoon/cocoon.js
17
17
  //= require chosen-jquery/lib/chosen.jquery.js
18
18
 
19
19
  // VENDOR
@@ -36,7 +36,7 @@ nav.navbar.bg-light {
36
36
  margin-bottom:2rem;
37
37
  }
38
38
 
39
- footer {
39
+ footer.gbl-admin {
40
40
  border-top: 1rem solid #0088ce;
41
41
  margin-top: 4rem;
42
42
  background:rgba(0, 0, 0, 0.8) image-url('aerial_photo.jpg') repeat;
@@ -26,3 +26,111 @@ label, legend {
26
26
  html {
27
27
  scroll-padding-top: 4rem; /* height of your sticky header */
28
28
  }
29
+
30
+ // Simple Form / Bootstrap 5 / Select
31
+ //
32
+ // GBL is using BS4 now, but SimpleForm is already on BS5
33
+ // Adding support for BS5's .form-select class until we upgrade to BS5
34
+ $form-select-padding-y: $input-padding-y;
35
+ $form-select-padding-x: $input-padding-x;
36
+ $form-select-font-family: $input-font-family;
37
+ $form-select-font-size: $input-font-size;
38
+ $form-select-indicator-padding: $form-select-padding-x * 3; // Extra padding for background-image
39
+ $form-select-font-weight: $input-font-weight;
40
+ $form-select-line-height: $input-line-height;
41
+ $form-select-color: $input-color;
42
+ $form-select-bg: $input-bg;
43
+ $form-select-disabled-color: null;
44
+ $form-select-disabled-bg: $gray-200;
45
+ $form-select-disabled-border-color: $gray-800;
46
+ $form-select-bg-position: right $form-select-padding-x center;
47
+ $form-select-bg-size: 16px 12px; // In pixels because image dimensions
48
+ $form-select-indicator-color: $gray-800;
49
+ $form-select-indicator: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill='none' stroke='#{$form-select-indicator-color}' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/></svg>");
50
+
51
+ $form-select-feedback-icon-padding-end: $form-select-padding-x * 2.5 + $form-select-indicator-padding;
52
+ $form-select-feedback-icon-position: center right $form-select-indicator-padding;
53
+ $form-select-feedback-icon-size: $input-height-inner-half $input-height-inner-half;
54
+
55
+ $form-select-border-width: $input-border-width;
56
+ $form-select-border-color: $input-border-color;
57
+ $form-select-border-radius: $border-radius;
58
+
59
+ $form-select-focus-border-color: $input-focus-border-color;
60
+ $form-select-focus-width: $input-focus-width;
61
+ $form-select-focus-box-shadow: 0 0 0 $form-select-focus-width $input-btn-focus-color;
62
+
63
+ $form-select-padding-y-sm: $input-padding-y-sm;
64
+ $form-select-padding-x-sm: $input-padding-x-sm;
65
+ $form-select-font-size-sm: $input-font-size-sm;
66
+
67
+ $form-select-padding-y-lg: $input-padding-y-lg;
68
+ $form-select-padding-x-lg: $input-padding-x-lg;
69
+ $form-select-font-size-lg: $input-font-size-lg;
70
+
71
+ $form-select-transition: $input-transition;
72
+
73
+ .form-select {
74
+ display: block;
75
+ width: 100%;
76
+ padding: $form-select-padding-y $form-select-indicator-padding $form-select-padding-y $form-select-padding-x;
77
+ // stylelint-disable-next-line property-no-vendor-prefix
78
+ -moz-padding-start: subtract($form-select-padding-x, 3px); // See https://github.com/twbs/bootstrap/issues/32636
79
+ font-family: $form-select-font-family;
80
+ @include font-size($form-select-font-size);
81
+ font-weight: $form-select-font-weight;
82
+ line-height: $form-select-line-height;
83
+ color: $form-select-color;
84
+ background-color: $form-select-bg;
85
+ background-image: escape-svg($form-select-indicator);
86
+ background-repeat: no-repeat;
87
+ background-position: $form-select-bg-position;
88
+ background-size: $form-select-bg-size;
89
+ border: $form-select-border-width solid $form-select-border-color;
90
+ @include border-radius($form-select-border-radius, 0);
91
+ @include transition($form-select-transition);
92
+ appearance: none;
93
+
94
+ &:focus {
95
+ border-color: $form-select-focus-border-color;
96
+ outline: 0;
97
+ @if $enable-shadows {
98
+ @include box-shadow($form-select-box-shadow, $form-select-focus-box-shadow);
99
+ } @else {
100
+ // Avoid using mixin so we can pass custom focus shadow properly
101
+ box-shadow: $form-select-focus-box-shadow;
102
+ }
103
+ }
104
+
105
+ &[multiple],
106
+ &[size]:not([size="1"]) {
107
+ padding-right: $form-select-padding-x;
108
+ background-image: none;
109
+ }
110
+
111
+ &:disabled {
112
+ color: $form-select-disabled-color;
113
+ background-color: $form-select-disabled-bg;
114
+ border-color: $form-select-disabled-border-color;
115
+ }
116
+
117
+ // Remove outline from select box in FF
118
+ &:-moz-focusring {
119
+ color: transparent;
120
+ text-shadow: 0 0 0 $form-select-color;
121
+ }
122
+ }
123
+
124
+ .form-select-sm {
125
+ padding-top: $form-select-padding-y-sm;
126
+ padding-bottom: $form-select-padding-y-sm;
127
+ padding-left: $form-select-padding-x-sm;
128
+ @include font-size($form-select-font-size-sm);
129
+ }
130
+
131
+ .form-select-lg {
132
+ padding-top: $form-select-padding-y-lg;
133
+ padding-bottom: $form-select-padding-y-lg;
134
+ padding-left: $form-select-padding-x-lg;
135
+ @include font-size($form-select-font-size-lg);
136
+ }
@@ -101,12 +101,12 @@ module Admin
101
101
 
102
102
  respond_to do |format|
103
103
  if DocumentAccess.import(params.dig(:document_access, :assets, :file))
104
- format.html { redirect_to document_accesses_path, notice: "Document access links were created successfully." }
104
+ format.html { redirect_to admin_document_accesses_path, notice: "Document access links were created successfully." }
105
105
  else
106
- format.html { redirect_to document_accesses_path, notice: "Access URLs could not be created." }
106
+ format.html { redirect_to admin_document_accesses_path, notice: "Access URLs could not be created." }
107
107
  end
108
108
  rescue => e
109
- format.html { redirect_to document_accesses_path, notice: "Access URLs could not be created. #{e}" }
109
+ format.html { redirect_to admin_document_accesses_path, notice: "Access URLs could not be created. #{e}" }
110
110
  end
111
111
  end
112
112
 
@@ -110,7 +110,7 @@ module Admin
110
110
 
111
111
  @parent.update(representative: @parent.members.order(:position).first) if @parent.representative_id.nil?
112
112
 
113
- redirect_to document_path(@parent.friendlier_id, anchor: "nav-members")
113
+ redirect_to admin_document_path(@parent.friendlier_id, anchor: "nav-members")
114
114
  end
115
115
 
116
116
  def convert_to_child_work
@@ -10,6 +10,8 @@ module Admin
10
10
  # GET /documents
11
11
  # GET /documents.json
12
12
  def index
13
+ @request = "#{request.protocol}#{request.host}:#{request.port}"
14
+
13
15
  query_params = {
14
16
  q: params["q"],
15
17
  f: params["f"],
@@ -18,7 +20,7 @@ module Admin
18
20
  sort: params["sort"] || "score desc",
19
21
  daterange: params["daterange"] || nil
20
22
  }
21
- @documents = BlacklightApi.new(**query_params)
23
+ @documents = BlacklightApi.new(@request, **query_params)
22
24
 
23
25
  respond_to do |format|
24
26
  format.html { render :index }
@@ -26,38 +28,44 @@ module Admin
26
28
 
27
29
  # JSON - BTAA Aardvark
28
30
  format.json_btaa_aardvark do
29
- ExportJsonJob.perform_later(current_user, query_params.merge!({format: "json_btaa_aardvark"}),
31
+ ExportJsonJob.perform_later(@request, current_user, query_params.merge!({format: "json_btaa_aardvark"}),
30
32
  ExportJsonService)
31
33
  head :no_content
32
34
  end
33
35
 
34
36
  # JSON - GBL Aardvark
35
37
  format.json_aardvark do
36
- ExportJsonJob.perform_later(current_user, query_params.merge!({format: "json_aardvark"}), ExportJsonService)
38
+ ExportJsonJob.perform_later(@request, current_user, query_params.merge!({format: "json_aardvark"}), ExportJsonService)
37
39
  head :no_content
38
40
  end
39
41
 
40
42
  # JSON - GBL v1
41
43
  format.json_gbl_v1 do
42
- ExportJsonJob.perform_later(current_user, query_params.merge!({format: "json_gbl_v1"}), ExportJsonService)
44
+ ExportJsonJob.perform_later(@request, current_user, query_params.merge!({format: "json_gbl_v1"}), ExportJsonService)
45
+ head :no_content
46
+ end
47
+
48
+ # JSON - FILE
49
+ format.json_file do
50
+ ExportJsonBulkJob.perform_later(@request, current_user, query_params.merge!({format: "json_file"}), ExportJsonService)
43
51
  head :no_content
44
52
  end
45
53
 
46
54
  # CSV - B1G
47
55
  format.csv do
48
- ExportJob.perform_later(current_user, query_params, ExportCsvService)
56
+ ExportJob.perform_later(@request, current_user, query_params, ExportCsvService)
49
57
  head :no_content
50
58
  end
51
59
 
52
60
  # CSV Document Downloads - B1G
53
61
  format.csv_document_downloads do
54
- ExportJob.perform_later(current_user, query_params, ExportCsvDocumentDownloadsService)
62
+ ExportJob.perform_later(@request, current_user, query_params, ExportCsvDocumentDownloadsService)
55
63
  head :no_content
56
64
  end
57
65
 
58
66
  # CSV Document Access Links - B1G
59
67
  format.csv_document_access_links do
60
- ExportJob.perform_later(current_user, query_params, ExportCsvDocumentAccessLinksService)
68
+ ExportJob.perform_later(@request, current_user, query_params, ExportCsvDocumentAccessLinksService)
61
69
  head :no_content
62
70
  end
63
71
  end
@@ -65,6 +73,7 @@ module Admin
65
73
 
66
74
  # Fetch documents from array of friendlier_ids
67
75
  def fetch
76
+ @request = "#{request.protocol}#{request.host}:#{request.port}"
68
77
  @documents = Document.where(friendlier_id: params["ids"])
69
78
 
70
79
  respond_to do |format|
@@ -73,42 +82,42 @@ module Admin
73
82
 
74
83
  # JSON - BTAA Aardvark
75
84
  format.json_btaa_aardvark do
76
- ExportJsonJob.perform_later(current_user, {ids: @documents.pluck(:friendlier_id), format: "json_btaa_aardvark"},
85
+ ExportJsonJob.perform_later(@request, current_user, {ids: @documents.pluck(:friendlier_id), format: "json_btaa_aardvark"},
77
86
  ExportJsonService)
78
87
  head :no_content
79
88
  end
80
89
 
81
90
  # JSON - GBL Aardvark
82
91
  format.json_aardvark do
83
- ExportJsonJob.perform_later(current_user, {ids: @documents.pluck(:friendlier_id), format: "json_aardvark"},
92
+ ExportJsonJob.perform_later(@request, current_user, {ids: @documents.pluck(:friendlier_id), format: "json_aardvark"},
84
93
  ExportJsonService)
85
94
  head :no_content
86
95
  end
87
96
 
88
97
  # JSON - GBL v1
89
98
  format.json_gbl_v1 do
90
- ExportJsonJob.perform_later(current_user, {ids: @documents.pluck(:friendlier_id), format: "json_gbl_v1"},
99
+ ExportJsonJob.perform_later(@request, current_user, {ids: @documents.pluck(:friendlier_id), format: "json_gbl_v1"},
91
100
  ExportJsonService)
92
101
  head :no_content
93
102
  end
94
103
 
95
104
  # CSV - B1G
96
105
  format.csv do
97
- ExportJob.perform_later(current_user, {ids: @documents.pluck(:friendlier_id), format: "csv"},
106
+ ExportJob.perform_later(@request, current_user, {ids: @documents.pluck(:friendlier_id), format: "csv"},
98
107
  ExportCsvService)
99
108
  head :no_content
100
109
  end
101
110
 
102
111
  # CSV Document Downloads - B1G
103
112
  format.csv_document_downloads do
104
- ExportJob.perform_later(current_user,
113
+ ExportJob.perform_later(@request, current_user,
105
114
  {ids: @documents.pluck(:friendlier_id), format: "csv_document_downloads"}, ExportCsvDocumentDownloadsService)
106
115
  head :no_content
107
116
  end
108
117
 
109
118
  # CSV Document Downloads - B1G
110
119
  format.csv_document_access_links do
111
- ExportJob.perform_later(current_user,
120
+ ExportJob.perform_later(@request, current_user,
112
121
  {ids: @documents.pluck(:friendlier_id), format: "csv_document_access_links"}, ExportCsvDocumentAccessLinksService)
113
122
  head :no_content
114
123
  end
@@ -4,7 +4,8 @@
4
4
  module Admin
5
5
  class SearchController < Admin::AdminController
6
6
  def index
7
- @facet_options = BlacklightApiFacets.new.facets
7
+ @request = "#{request.protocol}#{request.host}:#{request.port}"
8
+ @facet_options = BlacklightApiFacets.new(@request).facets
8
9
  end
9
10
  end
10
11
  end
@@ -4,7 +4,7 @@
4
4
  module Admin
5
5
  class UsersController < Admin::AdminController
6
6
  def index
7
- @users = User.all
7
+ @users = User.where(admin: true)
8
8
  end
9
9
  end
10
10
  end
@@ -28,7 +28,7 @@ class DocumentIndexer < Kithe::Indexer
28
28
  rec.updated_at.utc.iso8601 if rec&.updated_at
29
29
  end
30
30
 
31
- # - GEOMG
31
+ # - GBL ADMIN
32
32
  to_field "b1g_geom_import_id_ssi", obj_extract("import_id")
33
33
  end
34
34
  end
@@ -6,8 +6,9 @@ require "csv"
6
6
  class ExportJob < ApplicationJob
7
7
  queue_as :default
8
8
 
9
- def perform(current_user, query_params, export_service)
9
+ def perform(request, current_user, query_params, export_service)
10
10
  logger.debug("\n\n Background Job: ♞")
11
+ logger.debug("Request: #{request.inspect}")
11
12
  logger.debug("User: #{current_user.inspect}")
12
13
  logger.debug("Query: #{query_params.inspect}")
13
14
  logger.debug("Export Service: #{export_service.inspect}")
@@ -17,7 +18,7 @@ class ExportJob < ApplicationJob
17
18
  ActionCable.server.broadcast("export_channel", {data: "Hello from Export Job!"})
18
19
 
19
20
  # Query params into Doc ids
20
- document_ids = query_params[:ids] || crawl_query(query_params)
21
+ document_ids = query_params[:ids] || crawl_query(request, query_params)
21
22
 
22
23
  logger.debug("Document Ids: #{document_ids}")
23
24
 
@@ -56,15 +57,16 @@ class ExportJob < ApplicationJob
56
57
  })
57
58
  end
58
59
 
59
- def crawl_query(query_params, doc_ids = [])
60
+ def crawl_query(request, query_params, doc_ids = [])
60
61
  logger.debug("\n\n CRAWL Query: #{query_params}")
61
- api_results = BlacklightApiIds.new(query_params)
62
+ logger.debug("\n\n CRAWL Query Request: #{request}")
63
+ api_results = BlacklightApiIds.new(request, query_params)
62
64
  logger.debug("API Results: #{api_results.results.inspect}")
63
65
 
64
66
  doc_ids << api_results.results.pluck("id")
65
67
 
66
68
  unless api_results.meta["pages"]["next_page"].nil?
67
- crawl_query(query_params.merge!({page: api_results.meta["pages"]["next_page"]}),
69
+ crawl_query(request, query_params.merge!({page: api_results.meta["pages"]["next_page"]}),
68
70
  doc_ids)
69
71
  end
70
72
 
@@ -0,0 +1,94 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "csv"
4
+
5
+ # ExportJsonBulkJob
6
+ class ExportJsonBulkJob < ApplicationJob
7
+ queue_as :default
8
+
9
+ def perform(request, current_user, query_params, export_service)
10
+ logger.debug("\n\n Background Job: ♞")
11
+ logger.debug("Request: #{request.inspect}")
12
+ logger.debug("User: #{current_user.inspect}")
13
+ logger.debug("Query: #{query_params.inspect}")
14
+ logger.debug("Export Service: #{export_service.inspect}")
15
+ logger.debug("\n\n")
16
+
17
+ # Test broadcast
18
+ ActionCable.server.broadcast("export_channel", {data: "Hello from Export Job!"})
19
+
20
+ # Query params into Doc ids
21
+ document_ids = query_params[:ids] || crawl_query(request, query_params)
22
+
23
+ logger.debug("Document Ids: #{document_ids}")
24
+
25
+ # Send progress
26
+ documents = export_service.call(document_ids)
27
+
28
+ begin
29
+ # Array of JSON
30
+ @json_array = []
31
+
32
+ documents.each do |doc|
33
+ json_output = Admin::DocumentsController.render("_json_file.jbuilder",
34
+ locals: {document: doc})
35
+
36
+ json_obj = JSON.parse(json_output)
37
+ Rails.logger.debug json_obj
38
+
39
+ # Remove nil/null values from JSON
40
+ json_obj.compact!
41
+
42
+ @json_array << JSON.pretty_generate(json_obj)
43
+ rescue NoMethodError => e
44
+ Rails.logger.debug { "==== Error! - #{doc.friendlier_id} ====" }
45
+ Rails.logger.debug e.inspect
46
+ next
47
+ end
48
+ end
49
+
50
+ # Write into tempfile
51
+ @tempfile = Tempfile.new(["export-#{Time.zone.today}", ".json"]).tap do |file|
52
+ file.write("[#{@json_array.join(",")}]")
53
+ end
54
+ @tempfile.rewind
55
+
56
+ # Create notification
57
+ # Message: "Download Type|Row Count|Button Label"
58
+ notification = ExportNotification.with(message: "JSON FILE |#{ActionController::Base.helpers.number_with_delimiter(documents.size)} rows|JSON")
59
+
60
+ # Deliver notification
61
+ notification.deliver(current_user)
62
+
63
+ # Attach JSON file (can only attach after persisted)
64
+ notification.record.file.attach(io: @tempfile, filename: "geomg-export-#{Time.zone.today}.json",
65
+ content_type: "application/json")
66
+
67
+ # Update UI
68
+ ActionCable.server.broadcast("export_channel", {
69
+ data: "Notification ready!",
70
+ actions: [
71
+ {
72
+ method: "RefreshNotifications",
73
+ payload: current_user.notifications.unread.count
74
+ }
75
+ ]
76
+ })
77
+ end
78
+
79
+ def crawl_query(request, query_params, doc_ids = [])
80
+ logger.debug("\n\n CRAWL Query: #{query_params}")
81
+ logger.debug("\n\n CRAWL Query Request: #{request}")
82
+ api_results = BlacklightApiIds.new(request, query_params)
83
+ logger.debug("API Results: #{api_results.results.inspect}")
84
+
85
+ doc_ids << api_results.results.pluck("id")
86
+
87
+ unless api_results.meta["pages"]["next_page"].nil?
88
+ crawl_query(request, query_params.merge!({page: api_results.meta["pages"]["next_page"]}),
89
+ doc_ids)
90
+ end
91
+
92
+ doc_ids
93
+ end
94
+ end