Skip to content

Commit

Permalink
Feature: Add back slices (#598)
Browse files Browse the repository at this point in the history
* Add slices section to home page

* Update the design of the slice top notice bar

* fix home slice name styles

* fix slices error on home page, when there are no slices available

* make the annotator support slices

* make browse page compatible with slices

* update home slices section to include the number of ontologies per slice and the description

* make mappings page supports slices

* rearrange home page sections to be in this order: slices, ontoportal instances then collaborations

* remove unnecessary code in submission filter file

* Adjust the slice link to comply with the production URL

* update home page slices section style

* add a description to the home page slice section

* update home page slices section style

* update ontoportal instances and support home sections styles

* change the button of add new slice to suggest a new group/slice in the home page

* update slices descriptive texti in the home page

* add a description for ontoportal instances in the home page

* move home_ontoportal_tooltip to home helper

* add ontoportal links in config file

* remove http from slice link to make it work with https

* add slice notice to lang local files

* remove mappings statistics slices support in the UI cause it's already done in the back

* update ontoportal website links to be upper case

* fix slices https issue

---------

Co-authored-by: Syphax bouazzouni <[email protected]>
  • Loading branch information
Bilelkihal and syphax-bouazzouni committed Jun 14, 2024
1 parent 3121de5 commit ce19306
Show file tree
Hide file tree
Showing 15 changed files with 204 additions and 57 deletions.
36 changes: 18 additions & 18 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ GEM
railties (> 3.1)
childprocess (5.0.0)
coderay (1.1.3)
concurrent-ruby (1.3.2)
concurrent-ruby (1.3.3)
crack (1.0.0)
bigdecimal
rexml
Expand All @@ -152,7 +152,7 @@ GEM
docile (1.4.0)
domain_name (0.6.20240107)
ed25519 (1.3.0)
erubi (1.12.0)
erubi (1.13.0)
erubis (2.7.0)
excon (0.110.0)
execjs (2.9.1)
Expand All @@ -172,7 +172,7 @@ GEM
sass-rails
globalid (1.2.1)
activesupport (>= 6.1)
graphql (2.3.4)
graphql (2.3.5)
base64
graphql-client (0.22.0)
activesupport (>= 3.0)
Expand Down Expand Up @@ -312,7 +312,7 @@ GEM
net-protocol
net-ssh (7.2.3)
netrc (0.11.0)
newrelic_rpm (9.9.0)
newrelic_rpm (9.10.2)
nio4r (2.7.3)
nokogiri (1.15.6-x86_64-darwin)
racc (~> 1.4)
Expand Down Expand Up @@ -353,8 +353,8 @@ GEM
omniauth-rails_csrf_protection (1.0.2)
actionpack (>= 4.2)
omniauth (~> 2.0)
parallel (1.24.0)
parser (3.3.2.0)
parallel (1.25.1)
parser (3.3.3.0)
ast (~> 2.4.1)
racc
popper_js (1.16.1)
Expand Down Expand Up @@ -397,9 +397,9 @@ GEM
rails-i18n (7.0.9)
i18n (>= 0.7, < 2)
railties (>= 6.0.0, < 8)
railties (7.0.7)
actionpack (= 7.0.7)
activesupport (= 7.0.7)
railties (7.0.3)
actionpack (= 7.0.3)
activesupport (= 7.0.3)
method_source
rake (>= 12.2)
thor (~> 1.0)
Expand All @@ -415,19 +415,19 @@ GEM
json
redcarpet (3.6.0)
regexp_parser (2.9.2)
reline (0.5.8)
reline (0.5.9)
io-console (~> 0.5)
rest-client (2.1.0)
http-accept (>= 1.7.0, < 2.0)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
rexml (3.2.8)
strscan (>= 3.0.9)
rouge (4.2.1)
rexml (3.3.0)
strscan
rouge (4.3.0)
rspec-core (3.13.0)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.0)
rspec-expectations (3.13.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.1)
Expand Down Expand Up @@ -505,12 +505,12 @@ GEM
net-ssh (>= 2.8.0)
stimulus-rails (1.3.3)
railties (>= 6.0.0)
stringio (3.1.0)
stringio (3.1.1)
strscan (3.1.0)
temple (0.10.3)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
terser (1.2.2)
terser (1.2.3)
execjs (>= 0.3.0, < 3)
thor (1.3.1)
tilt (2.3.0)
Expand Down Expand Up @@ -594,7 +594,7 @@ DEPENDENCIES
mysql2
net-ftp (~> 0.2.0)
net-http (~> 0.3.2)
newrelic_rpm (< 9.10.0)
newrelic_rpm
oj
omniauth
omniauth-github
Expand All @@ -605,7 +605,7 @@ DEPENDENCIES
ontologies_api_client!
pry
puma (~> 5.0)
rails (= 7.0.7)
rails (= 7.0.3)
rails-i18n (~> 7.0.0)
recaptcha (~> 5.9.0)
rest-client
Expand Down
4 changes: 4 additions & 0 deletions app/assets/images/icons/slices.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
74 changes: 67 additions & 7 deletions app/assets/stylesheets/home.scss
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,59 @@ i.fa.fa-caret-square-o-down {
margin-bottom: 5px;
font-weight: 700;
}

