zizia 1.0.1 → 2.0.0.alpha.01

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +9 -0
  3. data/.travis.yml +1 -0
  4. data/README.md +24 -3
  5. data/Rakefile +4 -0
  6. data/app/assets/config/zizia_manifest.js +2 -0
  7. data/app/assets/images/zizia/.keep +0 -0
  8. data/app/assets/javascripts/zizia/application.js +13 -0
  9. data/app/assets/stylesheets/zizia/application.css +15 -0
  10. data/app/controllers/zizia/application_controller.rb +6 -0
  11. data/app/controllers/zizia/csv_imports_controller.rb +53 -0
  12. data/app/controllers/zizia/importer_documentation_controller.rb +12 -0
  13. data/app/helpers/importer_documentation_helper.rb +13 -0
  14. data/app/helpers/zizia/application_helper.rb +14 -0
  15. data/app/jobs/zizia/application_job.rb +5 -0
  16. data/app/jobs/zizia/start_csv_import_job.rb +16 -0
  17. data/app/mailers/zizia/application_mailer.rb +7 -0
  18. data/app/models/zizia/application_record.rb +6 -0
  19. data/app/models/zizia/csv_import.rb +21 -0
  20. data/app/uploaders/zizia/csv_manifest_uploader.rb +66 -0
  21. data/app/views/importer_documentation/guide.html.erb +1 -0
  22. data/app/views/layouts/zizia/application.html.erb +14 -0
  23. data/app/views/zizia/csv_imports/_actions.html.erb +3 -0
  24. data/app/views/zizia/csv_imports/_collection_selection.html.erb +3 -0
  25. data/app/views/zizia/csv_imports/_error.html.erb +10 -0
  26. data/app/views/zizia/csv_imports/_file_upload.html.erb +3 -0
  27. data/app/views/zizia/csv_imports/_form.html.erb +75 -0
  28. data/app/views/zizia/csv_imports/_no_collection.html.erb +7 -0
  29. data/app/views/zizia/csv_imports/_record_count.html.erb +7 -0
  30. data/app/views/zizia/csv_imports/_start_import_form.html.erb +9 -0
  31. data/app/views/zizia/csv_imports/index.html.erb +21 -0
  32. data/app/views/zizia/csv_imports/new.html.erb +2 -0
  33. data/app/views/zizia/csv_imports/preview.html.erb +76 -0
  34. data/app/views/zizia/csv_imports/show.html.erb +31 -0
  35. data/bin/rails +15 -0
  36. data/config/routes.rb +9 -0
  37. data/db/migrate/migrate/20190116214128_create_csv_imports.rb +10 -0
  38. data/db/migrate/migrate/20190116220312_add_manifest_to_csv_imports.rb +6 -0
  39. data/db/migrate/migrate/20190124153654_add_fedora_collection_id_to_csv_imports.rb +6 -0
  40. data/docs/customizing_metadata.md +43 -0
  41. data/lib/zizia/engine.rb +20 -0
  42. data/lib/zizia/input_record.rb +2 -2
  43. data/lib/zizia/version.rb +1 -1
  44. data/lib/zizia.rb +19 -17
  45. data/spec/controllers/importer_documentation_controller_spec.rb +14 -0
  46. data/spec/dummy/.gitignore +23 -0
  47. data/spec/dummy/Gemfile +57 -0
  48. data/spec/dummy/README.md +24 -0
  49. data/spec/dummy/Rakefile +6 -0
  50. data/spec/dummy/app/assets/config/manifest.js +3 -0
  51. data/spec/dummy/app/assets/csv/import_manifest.csv +1 -0
  52. data/spec/dummy/app/assets/images/.keep +0 -0
  53. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  54. data/spec/dummy/app/assets/javascripts/cable.js +13 -0
  55. data/spec/dummy/app/assets/javascripts/channels/.keep +0 -0
  56. data/spec/dummy/app/assets/markdown/importer_guide.md +256 -0
  57. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  58. data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
  59. data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
  60. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  61. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  62. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  63. data/spec/dummy/app/jobs/application_job.rb +2 -0
  64. data/spec/dummy/app/mailers/application_mailer.rb +4 -0
  65. data/spec/dummy/app/models/application_record.rb +3 -0
  66. data/spec/dummy/app/models/concerns/.keep +0 -0
  67. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  68. data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
  69. data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
  70. data/spec/dummy/bin/bundle +3 -0
  71. data/spec/dummy/bin/rails +9 -0
  72. data/spec/dummy/bin/rake +9 -0
  73. data/spec/dummy/bin/setup +38 -0
  74. data/spec/dummy/bin/spring +17 -0
  75. data/spec/dummy/bin/update +29 -0
  76. data/spec/dummy/bin/yarn +11 -0
  77. data/spec/dummy/config/application.rb +18 -0
  78. data/spec/dummy/config/boot.rb +3 -0
  79. data/spec/dummy/config/cable.yml +10 -0
  80. data/spec/dummy/config/database.yml +25 -0
  81. data/spec/dummy/config/environment.rb +5 -0
  82. data/spec/dummy/config/environments/development.rb +54 -0
  83. data/spec/dummy/config/environments/production.rb +91 -0
  84. data/spec/dummy/config/environments/test.rb +42 -0
  85. data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -0
  86. data/spec/dummy/config/initializers/assets.rb +14 -0
  87. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  88. data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
  89. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  90. data/spec/dummy/config/initializers/inflections.rb +16 -0
  91. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  92. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  93. data/spec/dummy/config/locales/en.yml +33 -0
  94. data/spec/dummy/config/puma.rb +56 -0
  95. data/spec/dummy/config/routes.rb +4 -0
  96. data/spec/dummy/config/secrets.yml +32 -0
  97. data/spec/dummy/config/spring.rb +6 -0
  98. data/spec/dummy/config.ru +5 -0
  99. data/spec/dummy/db/schema.rb +24 -0
  100. data/spec/dummy/db/seeds.rb +7 -0
  101. data/spec/dummy/lib/assets/.keep +0 -0
  102. data/spec/dummy/lib/tasks/.keep +0 -0
  103. data/spec/dummy/log/.keep +0 -0
  104. data/spec/dummy/package.json +5 -0
  105. data/spec/dummy/public/404.html +67 -0
  106. data/spec/dummy/public/422.html +67 -0
  107. data/spec/dummy/public/500.html +66 -0
  108. data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
  109. data/spec/dummy/public/apple-touch-icon.png +0 -0
  110. data/spec/dummy/public/favicon.ico +0 -0
  111. data/spec/dummy/public/robots.txt +1 -0
  112. data/spec/dummy/test/application_system_test_case.rb +5 -0
  113. data/spec/dummy/test/controllers/.keep +0 -0
  114. data/spec/dummy/test/fixtures/.keep +0 -0
  115. data/spec/dummy/test/fixtures/files/.keep +0 -0
  116. data/spec/dummy/test/helpers/.keep +0 -0
  117. data/spec/dummy/test/integration/.keep +0 -0
  118. data/spec/dummy/test/mailers/.keep +0 -0
  119. data/spec/dummy/test/models/.keep +0 -0
  120. data/spec/dummy/test/system/.keep +0 -0
  121. data/spec/dummy/test/test_helper.rb +10 -0
  122. data/spec/dummy/vendor/.keep +0 -0
  123. data/spec/models/csv_import_spec.rb +18 -0
  124. data/spec/spec_helper.rb +10 -0
  125. data/spec/views/importer_documentation/guide.html.erb_spec.rb +9 -0
  126. data/spec/zizia_spec.rb +13 -0
  127. data/zizia.gemspec +12 -6
  128. metadata +226 -25
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 488d9a3f2c71f53ed2134084ed2c9acb446b1eae14f4ce9c0a8959557297a733
4
- data.tar.gz: c4bc95f1c51e4f619329ad287cdbe15234501bdf0695d8beb42f0d9c99355339
3
+ metadata.gz: 024af582dbc7b0f9e6a9cef853e26b3822c19de334087eb0d209306e5ae7360b
4
+ data.tar.gz: 967080be47ce3a04039352847e7eb0913dfa0bfd7adf9cae5f7636cd4f7c1ba7
5
5
  SHA512:
