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.
Files changed (162) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +24 -11
  3. data/Rakefile +83 -47
  4. data/app/assets/javascripts/geoblacklight_admin/chosen.js +1 -0
  5. data/app/assets/stylesheets/geoblacklight_admin/_core.scss +24 -0
  6. data/app/assets/stylesheets/geoblacklight_admin/modules/_nav.scss +0 -5
  7. data/app/assets/stylesheets/geoblacklight_admin/modules/_tables.scss +1 -1
  8. data/app/controllers/admin/admin_controller.rb +16 -0
  9. data/app/controllers/admin/advanced_search_controller.rb +7 -1
  10. data/app/controllers/admin/assets_controller.rb +47 -32
  11. data/app/controllers/admin/bookmarks_controller.rb +17 -5
  12. data/app/controllers/admin/bulk_actions_controller.rb +32 -1
  13. data/app/controllers/admin/document_accesses_controller.rb +38 -0
  14. data/app/controllers/admin/document_assets_controller.rb +47 -89
  15. data/app/controllers/admin/document_distributions_controller.rb +172 -0
  16. data/app/controllers/admin/documents_controller.rb +43 -57
  17. data/app/controllers/admin/elements_controller.rb +24 -0
  18. data/app/controllers/admin/form_elements_controller.rb +33 -0
  19. data/app/controllers/admin/ids_controller.rb +6 -0
  20. data/app/controllers/admin/import_documents_controller.rb +11 -1
  21. data/app/controllers/admin/imports_controller.rb +34 -4
  22. data/app/controllers/admin/mappings_controller.rb +15 -0
  23. data/app/controllers/admin/notifications_controller.rb +27 -0
  24. data/app/controllers/admin/reference_types_controller.rb +106 -0
  25. data/app/controllers/admin/search_controller.rb +7 -0
  26. data/app/controllers/admin/users_controller.rb +10 -0
  27. data/app/helpers/asset_helper.rb +6 -0
  28. data/app/helpers/bulk_actions_helper.rb +10 -1
  29. data/app/helpers/document_helper.rb +36 -0
  30. data/app/helpers/geoblacklight_admin_helper.rb +88 -8
  31. data/app/helpers/mappings_helper.rb +26 -0
  32. data/app/indexers/document_indexer.rb +22 -2
  33. data/app/javascript/channels/consumer.js +6 -0
  34. data/app/javascript/channels/export_channel.js +30 -0
  35. data/app/javascript/channels/index.js +3 -0
  36. data/app/javascript/controllers/results_controller.js +14 -0
  37. data/app/javascript/index.js +8 -2
  38. data/app/jobs/bulk_action_revert_document_job.rb +4 -12
  39. data/app/jobs/bulk_action_run_document_job.rb +2 -10
  40. data/app/jobs/export_job.rb +35 -8
  41. data/app/jobs/geoblacklight_admin/delete_thumbnail_job.rb +19 -0
  42. data/app/jobs/geoblacklight_admin/remove_parent_dct_references_uri_job.rb +16 -0
  43. data/app/jobs/geoblacklight_admin/set_parent_dct_references_uri_job.rb +17 -0
  44. data/app/jobs/geoblacklight_admin/store_image_job.rb +22 -0
  45. data/app/jobs/import_document_job.rb +1 -4
  46. data/app/jobs/import_run_job.rb +1 -1
  47. data/app/models/admin/bookmark.rb +1 -1
  48. data/app/models/asset.rb +20 -0
  49. data/app/models/bulk_action.rb +2 -1
  50. data/app/models/bulk_actions/change_publication_state.rb +0 -25
  51. data/app/models/bulk_actions/delete_thumbnails.rb +6 -0
  52. data/app/models/bulk_actions/draft_document.rb +6 -0
  53. data/app/models/bulk_actions/harvest_thumbnails.rb +6 -0
  54. data/app/models/bulk_actions/publish_document.rb +6 -0
  55. data/app/models/bulk_actions/unpublish_document.rb +6 -0
  56. data/app/models/document/geom_validator.rb +8 -0
  57. data/app/models/document/reference.rb +65 -65
  58. data/app/models/document.rb +129 -72
  59. data/app/models/document_distribution.rb +145 -0
  60. data/app/models/element.rb +2 -0
  61. data/app/models/geoblacklight_admin/schema.rb +10 -2
  62. data/app/models/import/csv_duplicates_validator.rb +2 -0
  63. data/app/models/import/csv_header_validator.rb +3 -1
  64. data/app/models/import_btaa_aardvark.rb +2 -2
  65. data/app/models/import_document_state_machine.rb +1 -0
  66. data/app/models/import_gblv1.rb +2 -2
  67. data/app/models/reference_type.rb +40 -0
  68. data/app/models/user.rb +4 -2
  69. data/app/services/export_csv_document_distributions_service.rb +61 -0
  70. data/app/services/geoblacklight_admin/image_service/iiif_manifest.rb +39 -43
  71. data/app/services/geoblacklight_admin/image_service/tms.rb +0 -8
  72. data/app/services/geoblacklight_admin/image_service.rb +1 -1
  73. data/app/services/geoblacklight_admin/item_viewer.rb +4 -4
  74. data/app/views/admin/bookmarks/index.html.erb +19 -14
  75. data/app/views/admin/bulk_actions/show.html.erb +1 -1
  76. data/app/views/admin/document_accesses/import.html.erb +6 -2
  77. data/app/views/admin/document_assets/_assets_table.html.erb +49 -0
  78. data/app/views/admin/document_assets/_form.html.erb +2 -3
  79. data/app/views/admin/document_assets/index.html.erb +1 -47
  80. data/app/views/admin/document_distributions/_document_distribution.html.erb +39 -0
  81. data/app/views/admin/document_distributions/_document_distribution.json.jbuilder +2 -0
  82. data/app/views/admin/document_distributions/_form.html.erb +34 -0
  83. data/app/views/admin/document_distributions/destroy_all.html.erb +82 -0
  84. data/app/views/admin/document_distributions/edit.html.erb +12 -0
  85. data/app/views/admin/document_distributions/import.html.erb +80 -0
  86. data/app/views/admin/document_distributions/index.html.erb +143 -0
  87. data/app/views/admin/document_distributions/index.json.jbuilder +1 -0
  88. data/app/views/admin/document_distributions/new.html.erb +11 -0
  89. data/app/views/admin/document_distributions/show.html.erb +10 -0
  90. data/app/views/admin/document_distributions/show.json.jbuilder +1 -0
  91. data/app/views/admin/documents/_document.html.erb +1 -3
  92. data/app/views/admin/documents/_form.html.erb +2 -4
  93. data/app/views/admin/documents/_form_control.html.erb +5 -2
  94. data/app/views/admin/documents/_form_nav.html.erb +14 -5
  95. data/app/views/admin/documents/_form_nav_kithe.html.erb +4 -1
  96. data/app/views/admin/documents/_json_aardvark.jbuilder +1 -1
  97. data/app/views/admin/documents/_json_gbl_v1.jbuilder +1 -1
  98. data/app/views/admin/documents/_result_selected_options.html.erb +5 -2
  99. data/app/views/admin/documents/admin.html.erb +5 -5
  100. data/app/views/admin/documents/features/_document_references.html.erb +23 -0
  101. data/app/views/admin/documents/features/_multiple_download_links.html.erb +29 -26
  102. data/app/views/admin/ids/fetch.json.jbuilder +0 -2
  103. data/app/views/admin/ids/index.json.jbuilder +0 -2
  104. data/app/views/admin/imports/_form.html.erb +1 -1
  105. data/app/views/admin/imports/show.html.erb +1 -1
  106. data/app/views/admin/layouts/application.html.erb +4 -2
  107. data/app/views/admin/mappings/index.html.erb +1 -1
  108. data/app/views/admin/notifications/_notification.html.haml +29 -28
  109. data/app/views/admin/reference_types/_form.html.erb +25 -0
  110. data/app/views/admin/reference_types/_reference_type.html.erb +52 -0
  111. data/app/views/admin/reference_types/_reference_type.json.jbuilder +2 -0
  112. data/app/views/admin/reference_types/edit.html.erb +12 -0
  113. data/app/views/admin/reference_types/index.html.erb +52 -0
  114. data/app/views/admin/reference_types/index.json.jbuilder +1 -0
  115. data/app/views/admin/reference_types/new.html.erb +11 -0
  116. data/app/views/admin/reference_types/show.html.erb +3 -0
  117. data/app/views/admin/reference_types/show.json.jbuilder +1 -0
  118. data/app/views/admin/shared/_footer.html.erb +5 -2
  119. data/app/views/admin/shared/_js_behaviors.html.erb +2 -3
  120. data/app/views/admin/shared/_navbar.html.erb +9 -2
  121. data/app/views/admin/users/index.html.erb +0 -1
  122. data/app/views/catalog/_show_gbl_admin.html.erb +1 -1
  123. data/config/initializers/defaults.yml +310 -0
  124. data/config/initializers/rails_config.rb +8 -0
  125. data/config/locales/documents.en.yml +14 -0
  126. data/config/routes.rb +30 -5
  127. data/db/import_references_schema_support.numbers +0 -0
  128. data/db/migrate/20230316183001_add_geoblacklight_admin_gem.rb +0 -12
  129. data/db/migrate/20241009200524_create_admin_reference_types.rb +13 -0
  130. data/db/migrate/20241010161420_create_document_references.rb +14 -0
  131. data/db/migrate/20241120238823_rename_references_to_distributions.rb +5 -0
  132. data/db/seeds.rb +5 -0
  133. data/db/seeds_elements.csv +1 -1
  134. data/db/seeds_elements.numbers +0 -0
  135. data/db/seeds_reference_types.csv +29 -0
  136. data/db/seeds_reference_types.numbers +0 -0
  137. data/db/structure.sql +1 -38
  138. data/lib/compose.yml +31 -0
  139. data/lib/generators/geoblacklight_admin/config_generator.rb +53 -12
  140. data/lib/generators/geoblacklight_admin/install_generator.rb +8 -0
  141. data/lib/generators/geoblacklight_admin/templates/btaa_sample_records.csv +5 -0
  142. data/lib/generators/geoblacklight_admin/templates/config/database.yml +1 -1
  143. data/lib/generators/geoblacklight_admin/templates/config/initializers/devise.rb +0 -2
  144. data/lib/generators/geoblacklight_admin/templates/config/initializers/mime_types.rb +1 -0
  145. data/lib/generators/geoblacklight_admin/templates/demo-app/Dockerfile +31 -0
  146. data/lib/generators/geoblacklight_admin/templates/demo-app/compose.yml +42 -0
  147. data/lib/generators/geoblacklight_admin/templates/demo-app/start-server.sh +21 -0
  148. data/lib/geoblacklight_admin/engine.rb +4 -0
  149. data/lib/geoblacklight_admin/rake_task.rb +2 -0
  150. data/lib/geoblacklight_admin/tasks/distributions.rake +69 -0
  151. data/lib/geoblacklight_admin/tasks/images.rake +1 -0
  152. data/lib/geoblacklight_admin/tasks/solr.rake +31 -0
  153. data/lib/geoblacklight_admin/version.rb +1 -1
  154. data/lib/geoblacklight_admin.rb +4 -0
  155. metadata +137 -53
  156. data/app/helpers/import_documents_helper.rb +0 -5
  157. data/app/javascript/entrypoints/engine.js +0 -8
  158. data/config/locales/devise_invitable.en.yml +0 -31
  159. data/lib/generators/geoblacklight_admin/templates/devise/invitations/edit.html.erb +0 -15
  160. data/lib/generators/geoblacklight_admin/templates/devise/invitations/new.html.erb +0 -15
  161. data/lib/generators/geoblacklight_admin/templates/devise/mailer/invitation_instructions.html.erb +0 -11
  162. data/lib/generators/geoblacklight_admin/templates/devise/mailer/invitation_instructions.text.erb +0 -11
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "csv"
4
+
5
+ # ExportCsvDocumentDistributionsService
6
+ #
7
+ # This service is responsible for exporting document distributions to a CSV format.
8
+ # It broadcasts the progress of the export process via ActionCable.
9
+ class ExportCsvDocumentDistributionsService
10
+ # Returns a short name for the service.
11
+ #
12
+ # @return [String] the short name of the service.
13
+ def self.short_name
14
+ "Document Distributions"
15
+ end
16
+
17
+ # Initiates the CSV export process for the given document IDs.
18
+ #
19
+ # @param document_ids [Array] an array of document IDs to export.
20
+ # @return [Array] the generated CSV file content as an array of rows.
21
+ #
22
+ # This method broadcasts the progress of the export process to the "export_channel".
23
+ # It processes the document IDs in slices and handles any NoMethodError exceptions
24
+ # that occur during the export process.
25
+ def self.call(document_ids)
26
+ ActionCable.server.broadcast("export_channel", {progress: 0})
27
+
28
+ document_ids = document_ids.flatten
29
+ total = document_ids.size
30
+ count = 0
31
+ slice_count = 100
32
+ csv_file = []
33
+
34
+ Rails.logger.debug { "\n\nExportCsvDocumentDistributionsService: #{document_ids.inspect}\n\n" }
35
+
36
+ CSV.generate(headers: true) do |_csv|
37
+ csv_file << DocumentDistribution.csv_column_names
38
+ document_ids.each_slice(slice_count) do |slice|
39
+ # Broadcast progress percentage
40
+ count += slice_count
41
+ progress = ((count.to_f / total) * 100).round
42
+ progress = 100 if progress > 100
43
+
44
+ ActionCable.server.broadcast("export_channel", {progress: progress})
45
+ slice.each do |doc_id|
46
+ doc = Document.find_by(friendlier_id: doc_id)
47
+
48
+ Rails.logger.debug { "\n\nDocDistributions: #{doc.document_distributions.size}\n\n" }
49
+
50
+ doc.document_distributions.each do |distribution|
51
+ csv_file << distribution.to_csv
52
+ end
53
+ rescue NoMethodError
54
+ Rails.logger.debug { "\n\nExport Failed: #{doc_id.inspect}\n\n" }
55
+ end
56
+ end
57
+ end
58
+
59
+ csv_file
60
+ end
61
+ end
@@ -54,57 +54,53 @@ module GeoblacklightAdmin
54
54
  # @param [Integer] thumbnail size