.home-section-title{
display: flex;
flex-direction: column;
align-items: start;
}
.home-section-title .text{
font-size: 20px;
font-weight: 600;
margin-bottom: 0;
}
.home-slice > a{
display: flex;
align-items: center;
}
.home-slice-icon{
display: flex;
flex-direction: column;
align-items: center;
}
.home-slice-icon svg{
width: 40px;
height: 40px;
}
.home-slices-container{
display: flex;
flex-wrap: wrap;
margin-top: 20px;
}
.home-section-description{
color: #888888;
}
.home-slice{
border: 1px solid var(--primary-color);
border-radius: 8px;
padding: 4px 15px;
margin-right: 20px;
margin-bottom: 20px;
}
.home-ontoportal-instances{
margin-top: 50px;
background: #FBFBFB;
width: 100%;
display: flex;
justify-content: center;
}
.ontoportal-instances-container{
padding: 0 50px;
width: 1248px;
padding-bottom: 20px;
}
.home-section-title.ontoportal{
margin-top: 20px;
}
.home-section-line{
width: 60px;
margin-top: 3px;
Expand All @@ -169,17 +221,26 @@ i.fa.fa-caret-square-o-down {
}
.home-statistics-container > div {
display: flex;
align-items: center;
align-items: start;
justify-content: center;
flex-wrap: wrap;
}
.home-agroportal-figures{
margin-bottom: 20px;
}

.home-slice-name{
font-size: 16px;
font-weight: 400;
margin-left: 10px;
}
.home-slice-ontologies{
font-size: 18px;
font-weight: 500;
margin-bottom: -18px;
}
.home-statistics-container > div > p {
font-size: 20px;
font-weight: 600;
margin-left: 18px;
margin-bottom: 0;
}
.home-statistics-item{
Expand Down Expand Up @@ -414,7 +475,6 @@ i.fa.fa-caret-square-o-down {
}
.home-support-items{
display: flex;
justify-content: center;
flex-wrap: wrap;
img{
object-fit: scale-down;
Expand All @@ -429,8 +489,8 @@ i.fa.fa-caret-square-o-down {
border-radius: 50%;
display: block;
}
.home-support-items > *:not(:first-child){
margin-left: 40px;
.home-support-items > div, .home-support-items > a {
margin-right: 40px;
}
.home-support-items a{
margin-bottom: 40px;
Expand Down
23 changes: 23 additions & 0 deletions app/assets/stylesheets/notice.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,26 @@ div#notice_message {
}
}

.slice-notice-bar-container{
background-color: var(--warning-color);
display: flex;
justify-content: center;
}
.slice-notice-bar{
width: var(--container-max-width);
padding: 10px 40px;
display: flex;
justify-content: space-between;
align-items: center;
color: white;
}
.slice-notice-bar>div{
display: flex;
}
.slice-notice-bar .slice-name{
margin-left: 5px;
font-weight: 600;
}
.slice-notice-bar .warning-button.primary-button{
background-color: #efb300 !important;
}
2 changes: 1 addition & 1 deletion app/assets/stylesheets/theme-variables.scss.erb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
// common variables
:root{
--error-color: #EB4335;
--warning-color: #e48c11;
--warning-color: #F2BE22;
--gray-color: #888888;
--success-color: #2DC54E;
--admin-color: #145FF4;
Expand Down
17 changes: 16 additions & 1 deletion app/controllers/annotator_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,23 @@ def annotator_results(uri)
else
@results_table_header.push(t('annotator.score'))
end
annotations = LinkedData::Client::HTTP.get(uri.dup.to_s, api_params)

# if we are in a slice, pass the ontologies of this slice in the params

if at_slice?
slice_ontologies_acronyms = @subdomain_filter[:ontologies].map{ |id| link_last_part(id)}
if api_params[:ontologies]
selected_ontolgies = api_params[:ontologies].split(',')
filtred_ontologies = selected_ontolgies.select{ |ontology| slice_ontologies_acronyms.include?(ontology) }
else
filtred_ontologies = slice_ontologies_acronyms
end
api_params[:ontologies] = filtred_ontologies.join(',')
end

annotations = LinkedData::Client::HTTP.get(uri, api_params)
@ontologies = LinkedData::Client::Models::Ontology.all({:include_views => true}).map{ |o| [o.id.to_s, o]}.to_h

@semantic_types = get_semantic_types
@results = []
annotations.each do |annotation|
Expand Down
1 change: 1 addition & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ def domain_ontology_set
@subdomain_filter[:active] = true
@subdomain_filter[:name] = slice.name
@subdomain_filter[:acronym] = slice.acronym
@subdomain_filter[:ontologies] = slice.ontologies
end
end

Expand Down
1 change: 1 addition & 0 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def index
metrics = metrics.each_with_object(Hash.new(0)) do |h, sum|
h.to_hash.slice(:classes, :properties, :individuals).each { |k, v| sum[k] += v }
end
@slices = LinkedData::Client::Models::Slice.all

@cls_count = metrics[:classes]
@individuals_count = metrics[:individuals]
Expand Down
1 change: 1 addition & 0 deletions app/controllers/mappings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def index
end
@options[select_text] = ontology_acronym
end


@options = @options.sort
@options.unshift([])
Expand Down
6 changes: 6 additions & 0 deletions app/helpers/home_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,10 @@ def discover_ontologies_button
end
end

def home_ontoportal_tooltip
ontoportal_link = link_to("(#{$ONTOPORTAL_WEBSITE_LINK})", $ONTOPORTAL_WEBSITE_LINK, target: '_blank')
github_link = link_to("(#{$ONTOPORTAL_GITHUB_REPO})", $ONTOPORTAL_GITHUB_REPO, target: '_blank')
content_tag(:div, t('home.ontoportal_description', ontoportal_link: ontoportal_link, github_link: github_link).html_safe, style: "max-width: 600px;")
end

end
55 changes: 41 additions & 14 deletions app/views/home/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -176,20 +176,38 @@
.home-statistics-link.justify-content-end
= link_to t("home.see_details"),'/statistics', target: "_blank"

.home-section
.home-statistics-container
.home-support-title
%p= t('home.support_and_collaborations')
- if @slices
.home-section
.home-section-title
.text
= "#{portal_name} slices"
%hr.home-section-line/
.home-support-items
- $HOME_PAGE_LOGOS&.each do |logo|
%a{href:logo[:url], target: "_blanc"}
%img{src: asset_path(logo[:img_src])}

.home-section
.home-statistics-container
.home-support-title
%p= t('home.ontoportal_instances')
.home-section-description
.div
= t('home.slices_description')
.home-slices-container
- @slices.each do |slice, index|
- slice_link = "https://#{slice.acronym}.#{$UI_URL.sub("https://", "")}"
.home-slice{'data-controller': 'tooltip', title: content_tag(:div, slice.description, style: 'max-width: 200px')}
= link_to slice_link, target: '_blank' do
.home-slice-icon
.home-slice-ontologies
= slice.ontologies.length
= inline_svg 'icons/slices.svg', width: "70", height: "70"

.home-slice-name
= "#{slice.name} (#{slice.acronym})"
= render Buttons::RegularButtonComponent.new(id:'regular-button', value: t('home.suggest_slice'), variant: "secondary", state: "regular", href: '/feedback') do |btn|
- btn.icon_right do
= inline_svg_tag "icons/plus.svg"

.home-ontoportal-instances
.ontoportal-instances-container
.home-section-title.ontoportal
.d-flex.align-items-center
.text.mr-2
= t('home.ontoportal_instances')
= render Display::InfoTooltipComponent.new(text: home_ontoportal_tooltip)
%hr.home-section-line/
.home-support-items
- $PORTALS_INSTANCES&.each do |portal|
Expand All @@ -198,7 +216,16 @@
= inline_svg 'logo-white.svg', width: "35", height: "26"
%p{style: "color: #{portal[:color]}"}
= portal[:portal]


.home-section
.home-section-title
.text
= t('home.support_and_collaborations')
%hr.home-section-line/
.home-support-items
- $HOME_PAGE_LOGOS&.each do |logo|
%a{href:logo[:url], target: "_blanc"}
%img{src: asset_path(logo[:img_src])}

:javascript
function submitAnnotator(){
Expand Down
Loading

0 comments on commit ce19306

Please sign in to comment.