diff --git a/beat/web/reports/static/reports/app/factories/experimentFactory.js b/beat/web/reports/static/reports/app/factories/experimentFactory.js index 4f0d7234e44225c709253e78839c549f20977120..0a53f720060ba42efa4a343aea0dd15298dc37d2 100644 --- a/beat/web/reports/static/reports/app/factories/experimentFactory.js +++ b/beat/web/reports/static/reports/app/factories/experimentFactory.js @@ -20,7 +20,7 @@ * with the BEAT platform. If not, see http://www.gnu.org/licenses/. */ //This factory retrieves data from the REST API and associates it with the $scope -angular.module('reportApp').factory('experimentFactory', 'UrlService', function($http, $q, UrlService){ +angular.module('reportApp').factory('experimentFactory', ['$http', 'UrlService', function($http, UrlService){ let urlBase = '/api/v1/experiments'; let prefix = new URL(UrlService.getPrefix()).pathname; if(prefix.endsWith('/')) @@ -51,4 +51,4 @@ angular.module('reportApp').factory('experimentFactory', 'UrlService', function( }); } }; -}); +}]); diff --git a/beat/web/reports/static/reports/app/factories/plotterFactory.js b/beat/web/reports/static/reports/app/factories/plotterFactory.js index f06d2ccd17ec421cfc9e13e89a4f727b95dfaa63..7336320c38a2489c59654a213798cf87fb49bfd6 100644 --- a/beat/web/reports/static/reports/app/factories/plotterFactory.js +++ b/beat/web/reports/static/reports/app/factories/plotterFactory.js @@ -20,7 +20,7 @@ * with the BEAT platform. If not, see http://www.gnu.org/licenses/. */ //This factory retrieves data from the REST API and associates it with the $scope -angular.module('reportApp').factory('plotterFactory', ['$http', function($http){ +angular.module('reportApp').factory('plotterFactory', ['$http', 'UrlService', function($http, UrlService){ let prefix = new URL(UrlService.getPrefix()).pathname; if(prefix.endsWith('/')) prefix = prefix.slice(0, -1); diff --git a/beat/web/reports/static/reports/app/services/plotService.js b/beat/web/reports/static/reports/app/services/plotService.js index b8ae139df32e1bf03a7ade529669acf0524d465d..b3efb372abb29fd1b5e3aa1ea404136880d43c26 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