55
55
  # @return [String] iiif thumbnail url
56
56
  def self.image_url(document, _size)
57
- Rails.logger.debug("\n\nViewer Endpoint: #{document.viewer_endpoint}")
57
+ tempfile = Down.download(document.viewer_endpoint)
58
+ manifest_json = JSON.parse(tempfile.read)
58
59
 
59
- begin
60
- tempfile = Down.download(document.viewer_endpoint)
61
- manifest_json = JSON.parse(tempfile.read)
62
-
63
- # Sequences - Return the first image if it exists
64
- # - best case option
65
- if manifest_json.dig("sequences", 0, "canvases", 0, "images", 0, "resource", "@id")
66
- Rails.logger.debug("\n Image: sequences \n")
67
- if manifest_json.dig("sequences", 0, "canvases", 0, "images", 0, "resource", "@id").include?("osu")
68
- Rails.logger.debug("\n Image: sequences - OSU variant \n")
69
- manifest_json.dig("sequences", 0, "canvases", 0, "images", 0, "resource", "service", "@id") + "/full/1000,/0/default.jpg"
70
- else
71
- manifest_json.dig("sequences", 0, "canvases", 0, "images", 0, "resource", "@id")
72
- end
73
-
74
- # Items - Return the first item image if it exists
75
- # - Northwestern
76
- elsif manifest_json.dig("items", 0, "items", 0, "items", 0, "body", "id")
77
- Rails.logger.debug("\n Image: items body id \n")
78
- manifest_json.dig("items", 0, "items", 0, "items", 0, "body", "id")
60
+ # Sequences - Return the first image if it exists
61
+ # - best case option
62
+ if manifest_json.dig("sequences", 0, "canvases", 0, "images", 0, "resource", "@id")
63
+ Rails.logger.debug("\n Image: sequences \n")
64
+ if manifest_json.dig("sequences", 0, "canvases", 0, "images", 0, "resource", "@id").include?("osu")
65
+ Rails.logger.debug("\n Image: sequences - OSU variant \n")
66
+ manifest_json.dig("sequences", 0, "canvases", 0, "images", 0, "resource", "service", "@id") + "/full/1000,/0/default.jpg"
67
+ else
68
+ manifest_json.dig("sequences", 0, "canvases", 0, "images", 0, "resource", "@id")
69
+ end
79
70
 
