From 08bbab0d1cf2e523d9ad6a8c24b9ae4fca286741 Mon Sep 17 00:00:00 2001 From: Syphax Date: Sat, 12 Oct 2024 15:49:15 +0200 Subject: [PATCH 01/14] remove ontology bridge code --- .env.sample | 2 +- app/assets/javascripts/bp_ontolobridge.js | 359 --------------------- app/assets/stylesheets/ontolobridge.scss | 35 -- app/controllers/ontolobridge_controller.rb | 64 ---- app/helpers/application_helper.rb | 5 - app/views/concepts/_load.html.haml | 21 -- app/views/concepts/_request_term.html.haml | 45 --- config/application.rb | 1 - config/bioportal_config_env.rb.sample | 6 +- config/initializers/graphql_client.rb | 1 - config/locales/en.yml | 19 -- config/routes.rb | 6 +- 12 files changed, 3 insertions(+), 561 deletions(-) delete mode 100644 app/assets/javascripts/bp_ontolobridge.js delete mode 100644 app/assets/stylesheets/ontolobridge.scss delete mode 100644 app/controllers/ontolobridge_controller.rb delete mode 100644 app/views/concepts/_load.html.haml delete mode 100644 app/views/concepts/_request_term.html.haml diff --git a/.env.sample b/.env.sample index 94f4a336b..e8c76bf36 100644 --- a/.env.sample +++ b/.env.sample @@ -8,7 +8,7 @@ UI_URL=http://localhost:3000 API_URL=http://localhost:9393 API_KEY= -UI_THEME=ontoportal +UI_THEME=bioportal BIOMIXER_URL= BIOMIXER_APIKEY= diff --git a/app/assets/javascripts/bp_ontolobridge.js b/app/assets/javascripts/bp_ontolobridge.js deleted file mode 100644 index d4acc3e97..000000000 --- a/app/assets/javascripts/bp_ontolobridge.js +++ /dev/null @@ -1,359 +0,0 @@ -function bindAddRequestTermClick() { - jQuery("a.add_request_term").live('click', function(){ - var id = jQuery(this).attr("data-parent-id"); - addRequestTermBox(id); - }); -} - -function bindCancelRequestTermClick() { - jQuery(".request_term_form_div .cancel").live('click', function() { - removeRequestTermBox(); - }); -} - -function bindNewTermInstructionsClick() { - jQuery("#new_term_instructions").live("click", function() { - jQuery(this).trumbowyg({ - btns: [ - ['viewHTML'], - ['undo', 'redo'], // Only supported in Blink browsers - ['formatting'], - ['strong', 'em', 'del'], - ['superscript', 'subscript'], - ['link'], - ['insertImage'], - ['justifyLeft', 'justifyCenter', 'justifyRight', 'justifyFull'], - ['unorderedList', 'orderedList'], - ['horizontalRule'], - ['removeformat'], - ['fullscreen'] - ] - }); - jQuery("#new_term_instructions_submit").show(); - jQuery("#new_term_instructions_cancel").show(); - }); -} - -function bindNewTermInstructionsSubmit() { - jQuery("#new_term_instructions_submit").live("click", function() { - saveNewTermInstructions(); - }); -} - -function bindNewTermInstructionsCancel() { - jQuery("#new_term_instructions_cancel").live("click", function() { - var oldVal = jQuery("#new_term_instructions_old").val().trim(); - var curVal = jQuery('#new_term_instructions').html().trim(); - - if (oldVal != curVal) { - if (confirm('Are you sure you want to discard your changes?')) { - jQuery('#new_term_instructions').trumbowyg('destroy'); - jQuery('#new_term_instructions').html(oldVal); - hideButtons(); - } - } else { - jQuery('#new_term_instructions').trumbowyg('destroy'); - hideButtons(); - } - }); -} - -function preventNewTermInstructionsFormSubmit() { - jQuery("#new_term_instructions_form").submit(function(e) { - e.preventDefault(e); - }); -} - -function clearProgressMessage(parentContainerID) { - var progMsgElem = jQuery("#" + parentContainerID + " #progress_message"); - progMsgElem.hide(); - progMsgElem.html(""); -} - -function showProgressMessage(parentContainerID) { - clearProgressMessage(parentContainerID); - var msg = "Saving..."; - var progMsgElem = jQuery("#" + parentContainerID + " #progress_message"); - progMsgElem.text(msg).html(); - progMsgElem.show(); -} - -function saveNewTermInstructions() { - var params = jQuery('#new_term_instructions_form').serialize(); - var newInstructions = jQuery('#new_term_instructions').html().trim(); - params += '&new_term_instructions=' + newInstructions; - var parentContainerID = 'new_term_instructions_container'; - showProgressMessage(parentContainerID); - - jQuery.ajax({ - type: "POST", - url: "/ontolobridge/save_new_term_instructions", - dataType: "json", - data: params, - success: function(data) { - var status = data[1]; - - if (status && status >= 400 || data[0]['error'].length) { - showStatusMessages('', data[0]['error']); - } else { - jQuery('#new_term_instructions').trumbowyg('destroy'); - jQuery("#new_term_instructions_old").val(newInstructions); - showStatusMessages(data[0]["success"], ''); - setTimeout(function() { clearStatusMessages(); }, 5000); - } - }, - error: function(request, textStatus, errorThrown) { - showStatusMessages('', errorThrown); - }, - complete: function(request, textStatus) { - clearProgressMessage(parentContainerID); - hideButtons(); - } - }); -} - -function hideButtons() { - jQuery("#new_term_instructions_submit").hide(); - jQuery("#new_term_instructions_cancel").hide(); -} - -function bindRequestTermSaveClick() { - var success = ""; - var error = ""; - var user = jQuery(document).data().bp.user; - var ontology_id = jQuery(document).data().bp.ont_viewer.ontology_id; - var params = jQuery("#request_term_form").serialize(); - params += "&ontology=" + ontology_id + "&email=" + user["email"] - - if (user["firstName"] && user["lastName"]) { - params += "&submitter=" + user["firstName"] + " " + user["lastName"]; - } - - var parentContainerID = 'proposal_buttons'; - showProgressMessage(parentContainerID); - - jQuery.ajax({ - type: "POST", - url: "/ontolobridge", - data: params, - dataType: "json", - success: function(data) { - var status = data[1]; - - if (status && status >= 400) { - showStatusMessages('', data[0]["error"]); - } else { - var msg = "A new term request has been submitted successfully:

