Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/stage' into stage
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Oct 28, 2024
2 parents 894798b + 9c76426 commit afabee9
Show file tree
Hide file tree
Showing 41 changed files with 671 additions and 340 deletions.
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,11 @@ gem 'inline_svg'
# ISO language codes and flags
gem "iso-639", "~> 0.3.6"
gem "flag-icons-rails", "~> 3.4"
gem 'ontologies_api_client', git: 'https://github.com/ontoportal-lirmm/ontologies_api_ruby_client.git', branch: 'feature/federated-search'

# Custom API client
gem 'ontologies_api_client', git: 'https://github.com/ontoportal-lirmm/ontologies_api_ruby_client.git', branch: 'development'
# Ruby 2.7.8 pinned gems (to remove when migrating to Ruby >= 3.0)

gem 'ffi', '~> 1.16.3'
gem 'net-ftp', '~> 0.2.0', require: false
gem 'net-http', '~> 0.3.2'
Expand Down
18 changes: 10 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GIT
remote: https://github.com/ontoportal-lirmm/ontologies_api_ruby_client.git
revision: d2134bf8738c82c5bbf7971d7295873f8c6d953a
branch: feature/federated-search
revision: 0598e0068e545a5be9bbb501b0155c8bb2d9afb5
branch: development
specs:
ontologies_api_client (2.2.0)
activesupport (~> 7.0.4)
Expand Down Expand Up @@ -145,6 +145,7 @@ GEM
crass (1.0.6)
css_parser (1.17.1)
addressable
csv (3.3.0)
dalli (3.2.8)
date (3.3.4)
debug (1.9.2)
Expand Down Expand Up @@ -176,7 +177,7 @@ GEM
sass-rails
globalid (1.2.1)
activesupport (>= 6.1)
graphql (2.3.16)
graphql (2.3.18)
base64
fiber-storage
graphql-client (0.23.0)
Expand Down Expand Up @@ -217,7 +218,7 @@ GEM
terminal-table (>= 1.5.1)
i18n-tasks-csv (1.1)
i18n-tasks (~> 0.9)
importmap-rails (2.0.1)
importmap-rails (2.0.3)
actionpack (>= 6.0.0)
activesupport (>= 6.0.0)
railties (>= 6.0.0)
Expand All @@ -228,7 +229,8 @@ GEM
irb (1.14.1)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
iso-639 (0.3.6)
iso-639 (0.3.8)
csv
jquery-rails (4.6.0)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
Expand All @@ -245,7 +247,7 @@ GEM
bindata
faraday (~> 2.0)
faraday-follow_redirects
jwt (2.9.1)
jwt (2.9.3)
base64
language_server-protocol (3.17.0.3)
launchy (3.0.1)
Expand Down Expand Up @@ -293,7 +295,7 @@ GEM
mime-types-data (3.2024.1001)
mini_mime (1.1.5)
minitest (5.25.1)
msgpack (1.7.2)
msgpack (1.7.3)
multi_json (1.15.0)
multi_xml (0.6.0)
multipart-post (2.4.1)
Expand Down Expand Up @@ -516,7 +518,7 @@ GEM
temple (0.10.3)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
terser (1.2.3)
terser (1.2.4)
execjs (>= 0.3.0, < 3)
thor (1.3.2)
tilt (2.4.0)
Expand Down
3 changes: 2 additions & 1 deletion app/assets/stylesheets/components/chips.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@

}
.chips-container.disabled div label > span, .chips-container div label span:has(span.disabled){
opacity: 60%;
opacity: 60%;
background-color: #f8f9fa !important;
}