80
- # Items - Return the first item image if it exists
81
- # - strange option
82
- elsif manifest_json.dig("items", 0, "items", 0, "items", 0, "id")
83
- Rails.logger.debug("\n Image: items id \n")
84
- manifest_json.dig("items", 0, "items", 0, "items", 0, "id")
71
+ # Items - Return the first item image if it exists
72
+ # - Northwestern
73
+ elsif manifest_json.dig("items", 0, "items", 0, "items", 0, "body", "id")
74
+ Rails.logger.debug("\n Image: items body id \n")
75
+ manifest_json.dig("items", 0, "items", 0, "items", 0, "body", "id")
85
76
 
86
- # Thumbnail - Return the "thumbnail" if it exists
87
- # - varies in size depending on the provider
88
- # - worst case option really
89
- # - can be @id or id
90
- elsif manifest_json["thumbnail"]
91
- Rails.logger.debug("\n Image: thumbnail \n")
92
- if manifest_json.dig("thumbnail", "@id")
93
- manifest_json.dig("thumbnail", "@id")
94
- else
95
- manifest_json.dig("thumbnail", "id")
96
- manifest_json.dig("thumbnail", "id")
97
- end
77
+ # Items - Return the first item image if it exists
78
+ # - strange option
79
+ elsif manifest_json.dig("items", 0, "items", 0, "items", 0, "id")
80
+ Rails.logger.debug("\n Image: items id \n")
81
+ manifest_json.dig("items", 0, "items", 0, "items", 0, "id")
98
82
 
