Skip to content

Commit

Permalink
Addresses Review Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
gbdubs committed Jan 20, 2024
1 parent 9390566 commit 3d13e49
Showing 1 changed file with 20 additions and 22 deletions.
42 changes: 20 additions & 22 deletions frontend/components/analysis/AccessButtons.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,32 +36,30 @@ const canAccess = computed(() => {
const downloadInProgress = useState<boolean>(`${statePrefix}.downloadInProgress`, () => false)
const doDownload = async () => {
downloadInProgress.value = true
await pactaClient.accessBlobContent({
const response: AccessBlobContentResp = await pactaClient.accessBlobContent({
items: props.analysis.artifacts.map((asset): AccessBlobContentReqItem => ({
blobId: asset.blob.id,
})),
}).then(async (response: AccessBlobContentResp) => {
const zip = new JSZip()
await Promise.all(response.items.map(
async (item): Promise<void> => {
const response = await fetch(item.downloadUrl)
const data = await response.blob()
const blob = presentOrFileBug(props.analysis.artifacts.find((artifact) => artifact.blob.id === item.blobId)).blob
const fileName = `${blob.fileName}`
zip.file(fileName, data)
}),
)
return await zip.generateAsync({ type: 'blob' })
}).then((content) => {
const element = document.createElement('a')
element.href = URL.createObjectURL(content)
const fileName = `${props.analysis.name}.zip`
element.download = fileName
document.body.appendChild(element)
element.click()
document.body.removeChild(element)
downloadInProgress.value = false
})
const zip = new JSZip()
await Promise.all(response.items.map(
async (item): Promise<void> => {
const response = await fetch(item.downloadUrl)
const data = await response.blob()
const blob = presentOrFileBug(props.analysis.artifacts.find((artifact) => artifact.blob.id === item.blobId)).blob
const fileName = `${blob.fileName}`
zip.file(fileName, data)
}),
)
const content = await zip.generateAsync({ type: 'blob' })
const element = document.createElement('a')
element.href = URL.createObjectURL(content)
const fileName = `${props.analysis.name}.zip`
element.download = fileName
document.body.appendChild(element)
element.click()
document.body.removeChild(element)
downloadInProgress.value = false
}
const openReport = () => navigateTo(`${apiServerURL}/report/${props.analysis.id}/`, {
Expand Down

0 comments on commit 3d13e49

Please sign in to comment.