From 186c897cd2ebeda9ecf700e218e15b5caaa6f31c Mon Sep 17 00:00:00 2001 From: Hector Correa Date: Mon, 4 Nov 2024 14:55:27 -0500 Subject: [PATCH 1/5] Started to add code to load file list via AJAX Co-authored-by: Claudia Lee --- app/views/catalog/_show_documents.html.erb | 29 +--------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/app/views/catalog/_show_documents.html.erb b/app/views/catalog/_show_documents.html.erb index b41f2ae8..794492e4 100644 --- a/app/views/catalog/_show_documents.html.erb +++ b/app/views/catalog/_show_documents.html.erb @@ -15,38 +15,10 @@ # Filename - <% if @document.data_source == "dataspace" %> - Description - <% end %> Filesize - <% DatasetFile.sort_file_array(@document.files).each_with_index do |file, ix| %> - - - <%= ix + 1 %> - - - - - <% if @render_links%> - <%= truncate(file.full_path, length: 60) %> - <% else %> - <%= truncate(file.full_path, length: 60) %> - <% end %> - - - <% if @document.data_source == "dataspace" %> - - <%= file.description %> - - <% end %> - - <%= number_to_human_size(file.size) %> - - - <% end %> @@ -64,6 +36,7 @@ $(function() { // Wire DataTable for the file list. + // TODO: Update to load via AJAX $('#files-table').DataTable(); // Track file downloads via Plausible. From 47ff4504b41bf70f0a61aff1ee3b7ac0c3d459b6 Mon Sep 17 00:00:00 2001 From: Hector Correa Date: Fri, 8 Nov 2024 15:09:57 -0500 Subject: [PATCH 2/5] Co-authored-by: Claudia Lee --- app/controllers/catalog_controller.rb | 23 ++++++++++++++++++++ app/views/catalog/_show_documents.html.erb | 25 ++++++++++++++-------- config/routes.rb | 1 + 3 files changed, 40 insertions(+), 9 deletions(-) diff --git a/app/controllers/catalog_controller.rb b/app/controllers/catalog_controller.rb index 0eec8ff1..89081afe 100644 --- a/app/controllers/catalog_controller.rb +++ b/app/controllers/catalog_controller.rb @@ -268,6 +268,16 @@ def show end end + def file_list + document = solr_find(params["id"]) + + file1 = {name: "hello.txt", size: 123} + file2 = {name: "bye.txt", size: 222} + file_list = {data: [file1, file2]} + + render json: file_list.to_json + end + # Returns the raw BibTex citation information def bibtex _unused, @document = search_service.fetch(params[:id]) @@ -339,4 +349,17 @@ def pppl_reporting_feed format.json { render json: @documents } end end + + private + def solr_find(id) + solr_url = Blacklight.default_configuration.connection_config[:url] + solr = RSolr.connect(url: solr_url) + solr_params = { + q: "id:#{id}", + fl: '*', + } + response = solr.get('select', params: solr_params) + solr_doc = response["response"]["docs"][0] + SolrDocument.new(solr_doc) + end end diff --git a/app/views/catalog/_show_documents.html.erb b/app/views/catalog/_show_documents.html.erb index 794492e4..7a6d6311 100644 --- a/app/views/catalog/_show_documents.html.erb +++ b/app/views/catalog/_show_documents.html.erb @@ -13,14 +13,17 @@ - - - + + - - - + + + + + + +
#FilenameFilesizeNameSize
NameSize
<% end %> @@ -35,9 +38,13 @@