99
- # Fail - Gonna fail
83
+ # Thumbnail - Return the "thumbnail" if it exists
84
+ # - varies in size depending on the provider
85
+ # - worst case option really
86
+ # - can be @id or id
87
+ elsif manifest_json["thumbnail"]
88
+ Rails.logger.debug("\n Image: thumbnail \n")
89
+ if manifest_json.dig("thumbnail", "@id")
90
+ manifest_json.dig("thumbnail", "@id")
100
91
  else
101
- Rails.logger.debug("\n Image: failed \n")
102
- document.viewer_endpoint
92
+ manifest_json.dig("thumbnail", "id")
93
+ manifest_json.dig("thumbnail", "id")
103
94
  end
104
- rescue => e
105
- Rails.logger.debug("\n Rescued: #{e.inspect} \n")
95
+
96
+ # Fail - Gonna fail
97
+ else
98
+ Rails.logger.debug("\n Image: failed \n")
106
99
  document.viewer_endpoint
107
100
  end
101
+ rescue => e
102
+ Rails.logger.debug("\n Rescued: #{e.inspect} \n")
103
+ document.viewer_endpoint
108
104
  end
109
105
  end
110
106
  end
@@ -14,29 +14,21 @@ module GeoblacklightAdmin
14
14
  # @param [Integer] thumbnail size
