From ce2d73f6c3aa2abe1645f0ca579685459ca889ea Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Mon, 20 Nov 2023 21:22:00 +0100 Subject: [PATCH] if submission status icon helper with the correct conditions --- app/helpers/ontologies_helper.rb | 51 ++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/app/helpers/ontologies_helper.rb b/app/helpers/ontologies_helper.rb index 773aac706..74d34092a 100644 --- a/app/helpers/ontologies_helper.rb +++ b/app/helpers/ontologies_helper.rb @@ -152,7 +152,7 @@ def status_link(submission, latest = false, target = '') def submission_status2string(data) return '' if data[:submissionStatus].nil? - + # Massage the submission status into a UI string # submission status values, from: # https://github.com/ncbo/ontologies_linked_data/blob/master/lib/ontologies_linked_data/models/submission_status.rb @@ -172,7 +172,7 @@ def submission_status2string(data) end status.concat errors return '' if status.empty? - + '(' + status.join(', ') + ')' end @@ -181,16 +181,30 @@ def status_string(data) submission_status2string(data) end - + + def submission_status_ok?(status) + status.include?('Parsed') && !status.include?('Error') + end + + def submission_status_error?(status) + !status.include?('Parsed') && status.include?('Error') + end + + def submission_status_warning?(status) + status.include?('Parsed') && status.include?('Error') + end + def submission_status_icons(status) - if status.include?('Parsed') && !status.include?('Error Diff') + if submission_status_ok?(status) "success-icon.svg" - elsif status.include?('Error Diff') && !status.include?('Parsed') + elsif submission_status_error?(status) 'error-icon.svg' elsif status == '(Archived)' 'archive.svg' - else + elsif submission_status_warning?(status) "alert-triangle.svg" + else + "info.svg" end end @@ -306,6 +320,10 @@ def visits_chart_dataset(visits_data) }].to_json end + def submission_ready?(submission) + submission.nil? || Array(submission.submissionStatus).include?('RDF') + end + def sections_to_show sections = ['summary'] @@ -317,6 +335,27 @@ def sections_to_show end sections end + + def not_ready_submission_alert(ontology: @ontology, submission: @submission) + if ontology.admin?(session[:user]) + status = status_string(submission) + type = nil + message = nil + if submission_status_error?(status) + type = 'danger' + message = "The ontology processing failed, with the current statuses: #{status}" + elsif submission_status_warning?(status) + message = "The ontology parsing succeeded, but some processing steps failed, here are the current statuses: #{status}" + type = 'warning' + + elsif !submission_ready?(submission) + type = 'info' + message = "The ontology is processing. Sections such as #{ontology_data_sections.join(', ')} will be available once processing is complete." + end + render Display::AlertComponent.new(message: message, type: type) if type + end + end + def dispaly_complex_text(definitions) html = "" definitions.each do |definition|