From 0147cfc3b1a150c4f388c206d9be43c98bc2d002 Mon Sep 17 00:00:00 2001 From: yingfeng Date: Mon, 16 Oct 2023 11:12:46 -0400 Subject: [PATCH] AMP-2990/3006 - refactor workflowResultService get media link methods - update all references to above methods - rewrite logic for mediaElement to use symlink - rewrite logic for all links to use click event to process symlink --- src/components/dashboard/DashboardTable.vue | 32 +++++++++--- src/components/entity/EntityList.vue | 2 +- src/components/entity/OutputFile.vue | 3 +- .../evaluation/TestResultsVisualiz.vue | 12 ++--- src/service/workflow-result-service.js | 50 +++++++++++++------ .../dashboard/DashboardTable.spec.js | 2 +- 6 files changed, 66 insertions(+), 35 deletions(-) diff --git a/src/components/dashboard/DashboardTable.vue b/src/components/dashboard/DashboardTable.vue index f8c3daea..a12e2bc8 100644 --- a/src/components/dashboard/DashboardTable.vue +++ b/src/components/dashboard/DashboardTable.vue @@ -131,11 +131,10 @@ {{ rec.externalId }} {{ rec.itemName }} - {{ rec.primaryfileName }} @@ -154,8 +153,7 @@ outputReady(rec)" > {{ rec.outputName }} {{ rec.outputLabel }}{{ testResult.primaryFilename }} ({{ testResult.workflowResult.workflowStep diff --git a/src/service/workflow-result-service.js b/src/service/workflow-result-service.js index b2f26e16..d3c35b80 100644 --- a/src/service/workflow-result-service.js +++ b/src/service/workflow-result-service.js @@ -52,29 +52,51 @@ export default class WorkflowResultService extends BaseService { }); return data; } - - async getSourceLink(primaryfileId) { - const url = `/primaryfiles/${primaryfileId}/media`; - var symlink = await super.get_auth(url).then((result) => { - return result.headers['Location']; - }); - return symlink; - } - async getSourceUrl(primaryfileId) { + // get symlink for primaryfile media + async getMediaSymlink(primaryfileId) { const url = `/primaryfiles/${primaryfileId}/media`; - var content = await super.get_auth(url).then((result) => { + var symlink = await super.get_auth(url).then((result) => { return result.data; }); - return content; + return symlink; } - async getOutputUrl(id) { + // get symlink for workflow result output + async getOutputSymlink(id) { const url = `/workflow-results/${id}/output`; - var content = await super.get_auth(url).then((result) => { + var symlink = await super.get_auth(url).then((result) => { return result.data; }); - return content; + return symlink; + } + + // onclick event handler for media/output links: + // get content of media or output based on forOutput boolean + // note that this method is shared across multiple components. + async getSymlinkContent(result, forOutput, event) { + // get the link element being clicked + let link = event.target; + + // only process the event when the link href hasm't been populated + if (!link.href) { + // get symlink URL via API call + let symlink = "" + if (forOutput) { + symlink = await this.getOutputSymlink(result.id); + } + else { + symlink = await this.getMediaSymlink(result.primaryfileId); + } + + // TODO handle error resposne + + // initialize the link URL and trigger a click to request the content + link.href = symlink; + link.click(); + console.log("forOutput = " + forOutput + ", symlink = " + symlink) + } + // otherwise do nothing and just let browser handle the link click } async deleteWorkflowResult(id) { diff --git a/tests/unit/components/dashboard/DashboardTable.spec.js b/tests/unit/components/dashboard/DashboardTable.spec.js index a16352d4..a4ee7ab7 100644 --- a/tests/unit/components/dashboard/DashboardTable.spec.js +++ b/tests/unit/components/dashboard/DashboardTable.spec.js @@ -61,7 +61,7 @@ function(){ workflowStep: "contact_sheets"}],filters: null, totalResults: 1}); }, - getSourceUrl: (id) => { + getMediaSymlink: (id) => { return id; } }