15
15
  # @return [String] tms thumbnail url
16
16
  def self.image_url(document, size)
17
- puts "\nTMS IMAGE URL..."
18
- puts "document.viewer_endpoint: #{document.viewer_endpoint.inspect}"
19
-
20
17
  # Begins with:
21
18
  # https://cugir.library.cornell.edu/geoserver/gwc/service/tms/1.0.0/cugir%3Acugir007957@EPSG%3A3857@png/{z}/{x}/{y}.png
22
19
 
23
20
  # Works with:
24
21
  # https://cugir.library.cornell.edu/geoserver/wms/reflect?&FORMAT=image%2Fpng&TRANSPARENT=TRUE&LAYERS=cugir007957&WIDTH=1500&HEIGHT=1500
25
22
 
26
- puts "\nPARSE TMS URL..."
27
23
  # Parse the URL using Addressable::URI which handles more complex URIs
28
24
  parsed_url = Addressable::URI.parse(document.viewer_endpoint)
29
25
 
30
- puts "Parsed URL: #{parsed_url.inspect}"
31
-
32
26
  # Build a hash to store the extracted components
33
27
  parsed_data = {
34
28
  base_url: "#{parsed_url.scheme}://#{parsed_url.host}#{parsed_url.port ? ":" + parsed_url.port.to_s : ""}",
35
29
  path_pattern: parsed_url.path
36
30
  }
37
31
 
38
- puts "Parsed Data: #{parsed_data.inspect}"
39
-
40
32
  endpoint = parsed_data[:base_url]
41
33
  "#{endpoint}/geoserver/wms/reflect?" \
42
34
  "&FORMAT=image%2Fpng" \
@@ -191,7 +191,7 @@ module GeoblacklightAdmin
191
191
 
192
192
  # Retreives a url to a static thumbnail from the document's dct_references field, if it exists.
193
193
  def image_reference
194
- @document.references["http://schema.org/thumbnailUrl"]
194
+ @document.distributions["http://schema.org/thumbnailUrl"]
195
195
  end
196
196
 
197
197
  # Default image size.
@@ -2,9 +2,9 @@
2
2
 
3
3
  module GeoblacklightAdmin
4
4
  class ItemViewer
5
- def initialize(references)
6
- @references = references
7
- @keys = references.keys.collect { |k| reference_uri_2_key(k) }
5
+ def initialize(distributions)
6
+ @distributions = distributions
7
+ @keys = distributions.keys.collect { |k| reference_uri_2_key(k) }
8
8
  end
9
9
 
10
10
  def viewer_protocol
@@ -12,7 +12,7 @@ module GeoblacklightAdmin
12
12
  end
13
13
 
14
14
  def viewer_endpoint
15
- @references[viewer_protocol_2_endpoint]
15
+ @distributions[viewer_protocol_2_endpoint]
16
16
  end
17
17
 
18
18
  def reference_uri_2_key(value)
@@ -2,20 +2,25 @@
2
2
 
3
3
  <h1>Bookmarks (<%= current_user.bookmarks.where(document_type: 'Kithe::Model').size %>)</h1>
4
4
 
5
- <p>
6
- <%= render "admin/documents/result_toggle" %>
7
- <%= render "admin/documents/result_selected_options" %>
8
- <span class='float-right'>
9
- <%== pagy_bootstrap_nav(@pagy) %>
10
- </span>
11
- </p>
5
+ <%- if @pagy %>
12
6
 
13
- <hr/>
7
+ <p>
8
+ <%= render "admin/documents/result_toggle" %>
9
+ <%= render "admin/documents/result_selected_options" %>
10
+ <span class='float-right'>
11
+ <%== pagy_bootstrap_nav(@pagy) %>
12
+ </span>
13
+ </p>
14
14
 
15
- <%= render "admin/documents/result_selection_options" %>
15
+ <hr/>
16
16
 
17
- <ol id='results' class='list-unstyled' data-controller='results'>
18
- <% @bookmarks.each_with_index do |bookmark, index| %>
19
- <%= render 'admin/documents/document', document: Kithe::Model.find(bookmark.document_id), index: index %>
20
- <% end %>
21
- </ol>
17
+ <%= render "admin/documents/result_selection_options" %>
18
+
19
+ <ol id='results' class='list-unstyled' data-controller='results'>
20
+ <% @bookmarks.each_with_index do |bookmark, index| %>
21
+ <%= render 'admin/documents/document', document: Kithe::Model.find(bookmark.document_id), index: index %>
22
+ <% end %>
23
+ </ol>
24
+ <%- else %>
25
+ <p>No bookmarks found.</p>
26
+ <%- end %>
@@ -43,7 +43,7 @@
43
43
  <% if @bulk_action.state_machine.current_state == 'created' %>
