job history

This commit is contained in:
mihaisc 2020-03-30 19:22:48 +03:00
parent 1b20b12cce
commit 553535c578
10 changed files with 113 additions and 8 deletions

View File

@ -15,7 +15,7 @@
.header {
// stylelint-disable value-keyword-case
composes: categoryimage;
composes: categoryImage;
// stylelint-enable value-keyword-case
height: 8rem;
margin-top: $spacer / $line-height;
@ -23,7 +23,7 @@
.dimmed {
// stylelint-disable value-keyword-case
composes: categoryimage;
composes: categoryImage;
// stylelint-enable value-keyword-case
opacity: .6;
}

View File

@ -18,7 +18,7 @@
/* yellow triangle */
.statusIndicatorCloseEnough {
// stylelint-disable value-keyword-case
composes: statusindicator;
composes: statusIndicator;
// stylelint-enable value-keyword-case
background: none;
width: 0;
@ -31,7 +31,7 @@
/* green circle */
.statusIndicatorActive {
// stylelint-disable value-keyword-case
composes: statusindicator;
composes: statusIndicator;
// stylelint-enable value-keyword-case
border-radius: 50%;
background: $green;

View File

@ -0,0 +1,13 @@
import React, { useEffect, useState } from 'react'
import { getUserJobs } from '../../utils/getUserJobs'
import { User } from '../../context';
import Spinner from '../atoms/Spinner'
export default function JobTeaser() {
return (
<div>Job teaser</div>
)
}

View File

@ -2,7 +2,7 @@
.latestAssetsWrap {
// full width break out of container
margin-right: calc(-50vw + 50%);
// margin-right: calc(-50vw + 50%);
}
.latestAssets {

View File

@ -0,0 +1,41 @@
import React, { useEffect, useState } from 'react'
import { getUserJobs } from '../../utils/getUserJobs'
import { User } from '../../context';
import Spinner from '../atoms/Spinner'
import JobTeaser from '../molecules/JobTeaser';
export default function JobsUser() {
const { ocean, account } = React.useContext(User);
const [jobList, setJobList] = useState<any[]>([])
const [isLoading, setIsLoading] = useState(false)
useEffect(() => {
setIsLoading(true)
async function getJobs() {
console.log(account)
const userJobs = await getUserJobs(ocean, account)
console.log('user jobs', userJobs)
setJobList(userJobs as any)
setIsLoading(false)
}
getJobs()
}, [account])
return (
<>
{isLoading ?
<Spinner />
: jobList.length ?
jobList.map((job: any) =>
(
<JobTeaser key={job.agreementId} />
)
) : ''
}
</>
)
}

View File

@ -2,7 +2,6 @@ import React, { PureComponent } from 'react'
import { DDO, File } from '@oceanprotocol/squid'
import AssetFile from './AssetFile'
import { User } from '../../../context'
import Web3message from '../../organisms/Web3message'
import styles from './AssetFilesDetails.module.scss'
export default class AssetFilesDetails extends PureComponent<{

View File

@ -68,7 +68,6 @@ class Asset extends Component<AssetProps, AssetState> {
ddo,
error,
isLoading,
computeMetadata,
ocean
} = this.state
const { main, additionalInformation } = metadata

View File

@ -5,16 +5,20 @@ import Web3message from '../components/organisms/Web3message'
import { User } from '../context'
import Content from '../components/atoms/Content'
import withTracker from '../hoc/withTracker'
import JobsUser from '../components/organisms/JobsUser'
class History extends Component {
public static contextType = User
public render() {
return (
<Route title="History">
<Content>
{!this.context.isLogged && <Web3message />}
<div>Assets</div>
<AssetsUser list />
<div>Jobs</div>
<JobsUser />
</Content>
</Route>
)

View File

@ -0,0 +1,49 @@
const tempList =
[{
"agreementId": "a40d4fbddf7c45fb988b3f47e7fb8d50386ee8c968c94a0db6909cd96582e6cd",
"algorithmLogUrl": null,
"dateCreated": 1585581794.73346,
"dateFinished": null,
"jobId": "5e67cdffc2224907b10cdb80820033ee",
"owner": "0x4D156A2ef69ffdDC55838176C6712C90f60a2285",
"removed": 0,
"resultsDid": "",
"resultsUrl": "",
"status": 10,
"statusText": "Job started",
"stopreq": 0
},
{
"agreementId": "a40d4fbdd434c45fb988b3f47e7fb8d50386ee8c968c94a0db6909cd96582e6cd",
"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) {
try {
const accounts = await ocean.accounts.list()
//const jobList = await ocean.compute.status(account)
// const jobList = await ocean.compute.status(accounts[0])
return tempList;
} catch (error) {
console.error(error.message)
}
}