Skip to content

Commit

Permalink
Merge branch 'development' into stage
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Dec 19, 2023
2 parents e89d2b7 + 502053e commit 871305d
Show file tree
Hide file tree
Showing 22 changed files with 179 additions and 141 deletions.
26 changes: 14 additions & 12 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GIT
remote: https://github.com/ontoportal-lirmm/ontologies_api_ruby_client.git
revision: 169afb7c1002f9db2b3276af36d552575cc80ba2
revision: 674193220f93d99587e6d3a969adcb384caf0a61
branch: development
specs:
ontologies_api_client (2.2.0)
Expand Down Expand Up @@ -99,6 +99,7 @@ GEM
erubi (~> 1.4)
parser (>= 2.4)
smart_properties
bigdecimal (3.1.5)
bindata (2.4.15)
bindex (0.8.1)
bootsnap (1.17.0)
Expand Down Expand Up @@ -147,9 +148,9 @@ GEM
daemons (1.4.1)
dalli (3.2.6)
date (3.3.4)
debug (1.8.0)
irb (>= 1.5.0)
reline (>= 0.3.1)
debug (1.9.0)
irb (~> 1.10)
reline (>= 0.3.8)
deepl-rb (2.5.3)
diff-lcs (1.5.0)
docile (1.4.0)
Expand All @@ -158,7 +159,7 @@ GEM
erubi (1.12.0)
erubis (2.7.0)
eventmachine (1.2.7)
excon (0.105.0)
excon (0.108.0)
execjs (2.9.1)
faraday (2.0.1)
faraday-net_http (~> 2.0)
Expand All @@ -177,7 +178,7 @@ GEM
flamegraph (0.9.5)
globalid (1.2.1)
activesupport (>= 6.1)
graphql (2.1.6)
graphql (2.1.7)
racc (~> 1.4)
graphql-client (0.18.0)
activesupport (>= 3.0)
Expand Down Expand Up @@ -218,8 +219,8 @@ GEM
inline_svg (1.9.0)
activesupport (>= 3.0)
nokogiri (>= 1.6)
io-console (0.6.0)
irb (1.9.1)
io-console (0.7.1)
irb (1.10.1)
rdoc
reline (>= 0.3.8)
iso-639 (0.3.6)
Expand All @@ -231,7 +232,7 @@ GEM
railties (>= 3.2.16)
jsbundling-rails (1.2.1)
railties (>= 6.0.0)
json (2.7.0)
json (2.7.1)
json-jwt (1.16.3)
activesupport (>= 4.2)
aes_key_wrap
Expand Down Expand Up @@ -319,7 +320,8 @@ GEM
rack (>= 1.2, < 4)
snaky_hash (~> 2.0)
version_gem (~> 1.1)
oj (3.16.1)
oj (3.16.3)
bigdecimal (>= 3.0)
omniauth (2.1.1)
hashie (>= 3.4.6)
rack (>= 2.2.3)
Expand All @@ -346,7 +348,7 @@ GEM
actionpack (>= 4.2)
omniauth (~> 2.0)
open_uri_redirections (0.2.1)
parallel (1.23.0)
parallel (1.24.0)
parser (3.2.2.4)
ast (~> 2.4.1)
racc
Expand Down Expand Up @@ -412,7 +414,7 @@ GEM
recaptcha (5.9.0)
json
redcarpet (3.6.0)
regexp_parser (2.8.2)
regexp_parser (2.8.3)
reline (0.4.1)
io-console (~> 0.5)
rest-client (2.1.0)
Expand Down
3 changes: 2 additions & 1 deletion app/components/ontology_subscribe_button_component.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# frozen_string_literal: true

class OntologySubscribeButtonComponent < ViewComponent::Base
def initialize(ontology_id:, subscribed:, user_id:, count: 0, link: 'javascript:void(0);')
def initialize(id: '', ontology_id:, subscribed:, user_id:, count: 0, link: 'javascript:void(0);')
super
@id = id
@subscribed = subscribed
@sub_text = subscribed ? 'UnWatch' : 'Watch'
@link = link
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%div{@controller_params, style: 'margin-left: 10px;'}
%div{@controller_params, style: 'margin-left: 10px;', id: @id}
= render PillButtonComponent.new do
%a.d-flex.align-items-center{href: @link}
= inline_svg_tag "eye.svg"
Expand Down
10 changes: 5 additions & 5 deletions app/controllers/agents_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def index

def show
# we use :agent_id not :id
@agent = LinkedData::Client::Models::Agent.find(params[:agent_id])
@agent = LinkedData::Client::Models::Agent.find(params[:agent_id].split('/').last)
not_found("Agent with id #{params[:agent_id]}") if @agent.nil?

@agent_id = params[:id] || agent_id(@agent)
Expand Down Expand Up @@ -67,7 +67,7 @@ def create
end