44
44
  <%= form_tag run_admin_bulk_action_path(@bulk_action), method: :patch do -%>
45
45
  <%= hidden_field_tag :run, true -%>
46
- <%= submit_tag 'Run Bulk Action' -%>
46
+ <%= submit_tag '+ Run Bulk Action', class: 'btn btn-primary btn-block' -%>
47
47
  <%- end -%>
48
48
  <% else %>
49
49
  <%= @bulk_action.state_machine.current_state %>
@@ -15,7 +15,11 @@
15
15
  <h2 class='h3'>Import for Multiple Documents</h2>
16
16
  <% end %>
17
17
 
18
- <h3 class='h4'>Import a CSV File</h3>
18
+ <p class="alert alert-info" role="alert">
19
+ <strong>Note:</strong> New Institutional Access URLs will be created. Existing Institutional Access URLs will be updated per the CSV file.
20
+ </p>
21
+
22
+ <h3 class='h4'>Upload a CSV File</h3>
19
23
  <%= simple_form_for DocumentAccess.new, url: import_admin_document_accesses_path, method: :post, multipart: true do |f| %>
20
24
  <div class="form-inputs">
21
25
  <%= f.simple_fields_for :assets do |asset_fields| %>
@@ -24,7 +28,7 @@
24
28
  </div>
25
29
 
26
30
  <div class="form-actions">
27
- <%= submit_tag "Import CSV", {class: 'btn btn-primary'} %>
31
+ <%= submit_tag "+ Import CSV", {class: 'btn btn-primary'} %>
28
32
  </div>
29
33
  <% end %>
30
34
  </div>
@@ -0,0 +1,49 @@
1
+ <div class="table-responsive">
2
+ <table class="table table-striped table-bordered sortable">
3
+ <thead class="thead-dark">
4
+ <tr>
5
+ <th>Thumbnail</th>
6
+ <th>Preview</th>
7
+ <th>Title</th>
8
+ <th>Label</th>
9
+ <th>MimeType</th>
10
+ <th>Reference URI Type</th>
11
+ <th colspan="2">Actions</th>
12
+ </tr>
13
+ </thead>
14
+ <tbody>
15
+ <% document_assets.each do |document_asset| %>
16
+ <tr>
17
+ <td>
18
+ <%= form_with model: document_asset, url: admin_document_document_asset_path(document_asset.parent, document_asset), method: :put, remote: true, class: 'thumbnail-form' do |f| %>
19
+ <%= f.check_box :thumbnail, class: 'thumbnail-toggle', onchange: "this.form.submit()" %>
20
+ <%= f.submit 'Save', class: 'btn btn-sm btn-primary d-none' %>
21
+ <% end %>
22
+ </td>
23
+ <td>
24
+ <% if document_asset.respond_to?(:thumbnail) %>
25
+ <% unless document_asset.file_url(:thumb_standard).nil? %>
26
+ <%= image_tag(document_asset.file_url(:thumb_standard), { height: 100 }) %>
27
+ <% end %>
28
+ <% end %>
29
+ </td>
30
+ <td><%= link_to(document_asset.title, document_asset.file.url) %></td>
31
+ <td><%= document_asset.label %></td>
32
+ <td>
33
+ <%= document_asset.file_data["metadata"]["mime_type"] %>
34
+ <span class="sr-only"><%= document_asset.inspect %></span>
35
+ </td>
36
+ <td>
37
+ <%= document_asset.dct_references_uri_key %>
38
+ </td>
39
+ <td>
40
+ <%= link_to 'Edit', edit_admin_document_document_asset_path(document_asset.parent, document_asset) %>
41
+ </td>
42
+ <td>
43
+ <%= link_to 'Destroy', admin_document_document_asset_path(document_asset.parent, document_asset), method: :delete, data: { confirm: 'Are you sure?' } %>
44
+ </td>
45
+ </tr>
46
+ <% end %>
47
+ </tbody>
48
+ </table>
49
+ </div>
@@ -1,11 +1,10 @@
1
- <%= @document_asset.class %>
2
-
3
1
  <%= simple_form_for [:admin, @document, @document_asset], :url => admin_document_document_asset_path(@document, @document_asset) do |f| %>
4
2
  <%= f.error_notification %>
5
3
  <%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %>
6
4
 
7
5
  <div class="form-inputs">
8
- <%= f.input :parent_id, input_html: { value: @document.friendlier_id, readonly: true } %>
6
+ <%= link_to "Parent Document", admin_document_path(@document_asset.parent) %>
7
+ <%= f.input :parent_id, as: :hidden %>
9
8
  <%= f.input :title %>
10
9
  <%= f.input :label %>
