From edd1cc0dbaea7ccdb0f1df514c526be3df10f6bf Mon Sep 17 00:00:00 2001 From: Bilel Kihal <61744974+Bilelkihal@users.noreply.github.com> Date: Wed, 27 Nov 2024 13:42:13 +0100 Subject: [PATCH 1/3] fix can't change portal language (#871) --- app/controllers/application_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index c27651a48..e6182c033 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -27,7 +27,7 @@ def set_locale cookies.permanent[:locale] = I18n.locale if cookies[:locale].nil? logger.debug "* Locale set to '#{I18n.locale}'" - I18n.locale = portal_lang if portal_language_enabled?(I18n.locale) + I18n.locale = portal_lang unless portal_language_enabled?(I18n.locale) session[:locale] = I18n.locale end @@ -430,7 +430,7 @@ def json_link(url, optional_params) optional_params_str = filtered_params.map { |param, value| "#{param}=#{value}" }.join("&") return base_url + optional_params_str + "&apikey=#{$API_KEY}" end - + def set_federated_portals RequestStore.store[:federated_portals] = params[:portals]&.split(',') end From aec6da841d210289d6eab018b48ba73ffe108956 Mon Sep 17 00:00:00 2001 From: Bilel Kihal <61744974+Bilelkihal@users.noreply.github.com> Date: Wed, 27 Nov 2024 13:45:40 +0100 Subject: [PATCH 2/3] Fix: `Federated search/browse` results count by portal (#870) * include non canonical portals in counting results for each portal * include non canonical portals in counting results for each portal in federated search * use portal_api and portal_ui in counting federation results instead of portal_name --- app/helpers/federation_helper.rb | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/app/helpers/federation_helper.rb b/app/helpers/federation_helper.rb index b1f785c18..f0b2fc409 100644 --- a/app/helpers/federation_helper.rb +++ b/app/helpers/federation_helper.rb @@ -219,14 +219,18 @@ def init_federation_portals_status end def federated_search_counts(search_results) - ids = search_results.map do |result| - result.dig(:root, :ontology_id) || rest_url - end + ids = search_results.flat_map do |result| + ontology_id = result.dig(:root, :ontology_id) || rest_url + other_portal_ids = result.dig(:root, :other_portals)&.map { |portal| portal[:link].split('?').first } || [] + [ontology_id] + other_portal_ids + end.uniq counts_ontology_ids_by_portal_name(ids) end def federated_browse_counts(ontologies) - ids = ontologies.map { |ontology| ontology[:id] } + ids = ontologies.flat_map do |ontology| + [ontology[:id]] + (ontology[:sources] || []) + end.uniq counts_ontology_ids_by_portal_name(ids) end @@ -239,8 +243,9 @@ def counts_ontology_ids_by_portal_name(portals_ids) counts[current_portal.downcase] += 1 if id.include?(current_portal.to_s.downcase) federation_portals.each do |portal| - portal_api = federated_portals[portal.downcase.to_sym][:api] - counts[portal.downcase] += 1 if id.include?(portal_api) + portal_api = federated_portals[portal.downcase.to_sym][:api].sub(/^https?:\/\//, '') + portal_ui = federated_portals[portal.downcase.to_sym][:ui].sub(/^https?:\/\//, '') + counts[portal.downcase] += 1 if (id.include?(portal_api) || id.include?(portal_ui)) end end From 34ce85ef2e9a0c12ef6d85bd173c68cd294c8536 Mon Sep 17 00:00:00 2001 From: Bilel Kihal <61744974+Bilelkihal@users.noreply.github.com> Date: Thu, 28 Nov 2024 14:46:28 +0100 Subject: [PATCH 3/3] Fix: Prevent display home portal tooltip if we get a non complete response (#851) * prevent display home portal tooltip if we get a non complete data * show any info we get from the api in portals home page tooltips --- app/controllers/home_controller.rb | 2 ++ app/views/home/portal_config.html.haml | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 068d217b8..b9737ae8a 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -48,6 +48,8 @@ def portal_config @config = $PORTALS_INSTANCES.select { |x| x[:name].downcase.eql?((params[:portal] || helpers.portal_name).downcase) }.first if @config && @config[:api] @portal_config = LinkedData::Client::Models::Ontology.top_level_links(@config[:api]).to_h + @color = @portal_config[:color].present? ? @portal_config[:color] : @config[:color] + @name = @portal_config[:title].present? ? @portal_config[:title] : @config[:name] else @portal_config = {} end diff --git a/app/views/home/portal_config.html.haml b/app/views/home/portal_config.html.haml index b484e9431..15f04baf1 100644 --- a/app/views/home/portal_config.html.haml +++ b/app/views/home/portal_config.html.haml @@ -4,21 +4,21 @@ .div.d-flex.align-items-center %div %div.text-center - = link_to @portal_config[:ui] || @config[:ui], target: '_blank', class: 'home-logo-instances mr-1 m-0', style: "background-color: #{@portal_config[:color] || @config[:color]}" do + = link_to @portal_config[:ui] || @config[:ui], target: '_blank', class: 'home-logo-instances mr-1 m-0', style: "background-color: #{@color}" do = inline_svg 'logo-white.svg', width: "35", height: "26" %div - %div.portal-configuration-title{style: "color: #{@portal_config[:color] || @config[:color]}"} + %div.portal-configuration-title{style: "color: #{@color}"} %h3 - = @portal_config[:title] || @config[:name] + = @name - if @portal_config[:numberOfArtefacts] .portal-config-ontologies = inline_svg_tag 'icons/ontology.svg' %span = "#{@portal_config[:numberOfArtefacts]} ontologies" - - if @portal_config[:description] + - if @portal_config[:description].present? .portal-description = @portal_config[:description] - - if @portal_config[:federated_portals] + - if @portal_config[:federated_portals].present? %div.mb-1 .home-section-title .text @@ -31,7 +31,7 @@ %p{style: "color: #{portal[:color]}"} = portal[:name] - - if @portal_config[:fundedBy] + - if @portal_config[:fundedBy].present? %div.mb-1 .home-section-title .portal-config-title-text