6
- metadata.gz: 5e53b4a49325cab2f77a6fd714e73b9de8c269fff9960daf211897ecad7cd40c81d75ad92ef68a8d8d7bf6bf822b1044e4969888c887bb7e21d4b8198ab2d4e0
7
- data.tar.gz: 010b019094941db98acbe9bfd2a92df88f150a45d9cd1de23337dcf74b0525c4f1430715a9c0a87a01dea9b8bf5bc3dac714fb9be4df7fca64ab1e8161fe84d7
6
+ metadata.gz: 70104aeca87a2ed4b657af0ed0a2f2990dbea38f76d4ebca567395b64c0392c7e02952955fe7509c612312dfc7da05f90ccd113ec121c68bb6c467bae66ca498
7
+ data.tar.gz: 6b588a28977d885d025673accd8f33e82792ffb03eb2e465a86f458883ac2e455a89d66f8d59fa4d3ad66ff8e7a065b4b109c9cab0a430d2ac461fd4335d1293
data/.rubocop.yml CHANGED
@@ -5,6 +5,13 @@ inherit_gem:
5
5
 
6
6
  AllCops:
7
7
  TargetRubyVersion: 2.3
8
+ Exclude:
9
+ - 'db/**/*'
10
+ - 'config/**/*'
11
+ - 'script/**/*'
12
+ - 'vendor/**/*'
13
+ - 'bin/{rails,rake}'
14
+ - 'spec/dummy/**/*'
8
15
 