11
10
  <%= f.input :dct_references_uri_key, collection: I18n.t("activemodel.enum_values.document/reference.category").invert.sort.insert(0, ["Choose Reference Type", nil]), label: 'Reference' %>
@@ -30,53 +30,7 @@
30
30
  </h6>
31
31
  <% end %>
32
32
 
33
- <div class="table-responsive">
34
- <table class="table table-striped table-bordered sortable">
35
- <thead class="thead-dark">
36
- <tr>
37
- <th>Thumbnail</th>
38
- <th>Preview</th>
39
- <th>Title</th>
40
- <th>Label</th>
41
- <th>MimeType</th>
42
- <th>Reference URI Type</th>
43
- <th colspan="2">Actions</th>
44
- </tr>
45
- </thead>
46
- <tbody>
47
- <% @document_assets.each do |document_asset| %>
48
- <tr>
49
- <td>
50
- <% if document_asset.respond_to?(:thumbnail) %>
51
- <%= document_asset.thumbnail %>
52
- <% end %>
53
- </td>
54
- <td>
55
- <% if document_asset.respond_to?(:thumbnail) %>
56
- <% unless document_asset.file_url(:thumb_standard).nil? %>
57
- <%= image_tag(document_asset.file_url(:thumb_standard), { height: 100 }) %>
58
- <% end %>
59
- <% end %>
60
- </td>
61
- <td><%= link_to(document_asset.title, document_asset.file.url) %></td>
62
- <td><%= document_asset.label %></td>
63
- <td>
64
- <%= document_asset.file_data["metadata"]["mime_type"] %>
65
- <span class="sr-only"><%= document_asset.inspect %></span>
66
- </td>
67
- <td>
68
- <%= document_asset.dct_references_uri_key %>
69
- </td>
70
- <td>
71
- <%= link_to 'Edit', edit_admin_document_document_asset_path(document_asset.parent, document_asset) %>
72
- </td>
73
- <td>
74
- <%= link_to 'Destroy', admin_document_document_asset_path(document_asset.parent, document_asset), method: :delete, data: { confirm: 'Are you sure?' } %>
75
- </td>
76
- </tr>
77
- <% end %>
78
- </tbody>
79
- </table>
33
+ <%= render partial: 'assets_table', locals: { document_assets: @document_assets } %>
80
34
 
81
35
  <% if @pagy %>
82
36
  <h6>