def edit
@agent = LinkedData::Client::Models::Agent.find("#{rest_url}/Agents/#{params[:id]}")
@agent = LinkedData::Client::Models::Agent.find(params[:id].split('/').last)
@name_prefix = params[:name_prefix] || ''
@show_affiliations = params[:show_affiliations].nil? || params[:show_affiliations].eql?('true')
@deletable = params[:deletable].to_s.eql?('true')
Expand Down Expand Up @@ -99,7 +99,7 @@ def update
else
success_message = 'Agent successfully updated'
table_line_id = agent_table_line_id(agent_id(agent))
agent = LinkedData::Client::Models::Agent.find(agent.id)
agent = LinkedData::Client::Models::Agent.find(agent.id.split('/').last)
streams = [alert_success(id: alert_id) { success_message },
replace(table_line_id, partial: 'agents/show_line', locals: { agent: agent })
]
Expand Down Expand Up @@ -147,7 +147,7 @@ def update_agent_usages

def destroy
error = nil
@agent = LinkedData::Client::Models::Agent.find("#{rest_url}/Agents/#{params[:id]}")
@agent = LinkedData::Client::Models::Agent.find(params[:id].split('/').last)
success_text = ''

if @agent.nil?
Expand Down Expand Up @@ -198,7 +198,7 @@ def save_agent(params)
end

def update_agent(id = params[:id], params)
agent = LinkedData::Client::Models::Agent.find("#{rest_url}/Agents/#{id}")
agent = LinkedData::Client::Models::Agent.find(id)

params[:creator] = session[:user].id if (agent.creator.nil? || agent.creator.empty?) && (params[:creator] || '').empty?

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/concerns/ontology_updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def update_existent_ontology(acronym)
rescue StandardError
next
end
[@ontology, @ontology.update(values: new_values)]
[@ontology, @ontology.update(values: new_values, cache_refresh_all: false)]
end

def ontology_from_params
Expand Down Expand Up @@ -86,7 +86,7 @@ def update_submission_hash(acronym)
def reset_agent_attributes
helpers.agent_attributes.each do |attr|
current_val = @submission[attr]
new_values = Array(current_val).map { |x| LinkedData::Client::Models::Agent.find(x) }
new_values = Array(current_val).map { |x| LinkedData::Client::Models::Agent.find(x.split('/').last) }

new_values = new_values.first unless current_val.is_a?(Array)

Expand Down
12 changes: 7 additions & 5 deletions app/controllers/concerns/submission_updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ def save_submission(new_submission_hash)
@submission.save(cache_refresh_all: false)
end

def update_submission(new_submission_hash, submission_id)
def update_submission(new_submission_hash, submission_id , ontology = nil)

convert_values_to_types(new_submission_hash)

@ontology = LinkedData::Client::Models::Ontology.find_by_acronym(new_submission_hash[:ontology]).first
@ontology = ontology || LinkedData::Client::Models::Ontology.find_by_acronym(new_submission_hash[:ontology]).first
new_submission_hash.delete(:ontology)
@submission = @ontology.explore.submissions({ display: 'all' }, submission_id)

@submission = @ontology.explore.submissions({ include: 'all' }, submission_id)

new_values = new_submission_hash
new_values.each do |key, values|
Expand Down Expand Up @@ -61,8 +62,9 @@ def delete_ontologies_from_object(new_ontologies,old_ontologies,object)
private

def update_ontology_summary_only(is_remote = @submission.isRemote)
@ontology.summaryOnly = is_remote&.eql?('3')
@ontology.update
if is_remote && @ontology.summaryOnly != is_remote.eql?('3')
@ontology.update(values: {summaryOnly: is_remote.eql?('3')}, cache_refresh_all: false)
end
end

def convert_values_to_types(new_submission_hash)
Expand Down
57 changes: 39 additions & 18 deletions app/controllers/ontologies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,17 @@ def ontologies_filter
] + update_filters_counts

streams =if params[:page].nil?
[
prepend('ontologies_list_container', partial: 'ontologies/browser/ontologies'),
prepend('ontologies_list_container') {
helpers.turbo_frame_tag("ontologies_filter_count_request") do
helpers.browser_counter_loader
end
}
]
else
[replace("ontologies_list_view-page-1", partial: 'ontologies/browser/ontologies')]
end
[
prepend('ontologies_list_container', partial: 'ontologies/browser/ontologies'),
prepend('ontologies_list_container') {
helpers.turbo_frame_tag("ontologies_filter_count_request") do
helpers.browser_counter_loader
end
}
]
else
[replace("ontologies_list_view-page-1", partial: 'ontologies/browser/ontologies')]
end

render turbo_stream: streams + count_streams
end
Expand Down Expand Up @@ -246,7 +246,7 @@ def show
# See: https://github.com/ncbo/bioportal_web_ui/issues/133.
data_pages = KNOWN_PAGES - %w[summary notes]
if @ontology.summaryOnly && params[:p].present? && data_pages.include?(params[:p].to_s)
redirect_to(ontology_path(params[:ontology]), status: :temporary_redirect) and return
redirect_to(ontology_path(params[:ontology]), status: :temporary_redirect) and return
end

