diff --git a/app/assets/images/check.svg b/app/assets/images/check.svg new file mode 100644 index 0000000000..1a407a02d4 --- /dev/null +++ b/app/assets/images/check.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/app/components/concept_details_component.rb b/app/components/concept_details_component.rb index 2f55a5ddaa..e11a457876 100644 --- a/app/components/concept_details_component.rb +++ b/app/components/concept_details_component.rb @@ -40,15 +40,14 @@ def row_hash_properties(properties_set, ontology_acronym, &block) values = data[:values] url = data[:key] - - is_list = values.is_a?(Array) && values.size > 1 + style_as_badge = values.is_a?(Array) && values.size > 1 && short_values(values) ajax_links = Array(values).map do |v| if block_given? capture(v, &block) else if v.is_a?(String) - get_link_for_cls_ajax(v, ontology_acronym, '_blank', is_list) + get_link_for_cls_ajax(v, ontology_acronym, '_blank', style_as_badge) else display_in_multiple_languages([v].to_h, style_as_badge: true) end @@ -63,6 +62,18 @@ def row_hash_properties(properties_set, ontology_acronym, &block) out end + def short_values(vals) + vals.each do |str| + word_count = str.split.count + character_count = str.length + + unless word_count < 10 && character_count < 100 + return false + end + end + true + end + def properties_set_by_keys(keys, concept_properties, exclude_keys = []) concept_properties&.select do |k, v| (keys.include?(k) || !keys.select { |key| v[:key].to_s.include?(key) }.empty?) && !exclude_keys.include?(k) && diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index a460c29423..0230592f5f 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -14,14 +14,16 @@ class AdminController < ApplicationController def index @users = LinkedData::Client::Models::User.all + if session[:user].nil? || !session[:user].admin? redirect_to controller: 'login', action: 'index', redirect: '/admin' else + update_info(false) render action: 'index' end end - def update_info + def update_info(render_response = true) response = { update_info: {}, errors: '', success: '', notices: '' } json = LinkedData::Client::HTTP.get("#{ADMIN_URL}update_info", params, raw: true) @@ -32,6 +34,7 @@ def update_info response[:errors] = update_info['error'] response[:update_info] = update_info else + @update_info = update_info.symbolize_keys response[:update_info] = update_info response[:notices] = update_info['notes'] if update_info['notes'] response[:success] = 'Update info successfully retrieved' @@ -39,7 +42,7 @@ def update_info rescue StandardError => e response[:errors] = "Problem retrieving update info - #{e.message}" end - render json: response + render json: response if render_response end def update_check_enabled diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index d865e018b2..c60dd47cf5 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -379,12 +379,11 @@ def get_link_for_cls_ajax(cls_id, ont_acronym, target = nil, style_as_badge = fa if style_as_badge render ChipButtonComponent.new(text: cls_id) else - content_tag(:span, cls_id) + content_tag(:div, cls_id) end end end - def get_link_for_ont_ajax(ont_acronym) # Ajax call will replace the acronym with an ontology name (triggered by class='ont4ajax') href_ont = " href='#{bp_ont_link(ont_acronym)}' " diff --git a/app/javascript/controllers/clipboard_controller.js b/app/javascript/controllers/clipboard_controller.js deleted file mode 100644 index 30320b5e30..0000000000 --- a/app/javascript/controllers/clipboard_controller.js +++ /dev/null @@ -1,16 +0,0 @@ -import { Controller } from "@hotwired/stimulus" - -// Connects to data-controller="clipboard" -export default class extends Controller { - static targets = ['source', 'copiedIndicator'] - - copy() { - navigator.clipboard.writeText(this.sourceTarget.textContent); - - this.copiedIndicatorTarget.classList.remove('hidden'); - - setTimeout(() => { - this.copiedIndicatorTarget.classList.add('hidden'); - }, 2000); - } -} diff --git a/app/javascript/controllers/index.js b/app/javascript/controllers/index.js index fdf72f2dca..a758a7823e 100644 --- a/app/javascript/controllers/index.js +++ b/app/javascript/controllers/index.js @@ -19,8 +19,8 @@ application.register("change-requests", ChangeRequestsController) import LanguageChangeController from "./language_change_controller" application.register("language-change", LanguageChangeController) -import ClipboardController from "./clipboard_controller" -application.register("clipboard", ClipboardController) +import ClipboardComponentController from '../../components/clipboard_component/clipboard_component_controller' +application.register('clipboard', ClipboardComponentController) import LoadChartController from "./load_chart_controller" application.register("load-chart", LoadChartController) diff --git a/app/views/admin/index.html.haml b/app/views/admin/index.html.haml index ebd4340aaa..4b11cdd6aa 100644 --- a/app/views/admin/index.html.haml +++ b/app/views/admin/index.html.haml @@ -56,15 +56,11 @@ %div#site-admin-appliance-id.mb-5 %div.site-admin-page-header APPLIANCE ID - %dive.site-admin-page-section - %div{'data-controller': 'clipboard'} - %div#appliance-id - %span{'data-clipboard-target': 'source'} - %div{class: 'd-flex align-items-center mt-2'} - = tag.button('Copy to clipboard', 'data-action': 'clipboard#copy', - class: 'btn btn-sm btn-outline-secondary') - %span{'data-clipboard-target': 'copiedIndicator', - class: 'hidden text-success fw-semibold ms-2'} Copied! + %div.site-admin-page-section + %div#appliance-id + %span + = content_tag(:span, style: 'display: inline-block;') do + = render ClipboardComponent.new(message: @update_info[:appliance_id], title: 'Copy Appliance ID', show_content: false) -# Ontology Administration tab %div.tab-pane.fade{id: "ontology-admin", role: "tabpanel", aria: { labelledby: "ontology-admin-tab" }} diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index 28f42ff7c6..966f721775 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -29,11 +29,9 @@ -# User's API key %h4{class: 'pb-2 my-4 border-bottom'} API Key = tag.p("Your API key can be used to access the #{$SITE} RESTful API and services", class: 'text-muted') - %div{'data-controller': 'clipboard'} - %span{'data-clipboard-target': 'source'}= session[:user].apikey - %div{class: 'd-flex align-items-center mt-2'} - = tag.button 'Copy to clipboard', 'data-action': 'clipboard#copy', class: 'btn btn-sm btn-outline-secondary' - %span{'data-clipboard-target': 'copiedIndicator', class: 'hidden text-success fw-semibold ms-2'} Copied! + = session[:user].apikey + = content_tag(:span, style: 'display: inline-block;') do + = render ClipboardComponent.new(message: session[:user].apikey, title: 'Copy API Key', show_content: false) -# User's subscriptions - unless @user.subscription.blank?