1
0
mirror of https://github.com/oceanprotocol/commons.git synced 2023-03-15 18:03:00 +01:00

fix get jobs

This commit is contained in:
alexcos20 2020-04-15 15:33:08 +03:00
parent e7cd6105bf
commit 3f7e8f9f18
2 changed files with 12 additions and 39 deletions

View File

@ -7,6 +7,7 @@ import Dotdotdot from 'react-dotdotdot'
export default function JobTeaser({ job }: { job: any }) { export default function JobTeaser({ job }: { job: any }) {
const { ocean } = useContext(User) const { ocean } = useContext(User)
const [assetName, setAssetName] = useState() const [assetName, setAssetName] = useState()
const [assetUrl, setAssetUrl] = useState()
useEffect(() => { useEffect(() => {
async function getAsset() { async function getAsset() {
try { try {
@ -18,7 +19,9 @@ export default function JobTeaser({ job }: { job: any }) {
const asset = await (ocean as any).assets.resolve(did) const asset = await (ocean as any).assets.resolve(did)
const { attributes } = asset.findServiceByType('metadata') const { attributes } = asset.findServiceByType('metadata')
const { main } = attributes const { main } = attributes
const link = "/asset/did:op:" + did
setAssetName(main.name) setAssetName(main.name)
setAssetUrl(link as any)
} catch (error) { } catch (error) {
console.log(error) console.log(error)
} }
@ -30,7 +33,7 @@ export default function JobTeaser({ job }: { job: any }) {
return ( return (
<article className={styles.assetList}> <article className={styles.assetList}>
<div className={styles.listRow}> <div className={styles.listRow}>
<h1>{assetName}</h1> <h1><a href={assetUrl}>{assetName}</a></h1>
<div <div
className={styles.date} className={styles.date}
title={`Created on ${job.dateCreated}`} title={`Created on ${job.dateCreated}`}

View File

@ -1,47 +1,17 @@
const tempList = import { Account } from '@oceanprotocol/squid'
[{
"agreementId": "a40d4fbddf7c45fb988b3f47e7fb8d50386ee8c968c94a0db6909cd96582e6cd",
"algorithmLogUrl": null,
"dateCreated": 1585581794.73346,
"dateFinished": null,
"jobId": "5e67cdffc2224907b10cdb802820033ee",
"owner": "0x4D156A2ef69ffdDC55838176C6712C90f60a2285",
"removed": 0,
"resultsDid": "",
"resultsUrl": "",
"status": 10,
"statusText": "Job started",
"stopreq": 0
},
{
"agreementId": "a40d4fbddf7c45fb988b3f47e7fb8d50386ee8c968c94a0db6909cd96582e6cd",
"algorithmLogUrl": null,
"dateCreated": 1585581794.73346,
"dateFinished": null,
"jobId": "5e67cdffc2224907b10cdb80820033ee",
"owner": "0x4D156A2ef69ffdDC55838176C6712C90f60a2285",
"removed": 0,
"resultsDid": "",
"resultsUrl": "",
"status": 10,
"statusText": "Job started",
"stopreq": 0
}
]
export async function getUserJobs(ocean: any, account: string) { export async function getUserJobs(ocean: any, account: string) {
try { try {
const accounts = await ocean.accounts.list() let account: Account
//const jobList = await ocean.compute.status(account) ;[account] = await ocean.accounts.list()
// const jobList = await ocean.compute.status(accounts[0])
await account.authenticate()
return tempList; const jobList = await ocean.compute.status(account)
return jobList;
} catch (error) { } catch (error) {
console.error(error.message) console.error(error)
} }
} }