Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature : create a new component to display status of submissions #345

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/assets/images/icons/alert-triangle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/images/icons/archive.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/images/icons/error-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/images/icons/success-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions app/assets/stylesheets/submissions.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@ div#contacts div.contact.col-sm-10.offset-sm-2 {
}
.tab-content{
position: relative;
}
.spacer {
margin-left: 10px;
margin-top: -13px;
}
5 changes: 3 additions & 2 deletions app/components/display/info_tooltip_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

class Display::InfoTooltipComponent < ViewComponent::Base

def initialize(text: )
def initialize(text: nil , icon: "info.svg")
super
@text = text
@icon = icon
end
def call
image_tag("icons/info.svg", data:{controller:'tooltip', 'tooltip-interactive-value': 'true'}, title: @text)
image_tag("icons/#{@icon}", data:{controller:'tooltip', 'tooltip-interactive-value': 'true'}, title: @text)
end

end
1 change: 1 addition & 0 deletions app/components/ontology_browse_card_component.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

class OntologyBrowseCardComponent < ViewComponent::Base
include OntologiesHelper

def initialize(ontology: nil)
super
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
= ontology[:name]+" ("+ontology[:acronym]+")"
- if ontology[:private]
%i.fas.fa-key{title:"Private Ontology"}
- ontology_status = status_string(ontology)
= render Display::InfoTooltipComponent.new(text: ontology_status, icon: submission_status_icons(ontology_status)) if session[:user]&.admin?
syphax-bouazzouni marked this conversation as resolved.
Show resolved Hide resolved
.browse-desc-container{data:{controller:"text-truncate", 'text-truncate-more-text-value': '+ Show more ...' , 'text-truncate-less-text-value': '- Show less ...'}}
%p.browse-desc-text{'data-text-truncate-target': 'content'}
= ontology[:description]
Expand Down
29 changes: 29 additions & 0 deletions app/components/submission_status_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
class SubmissionStatusComponent < ViewComponent::Base
include OntologiesHelper

def initialize(submission, latest)
@submission = submission
@latest = latest
end

def submission_version
@submission.version.to_s if @submission.version.present?
end

def submission_link
if @submission.version.present?
if @submission.ontology.summaryOnly || !@latest
submission_version
else
link_to submission_version, ontology_path(@submission.ontology.acronym)
end
end
end

def submission_status
return unless @submission.submissionStatus.present?
statuses = submission_status2string(@submission)
end

end

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#submission-status{style: "display: -webkit-inline-box"}
- if @submission.version.present?
%p= submission_link
- else
%p unknown
.spacer
- submission_status = status_string(@submission)
= render Display::InfoTooltipComponent.new(text: submission_status, icon: submission_status_icons(submission_status))
28 changes: 24 additions & 4 deletions app/helpers/ontologies_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,16 +148,18 @@ def status_link(submission, latest = false, target = '')
version_link + status_text
end

def submission_status2string(sub)
return '' if sub.submissionStatus.nil?

def submission_status2string(data)
syphax-bouazzouni marked this conversation as resolved.
Show resolved Hide resolved
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
# "UPLOADED", "RDF", "RDF_LABELS", "INDEXED", "METRICS", "ANNOTATOR", "ARCHIVED" and 'ERROR_*' for each.
# Strip the URI prefix from the status codes (works even if they are not URIs)
# The order of the codes must be assumed to be random, it is not an entirely
# predictable sequence of ontology processing stages.
codes = sub.submissionStatus.map { |s| s.split('/').last }
codes = data[:submissionStatus].map { |s| s.split('/').last }
errors = codes.select { |c| c.start_with? 'ERROR' }.map { |c| c.gsub("_", " ").split(/(\W)/).map(&:capitalize).join }.compact
status = []
status.push('Parsed') if (codes.include? 'RDF') && (codes.include? 'RDF_LABELS')
Expand All @@ -169,10 +171,28 @@ def submission_status2string(sub)
end
status.concat errors
return '' if status.empty?

'(' + status.join(', ') + ')'
end

def status_string(data)
return '' unless data.present? && data[:submissionStatus].present?

submission_status2string(data)
end

def submission_status_icons(status)
if status.include?('Parsed') && !status.include?('Error Diff')
"success-icon.svg"
elsif status.include?('Error Diff') && !status.include?('Parsed')
'error-icon.svg'
elsif status == '(Archived)'
'archive.svg'
else
"alert-triangle.svg"
end
end

# Link for private/public/licensed ontologies
def visibility_link(ontology)
ont_url = "/ontologies/#{ontology.acronym}" # 'ontology' is NOT a submission here
Expand Down
3 changes: 2 additions & 1 deletion app/views/submissions/_submissions.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@

- if @ontology.admin?(session[:user])
- r.td { raw sub.submissionId }
- r.td { raw status_link(sub, sub.submissionId==submission_readyId)}
- r.td do
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't need to add a column for the status, why not just append it to the version column?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried that approach, but it caused an issue

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, it's not important.

= render SubmissionStatusComponent.new(sub, sub.submissionId==submission_readyId)
- r.td { xmldatetime_to_date(sub.modificationDate) unless sub.modificationDate.nil? }
- r.td { xmldatetime_to_date(sub.creationDate) unless sub.creationDate.nil? }

Expand Down