From 49eaa5f9775367fb6c951b9eacb8741f9ba8e227 Mon Sep 17 00:00:00 2001 From: Lucas ONeil Date: Thu, 1 Sep 2022 08:20:57 -0700 Subject: [PATCH 1/3] direct link Signed-off-by: Lucas ONeil --- app/frontend/src/services/comsService.js | 32 ++++++++++-------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/app/frontend/src/services/comsService.js b/app/frontend/src/services/comsService.js index 6716fd0..cc68d07 100644 --- a/app/frontend/src/services/comsService.js +++ b/app/frontend/src/services/comsService.js @@ -40,7 +40,7 @@ export default { responseType: 'blob', params: { versionId: versionId, - download: download + download: 'proxy' } }).then((response) => { const url = window.URL.createObjectURL(new Blob([response.data])); @@ -51,24 +51,18 @@ export default { link.click(); }); } else { - // Not sure how to do opaqueredirect with axios so leaning back to fetch for this one - // https://github.com/axios/axios/issues/932 - const url = comsAxios(); - const auth = `Bearer ${Vue.prototype.$keycloak.token}`; - return fetch(`${url.defaults.baseURL}/object/${objectId}`, { - redirect: 'manual', - headers: { - 'Authorization': auth - } - }).then((res) => { - if (res.type === 'opaqueredirect') { - window.open( - res.url, - '_blank' - ); - } else { - throw new Error(`Not a redirect. Status: ${res.status}`); + // Get just the link to the unlocked object store entity and open it + comsAxios().get(`/object/${objectId}`, { + params: { + versionId: versionId, + download: 'url' } + }).then((response) => { + const url = response.data + const link = document.createElement('a'); + link.href = url; + document.body.appendChild(link); + link.click(); }); } }, @@ -80,7 +74,7 @@ export default { */ listObjects(params = {}) { // remove objId array if its first element is undefined - if( params.objId && params.objId[0] === undefined) delete params.objId; + if (params.objId && params.objId[0] === undefined) delete params.objId; return comsAxios().get('/object', { params: params }); }, From a667e3576aa2489929ea6f38131002716cb1cb05 Mon Sep 17 00:00:00 2001 From: Lucas ONeil Date: Thu, 1 Sep 2022 08:24:33 -0700 Subject: [PATCH 2/3] unused import Signed-off-by: Lucas ONeil --- app/frontend/src/services/comsService.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/frontend/src/services/comsService.js b/app/frontend/src/services/comsService.js index cc68d07..c9a2559 100644 --- a/app/frontend/src/services/comsService.js +++ b/app/frontend/src/services/comsService.js @@ -1,5 +1,4 @@ import { comsAxios } from '@/services/interceptors'; -import Vue from 'vue'; // Calls to the COMS API export default { @@ -58,7 +57,7 @@ export default { download: 'url' } }).then((response) => { - const url = response.data + const url = response.data; const link = document.createElement('a'); link.href = url; document.body.appendChild(link); From 5f07a3c4ce2a59862b1ea05f4f07513121ebe99f Mon Sep 17 00:00:00 2001 From: Lucas ONeil Date: Thu, 1 Sep 2022 08:41:52 -0700 Subject: [PATCH 3/3] Target blank Signed-off-by: Lucas ONeil --- app/frontend/src/services/comsService.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/frontend/src/services/comsService.js b/app/frontend/src/services/comsService.js index c9a2559..6b9a7f8 100644 --- a/app/frontend/src/services/comsService.js +++ b/app/frontend/src/services/comsService.js @@ -58,10 +58,7 @@ export default { } }).then((response) => { const url = response.data; - const link = document.createElement('a'); - link.href = url; - document.body.appendChild(link); - link.click(); + window.open(url, '_blank'); }); } },