Skip to content

Commit

Permalink
Merge branch 'development' into feature/select-children-of-category-w…
Browse files Browse the repository at this point in the history
…hen-selecting-it
  • Loading branch information
Bilelkihal committed Jan 3, 2025
2 parents 7081622 + afd56c0 commit 4627639
Show file tree
Hide file tree
Showing 52 changed files with 350 additions and 254 deletions.
2 changes: 2 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ API_KEY=

UI_THEME=ontoportal

TWITTER_NEWS=

BIOMIXER_URL=
BIOMIXER_APIKEY=

Expand Down
1 change: 0 additions & 1 deletion app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
//
//= require bioportal
//= require admin/licenses
//= require bp_notes
//= require bp_form_complete
//= require bp_admin
//= require concepts
Expand Down
42 changes: 0 additions & 42 deletions app/assets/javascripts/bp_notes.js

This file was deleted.

1 change: 0 additions & 1 deletion app/assets/stylesheets/components/tree_view.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ padding:0;
a.tree-link {
display: inline-block;
padding: 5px;
word-break: break-all;
text-wrap: wrap;
color: var(--primary-color) !important;
}
Expand Down
2 changes: 1 addition & 1 deletion app/assets/stylesheets/home.scss
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ i.fa.fa-caret-square-o-down {
.home-statistics-container > div {
display: flex;
align-items: start;
justify-content: center;
justify-content: flex-start;
flex-wrap: wrap;
}
.home-agroportal-figures{
Expand Down
3 changes: 2 additions & 1 deletion app/assets/stylesheets/ontologies.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ $ont-metadata-bg-color: #e2ebf0;
$widget-table-border-color: #EFEFEF;



.admin-background{
a.chip_button_container_clickable{
color: var(--admin-color) !important;
Expand Down Expand Up @@ -314,4 +315,4 @@ $widget-table-border-color: #EFEFEF;
color: white;
border-radius: 10px;
position: relative;
}
}
32 changes: 31 additions & 1 deletion app/assets/stylesheets/taxonomy.scss
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,18 @@
}
.taxonomy-card .description{
color: #666666;
padding-bottom: 5px;
}

.taxonomy-card .descriptionlink svg{
margin: 0px 2px;
height: 19px;
}

.taxonomy-card .descriptionlink svg path{
fill: #666666;
}
.category-link{
color: #666666 !important;
}
.taxonomy-slice-svg{
width: 35px;
Expand Down Expand Up @@ -98,4 +109,23 @@
background-color: var(--primary-color);
}

.taxonomy-empty-illustration{
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
.browse-empty-illustration {
margin-top: 40px;
}
}


.taxonomy-empty-illustration-text{
color: var(--gray-color);

}
.taxonomy-empty-illustration-button{
width: 168px;
}

1 change: 1 addition & 0 deletions app/components/display/taxonomy_card_component.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class Display::TaxonomyCardComponent < ViewComponent::Base
include UrlsHelper
def initialize(taxonomy: , ontologies_names: )
@taxonomy = taxonomy
@ontologies_names = ontologies_names
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,22 @@
= "#{@taxonomy.name} (#{@taxonomy.acronym})"
%a{href: "https://#{@taxonomy.acronym}.#{$UI_URL.sub("https://", "")}"}
= inline_svg_tag('icons/slices.svg', class: "taxonomy-slice-svg #{@taxonomy.is_slice ? '' : 'd-none'}")

- if link?(@taxonomy.description)
.descriptionlink
%a.category-link{href: @taxonomy.description, target: '_blank'}
= @taxonomy.description
= inline_svg_tag 'icons/external-link.svg'

%a.ontologies{href: "/ontologies?#{@taxonomy.id.split('/')[-2]}=#{@taxonomy.acronym}"}
= inline_svg_tag('icons/ontology.svg')
.number-of-ontologies
= "#{@taxonomy.ontologies.length} ontologies"
.description
= render TextAreaFieldComponent.new(value: @taxonomy.description)

- unless link?(@taxonomy.description)
.description.mb-1
= render TextAreaFieldComponent.new(value: @taxonomy.description)

.ontologies-cards
- @taxonomy.ontologies.each_with_index do |ontology, index|
- if index>10
Expand Down
5 changes: 5 additions & 0 deletions app/components/federated_portal_button_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

class FederatedPortalButtonComponent < ViewComponent::Base
attr_reader :name, :tooltip, :link, :color, :light_color
include UrlsHelper

def initialize(name:, link:, color:, tooltip:, light_color:)
@name = name
Expand All @@ -10,4 +11,8 @@ def initialize(name:, link:, color:, tooltip:, light_color:)
@color = color
@light_color = light_color
end

def internal?
!link?(@link)
end
end
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%span{'data-controller': 'federation-portals-colors',
'data-federation-portals-colors-color-value': color,
'data-federation-portals-colors-portal-name-value': name.downcase}
%a{ href: link, target: '_blank', 'data-controller' => 'tooltip', title: tooltip, class: 'federation-portal-button button icon-right', style: color ? "background-color: #{light_color} !important" : '' }
%a{ href: link, target: internal? ? '_top' : '_blank', 'data-controller' => 'tooltip', title: tooltip, class: 'federation-portal-button button icon-right', style: color ? "background-color: #{light_color} !important" : '' }
= inline_svg_tag('logos/ontoportal.svg', class: "federated-icon-#{name.downcase}")
%div{ class: 'text', style: color ? "color: #{color} !important" : '' }
= name.humanize.gsub("portal", "Portal")
9 changes: 9 additions & 0 deletions app/controllers/admin/categories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ class Admin::CategoriesController < ApplicationController

def index
@categories = _categories

@parents_list = Hash.new { |hash, key| hash[key] = [] }
@categories.each do |category|
category.parentCategory.each do |parent|
@parents_list[parent] << category.acronym
end
end


end

def new
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/agents_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def show
end

def ajax_agents
filters = { query: params[:query], qf: "identifiers_texts^20 acronym_text^15 name_text^10 email_text^10"}
filters = { query: "#{params[:query]}*", qf: "identifiers_texts^20 acronym_text^15 name_text^10 email_text^10"}
@agents = LinkedData::Client::HTTP.get('/search/agents', filters)
agents_json = @agents.collection.map do |x|
{
Expand Down
16 changes: 11 additions & 5 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# Likewise, all the methods added will be available for all controllers.

class ApplicationController < ActionController::Base
include InternationalisationHelper
include InternationalisationHelper, MultiLanguagesHelper

before_action :set_locale

Expand All @@ -26,6 +26,9 @@ def set_locale
I18n.locale = cookies[:locale] || detect_locale
cookies.permanent[:locale] = I18n.locale if cookies[:locale].nil?
logger.debug "* Locale set to '#{I18n.locale}'"

I18n.locale = portal_lang unless portal_language_enabled?(I18n.locale)

session[:locale] = I18n.locale
end

Expand Down Expand Up @@ -250,12 +253,15 @@ def authorize_and_redirect
end

def authorize_admin
admin = session[:user] && session[:user].admin?
redirect_to_home unless admin
redirect_to_home unless current_user_admin?
end

def current_user_admin?
session[:user] && session[:user].admin?
session[:user]&.admin? || current_login_as_admin?
end

def current_login_as_admin?
session[:admin_user]&.admin?
end

def ontology_restricted?(acronym)
Expand Down Expand Up @@ -424,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
Expand Down
25 changes: 15 additions & 10 deletions app/controllers/collections_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,19 @@ def show_label

def show_members
@ontology = LinkedData::Client::Models::Ontology.find_by_acronym(params[:ontology_id] || params[:ontology]).first
@submission = @ontology.explore.latest_submission(include:'uriRegexPattern,preferredNamespaceUri')
@collection = get_request_collection
@submission = @ontology.explore.latest_submission(include: 'uriRegexPattern,preferredNamespaceUri')
page = params[:page] || '1'
@auto_click = page.to_s.eql?('1')
@page = @collection.explore.members({page: page, language: request_lang})
@concepts = @page.collection
@collection = get_request_collection(@ontology)

if @collection
@page = @collection.explore.members({ page: page, language: request_lang })
@concepts = @page.collection
else
@page = OpenStruct.new({ nextPage: 1, page: 1 })
@concepts = []
end

if @ontology.nil?
ontology_not_found params[:ontology]
else
Expand All @@ -72,14 +79,12 @@ def show_members

private

def get_request_collection
def get_request_collection(ontology = nil)
params[:id] = request_collection_id

if params[:id].nil? || params[:id].empty?
render plain: t('collections.error_valid_collection')
return
end
@ontology = LinkedData::Client::Models::Ontology.find_by_acronym(params[:ontology_id] || params[:ontology]).first
return nil if params[:id].nil? || params[:id].empty?

@ontology = ontology || LinkedData::Client::Models::Ontology.find_by_acronym(params[:ontology_id] || params[:ontology]).first
ontology_not_found(params[:ontology_id]) if @ontology.nil?
get_collection(@ontology, params[:id])
end
Expand Down
8 changes: 6 additions & 2 deletions app/controllers/concepts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,12 @@ def index
def show_label
cls_id = params[:concept] || params[:id]
ont_id = params[:ontology]
pref_label = concept_label(ont_id, cls_id)
cls = @ontology.explore.single_class({ language: request_lang, include: 'prefLabel' }, cls_id)
pref_label = begin
concept_label(ont_id, cls_id)
rescue
cls_id
end
cls = @ontology.explore&.single_class({ language: request_lang, include: 'prefLabel' }, cls_id)
label = helpers.main_language_label(pref_label)
link = concept_path(cls_id, ont_id, request_lang)

Expand Down
27 changes: 15 additions & 12 deletions app/controllers/concerns/search_aggregator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -251,18 +251,21 @@ def blacklist_cls_id_components(cls_id, blacklist_words)
def merge_federated_results(search_results)
search_results.each do |element|
element[:root][:other_portals] = []

element[:reuses].reject! do |reuse|
element_ontology_id = element[:root][:ontology_id].split('/').last
element_uri = element[:root][:uri]
reuse_ontology_id = reuse[:root][:ontology_id].split('/').last
reuse_uri = reuse[:root][:uri]

if element_ontology_id == reuse_ontology_id && element_uri == reuse_uri
element[:root][:other_portals] << build_other_portal_entry(reuse)
true
else
false
element_ontology_id = element[:root][:ontology_id].split('/').last
element_uri = element[:root][:uri]
[element[:reuses], search_results].each do |collection|
collection.reject! do |entry|
next if entry == element

entry_ontology_id = entry[:root][:ontology_id].split('/').last
entry_uri = entry[:root][:uri]

if element_ontology_id == entry_ontology_id && element_uri == entry_uri
element[:root][:other_portals] << build_other_portal_entry(entry)
true
else
false
end
end
end
end
Expand Down
17 changes: 14 additions & 3 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,20 @@ def index

@anal_ont_names = []
@anal_ont_numbers = []
@analytics.sort_by{|ont, count| -count}[0..4].each do |ont, count|
@anal_ont_names << ont
@anal_ont_numbers << count
if @analytics.empty?
all_metrics = LinkedData::Client::Models::Metrics.all
all_metrics.sort_by{|x| -(x.classes + x.individuals)}[0..4].each do |x|
@anal_ont_names << x.id.split('/')[-4]
@anal_ont_numbers << (x.classes + x.individuals) || 0
end
else
@analytics.sort_by{|ont, count| -count}[0..4].each do |ont, count|
@anal_ont_names << ont
@anal_ont_numbers << count
end
end


end

def set_cookies
Expand All @@ -39,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
Expand Down
Loading

0 comments on commit 4627639

Please sign in to comment.