.chips-container div label input[type="checkbox"]:checked ~ span{
Expand Down
2 changes: 2 additions & 0 deletions app/assets/stylesheets/search.scss
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,15 @@
.search-page-advanced-button .text{
margin-left: 10px;
color: var(--primary-color);
margin-top: 2px;
}

.search-page-advanced-button .icon svg path{
fill: var(--primary-color);
}
.search-page-number-of-results{
color: #888888;
max-width: 800px;
}

.search-page-result-element{
Expand Down
11 changes: 10 additions & 1 deletion app/components/chips_component.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
class ChipsComponent < ViewComponent::Base

renders_one :count
def initialize(id:nil, name:, label: nil, value: nil, checked: false, tooltip: nil, disabled: false)
def initialize(id:nil, name:, label: nil, value: nil, checked: false, tooltip: nil, disabled: false, loading: false)
@id = id || name
@name = name
@value = value || 'true'
@checked = checked
@label = label || @value
@tooltip = tooltip
@disabled = disabled
@loading = loading
end

def checked?
@checked
end

def disabled_class_name
@disabled ? 'disabled' : ''
end

def loading_class_name
@loading ? 'loading' : ''
end
end
20 changes: 12 additions & 8 deletions app/components/chips_component/chips_component.html.haml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
.chips-container{class: @disabled ? 'disabled' : '', 'data-controller': 'tooltip', title: @tooltip}
.chips-container{class: "#{disabled_class_name} #{loading_class_name}", 'data-controller': 'tooltip', title: @tooltip}
%div
%label{:for => "chips-#{@id}-check"}
%input{:id => "chips-#{@id}-check", :name => @name, :type => "checkbox", :value => @value, checked: checked?, disabled: @disabled}
%span
= inline_svg_tag 'check.svg', class: 'chips-check-icon'
%div
= @label
= count
- if @loading
%label
%span.skeleton
- else
%label{:for => "chips-#{@id}-check"}
%input{:id => "chips-#{@id}-check", :name => @name, :type => "checkbox", :value => @value, checked: checked?, disabled: @disabled}
%span
= inline_svg_tag 'check.svg', class: 'chips-check-icon'
%div
= @label
= count
16 changes: 14 additions & 2 deletions app/components/display/search_result_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@ class Display::SearchResultComponent < ViewComponent::Base
include ModalHelper
include MultiLanguagesHelper
include FederationHelper
include ComponentsHelper

renders_many :subresults, Display::SearchResultComponent
renders_many :reuses, Display::SearchResultComponent
def initialize(number: 0,title: nil, ontology_acronym: nil ,uri: nil, definition: nil, link: nil, is_sub_component: false, portal_name: nil, portal_color: nil, portal_light_color: nil, other_portals: [])

def initialize(number: 0,title: nil, ontology_id: nil ,uri: nil, definition: nil, link: nil, is_sub_component: false, portal_name: nil, portal_color: nil, portal_light_color: nil, other_portals: [])
@title = title
@uri = uri
@definition = definition
@link = link
@is_sub_component = is_sub_component
@ontology_acronym = ontology_acronym
@ontology_acronym = ontology_id&.split('/')&.last
@number = number.to_s
@portal_name = portal_name
@portal_color = portal_color
Expand Down Expand Up @@ -74,4 +76,14 @@ def reveal_ontologies_button(text,id,icon)
inline_svg_tag("icons/arrow-down.svg", class: "federated-icon-#{@portal_name}")
end
end

def external_class?
!@portal_name.nil?
end

def all_federated_portals
out = Array(@other_portals)
out.prepend({name: @portal_name, color: @portal_color, light_color: @portal_light_color, link: @link}) if external_class?
out
end
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.search-result-component{class: sub_component_class, 'data-controller': 'reveal-component federation', 'data-federation-config-value': federated_portals.to_h.to_json}
.search-result-component{class: sub_component_class, 'data-controller': 'reveal-component'}
%a.title{href: @link, style: @portal_color ? "color: #{@portal_color} !important" : '', target: @portal_color ? "_blank" : ''}
.d-flex.align-items-center
= @title
Expand All @@ -10,17 +10,15 @@
- if @definition
= display_in_multiple_languages(@definition)
.actions
- unless @portal_name
- unless external_class?
= details_button
= visualize_button
= mappings_button
- if subresults?
= reveal_ontologies_button("#{subresults.size} #{t('search.result_component.more_from_ontology')}", sub_ontologies_id, 'icons/three-dots.svg')
- if reuses?
= reveal_ontologies_button("#{t('search.result_component.reuses_in')} #{reuses.size} ontologies", reuses_id, 'icons/reuses.svg')
- if @portal_name
= portal_button(name: @portal_name, color: @portal_color, light_color: @portal_light_color, link: @link, tooltip: "Source #{@portal_name.humanize.gsub("portal", "Portal")}")
- @other_portals.each do |p|
- all_federated_portals.each do |p|
= portal_button(name: p[:name], color: p[:color], light_color: p[:light_color], link: p[:link], tooltip: "Source #{p[:name].humanize.gsub("portal", "Portal")}")
- if subresults?
.more-from-ontology.d-none{id: sub_ontologies_id}
Expand All @@ -35,4 +33,4 @@
.search-result-sub-components
- reuses.each do |reuse|
.search-result-sub-component
= reuse
= reuse
13 changes: 13 additions & 0 deletions app/components/federated_portal_button_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

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

def initialize(name:, link:, color:, tooltip:, light_color:)
@name = name
@tooltip = tooltip
@link = link
@color = color
@light_color = light_color
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +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" : '' }
= inline_svg_tag('logos/ontoportal.svg', class: "federated-icon-#{name.downcase}")
%div{ class: 'text', style: color ? "color: #{color} !important" : '' }
= name.humanize.gsub("portal", "Portal")
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
static values = {
color: String,
portalName: String,
}
connect() {
this.#initIconsStyle()
}

#initIconsStyle(){
const style = document.createElement('style');
style.innerHTML = `.federated-icon-${this.portalNameValue} path { fill: ${this.colorValue} !important; }\n`;
document.head.appendChild(style);
}

}
4 changes: 2 additions & 2 deletions app/components/ontology_browse_card_component.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class OntologyBrowseCardComponent < ViewComponent::Base
include ApplicationHelper, OntologiesHelper, FederationHelper
include ApplicationHelper, OntologiesHelper, FederationHelper, ComponentsHelper

