From 798e5688cbfa2bfb249f33a33b2a32c56a6b62e2 Mon Sep 17 00:00:00 2001 From: Jaden Diefenbaugh <jaden.diefenbaugh@idiap.ch> Date: Tue, 19 Dec 2017 12:16:49 +0100 Subject: [PATCH] more url fixes when injecting plots into reports --- .../static/reports/app/services/plotService.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/beat/web/reports/static/reports/app/services/plotService.js b/beat/web/reports/static/reports/app/services/plotService.js index b8ae139df..b3efb372a 100644 --- a/beat/web/reports/static/reports/app/services/plotService.js +++ b/beat/web/reports/static/reports/app/services/plotService.js @@ -117,7 +117,9 @@ angular.module('reportApp').factory('PlotService', ['UrlService', function(UrlSe }; const fetchDownload = (requestData, contentType) => { - const urlPrefix = ''; + let prefix = new URL(UrlService.getPrefix()).pathname; + if(prefix.endsWith('/')) + prefix = prefix.slice(0, -1); // override the 'merged' property to always request the merged version. // requested the unmerged version only downloads the first image. @@ -126,7 +128,7 @@ angular.module('reportApp').factory('PlotService', ['UrlService', function(UrlSe return new Promise((resolve, reject) => { beat.experiments.utils.getPlotData( // url_prefix - urlPrefix, + prefix, // spread out the request data to fill the next 3 spots ...requestData, // content type: png, jpeg, pdf @@ -142,14 +144,14 @@ angular.module('reportApp').factory('PlotService', ['UrlService', function(UrlSe // makes the call to the server, via some helper funcs found in the global namespace const fetchRender = (requestData, containerId, onRenderCallback) => { - // the 'url_prefix' field found throughout the BEAT code is confusing, - // but it seems to always be an empty string now - const urlPrefix = '';//UrlService.getApiSegment().split('/').filter(s => s.length > 0).join('/'); + let prefix = new URL(UrlService.getPrefix()).pathname; + if(prefix.endsWith('/')) + prefix = prefix.slice(0, -1); // this func *cannot* be promisified! the callback is fired whenever the plot is re-rendered. beat.experiments.utils.displayPlot( // url_prefix - urlPrefix, + prefix, // element to append render to document.getElementById(`${ containerId }`), // spread out the request data to fill the next 3 spots -- GitLab