#@ob_instructions = helpers.ontolobridge_instructions_template(@ontology)
Expand Down Expand Up @@ -346,6 +346,28 @@ def summary
end
end

def subscriptions
ontology_id = params[:ontology_id]
return not_found if ontology_id.nil?

ontology_acronym = ontology_id.split('/').last

if session[:user].nil?
link = "/login?redirect=#{request.url}"
subscribed = false
user_id = nil
else
user = LinkedData::Client::Models::User.find(session[:user].id)
subscribed = helpers.subscribed_to_ontology?(ontology_acronym, user)
link = "javascript:void(0);"
user_id = user.id
end

count = helpers.count_subscriptions(ontology_id)
render inline: helpers.turbo_frame_tag('subscribe_button') {
render_to_string(OntologySubscribeButtonComponent.new(id: 'subscribe_button', ontology_id: ontology_id, subscribed: subscribed, user_id: user_id, count: count, link: link), layout: nil)
}
end

def virtual
redirect_new_api
Expand All @@ -362,7 +384,7 @@ def widgets
render partial: 'ontologies/sections/widgets', layout: 'ontology_viewer'
end
end


def show_additional_metadata
@metadata = submission_metadata
Expand Down Expand Up @@ -439,12 +461,11 @@ def ontology_relations_data(sub = @submission_latest)

target_id = relation_value
target_in_portal = false
target_ont = nil
# if we find our portal URL in the ontology URL, then we just keep the ACRONYM to try to get the ontology.
relation_value = relation_value.split('/').last if relation_value.include?($UI_URL)

# Use acronym to get ontology from the portal
target_ont = LinkedData::Client::Models::Ontology.find_by_acronym(relation_value).first
if target_ont
if relation_value.include?(portal_name)
relation_value = relation_value.split('/').last
target_ont = LinkedData::Client::Models::Ontology.find_by_acronym(relation_value).first
target_id = target_ont.acronym
target_in_portal = true
end
Expand Down
23 changes: 5 additions & 18 deletions app/controllers/ontologies_metadata_curator_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,16 @@ class OntologiesMetadataCuratorController < ApplicationController
before_action :submission_metadata, only: [:result, :edit, :update, :show_metadata_by_ontology]

def result
@ontologies_ids = params[:ontology] ? params[:ontology][:ontologyId] : []
@ontologies_ids = params[:ontology] ? Array(params[:ontology][:ontologyId]) : []
@metadata_sel = params[:search] ? params[:search][:metadata] : []
@show_submissions = !params[:show_submissions].nil?
@ontologies = []
@submissions = []

if @ontologies_ids.nil? || @ontologies_ids.empty?
@ontologies = LinkedData::Client::Models::Ontology.all
else
@ontologies_ids.each do |data|
@ontologies << LinkedData::Client::Models::Ontology.find_by_acronym(data).first
end
end

display_attribute = equivalent_properties(@metadata_sel) + %w[submissionId]
@ontologies.each do |ont|
if @show_submissions
submissions = ont.explore.submissions({ include: display_attribute.join(',') })
else
submissions = [ont.explore.latest_submission({ include: display_attribute.join(',') })]
end
submissions.each { |sub| append_submission(ont, sub) }
end

@submissions = LinkedData::Client::Models::OntologySubmission.all(acronym: @ontologies_ids.join('|'), display_links: false, display_context: false, include: display_attribute.join(','), include_status: 'RDF')
@submissions.reject!{|x| !@ontologies_ids.include?(x.id.split('/')[-3])} unless @ontologies_ids.empty?
@submissions.sort_by!{|x| x.id}

respond_to do |format|
format.html { redirect_to admin_index_path }
Expand Down
9 changes: 5 additions & 4 deletions app/controllers/submissions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ def update
acronym = params[:ontology_id]
submission_id = params[:id]
if params[:ontology]
@ontology = update_existent_ontology(acronym)
if @ontology.nil? || response_error?(@ontology)
show_new_errors(@ontology, partial: 'submissions/form_content', id: 'test')
@ontology, response = update_existent_ontology(acronym)

if response.nil? || response_error?(response)
show_new_errors(response, partial: 'submissions/form_content', id: 'test')
return
end
end
Expand All @@ -100,7 +101,7 @@ def update
notice: 'Submission updated successfully'
end

@submission, response = update_submission(update_submission_hash(acronym), submission_id)
@submission, response = update_submission(update_submission_hash(acronym), submission_id, @ontology)
if params[:attribute].nil?
if response_error?(response)
show_new_errors(response, partial: 'submissions/form_content', id: 'test')
Expand Down
Loading

0 comments on commit 871305d

Please sign in to comment.