Skip to content

Commit

Permalink
Merge branch 'release/0.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
ewlarson committed Oct 12, 2023
2 parents 5f4b980 + e4e8c5a commit 194e056
Show file tree
Hide file tree
Showing 25 changed files with 82 additions and 47 deletions.
2 changes: 1 addition & 1 deletion app/assets/stylesheets/geoblacklight_admin/_core.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ nav.navbar.bg-light {
margin-bottom:2rem;
}

footer {
footer.gbl-admin {
border-top: 1rem solid #0088ce;
margin-top: 4rem;
background:rgba(0, 0, 0, 0.8) image-url('aerial_photo.jpg') repeat;
Expand Down
Empty file.
10 changes: 0 additions & 10 deletions app/controllers/admin/concerns/upload_util.rb

This file was deleted.

6 changes: 3 additions & 3 deletions app/controllers/admin/document_accesses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ def import

respond_to do |format|
if DocumentAccess.import(params.dig(:document_access, :assets, :file))
format.html { redirect_to document_accesses_path, notice: "Document access links were created successfully." }
format.html { redirect_to admin_document_accesses_path, notice: "Document access links were created successfully." }
else
format.html { redirect_to document_accesses_path, notice: "Access URLs could not be created." }
format.html { redirect_to admin_document_accesses_path, notice: "Access URLs could not be created." }
end
rescue => e
format.html { redirect_to document_accesses_path, notice: "Access URLs could not be created. #{e}" }
format.html { redirect_to admin_document_accesses_path, notice: "Access URLs could not be created. #{e}" }
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/document_assets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def attach_files

@parent.update(representative: @parent.members.order(:position).first) if @parent.representative_id.nil?

redirect_to document_path(@parent.friendlier_id, anchor: "nav-members")
redirect_to admin_document_path(@parent.friendlier_id, anchor: "nav-members")
end

def convert_to_child_work
Expand Down
1 change: 0 additions & 1 deletion app/jobs/export_json_bulk_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ def perform(request, current_user, query_params, export_service)
json_obj.compact!

@json_array << JSON.pretty_generate(json_obj)

rescue NoMethodError => e
Rails.logger.debug { "==== Error! - #{doc.friendlier_id} ====" }
Rails.logger.debug e.inspect
Expand Down
2 changes: 1 addition & 1 deletion app/models/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Document < Kithe::Work

attr_accessor :skip_callbacks

has_paper_trail
has_paper_trail ignore: [:publication_state]
belongs_to :import, optional: true

# Statesman
Expand Down
2 changes: 1 addition & 1 deletion app/models/document/date_range_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def validate(record)

def valid_yyyy(date)
if date[/\D/]
return false unless date == "*"
false unless date == "*"
else
true
end
Expand Down
6 changes: 4 additions & 2 deletions app/models/document_access.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require "csv"

# DocumentAccess
class DocumentAccess < ApplicationRecord
belongs_to :document, foreign_key: :friendlier_id, primary_key: :friendlier_id
Expand All @@ -10,7 +12,7 @@ class DocumentAccess < ApplicationRecord

def self.import(file)
logger.debug("CSV Import")
CSV.foreach(file.path, headers: true) do |row|
::CSV.foreach(file.path, headers: true) do |row|
logger.debug("CSV Row: #{row.to_hash}")
document_access = DocumentAccess.find_or_initialize_by(friendlier_id: row[0], institution_code: row[1])
document_access.update(row.to_hash)
Expand All @@ -19,7 +21,7 @@ def self.import(file)

def self.destroy_all(file)
logger.debug("CSV Destroy")
CSV.foreach(file.path, headers: true) do |row|
::CSV.foreach(file.path, headers: true) do |row|
logger.debug("CSV Row: #{row.to_hash}")
DocumentAccess.destroy_by(id: row[0], friendlier_id: row[1])
end
Expand Down
6 changes: 4 additions & 2 deletions app/models/document_download.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require "csv"

# DocumentDownload
class DocumentDownload < ApplicationRecord
belongs_to :document, inverse_of: :document_downloads, foreign_key: :friendlier_id, primary_key: :friendlier_id
Expand All @@ -10,7 +12,7 @@ class DocumentDownload < ApplicationRecord

def self.import(file)
logger.debug("CSV Import")
CSV.foreach(file.path, headers: true) do |row|
::CSV.foreach(file.path, headers: true) do |row|
logger.debug("CSV Row: #{row.to_hash}")
document_download = DocumentDownload.find_or_initialize_by(friendlier_id: row[0], label: row[1], value: row[2])
document_download.update(row.to_hash)
Expand All @@ -19,7 +21,7 @@ def self.import(file)

def self.destroy_all(file)
logger.debug("CSV Destroy")
CSV.foreach(file.path, headers: true) do |row|
::CSV.foreach(file.path, headers: true) do |row|
logger.debug("CSV Row: #{row.to_hash}")
DocumentDownload.destroy_by(id: row[0], friendlier_id: row[1])
end
Expand Down
19 changes: 18 additions & 1 deletion app/models/import_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@ def state_machine
end

def to_hash
{
data_hash = {
friendlier_id: friendlier_id,
title: title,
json_attributes: nullify_empty_json_attributes,
import_id: import_id
}

append_created_at(data_hash)
append_updated_at(data_hash)
end

def nullify_empty_json_attributes
Expand All @@ -31,4 +34,18 @@ def nullify_empty_json_attributes

clean_hash
end

def append_created_at(data_hash)
if data_hash[:json_attributes].has_key?("date_created_dtsi")
data_hash[:created_at] = data_hash[:json_attributes]["date_created_dtsi"]
end
data_hash
end

def append_updated_at(data_hash)
if data_hash[:json_attributes].has_key?("date_modified_dtsi")
data_hash[:updated_at] = data_hash[:json_attributes]["date_modified_dtsi"]
end
data_hash
end
end
4 changes: 2 additions & 2 deletions app/views/admin/bulk_actions/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
<td><%= bulk_action.field_name %></td>
<td><%= bulk_action.field_value %></td>
<td><%= bulk_action.created_at %></td>
<td><%= link_to 'Show', bulk_action %></td>
<td><%= link_to 'Show', admin_bulk_action_path(bulk_action) %></td>
<td><%= link_to 'Edit', edit_bulk_action_path(bulk_action) %></td>
<td><%= link_to 'Destroy', bulk_action, method: :delete, data: { confirm: 'Are you sure?' } %></td>
<td><%= link_to 'Destroy', admin_bulk_action_path(bulk_action), method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
Expand Down
6 changes: 3 additions & 3 deletions app/views/admin/document_assets/display_attach_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
<p>To: <%= @document.title %> (<%= @document.friendlier_id %>)
<p>Once the files have been uploaded and are ready for attachment, you can proceed to Attach</p>

<%= form_with(url: asset_ingest_path(@document && @document.friendlier_id), method: :post, local: true) do |form| %>
<%= form_with(url: admin_asset_ingest_path(@document && @document.friendlier_id), method: :post, local: true) do |form| %>

<div class="row">

<div class="col-md-6 mb-3">
<h2>1. Upload Files</h2>

<%= content_tag "div", class: "uppy-dashboard-container", data: UploadUtil.kithe_upload_data_config do %>
<%= content_tag "div", class: "uppy-dashboard-container", data: Admin::UploadUtil.kithe_upload_data_config do %>
<% end %>
</div>

<div class="col-sm-6">
<h2>2. Attach files</h2>
<div class="d-flex justify-content-between">
<%= form.submit "Attach", class: "btn btn-primary btn-lg", data: { toggle: "kithe-upload-submit" } %>
<%= link_to "Cancel", document_path(@document),
<%= link_to "Cancel", admin_document_path(@document),
class: "btn btn-outline-secondary btn-lg",
data: { confirm: "Cancel attach files?" }
%>
Expand Down
6 changes: 3 additions & 3 deletions app/views/admin/document_assets/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
Document &middot; Assets

<% if params[:document_id] %>
<%= link_to '+ Upload Assets', display_attach_form_document_document_assets_url(@document), { class: 'btn btn-primary float-right mr-2' } %>
<%= link_to '+ Upload Assets', display_attach_form_admin_document_document_assets_url(@document), { class: 'btn btn-primary float-right mr-2' } %>
<% end %>
</h1>
<% if params[:document_id] %>
<h2 class='h3'>
<%= link_to(@document.title, document_path(@document)) %>
<%= link_to(@document.title, admin_document_path(@document)) %>
&middot;
<%= @document_assets.count %> assets
</h2>
Expand Down Expand Up @@ -44,7 +44,7 @@
<%= document_asset.file_data["metadata"]["mime_type"] %>
<span class="sr-only"><%= document_asset.inspect %></span>
</td>
<td><%= link_to 'Destroy', document_document_asset_path(document_asset.parent, document_asset), method: :delete, data: { confirm: 'Are you sure?' } %></td>
<td><%= link_to 'Destroy', admin_document_document_asset_path(document_asset.parent, document_asset), method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/document_downloads/import.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<h1 style="width:100%; border-bottom:dotted;" class="mb-4">
Document &middot; Download Links
<% if params[:document_id] %>
<%= link_to '+ New Download Link', new_document_document_download_path(@document), { class: 'btn btn-primary float-right' } %>
<%= link_to '+ New Download Link', new_admin_document_document_download_path(@document), { class: 'btn btn-primary float-right' } %>
<% end %>
</h1>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<span id="result-selected-options" class="hidden" data-scope="pageset" data-controller="results" data-resultset="<%= admin_documents_path( params.to_unsafe_h.merge({rows: '1000000'})) %>" data-pageset="/fetch?">
<span id="result-selected-options" class="hidden" data-scope="pageset" data-controller="results" data-resultset="<%= admin_documents_path( params.to_unsafe_h.merge({rows: '10000'})) %>" data-pageset="/fetch?">

<%= form_with(model: BulkAction.new, html: { id: 'result-action-form', data: { type: "html", action: "submit->results#setPubState" }, style: 'display:inline'}, url: admin_bulk_actions_path) do |form| -%>
<%= form.hidden_field :request, value: "#{request.protocol}#{request.host}:#{request.port}" %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/shared/_js_behaviors.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
target: '.uppy-dashboard-container'
})
.use(XHRUpload, {
endpoint: '/direct_upload',
endpoint: '/admin/direct_upload',
fieldName: 'file'
})

Expand Down
12 changes: 6 additions & 6 deletions app/views/admin/shared/_navbar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@

<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav flex-row ml-md-auto d-none d-md-flex">
<li class="nav-item">
<%= link_to root_url, { class: 'nav-link' } do %>
GeoBlacklight Home
<% end %>
</li>
<% if user_signed_in? %>
<li class="nav-item">
<%= link_to admin_notifications_url, { class: 'nav-link' } do %>
Expand All @@ -56,7 +51,7 @@
<%= link_to "Access Links", admin_document_accesses_path, {class: 'dropdown-item'} %>
<%= link_to "Download Links", admin_document_downloads_path, {class: 'dropdown-item'} %>
<div class="dropdown-divider"></div>
<%= link_to "Blazer", '/blazer', {class: 'dropdown-item', data: { turbolinks: false }} %>
<%= link_to "Blazer", '/admin/blazer', {class: 'dropdown-item', data: { turbolinks: false }} %>
<div class="dropdown-divider"></div>
<%= link_to "Elements", admin_elements_path, {class: 'dropdown-item', data: { turbolinks: false }} %>
<%= link_to "Form Elements", admin_form_elements_path, {class: 'dropdown-item', data: { turbolinks: false }} %>
Expand All @@ -78,6 +73,11 @@
<%= link_to('Sign in', new_user_session_path, {class: 'nav-link'}) %>
</li>
<% end %>
<li class="nav-item">
<%= link_to root_url, { class: 'nav-link' } do %>
GeoBlacklight Home
<% end %>
</li>
</ul>
</div>
</nav>
6 changes: 3 additions & 3 deletions db/seeds_elements.csv
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ Accrual Periodicity,b1g_dct_accrualPeriodicity_s,https://geobtaa.github.io/metad
Date Accessioned,b1g_dateAccessioned_sm,https://geobtaa.github.io/metadata/b1g-custom-elements/#date-accessioned,string,FALSE,TRUE,TRUE,,,date-accessioned1|date-accessioned2,,,,FALSE,TRUE,TRUE,,TRUE,,TRUE,,,47
Date Retired,b1g_dateRetired_s,https://geobtaa.github.io/metadata/b1g-custom-elements/#date-retired,string,FALSE,FALSE,TRUE,,YYYY-MM-DD,date-retired,,datepicker,,FALSE,TRUE,FALSE,,TRUE,,TRUE,,,48
Status,b1g_status_s,https://geobtaa.github.io/metadata/b1g-custom-elements/#status,string,FALSE,FALSE,TRUE,,,Active,,,,FALSE,TRUE,FALSE,,TRUE,,TRUE,,,49
Publication State,b1g_publication_state_s,https://geobtaa.github.io/metadata/b1g-custom-elements/#publication-state,string,TRUE,FALSE,TRUE,,,published,publication_states,,,TRUE,FALSE,FALSE,,TRUE,current_state,TRUE,current_state,,50
Publication State,b1g_publication_state_s,https://geobtaa.github.io/metadata/b1g-custom-elements/#publication-state,string,TRUE,FALSE,TRUE,,,published,publication_states,,,TRUE,TRUE,FALSE,,TRUE,current_state,TRUE,current_state,,50
Suppressed Record,gbl_suppressed_b,https://opengeometadata.org/ogm-aardvark/#suppressed,boolean,FALSE,FALSE,TRUE,,,FALSE,,,,FALSE,TRUE,FALSE,,TRUE,,TRUE,,,51
Child Record,b1g_child_record_b,https://geobtaa.github.io/metadata/b1g-custom-elements/#child-record,boolean,FALSE,FALSE,TRUE,,,FALSE,,,,FALSE,TRUE,FALSE,,TRUE,,TRUE,,,52
Mediator,b1g_dct_mediator_sm,https://geobtaa.github.io/metadata/b1g-custom-elements/#mediator,string,FALSE,TRUE,TRUE,,,mediator1|mediator2,,,,FALSE,TRUE,TRUE,,TRUE,,TRUE,,,53
Access,b1g_access_s,https://geobtaa.github.io/metadata/b1g-custom-elements/#access,string,FALSE,FALSE,TRUE,,,access,,,,FALSE,TRUE,FALSE,,TRUE,,TRUE,access_json,,54
Created At,date_created_dtsi,,datetime,FALSE,FALSE,FALSE,,,2021-12-09 15:50:49.803415,,,,TRUE,FALSE,FALSE,,TRUE,created_at_dt,TRUE,created_at_dt,,55
Updated At,date_modified_dtsi,,datetime,FALSE,FALSE,FALSE,,,2022-12-12 17:02:03.422663,,,,TRUE,FALSE,FALSE,,TRUE,gbl_mdModified_dt,TRUE,gbl_mdModified_dt,,56
Created At,date_created_dtsi,,datetime,FALSE,FALSE,FALSE,,,2021-12-09 15:50:49.803415,,,,TRUE,TRUE,FALSE,,TRUE,created_at_dt,TRUE,created_at_dt,,55
Updated At,date_modified_dtsi,,datetime,FALSE,FALSE,FALSE,,,2022-12-12 17:02:03.422663,,,,TRUE,TRUE,FALSE,,TRUE,gbl_mdModified_dt,TRUE,gbl_mdModified_dt,,56
Binary file modified db/seeds_elements.numbers
Binary file not shown.
4 changes: 2 additions & 2 deletions geoblacklight_admin.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Gem::Specification.new do |s|
s.add_dependency "blacklight_advanced_search"
s.add_dependency "blacklight_range_limit"
s.add_dependency "bootstrap", "~> 4.0"
s.add_dependency "chosen-rails", "1.0"
s.add_dependency "chosen-rails", "~> 1.10"
s.add_dependency "cocoon", "~> 1.2"
s.add_dependency "config", "~> 4.0"
s.add_dependency "devise", "~> 4.7"
Expand All @@ -45,7 +45,7 @@ Gem::Specification.new do |s|
s.add_dependency "ruby-progressbar"
s.add_dependency "simple_form", "~> 5.0"
s.add_dependency "sprockets", "< 4"
s.add_dependency "statesman", "~> 7.1.0"
s.add_dependency "statesman", "~> 10.0"

s.add_development_dependency "byebug", "~> 11.1"
s.add_development_dependency "capybara", "~> 3.0"
Expand Down
3 changes: 2 additions & 1 deletion lib/generators/geoblacklight_admin/config_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def create_gbl_admin_initializer_files
copy_file "config/initializers/kithe.rb", "config/initializers/kithe.rb", force: true
copy_file "config/initializers/mime_types.rb", "config/initializers/mime_types.rb", force: true
copy_file "config/initializers/pagy.rb", "config/initializers/pagy.rb", force: true
copy_file "config/initializers/shrine.rb", "config/initializers/shrine.rb", force: true
copy_file "config/initializers/simple_form.rb", "config/initializers/simple_form.rb", force: true
copy_file "config/initializers/simple_form_bootstrap.rb", "config/initializers/simple_form_bootstrap.rb", force: true
copy_file "config/initializers/statesman.rb", "config/initializers/statesman.rb", force: true
Expand Down Expand Up @@ -212,7 +213,7 @@ def set_routes
get "/documents/:id/ingest", to: "document_assets#display_attach_form", as: "asset_ingest"
post "/documents/:id/ingest", to: "document_assets#attach_files"
#mount Kithe::AssetUploader.upload_endpoint(:cache) => "/direct_upload", :as => :direct_app_upload
mount Kithe::AssetUploader.upload_endpoint(:cache) => "/direct_upload", :as => :direct_app_upload
resources :collections, except: [:show]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,15 @@
BLACKLIGHT_JSON_API = ENV["BLACKLIGHT_JSON_API"]
BLACKLIGHT_JSON_API_IDS = ENV["BLACKLIGHT_JSON_API_IDS"]
BLACKLIGHT_JSON_API_FACETS = ENV["BLACKLIGHT_JSON_API_FACETS"]

# Former Controller > Concern
module Admin
module UploadUtil
def self.kithe_upload_data_config(toggle_value: "kithe-upload")
{
toggle: toggle_value,
upload_endpoint: Rails.application.routes.url_helpers.admin_direct_app_upload_path
}
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require "shrine"
require "shrine/storage/file_system"

Shrine.storages = {
cache: Shrine::Storage::FileSystem.new("public", prefix: "uploads/cache"), # temporary
store: Shrine::Storage::FileSystem.new("public", prefix: "uploads") # permanent
}

Shrine.plugin :activerecord
Shrine.plugin :upload_endpoint
Shrine.plugin :cached_attachment_data # for retaining the cached file across form redisplays
Shrine.plugin :restore_cached_data # re-extract metadata when attaching a cached file
2 changes: 1 addition & 1 deletion lib/geoblacklight_admin/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module GeoblacklightAdmin
VERSION = "0.2.1"
VERSION = "0.3.0"
end

0 comments on commit 194e056

Please sign in to comment.