mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-28 09:43:01 +08:00
Fix relative links in protocolsio iframe
Closes SCI-3660
This commit is contained in:
parent
7ac410e573
commit
5eb197127f
2 changed files with 14 additions and 3 deletions
|
@ -4,6 +4,7 @@
|
|||
function applyClickCallbackOnProtocolCards() {
|
||||
$('.protocol-card').off('click').on('click', function(e) {
|
||||
var currProtocolCard = $(this);
|
||||
var baseTag = document.createElement('base');
|
||||
|
||||
// Check whether this card is already active and deactivate it
|
||||
if ($(currProtocolCard).hasClass('active')) {
|
||||
|
@ -30,7 +31,14 @@ function applyClickCallbackOnProtocolCards() {
|
|||
$('.empty-preview-panel').hide();
|
||||
$('.full-preview-panel').show();
|
||||
$('.btn-holder').html($(currProtocolCard).find('.external-import-btn').clone());
|
||||
|
||||
// Set base tag to account for relative links in the iframe
|
||||
baseTag.href = data.base_uri;
|
||||
iFrame.contents().find('head').html(baseTag);
|
||||
|
||||
// Set iframe content
|
||||
iFrame.contents().find('body').html(data.html);
|
||||
|
||||
scrollbox.scrollTo(0);
|
||||
iFrame.contents().find('body').find('table.htCore').css('width', '100%');
|
||||
iFrame.contents().find('body').find('span').css('word-break', 'break-word');
|
||||
|
|
|
@ -31,10 +31,13 @@ class ExternalProtocolsController < ApplicationController
|
|||
api_client = "ProtocolImporters::#{endpoint_name}::ApiClient".constantize.new
|
||||
|
||||
html_preview = api_client.protocol_html_preview(show_params[:protocol_id])
|
||||
base_uri = URI.parse(html_preview.request.last_uri.to_s)
|
||||
base_uri = "#{base_uri.scheme}://#{base_uri.host}"
|
||||
|
||||
render json: {
|
||||
protocol_source: show_params[:protocol_source],
|
||||
protocol_id: show_params[:protocol_id],
|
||||
base_uri: base_uri,
|
||||
html: html_preview
|
||||
}
|
||||
rescue StandardError => e
|
||||
|
@ -103,15 +106,15 @@ class ExternalProtocolsController < ApplicationController
|
|||
end
|
||||
|
||||
def index_params
|
||||
params.permit(:protocol_source, :key, :page_id, :page_size, :sort_by)
|
||||
params.permit(:team_id, :protocol_source, :key, :page_id, :page_size, :sort_by)
|
||||
end
|
||||
|
||||
def show_params
|
||||
params.permit(:protocol_source, :protocol_id)
|
||||
params.permit(:team_id, :protocol_source, :protocol_id)
|
||||
end
|
||||
|
||||
def new_params
|
||||
params.permit(:protocol_source, :protocol_client_id)
|
||||
params.permit(:team_id, :protocol_source, :protocol_client_id)
|
||||
end
|
||||
|
||||
def create_protocol_params
|
||||
|
|
Loading…
Reference in a new issue