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

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

View File

@ -18,7 +18,7 @@
/* yellow triangle */ /* yellow triangle */
.statusIndicatorCloseEnough { .statusIndicatorCloseEnough {
// stylelint-disable value-keyword-case // stylelint-disable value-keyword-case
composes: statusindicator; composes: statusIndicator;
// stylelint-enable value-keyword-case // stylelint-enable value-keyword-case
background: none; background: none;
width: 0; width: 0;
@ -31,7 +31,7 @@
/* green circle */ /* green circle */
.statusIndicatorActive { .statusIndicatorActive {
// stylelint-disable value-keyword-case // stylelint-disable value-keyword-case
composes: statusindicator; composes: statusIndicator;
// stylelint-enable value-keyword-case // stylelint-enable value-keyword-case
border-radius: 50%; border-radius: 50%;
background: $green; 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 { .latestAssetsWrap {
// full width break out of container // full width break out of container
margin-right: calc(-50vw + 50%); // margin-right: calc(-50vw + 50%);
} }
.latestAssets { .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 { DDO, File } from '@oceanprotocol/squid'
import AssetFile from './AssetFile' import AssetFile from './AssetFile'
import { User } from '../../../context' import { User } from '../../../context'
import Web3message from '../../organisms/Web3message'
import styles from './AssetFilesDetails.module.scss' import styles from './AssetFilesDetails.module.scss'
export default class AssetFilesDetails extends PureComponent<{ export default class AssetFilesDetails extends PureComponent<{

View File

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

View File

@ -5,6 +5,7 @@ import Web3message from '../components/organisms/Web3message'
import { User } from '../context' import { User } from '../context'
import Content from '../components/atoms/Content' import Content from '../components/atoms/Content'
import withTracker from '../hoc/withTracker' import withTracker from '../hoc/withTracker'
import JobsUser from '../components/organisms/JobsUser'
class History extends Component { class History extends Component {
public static contextType = User public static contextType = User
@ -14,7 +15,10 @@ class History extends Component {
<Route title="History"> <Route title="History">
<Content> <Content>
{!this.context.isLogged && <Web3message />} {!this.context.isLogged && <Web3message />}
<div>Assets</div>
<AssetsUser list /> <AssetsUser list />
<div>Jobs</div>
<JobsUser />
</Content> </Content>
</Route> </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)
}
}