9
16
  Lint/HandleExceptions:
10
17
  Exclude:
@@ -20,6 +27,7 @@ Metrics/BlockLength:
20
27
  Exclude:
21
28
  - 'spec/**/*'
22
29
  - 'lib/zizia/spec/**/*'
30
+ - 'zizia.gemspec'
23
31
 
24
32
  Metrics/ClassLength:
25
33
  Enabled: false
@@ -60,6 +68,7 @@ RSpec/MultipleExpectations:
60
68
  Exclude:
61
69
  - 'spec/zizia/hyrax_basic_metadata_mapper_spec.rb'
62
70
  - 'spec/integration/import_hyrax_csv.rb'
71
+ - 'spec/controllers/importer_documentation_controller_spec.rb'
63
72
 
64
73
  Style/StructInheritance:
65
74
  Enabled: false
data/.travis.yml CHANGED
@@ -8,4 +8,5 @@ rvm:
8
8
  - 2.4.5
9
9
  - 2.5.3
10
10
  script:
11
+ - RAILS_ENV='test' bundle exec rake db:migrate
11
12
  - bundle exec rake
data/README.md CHANGED
@@ -56,9 +56,30 @@ environment variables called `IMPORT_PATH`. If `IMPORT_PATH` is not set, `HyraxR
56
56
  To input any kind of file other than CSV, you need to provide a `Parser` (out of the box, we support simple CSV import with `CsvParser`). We will be writing guides about
57
57
  how to support custom mappers (for metadata outside of Hyrax's core and basic metadata fields).
58
58
 
59
- This software is primarily intended for use in a [Hyrax](https://github.com/samvera/hyrax) project.
60
- However, its dependency on `hyrax` is kept strictly optional so most of its code can be reused to
61
- good effect elsewhere. Note: As of release 2.0, `HyraxBasicMetadataMapper` will be the default mapper.
59
+ ## Hyrax User Interface
60
+
61
+ Zizia can be installed as a Rails Engine in a Hyrax application. To use the Zizia UI in Hyrax:
62
+
63
+ 1. Add the engine to `routes.rb`:
64
+ ```
65
+ mount Zizia::Engine => '/'
66
+ ```
67
+
68
+ 2. Add the helpers to the `ApplicationController`
69
+
70
+ ```
71
+ helper Zizia::Engine.helpers
72
+ ```
73
+
74
+ 3. Add documentation and sample csv files to your project at
75
+
76
+ `app/assets/csv/import_manifest.csv`
77
+
78
+ and
79
+
80
+ `app/assets/markdown/importer_guide.md`
81
+
82
+ 4. Add links to `/csv_imports/new` and `/importer_documentation/csv` in the Hyrax dashboard
62
83
 
63
84
  ## Development
64
85
 
data/Rakefile CHANGED
@@ -32,3 +32,7 @@ desc 'Check style and run specs'
32
32
  task ci: %w[rubocop spec_with_server]
33
33
 
34
34
  task default: :ci
35
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
36
+ load 'rails/tasks/engine.rake'
37
+
38
+ load 'rails/tasks/statistics.rake'
@@ -0,0 +1,2 @@
1
+ //= link_directory ../javascripts/zizia .js
2
+ //= link_directory ../stylesheets/zizia .css
File without changes
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file. JavaScript code in this file should be added after the last require_* statement.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+ module Zizia
3
+ class ApplicationController < ActionController::Base
4
+ protect_from_forgery with: :exception
5
+ end
6
+ end
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+ module Zizia
3
+ class CsvImportsController < ::ApplicationController
4
+ load_and_authorize_resource
5
+ before_action :load_and_authorize_preview, only: [:preview]
6
+
7
+ with_themed_layout 'dashboard'
8
+
9
+ def index; end
10
+
11
+ def show; end
12
+
13
+ def new; end
14
+
15
+ # Validate the CSV file and display errors or
16
+ # warnings to the user.
17
+ def preview; end
18
+
19
+ def create
20
+ @csv_import.user = current_user
21
+ preserve_cache
22
+
23
+ if @csv_import.save
24
+ @csv_import.queue_start_job
25
+ redirect_to @csv_import
26
+ else
27
+ render :new
28
+ end
29
+ end
30
+
31
+ private
32
+
33
+ def load_and_authorize_preview
34
+ @csv_import = CsvImport.new(create_params)
35
+ authorize! :create, @csv_import
36
+ end
37
+
38
+ def create_params
39
+ params.fetch(:csv_import, {}).permit(:manifest, :fedora_collection_id)
40
+ end
41
+
42
+ # Since we are re-rendering the form (once for
43
+ # :new and again for :preview), we need to
44
+ # manually set the cache, otherwise the record
45
+ # will lose the manifest file between the preview
46
+ # and the record save.
47
+ def preserve_cache
48
+ return unless params['csv_import']
49
+ @csv_import.manifest_cache = params['csv_import']['manifest_cache']
50
+ @csv_import.fedora_collection_id = params['csv_import']['fedora_collection_id']
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zizia
4
+ class ImporterDocumentationController < ApplicationController
5
+ def guide; end
6
+
7
+ def csv
8
+ return unless File.exist?(Rails.root.join('app', 'assets', 'csv', 'import_manifest.csv'))
9
+ send_file Rails.root.join('app', 'assets', 'csv', 'import_manifest.csv'), type: 'text/csv; charset=utf-8', disposition: 'attachment', filename: 'import_manifest.csv'
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ImporterDocumentationHelper
4
+ def render_guide
5
+ renderer = Redcarpet::Render::HTML.new(autolink: true, with_toc_data: true)
6
+ markdown = Redcarpet::Markdown.new(renderer)
7
+ if File.exist?(Rails.root.join('app', 'assets', 'markdown', 'importer_guide.md'))
8
+ markdown.render(File.open(Rails.root.join('app', 'assets', 'markdown', 'importer_guide.md')).read)
9
+ else
10
+ 'There is currently no documentation.'
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+ module Zizia
3
+ module ApplicationHelper
4
+ def collections_for_select
5
+ ActiveFedora::SolrService.query('has_model_ssim:Collection').map do |c|
6
+ [c['title_tesim'][0], c['id']]
7
+ end
8
+ end
9
+
10
+ def collections?
11
+ !ActiveFedora::SolrService.query('has_model_ssim:Collection').empty?
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+ module Zizia
3
+ class ApplicationJob < ActiveJob::Base
4
+ end
5
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zizia
4
+ class StartCsvImportJob < ApplicationJob
5
+ queue_as :default
6
+
7
+ def perform(csv_import_id)
8
+ csv_import = CsvImport.find csv_import_id
9
+ log_stream = Zizia.config.default_info_stream
10
+ log_stream << "Starting import with batch ID: #{csv_import_id}"
11
+ importer = ModularImporter.new(csv_import)
12
+ importer.import
13
+ endcs
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+ module Zizia
3
+ class ApplicationMailer < ActionMailer::Base
4
+ default from: 'from@example.com'
5
+ layout 'mailer'
6
+ end
7
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+ module Zizia
3
+ class ApplicationRecord < ActiveRecord::Base
4
+ self.abstract_class = true
5
+ end
6
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zizia
4
+ class CsvImport < ApplicationRecord
5
+ belongs_to :user
6
+
7
+ # This is where the CSV file is stored:
8
+ mount_uploader :manifest, CsvManifestUploader
9
+
10
+ delegate :warnings, to: :manifest, prefix: true
11
+
12
+ delegate :errors, to: :manifest, prefix: true
13
+
14
+ delegate :records, to: :manifest, prefix: true
15
+
16
+ def queue_start_job
17
+ StartCsvImportJob.perform_later(id)
18
+ # TODO: We'll probably need to store job_id on this record.
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'carrierwave'
4
+
5
+ module Zizia
6
+ class CsvManifestUploader < CarrierWave::Uploader::Base
7
+ # Choose what kind of storage to use for this uploader:
8
+ storage :file
9
+
10
+ # Process calls that method whenever a file is uploaded.
11
+ process :validate_csv
12
+
13
+ # The directory where the csv manifest will be stored.
14
+ def store_dir
15
+ configured_upload_path + "#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
16
+ end
17
+
18
+ def cache_dir
19
+ configured_cache_path + "#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
20
+ end
21
+
22
+ # Add a white list of extensions which are allowed to be uploaded.
23
+ # For images you might use something like this:
24
+ # %w(jpg jpeg gif png)
25
+ def extension_whitelist
26
+ %w[csv]
27
+ end
28
+
29
+ # These are stored in memory only, not persisted
30
+ def errors
31
+ @validator ? @validator.errors : []
32
+ end
33
+
34
+ # These are stored in memory only, not persisted
35
+ def warnings
36
+ @validator ? @validator.warnings : []
37
+ end
38
+
39
+ def records
40
+ @validator ? @validator.record_count : 0
41
+ end
42
+
43
+ private
44
+
45
+ def validate_csv
46
+ @validator = CsvManifestValidator.new(self)
47
+ @validator.validate
48
+ end
49
+
50
+ def configured_upload_path
51
+ ENV['CSV_MANIFESTS_PATH'] || base_path_uploads + 'csv_uploads'
52
+ end
53
+
54
+ def configured_cache_path
55
+ ENV['CSV_MANIFESTS_CACHE_PATH'] || base_path_cache + 'csv_uploads/cache'
56
+ end
57
+
58
+ def base_path_uploads
59
+ ENV['TRAVIS'] ? Rails.root : Hyrax.config.upload_path.call
60
+ end
61
+
62
+ def base_path_cache
63
+ ENV['TRAVIS'] ? Rails.root : Hyrax.config.cache_path.call
64
+ end
65
+ end
66
+ end
@@ -0,0 +1 @@
1
+ <%= render_guide.html_safe %>
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Zizia</title>
5
+ <%= stylesheet_link_tag "zizia/application", media: "all" %>
6
+ <%= javascript_include_tag "zizia/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,3 @@
1
+ <div class="actions">
2
+ <%= form.submit 'Preview Import', class: "btn btn-primary btn-lg" %>
3
+ </div>
@@ -0,0 +1,3 @@
1
+ <div class="form-group">
2
+ <%= form.select :fedora_collection_id, options_for_select(collections_for_select), {}, class: "form-control", id: "fedora_collection_id" %>
3
+ </div>
@@ -0,0 +1,10 @@
1
+ <% if csv_import.errors.any? %>
2
+ <div id="error_explanation">
3
+ <h2><%= pluralize(csv_import.errors.size, "error") %> prohibited this csv_import from being saved:</h2>
4
+ <ul>
5
+ <% csv_import.errors.full_messages.each do |message| %>
6
+ <li><%= message %></li>
7
+ <% end %>
8
+ </ul>
9
+ </div>
10
+ <% end %>
@@ -0,0 +1,3 @@
1
+ <%= form.file_field :manifest, required: true, id: 'file-upload', class: "file-upload form-control", onchange: "Tenejo.displayUploadedFile()" %>
2
+ <label for="file-upload" class="btn btn-lg btn-primary"><span class="glyphicon glyphicon-upload"></span> Upload Your CSV</label>
3
+ <div id="file-upload-display"></div>
@@ -0,0 +1,75 @@
1
+ <%= form_with(model: csv_import, local: true, html: { multipart: true }, url: preview_csv_import_path) do |form| %>
2
+ <div class="panel panel-default">
3
+ <div class="panel-body">
4
+ <div class="row">
5
+ <div class="col-md-8">
6
+ <h2> Getting Started </h2>
7
+ </div>
8
+ </div>
9
+ <div class="row">
10
+ <div class="col-md-4">
11
+ <div class="well well-lg">
12
+ <p><b>Read the CSV Field Guide</b> to learn what is required in your CSV.</p>
13
+ <div class="text-center">
14
+ <a href="/importer_documentation/guide" class="btn btn-default btn-lg"><i class="glyphicon glyphicon-book"></i> CSV Field Guide</a>
15
+ </div>
16
+ </div>
17
+ </div>
18
+ <div class="col-md-4">
19
+ <div class="well well-lg">
20
+ <p><b>Download a CSV template</b> to get started.</b></p>
21
+ <div class="text-center">
22
+ <a href="/importer_documentation/csv" data-turbolinks="false" class="btn btn-default btn-lg"><i class="glyphicon glyphicon-list"></i> Download a CSV Template</a>
23
+ </div>
24
+ </div>
25
+ </div>
26
+ </div>
27
+ <hr/>
28
+
29
+ <% if collections? %>
30
+ <div class="row">
31
+ <div class="col-md-8">
32
+ <h2> Upload Your CSV </h2>
33
+ </div>
34
+ </div>
35
+ <div class="row">
36
+ <div class="col-md-4">
37
+ <div class="well well-lg">
38
+ <p> <b>Upload a CSV</b> that has your content. </p>
39
+ <div class="text-center">
40
+ <%= render "file_upload", form: form %>
41
+ </div>
42
+ </div>
43
+ </div>
44
+ <div class="col-md-4">
45
+ <div class="well well-lg">
46
+ <p> <b>Choose a collection</b>. All imports need to be associated with a collection. </p>
47
+ <div class="text-center">
48
+ <%= render "collection_selection", form: form %>
49
+ </div>
50
+ </div>
51
+ </div>
52
+ <div class="col-md-4">
53
+ <div class="well well-lg">
54
+ <p> <b>Preview your import</b> before starting the process. </p>
55
+ <div class="text-center">
56
+ <%= render "actions", form: form %>
57
+ </div>
58
+ </div>
59
+ </div>
60
+ </div>
61
+
62
+ <div class="row">
63
+ <div class="col-md-4">
64
+ <%= render "error", csv_import: csv_import %>
65
+ </div>
66
+ <div class="col-md-4">
67
+ </div>
68
+ </div>
69
+
70
+
71
+ <%= form.hidden_field :manifest_cache %>
72
+ <% else %>
73
+ <%= render 'no_collection' %>
74
+ <% end %>
75
+ <% end %>
@@ -0,0 +1,7 @@
1
+ <div class="row">
2
+ <div class="col-md-4">
3
+ <div class="well well-lg no-collection">
4
+ You must <a href="/dashboard/collections">create a collection</a> before importing content.
5
+ </div>
6
+ </div>
7
+ </div>
@@ -0,0 +1,7 @@
1
+ <div class="row">
2
+ <div class="col-md-8">
3
+ <div class="alert alert-success">
4
+ <p> This import will add <%= @csv_import.manifest_records %> new records. </p>
5
+ </div>
6
+ </div>
7
+ </div>
@@ -0,0 +1,9 @@
1
+ <%= form_with(model: csv_import, local: true, html: { multipart: true }) do |form| %>
2
+
3
+ <%= form.hidden_field :manifest_cache %>
4
+ <%= form.hidden_field :fedora_collection_id, value: csv_import.fedora_collection_id %>
5
+
6
+ <div class="actions">
7
+ <%= form.submit 'Start Import', class: 'btn btn-lg btn-primary' %>
8
+ </div>
9
+ <% end %>
@@ -0,0 +1,21 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <h2>CSV Imports</h2>
4
+
5
+ <table>
6
+ <thead>
7
+ <tr>
8
+ <th colspan="3"></th>
9
+ </tr>
10
+ </thead>
11
+
12
+ <tbody>
13
+ <% @csv_imports.each do |csv_import| %>
14
+ <tr>
15
+ <% link_text = csv_import.manifest.file ? File.basename(csv_import.manifest.to_s) : 'show' %>
16
+ <td><%= link_to link_text, csv_import %></td>
17
+ </tr>
18
+ <% end %>
19
+ </tbody>
20
+ </table>
21
+
@@ -0,0 +1,2 @@
1
+ <h2><span class="glyphicon glyphicon-cloud-upload"></span> Begin Your CSV Import </h2>
2
+ <%= render 'form', csv_import: @csv_import %>
@@ -0,0 +1,76 @@
1
+ <h2><span class="glyphicon glyphicon-cloud-upload"></span> Preview your CSV Import</h2>
2
+ <div class="panel panel-default">
3
+ <div class="panel-body">
4
+ <div id='csv_info'>
5
+ <% if @csv_import.manifest.file %>
6
+ <div class="row">
7
+ <div class="col-md-4">
8
+ <label> CSV Manifest: </label>
9
+ <%= File.basename(@csv_import.manifest.to_s) %>
10
+ </div>
11
+ <div class="col-md-4">
12
+ <label> Collection: </label>
13
+ <%= ActiveFedora::SolrService.query("id:#{@csv_import.fedora_collection_id}")[0]['title_tesim'][0] %>
14
+ </div>
15
+ </div>
16
+ <% end %>
17
+
18
+ <%= render 'record_count', locals: { csv_import: @csv_import } %>
19
+
20
+ <% unless @csv_import.manifest_errors.empty? %>
21
+ <div class="row">
22
+ <div class="col-md-6">
23
+ <div class="alert alert-danger">
24
+ <div id='csv_errors'>
25
+ <b><i class="glyphicon glyphicon-remove-sign"></i> The CSV file has the following errors:</b>
26
+ <ul>
27
+ <% @csv_import.manifest_errors.each do |error| %>
28
+ <li> <%= error %> </li>
29
+ <% end %>
30
+ </ul>
31
+ </div>
32
+ </div>
33
+ </div>
34
+ </div>
35
+ <% end %>
36
+
37
+ <% unless @csv_import.manifest_warnings.empty? %>
38
+ <div class="row">
39
+ <div class="col-md-6">
40
+ <div class="alert alert-warning">
41
+ <div id='csv_warnings'>
42
+ <b><i class="glyphicon glyphicon-exclamation-sign"></i> The CSV file has the following warnings:</b>
43
+ <ul>
44
+ <% @csv_import.manifest_warnings.each do |warning| %>
45
+ <li> <%= warning %> </li>
46
+ <% end %>
47
+ </ul>
48
+ </div>
49
+ </div>
50
+ </div>
51
+ </div>
52
+ <% end %>
53
+
54
+ <% if @csv_import.manifest_errors.empty? %>
55
+ <div class="row">
56
+ <div class="col-md-2">
57
+ <%= render 'start_import_form', csv_import: @csv_import, class: "btn btn-large btn-danger" %>
58
+ </div>
59
+ <div class="col-md-2">
60
+ <%= link_to 'Cancel', new_csv_import_path, class: "btn btn-lg btn-danger" %>
61
+ </div>
62
+ </div>
63
+ <% else %>
64
+ <div class="row">
65
+ <div class="col-md-4">
66
+ <div class="well"><p>You will need to correct the errors with the CSV file before you can continue.</p></br>
67
+ <div class="text-center"><%= link_to 'Try Again', new_csv_import_path, class: 'btn btn-lg btn-primary' %>
68
+ </div>
69
+ </div>
70
+ </div>
71
+ </div>
72
+ <% end %>
73
+ </div>
74
+ </div>
75
+ </div>
76
+ </div>
@@ -0,0 +1,31 @@
1
+ <h2> Importing Records from a CSV File </h2>
2
+ <p id="notice"><%= notice %></p>
3
+
4
+ <div class="panel panel-default">
5
+ <div class="panel-body">
6
+
7
+ <p>
8
+ <label> CSV Manifest: </label>
9
+ <span> <%= File.basename(@csv_import.manifest.to_s) %> </span>
10
+ <br />
11
+ <label> Collection: </label>
12
+ <span> <%= ActiveFedora::SolrService.query("id:#{@csv_import.fedora_collection_id}")[0]['title_tesim'][0] %> </span>
13
+ <br />
14
+ <label> Uploaded by: </label>
15
+ <span> <%= @csv_import.user.name %> </span>
16
+ <br />
17
+ <label> Start time: </label>
18
+ <span> <%= @csv_import.created_at %> </span>
19
+ </p>
20
+
21
+ <div class="row">
22
+ <div class="col-md-6">
23
+ <div class='well'>
24
+ <p> Your records will be imported in the background. To check the current status, please check the background job status page. </p><br />
25
+ <div class="text-center"> <%= link_to 'Background Job Status', sidekiq_web_path, class: "btn btn-primary btn-lg" %> </div>
26
+ </div>
27
+ </div>
28
+ </div>
29
+
30
+ </div>
31
+ </div>