"; - removeRequestTermBox(); - - for (var i in data[0]) { - msg += i + ": " + data[0][i] + "
"; - } - showStatusMessages(msg, error); - } - }, - error: function(request, textStatus, errorThrown) { - error = "The following error has occurred: " + errorThrown + ". Please try again."; - showStatusMessages(success, error); - }, - complete: function(request, textStatus) { - clearProgressMessage(parentContainerID); - } - }); -} - -function removeRequestTermBox() { - jQuery(".request_term_form_div").html(""); -} - -function addRequestTermBox(id) { - clearStatusMessages(); - var formContainer = jQuery(".request_term_form_div"); - var requestTermForm = requestTermFields(id, formContainer); - var formID = requestTermForm.attr('id'); - var isPopulated = window.localStorage.getItem(formID + '_populated'); - - if (isPopulated) { - for (var key in window.localStorage) { - if (key.startsWith(formID)) { - var elemID = key.replace(formID + '_', ''); - var elem = jQuery('#' + formID + ' #' + elemID); - - if (elem.attr('type') === "checkbox") { - elem.prop("checked", true); - } else if (elem.length > 0) { - var val = window.localStorage.getItem(key); - elem.val(val); - } - window.localStorage.removeItem(key); - } - } - } - formContainer.show(); - jQuery("#label").focus(); -} - -function clearStatusMessages() { - jQuery("#ob_success_message").hide(); - jQuery("#ob_error_message").hide(); - jQuery("#ob_success_message").html(""); - jQuery("#ob_error_message").html(""); -} - -function showStatusMessages(success, error) { - if (success.length > 0) { - let ob = jQuery("#ob_success_message") - console.log('show ob message') - console.log(ob) - ob.html(success); - ob.show(); - } - - if (error.length > 0) { - jQuery("#ob_error_message").text(error).html(); - jQuery("#ob_error_message").show(); - } -} - -function requestTermButtons() { - var buttonSubmit = jQuery("