Skip to content

Commit

Permalink
Merge pull request #414 from deltaDAO/enhancement/compute-results
Browse files Browse the repository at this point in the history
enhancement: add file name and size to compute results
  • Loading branch information
moritzkirstein authored Sep 11, 2023
2 parents 5dae6ce + fdc58c3 commit aabe167
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export function prettySize(
separator = ' ',
postFix = ''
): string {
if (bytes === 0) return '0 Bytes'
if (!bytes) return 'n/a'

const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']
Expand Down
4 changes: 4 additions & 0 deletions src/components/Profile/History/ComputeJobs/Results.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
margin-bottom: calc(var(--spacer) / 3);
}

.downloadButton {
text-transform: none;
}

.help {
margin-top: calc(var(--spacer) / 3);
}
22 changes: 15 additions & 7 deletions src/components/Profile/History/ComputeJobs/Results.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import content from '../../../../../content/pages/history.json'
import { useWeb3 } from '@context/Web3'
import { useCancelToken } from '@hooks/useCancelToken'
import { getAsset } from '@utils/aquarius'
import { prettySize } from '@components/@shared/FormInput/InputElement/FilesInput/utils'

export default function Results({
job
Expand All @@ -34,23 +35,26 @@ export default function Results({
getAssetMetadata()
}, [job.inputDID, newCancelToken])

function getDownloadButtonValue(type: ComputeResultType): string {
function getDownloadButtonValue(
type: ComputeResultType,
name: string
): string {
let buttonName
switch (type) {
case 'output':
buttonName = 'results'
buttonName = `RESULTS (${name})`
break
case 'algorithmLog':
buttonName = 'algorithm logs'
buttonName = 'ALGORITHM LOGS'
break
case 'configrationLog':
buttonName = 'configuration logs'
buttonName = 'CONFIGURATION LOGS'
break
case 'publishLog':
buttonName = 'publish logs'
buttonName = 'PUBLISH LOGS'
break
default:
buttonName = 'results'
buttonName = `RESULTS (${name})`
break
}
return buttonName
Expand Down Expand Up @@ -86,10 +90,14 @@ export default function Results({
<Button
style="text"
size="small"
className={styles.downloadButton}
onClick={() => downloadResults(i)}
download
>
{getDownloadButtonValue(jobResult.type)}
{`${getDownloadButtonValue(
jobResult.type,
jobResult.filename
)} - ${prettySize(jobResult.filesize)}`}
</Button>
</ListItem>
) : (
Expand Down

1 comment on commit aabe167

@vercel
Copy link

@vercel vercel bot commented on aabe167 Sep 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.