diff --git a/package-lock.json b/package-lock.json index 21e985bbd..0411b7df7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4462,9 +4462,9 @@ "integrity": "sha512-LING+GvW37I0L40rZdPCZ1SvcZurDSGGhT0WOVPNO8oyh2C3bXModDBNE4+gCFa8pTbQBOc4ot1/Zoj9PfT/zA==" }, "@oceanprotocol/lib": { - "version": "0.7.1", - "resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-0.7.1.tgz", - "integrity": "sha512-vwwyFrygmH08gWA3OQESG7ZggEX0wfgnAYK9s9xWKhwi0IiRbNu3a25joCebXlENoEUIF7QRChBFeAlqV2OW0w==", + "version": "0.7.3", + "resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-0.7.3.tgz", + "integrity": "sha512-P+ImSOtNz2iDmYXVWutviBwxfFSY/zql362K+FZz3NQt4wYaMrCIiPALR2IF3/9v2FA2g9itTC7eGvWO7bfxqw==", "requires": { "@ethereum-navigator/navigator": "^0.5.0", "@oceanprotocol/contracts": "^0.5.6", diff --git a/package.json b/package.json index 1029a7a3c..25e6ec744 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "@coingecko/cryptoformat": "^0.4.2", "@loadable/component": "5.13.1", "@oceanprotocol/art": "^3.0.0", - "@oceanprotocol/lib": "^0.7.1", + "@oceanprotocol/lib": "^0.7.3", "@oceanprotocol/react": "^0.3.2", "@oceanprotocol/typographies": "^0.1.0", "@sindresorhus/slugify": "^1.0.0", diff --git a/src/@types/ComputeJobMetaData.d.ts b/src/@types/ComputeJobMetaData.d.ts index e2e090f24..444378339 100644 --- a/src/@types/ComputeJobMetaData.d.ts +++ b/src/@types/ComputeJobMetaData.d.ts @@ -1,4 +1,5 @@ export interface ComputeJobMetaData { + jobId: string did: string dateCreated: string dateFinished: string diff --git a/src/components/pages/History/ComputeDetailsModal.tsx b/src/components/pages/History/ComputeDetailsModal.tsx index ce7fdd928..8aa3eedfc 100644 --- a/src/components/pages/History/ComputeDetailsModal.tsx +++ b/src/components/pages/History/ComputeDetailsModal.tsx @@ -7,6 +7,7 @@ import BaseDialog from '../../atoms/BaseDialog' import { ComputeJob } from '@oceanprotocol/lib/dist/node/ocean/interfaces/ComputeJob' import { ComputeJobMetaData } from '@types/ComputeJobMetaData' import Time from '../../atoms/Time' +import shortid from 'shortid' export default function ComputeDetailsModal({ computeJob, @@ -17,13 +18,28 @@ export default function ComputeDetailsModal({ open: boolean onClose: () => void }): ReactElement { - const { ocean, status, accountId } = useOcean() + const { ocean, status, account } = useOcean() const [isLoading, setIsLoading] = useState(false) + useEffect(() => { async function getDetails() { - if (!accountId || !ocean || !computeJob) return + console.log('open', open) + if (!account || !ocean || !computeJob || !open) return + + console.log('open', open) try { setIsLoading(true) + const job = await ocean.compute.status( + account, + computeJob.did, + computeJob.jobId + ) + console.log(job[0]) + if (job && job.length > 0) { + computeJob.algorithmLogUrl = job[0].algorithmLogUrl + computeJob.resultsUrls = + (job[0] as any).resultsUrl !== '' ? (job[0] as any).resultsUrl : [] + } } catch (error) { Logger.error(error.message) } finally { @@ -31,7 +47,7 @@ export default function ComputeDetailsModal({ } } getDetails() - }, [ocean, status, accountId]) + }, [ocean, status, account, open]) return ( @@ -50,7 +66,7 @@ export default function ComputeDetailsModal({

{computeJob.algorithmLogUrl}

{computeJob.resultsUrls?.map((url) => { - return {url} + return {url} })}{' '}

diff --git a/src/components/pages/History/ComputeJobs.tsx b/src/components/pages/History/ComputeJobs.tsx index a6ba76015..2acb1bb75 100644 --- a/src/components/pages/History/ComputeJobs.tsx +++ b/src/components/pages/History/ComputeJobs.tsx @@ -98,12 +98,15 @@ export default function ComputeJobs(): ReactElement { const assetName = await getTitle(orderHistory[i].did) const computeJob = await ocean.compute.status( account, - orderHistory[i].did + orderHistory[i].did, + undefined, + false ) console.log(computeJob) computeJob.forEach((item) => { jobs.push({ did: orderHistory[i].did, + jobId: item.jobId, dateCreated: item.dateCreated, dateFinished: item.dateFinished, assetName: assetName, @@ -116,7 +119,14 @@ export default function ComputeJobs(): ReactElement { }) } console.log(jobs) - setJobs(jobs) + jobs + setJobs( + jobs.sort((a, b) => { + if (a.dateCreated > b.dateCreated) return -1 + if (a.dateCreated < b.dateCreated) return 1 + return 0 + }) + ) setUserAgreed(true) } catch (e) {