def initialize(ontology: nil, onto_link: nil, text_color: nil, bg_light_color: nil, portal_name: nil)
super
Expand All @@ -17,7 +17,7 @@ def ontology
end

def external_ontology?
!internal_ontology?(@ontology[:id]) || (Array(@ontology[:sources]).size > 1)
!internal_ontology?(@ontology[:id])
end

def onto_link
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@
%span.mx-1{data:{controller:'tooltip'}, title: t('components.view_of_the_ontology', ontology: ontology[:viewOfOnt].split('/').last )}
= render ChipButtonComponent.new(type: "clickable", text: t('components.view'), style: style_bg)

- if external_ontology?
- ontology[:sources].each do |id|
- config = ontology_portal_config(id)&.last || internal_portal_config(id) || {}
- unless config.blank?
%span{style: "padding: 3px 0; margin-right: 0.25rem;"}
= portal_button(name: config[:name], color: @text_color, light_color: @bg_light_color, link: ontoportal_ui_link(id), tooltip: "Source #{config[:name]}")

- ontology[:sources]&.each do |id|
- config = ontology_portal_config(id)&.last || internal_portal_config(id) || {}
- unless config.blank?
%span{style: "padding: 3px 0; margin-right: 0.25rem;"}
= portal_button(name: config[:name], color: config[:color], light_color: config[:"light-color"], link: ontoportal_ui_link(id), tooltip: "Source #{config[:name]}")

- if session[:user]&.admin?
%div.mx-1{title: content_tag(:div, debug(ontology), style: 'height: 300px; overflow: scroll'), data:{controller: 'tooltip', 'tooltip-interactive-value': 'true'}}
Expand All @@ -97,4 +97,4 @@
.two
.browse-sket-column-three
.one
.two
.two
Loading

0 comments on commit afabee9

Please sign in to comment.