Skip to content

Commit

Permalink
Assorted QoL tweaks
Browse files Browse the repository at this point in the history
- Define some i18n strings
- Only download the `audit_file.csv` for audits
- Show/hide download/view buttons when it makes sense
- Add some stragging env vars
  • Loading branch information
bcspragu committed Jan 15, 2025
1 parent 9166579 commit 2f82cc9
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 13 deletions.
37 changes: 24 additions & 13 deletions frontend/components/analysis/AccessButtons.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,25 +42,36 @@ const isViewable = computed(() => {
const downloadInProgress = useState<boolean>(`${statePrefix}.downloadInProgress`, () => false)
const doDownload = async () => {
downloadInProgress.value = true
// Just download the audit_file.csv for audits
const artifactsToDownload = props.analysis.analysisType === AnalysisType.ANALYSIS_TYPE_AUDIT ? props.analysis.artifacts.filter((a) => a.blob.fileName === 'audit_file.csv') : props.analysis.artifacts;

Check failure on line 46 in frontend/components/analysis/AccessButtons.vue

View workflow job for this annotation

GitHub Actions / frontend

Extra semicolon
const response: AccessBlobContentResp = await pactaClient.accessBlobContent({
items: props.analysis.artifacts.map((asset): AccessBlobContentReqItem => ({
items: artifactsToDownload.map((asset): AccessBlobContentReqItem => ({
blobId: asset.blob.id,
})),
})
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' })
let content: Blob | null = null
let fileName: string | null = null
if (response.items.length === 1) {
const resp = await fetch(response.items[0].downloadUrl)

Check failure on line 56 in frontend/components/analysis/AccessButtons.vue

View workflow job for this annotation

GitHub Actions / frontend

Expected indentation of 4 spaces but found 6
content = await resp.blob()

Check failure on line 57 in frontend/components/analysis/AccessButtons.vue

View workflow job for this annotation

GitHub Actions / frontend

Expected indentation of 4 spaces but found 6
fileName = artifactsToDownload[0].blob.fileName

Check failure on line 58 in frontend/components/analysis/AccessButtons.vue

View workflow job for this annotation

GitHub Actions / frontend

Expected indentation of 4 spaces but found 6
} else {
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)
}),
)
content = await zip.generateAsync({ type: 'blob' })
fileName = `${props.analysis.name}.zip`
}
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()
Expand Down
7 changes: 7 additions & 0 deletions frontend/components/portfolio/ListView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,13 @@ const auditLogURL = (id: string) => {
{{ slotProps.data.analyses.filter((a: Analysis) => a.analysisType === AnalysisType.ANALYSIS_TYPE_AUDIT).length }}
{{ tt('Audits') }}
</PVInlineMessage>
<PVInlineMessage
severity="success"
icon="pi pi-copy"
>
{{ slotProps.data.analyses.filter((a: Analysis) => a.analysisType === AnalysisType.ANALYSIS_TYPE_DASHBOARD).length }}
{{ tt('Dashboards') }}
</PVInlineMessage>
</div>
</CommonAccordionHeader>
</template>
Expand Down
1 change: 1 addition & 0 deletions frontend/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@
"Details": "Details",
"Groups": "Groups",
"Reports": "Reports",
"Dashboards": "Dashboards",
"Discard Changes": "Discard Changes",
"InitiativesHelpText": "Initiatives allow you to contribute your data for bulk analysis as part of a regulatory or other project. Adding a portfolio to an initiative enables the initiative owner to run analysis over your data as part of bulk runs, and enables them to download your data.",
"Audits": "Audits",
Expand Down
9 changes: 9 additions & 0 deletions taskrunner/taskrunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,15 @@ func (tr *TaskRunner) CreateAudit(ctx context.Context, req *task.CreateAuditRequ
Key: "CREATE_AUDIT_REQUEST",
Value: value,
},
// TODO(brandon): Unhardcode these
{
Key: "BENCHMARK_DIR",
Value: "/mnt/benchmark-data/65c1a416721b22a98c7925999ae03bc4",
},
{
Key: "PACTA_DATA_DIR",
Value: "/mnt/pacta-data/2023Q4_20240718T150252Z",
},
})
}

Expand Down

0 comments on commit 2f82cc9

Please sign in to comment.