mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-28 17:54:16 +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() {
|
function applyClickCallbackOnProtocolCards() {
|
||||||
$('.protocol-card').off('click').on('click', function(e) {
|
$('.protocol-card').off('click').on('click', function(e) {
|
||||||
var currProtocolCard = $(this);
|
var currProtocolCard = $(this);
|
||||||
|
var baseTag = document.createElement('base');
|
||||||
|
|
||||||
// Check whether this card is already active and deactivate it
|
// Check whether this card is already active and deactivate it
|
||||||
if ($(currProtocolCard).hasClass('active')) {
|
if ($(currProtocolCard).hasClass('active')) {
|
||||||
|
@ -30,7 +31,14 @@ function applyClickCallbackOnProtocolCards() {
|
||||||
$('.empty-preview-panel').hide();
|
$('.empty-preview-panel').hide();
|
||||||
$('.full-preview-panel').show();
|
$('.full-preview-panel').show();
|
||||||
$('.btn-holder').html($(currProtocolCard).find('.external-import-btn').clone());
|
$('.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);
|
iFrame.contents().find('body').html(data.html);
|
||||||
|
|
||||||
scrollbox.scrollTo(0);
|
scrollbox.scrollTo(0);
|
||||||
iFrame.contents().find('body').find('table.htCore').css('width', '100%');
|
iFrame.contents().find('body').find('table.htCore').css('width', '100%');
|
||||||
iFrame.contents().find('body').find('span').css('word-break', 'break-word');
|
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
|
api_client = "ProtocolImporters::#{endpoint_name}::ApiClient".constantize.new
|
||||||
|
|
||||||
html_preview = api_client.protocol_html_preview(show_params[:protocol_id])
|
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: {
|
render json: {
|
||||||
protocol_source: show_params[:protocol_source],
|
protocol_source: show_params[:protocol_source],
|
||||||
protocol_id: show_params[:protocol_id],
|
protocol_id: show_params[:protocol_id],
|
||||||
|
base_uri: base_uri,
|
||||||
html: html_preview
|
html: html_preview
|
||||||
}
|
}
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
|
@ -103,15 +106,15 @@ class ExternalProtocolsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def index_params
|
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
|
end
|
||||||
|
|
||||||
def show_params
|
def show_params
|
||||||
params.permit(:protocol_source, :protocol_id)
|
params.permit(:team_id, :protocol_source, :protocol_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def new_params
|
def new_params
|
||||||
params.permit(:protocol_source, :protocol_client_id)
|
params.permit(:team_id, :protocol_source, :protocol_client_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_protocol_params
|
def create_protocol_params
|
||||||
|
|
Loading…
Reference in a new issue