@@ -0,0 +1,39 @@
1
+ <%- @page_title = "GBL♦Admin - Document - Distribution - #{document_distribution.url}" %>
2
+
3
+ <h1>Distribution</h1>
4
+
5
+ <div class="row">
6
+ <div class="col-9">
7
+ <h2>
8
+ <%= document_distribution.url %>
9
+ <span class="float-right">
10
+ <%= link_to '~ Edit Distribution', edit_admin_document_document_distribution_path(@document, document_distribution), { class: 'btn btn-primary' } %>
11
+ <%= button_to "Destroy this distribution", admin_document_document_distribution_path(@document, document_distribution), method: :delete, class: "btn btn-danger" %>
12
+ </span>
13
+ </h2>
14
+
15
+ <table class="table table-bordered">
16
+ <thead class="thead-dark">
17
+ <tr>
18
+ <th class="header" style="width:300px;">Attribute</th>
19
+ <th class="header">Value</th>
20
+ </tr>
21
+ </thead>
22
+ <tr>
23
+ <th>Reference Type</th>
24
+ <td><%= document_distribution.reference_type.reference_type %></td>
25
+ </tr>
26
+ <tr>
27
+ <th>Reference URL</th>
28
+ <td><%= document_distribution.url %></td>
29
+ </tr>
30
+ <tr>
31
+ <th>Label</th>
32
+ <td><%= document_distribution.label %></td>
33
+ </tr>
34
+ </table>
35
+ </div>
36
+ </div>
37
+
38
+ <%= link_to 'Edit', edit_admin_document_document_distribution_path(@document, document_distribution) %> |
39
+ <%= link_to 'Back', admin_document_document_distributions_path(@document) %>
@@ -0,0 +1,2 @@
1
+ json.extract! document_distribution, :id, :created_at, :updated_at
2
+ json.url document_distribution_url(document_distribution, format: :json)
@@ -0,0 +1,34 @@
1
+ <%= simple_form_for([:admin, @document, @document_distribution]) do |f| %>
2
+ <%= f.error_notification %>
3
+ <%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %>
4
+
5
+ <div class="form-inputs">
6
+ <%= f.input :friendlier_id, input_html: { value: @document.friendlier_id, readonly: true } %>
7
+ <%= f.input :reference_type_id, as: :select, collection: ReferenceType.all.map { |r| [r.reference_type, r.id] }, label: 'Reference Type' %>
8
+ <%= f.input :url, label: 'Distribution URL' %>
9
+ <%= f.input :label, autofocus: true, input_html: { disabled: true, id: 'label-input' } %>
10
+
11
+ </div>
12
+
13
+ <div class="form-actions">
14
+ <%= f.button :submit, 'Create Download URL', {class: 'btn btn-primary'} %>
15
+ </div>
16
+ <% end %>
17
+
18
+ <script>
19
+ document.addEventListener('DOMContentLoaded', function() {
20
+ const distributionSelect = document.querySelector('select[name="document_distribution[reference_type_id]"]');
21
+ const labelInput = document.getElementById('label-input');
22
+
23
+ function toggleLabelInput() {
24
+ if (distributionSelect.options[distributionSelect.selectedIndex].text === 'Download file') {
25
+ labelInput.disabled = false;
26
+ } else {
27
+ labelInput.disabled = true;
28
+ }
29
+ }
30
+
31
+ distributionSelect.addEventListener('change', toggleLabelInput);
32
+ toggleLabelInput(); // Initial check
33
+ });
34
+ </script>
@@ -0,0 +1,82 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <h1 style="width:100%; border-bottom:dotted;" class="mb-4">
4
+ Document &middot; Destroy Distributions
5
+ <% if params[:document_id] %>
6
+ <%= link_to '+ New Distribution', new_document_document_distribution_path(@document), { class: 'btn btn-primary float-right' } %>
7
+ <% end %>
8
+ </h1>
9
+
10
+ <div class="row">
11
+ <div class="col-4">
12
+ <% if params[:document_id] %>
13
+ <h2 class='h3'><%= @document.title %></h2>
14
+ <% else %>
15
+ <h2 class='h3'>Destroy Multiple Distributions</h2>
16
+ <% end %>
17
+
18
+ <p class="alert alert-danger" role="alert">
19
+ <strong>Warning:</strong> All matching Distributions will be destroyed. There is <strong>NO UNDO</strong> here.
20
+ </p>
21
+ <h3 class='h4'>Upload a CSV File</h3>
22
+
23
+ <%= simple_form_for DocumentDistribution.new, url: destroy_all_admin_document_distributions_path, method: :post, multipart: true do |f| %>
24
+ <div class="form-group">
25
+ <div class="form-inputs">
26
+ <%= f.simple_fields_for :distributions do |distribution_fields| %>
27
+ <%= reference_fields.input :file, as: :file, input_html: {} %>
28
+ <%- end %>
29
+ </div>
30
+
31
+ <div class="form-actions">
32
+ <%= submit_tag "- Destroy All", {class: 'btn btn-danger'} %>
33
+ </div>
34
+ </div>
35
+ <% end %>
36
+ </div>
37
+ <div class="col-8">
38
+ <h4>Example CSV File</h4>
39
+ <table class="table table-bordered">
40
+ <thead>
41
+ <tr>
42
+ <th>friendlier_id</th>
43
+ <th>reference_type</th>
44
+ <th>distribution_url</th>
45
+ <th>label</th>
46
+ </tr>
47
+ </thead>
48
+ <tbody>
49
+ <tr>
50
+ <td>00add5b8-a7b1-42d4-b4de-ca99716a5096</td>
51
+ <td>download</td>
52
+ <td>https://s3.amazonaws.com/holc/tiles/WI/Madison/1937/rectified.zip</td>
53
+ <td>GeoTIFF</td>
54
+ </tr>
55
+ <tr>
56
+ <td>00add5b8-a7b1-42d4-b4de-ca99716a5096</td>
57
+ <td>download</td>
58
+ <td>https://s3.amazonaws.com/holc/tiles/WI/Madison/1937/holc-scan.jpg</td>
59
+ <td>JPEG</td>
60
+ </tr>
61
+ <tr>
62
+ <td>...</td>
63
+ <td>...</td>
64
+ <td>...</td>
65
+ <td>...</td>
66
+ </tr>
67
+ </tbody>
68
+ </table>
69
+
70
+ <h5>CSV File Column Definitions</h5>
71
+ <dl>
72
+ <dt>friendlier_id</dt>
73
+ <dd>The associated document's friendlier id</dd>
74
+ <dt>reference_type</dt>
75
+ <dd>The name of the reference type</dd>
76
+ <dt>distribution_url</dt>
77
+ <dd>The URL for the distribution</dd>
78
+ <dt>label</dt>
79
+ <dd>The label for the distribution, if the reference type is labeled</dd>
80
+ </dl>
81
+ </div>
82
+ </div>
@@ -0,0 +1,12 @@
1
+ <% content_for :title, "Editing document distribution" %>
2
+
3
+ <h1>Editing document distribution</h1>
4
+
5
+ <%= render "form", document_distribution: @document_distribution %>
6
+
7
+ <br>
8
+
9
+ <div>
10
+ <%= link_to "Show this document distribution", admin_document_document_distribution_path(@document, @document_distribution) %> |
11
+ <%= link_to "Back to document distributions", admin_document_document_distributions_path(@document) %>
12
+ </div>