Skip to content

Commit

Permalink
Fixes #13 , printing error message when an error occurs when getting …
Browse files Browse the repository at this point in the history
…fair score data
  • Loading branch information
syphax-bouazzouni committed Nov 9, 2021
1 parent f506294 commit cc21bb7
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
18 changes: 17 additions & 1 deletion app/assets/javascripts/fair_score.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ class FairScoreChartContainer{
this.requestHrefBase = (this.requestLink != null ?this.requestLink.attr("href") : "")

this.fairSpinner = jQuery("<div id='fair-spinner-container' class='w-100 text-center'> <div class='spinner-grow'></div> </div>")
this.fairMsgErr = jQuery("<div id='fair-msg-container' class='w-100 text-center'> Data not calculated , waiting for cache update </div>")
this.fairMsgErr.hide()
this.fairChartsContainer.before(this.fairSpinner)
this.fairChartsContainer.before(this.fairMsgErr)
this.charts = charts
}

Expand All @@ -52,19 +55,32 @@ class FairScoreChartContainer{
}
getFairScoreData(ontologies) {
if(this.fairChartsContainer){
this.hideMsgError()
this.showLoader();
this.#updateLink(ontologies)
this.ajaxCall(ontologies).then(data => {

this.hideLoader()
this.charts.forEach( x => x.setFairScoreData(data))
this.#fillScoreSpans(data)
}).catch(err => {
console.log(err)
this.hideLoader()
this.showMsgError()
})
}


}

showMsgError(){
this.fairChartsContainer.hide()
this.fairMsgErr.show()
}

hideMsgError(){
this.fairMsgErr.hide()
this.fairChartsContainer.show()
}
showLoader(){
this.fairChartsContainer.hide()
this.fairSpinner.show()
Expand Down
10 changes: 8 additions & 2 deletions app/controllers/ontologies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,14 @@ def index
o[:acronym] = ont.acronym
o[:projects] = ont.projects
o[:notes] = ont.notes
o[:fairScore] = @fair_scores[ont.acronym]["score"]
o[:normalizedFairScore] = @fair_scores[ont.acronym]["normalizedScore"]

if !@fair_scores[ont.acronym].nil?
o[:fairScore] = @fair_scores[ont.acronym]["score"]
o[:normalizedFairScore] = @fair_scores[ont.acronym]["normalizedScore"]
elsif
o[:fairScore] = 0
o[:normalizedFairScore] = 0
end

if o[:type].eql?("ontology_view")
unless ontologies_hash[ont.viewOf].blank?
Expand Down
7 changes: 6 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,12 @@
# Ontologies
get '/ontologies/view/edit/:id' => 'ontologies#edit_view', :constraints => { id: /[^\/?]+/ }
get '/ontologies/view/new/:id' => 'ontologies#new_view'
get '/ontologies/virtual/:ontology' => 'ontologies#virtual', :as => :ontology_virtual
get '/ontologies/virtual/:ontology
' => 'ontologies#virtual', :as => :ontology_virtual
get '/ontologies/success/:id' => 'ontologies#submit_success'
match '/ontologies/:acronym' => 'ontologies#update', via: [:get, :post]
match '/ontologies/:acronym/submissions/:id' => 'submissions#update', via: [:get, :post]
Expand Down

0 comments on commit cc21bb7

Please sign in to comment.