mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
Update compute history (#958)
* use status function * remobe get results button, use getResults function * use default index * lint fix * ocean.js version change * more lint fix * function parameter fix * credential type fix * cursor pointer on link hover Co-authored-by: ClaudiaHolhos <claudia@oceanprotocol.com>
This commit is contained in:
parent
34e424b13f
commit
b1388240dc
1392
package-lock.json
generated
1392
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -28,7 +28,7 @@
|
|||||||
"@coingecko/cryptoformat": "^0.4.4",
|
"@coingecko/cryptoformat": "^0.4.4",
|
||||||
"@loadable/component": "^5.15.0",
|
"@loadable/component": "^5.15.0",
|
||||||
"@oceanprotocol/art": "^3.2.0",
|
"@oceanprotocol/art": "^3.2.0",
|
||||||
"@oceanprotocol/lib": "^0.19.2",
|
"@oceanprotocol/lib": "^0.20.0",
|
||||||
"@oceanprotocol/typographies": "^0.1.0",
|
"@oceanprotocol/typographies": "^0.1.0",
|
||||||
"@portis/web3": "^4.1.0",
|
"@portis/web3": "^4.1.0",
|
||||||
"@sindresorhus/slugify": "^2.1.0",
|
"@sindresorhus/slugify": "^2.1.0",
|
||||||
|
@ -333,6 +333,7 @@ export default function Compute({
|
|||||||
appConfig.marketFeeAddress,
|
appConfig.marketFeeAddress,
|
||||||
undefined,
|
undefined,
|
||||||
null,
|
null,
|
||||||
|
null,
|
||||||
false
|
false
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -354,6 +355,7 @@ export default function Compute({
|
|||||||
appConfig.marketFeeAddress,
|
appConfig.marketFeeAddress,
|
||||||
undefined,
|
undefined,
|
||||||
null,
|
null,
|
||||||
|
null,
|
||||||
false
|
false
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { DDO, Credentials, CredentialType } from '@oceanprotocol/lib'
|
import { DDO, Credentials } from '@oceanprotocol/lib'
|
||||||
import React, { ReactElement, useEffect, useState } from 'react'
|
import React, { ReactElement, useEffect, useState } from 'react'
|
||||||
import { AdvancedSettingsForm } from '../../../../models/FormEditCredential'
|
import { AdvancedSettingsForm } from '../../../../models/FormEditCredential'
|
||||||
import { useOcean } from '../../../../providers/Ocean'
|
import { useOcean } from '../../../../providers/Ocean'
|
||||||
@ -9,6 +9,12 @@ export interface AdvancedSettings {
|
|||||||
isOrderDisabled: boolean
|
isOrderDisabled: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum CredentialType {
|
||||||
|
address = 'address',
|
||||||
|
credential3Box = 'credential3Box',
|
||||||
|
domain = 'domain'
|
||||||
|
}
|
||||||
|
|
||||||
export default function DebugEditCredential({
|
export default function DebugEditCredential({
|
||||||
values,
|
values,
|
||||||
ddo,
|
ddo,
|
||||||
|
@ -3,7 +3,7 @@ import React, { ReactElement, useState } from 'react'
|
|||||||
import { useAsset } from '../../../../providers/Asset'
|
import { useAsset } from '../../../../providers/Asset'
|
||||||
import { useUserPreferences } from '../../../../providers/UserPreferences'
|
import { useUserPreferences } from '../../../../providers/UserPreferences'
|
||||||
import styles from './index.module.css'
|
import styles from './index.module.css'
|
||||||
import { Logger, CredentialType, DDO } from '@oceanprotocol/lib'
|
import { Logger, DDO } from '@oceanprotocol/lib'
|
||||||
import MetadataFeedback from '../../../molecules/MetadataFeedback'
|
import MetadataFeedback from '../../../molecules/MetadataFeedback'
|
||||||
import { graphql, useStaticQuery } from 'gatsby'
|
import { graphql, useStaticQuery } from 'gatsby'
|
||||||
import { useWeb3 } from '../../../../providers/Web3'
|
import { useWeb3 } from '../../../../providers/Web3'
|
||||||
@ -51,6 +51,12 @@ const contentQuery = graphql`
|
|||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
|
enum CredentialType {
|
||||||
|
address = 'address',
|
||||||
|
credential3Box = 'credential3Box',
|
||||||
|
domain = 'domain'
|
||||||
|
}
|
||||||
|
|
||||||
function getDefaultCredentialType(credentialType: string): CredentialType {
|
function getDefaultCredentialType(credentialType: string): CredentialType {
|
||||||
switch (credentialType) {
|
switch (credentialType) {
|
||||||
case 'address':
|
case 'address':
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import React, { ReactElement, useEffect, useState } from 'react'
|
import React, { ReactElement, useEffect, useState } from 'react'
|
||||||
import axios from 'axios'
|
|
||||||
import { ComputeJobMetaData } from '../../../../../@types/ComputeJobMetaData'
|
import { ComputeJobMetaData } from '../../../../../@types/ComputeJobMetaData'
|
||||||
import Time from '../../../../atoms/Time'
|
import Time from '../../../../atoms/Time'
|
||||||
import Button from '../../../../atoms/Button'
|
import Button from '../../../../atoms/Button'
|
||||||
@ -101,12 +100,12 @@ export default function Details({
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<MetaItem title="Job ID" content={<code>{job.jobId}</code>} />
|
<MetaItem title="Job ID" content={<code>{job.jobId}</code>} />
|
||||||
{job.resultsDid && (
|
{/* {job.resultsDid && (
|
||||||
<MetaItem
|
<MetaItem
|
||||||
title="Published Results DID"
|
title="Published Results DID"
|
||||||
content={<code>{job.resultsDid}</code>}
|
content={<code>{job.resultsDid}</code>}
|
||||||
/>
|
/>
|
||||||
)}
|
)} */}
|
||||||
</div>
|
</div>
|
||||||
</Modal>
|
</Modal>
|
||||||
</>
|
</>
|
||||||
|
@ -6,3 +6,7 @@
|
|||||||
.help {
|
.help {
|
||||||
margin-top: calc(var(--spacer) / 3);
|
margin-top: calc(var(--spacer) / 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.result {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
import { Logger } from '@oceanprotocol/lib'
|
import { Logger } from '@oceanprotocol/lib'
|
||||||
import React, { ReactElement, useState } from 'react'
|
import React, { ReactElement, useEffect, useState } from 'react'
|
||||||
import Loader from '../../../../atoms/Loader'
|
import Loader from '../../../../atoms/Loader'
|
||||||
import { ComputeJobMetaData } from '../../../../../@types/ComputeJobMetaData'
|
import { ComputeJobMetaData } from '../../../../../@types/ComputeJobMetaData'
|
||||||
import { ListItem } from '../../../../atoms/Lists'
|
import { ListItem } from '../../../../atoms/Lists'
|
||||||
import Button from '../../../../atoms/Button'
|
|
||||||
import { useOcean } from '../../../../../providers/Ocean'
|
import { useOcean } from '../../../../../providers/Ocean'
|
||||||
import styles from './Results.module.css'
|
import styles from './Results.module.css'
|
||||||
import FormHelp from '../../../../atoms/Input/Help'
|
import FormHelp from '../../../../atoms/Input/Help'
|
||||||
import { graphql, useStaticQuery } from 'gatsby'
|
import { graphql, useStaticQuery } from 'gatsby'
|
||||||
|
import { ComputeResult } from '@oceanprotocol/lib/dist/node/ocean/interfaces/Compute'
|
||||||
|
|
||||||
export const contentQuery = graphql`
|
export const contentQuery = graphql`
|
||||||
query HistoryPageComputeResultsQuery {
|
query HistoryPageComputeResultsQuery {
|
||||||
@ -38,27 +38,45 @@ export default function Results({
|
|||||||
const [hasFetched, setHasFetched] = useState(false)
|
const [hasFetched, setHasFetched] = useState(false)
|
||||||
const isFinished = job.dateFinished !== null
|
const isFinished = job.dateFinished !== null
|
||||||
|
|
||||||
async function getResults() {
|
useEffect(() => {
|
||||||
if (!account || !ocean || !job) return
|
async function getResults() {
|
||||||
|
if (!account || !ocean || !job) return
|
||||||
try {
|
try {
|
||||||
setIsLoading(true)
|
setIsLoading(true)
|
||||||
const jobStatus = await ocean.compute.status(
|
const jobStatus = await ocean.compute.status(
|
||||||
account,
|
account,
|
||||||
job.did,
|
job.did,
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
job.jobId
|
job.jobId,
|
||||||
)
|
undefined
|
||||||
if (jobStatus?.length > 0) {
|
)
|
||||||
job.algorithmLogUrl = jobStatus[0].algorithmLogUrl
|
if (jobStatus) {
|
||||||
job.resultsUrl = jobStatus[0].resultsUrl
|
job.results = jobStatus[0].results
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
Logger.error(error.message)
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false)
|
||||||
|
setHasFetched(true)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getResults()
|
||||||
|
}, [ocean, account, job])
|
||||||
|
|
||||||
|
async function accessResult(result: ComputeResult, index: number) {
|
||||||
|
if (!account || !ocean || !job) return
|
||||||
|
try {
|
||||||
|
const jobResult = await ocean.compute.getResult(
|
||||||
|
account,
|
||||||
|
job.jobId,
|
||||||
|
index,
|
||||||
|
undefined
|
||||||
|
)
|
||||||
|
return jobResult
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
Logger.error(error.message)
|
Logger.error(error.message)
|
||||||
} finally {
|
|
||||||
setIsLoading(false)
|
|
||||||
setHasFetched(true)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,23 +84,18 @@ export default function Results({
|
|||||||
<div className={styles.results}>
|
<div className={styles.results}>
|
||||||
{hasFetched ? (
|
{hasFetched ? (
|
||||||
<ul>
|
<ul>
|
||||||
<ListItem>
|
{job.results &&
|
||||||
{job.algorithmLogUrl ? (
|
Array.isArray(job.results) &&
|
||||||
<a href={job.algorithmLogUrl} target="_blank" rel="noreferrer">
|
job.results.map((result, index) =>
|
||||||
View Log
|
result ? (
|
||||||
</a>
|
|
||||||
) : (
|
|
||||||
'No logs found.'
|
|
||||||
)}
|
|
||||||
</ListItem>
|
|
||||||
|
|
||||||
{job.resultsUrl &&
|
|
||||||
Array.isArray(job.resultsUrl) &&
|
|
||||||
job.resultsUrl.map((url, i) =>
|
|
||||||
url ? (
|
|
||||||
<ListItem key={job.jobId}>
|
<ListItem key={job.jobId}>
|
||||||
<a href={url} target="_blank" rel="noreferrer">
|
<a
|
||||||
View Result {i + 1}
|
className={styles.result}
|
||||||
|
onClick={() => accessResult(result, index)}
|
||||||
|
target="_blank"
|
||||||
|
rel="noreferrer"
|
||||||
|
>
|
||||||
|
{result.filename}
|
||||||
</a>
|
</a>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
) : (
|
) : (
|
||||||
@ -90,21 +103,10 @@ export default function Results({
|
|||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
</ul>
|
</ul>
|
||||||
|
) : isLoading ? (
|
||||||
|
<Loader />
|
||||||
) : (
|
) : (
|
||||||
<Button
|
!isFinished && <> Waiting for results...</>
|
||||||
style="primary"
|
|
||||||
size="small"
|
|
||||||
onClick={() => getResults()}
|
|
||||||
disabled={isLoading || !isFinished}
|
|
||||||
>
|
|
||||||
{isLoading ? (
|
|
||||||
<Loader />
|
|
||||||
) : !isFinished ? (
|
|
||||||
'Waiting for results...'
|
|
||||||
) : (
|
|
||||||
'Get Results'
|
|
||||||
)}
|
|
||||||
</Button>
|
|
||||||
)}
|
)}
|
||||||
<FormHelp className={styles.help}>{content.compute.storage}</FormHelp>
|
<FormHelp className={styles.help}>{content.compute.storage}</FormHelp>
|
||||||
</div>
|
</div>
|
||||||
|
@ -65,6 +65,7 @@ function useConsume(): UseConsume {
|
|||||||
marketFeeAddress,
|
marketFeeAddress,
|
||||||
undefined,
|
undefined,
|
||||||
null,
|
null,
|
||||||
|
null,
|
||||||
false
|
false
|
||||||
)
|
)
|
||||||
Logger.log('order created', orderId)
|
Logger.log('order created', orderId)
|
||||||
|
@ -2,7 +2,6 @@ import {
|
|||||||
CredentialAction,
|
CredentialAction,
|
||||||
Credential,
|
Credential,
|
||||||
Credentials,
|
Credentials,
|
||||||
CredentialType,
|
|
||||||
DDO
|
DDO
|
||||||
} from '@oceanprotocol/lib'
|
} from '@oceanprotocol/lib'
|
||||||
import * as Yup from 'yup'
|
import * as Yup from 'yup'
|
||||||
@ -13,6 +12,12 @@ export interface AdvancedSettingsForm {
|
|||||||
isOrderDisabled: boolean
|
isOrderDisabled: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum CredentialType {
|
||||||
|
address = 'address',
|
||||||
|
credential3Box = 'credential3Box',
|
||||||
|
domain = 'domain'
|
||||||
|
}
|
||||||
|
|
||||||
export const validationSchema: Yup.SchemaOf<AdvancedSettingsForm> =
|
export const validationSchema: Yup.SchemaOf<AdvancedSettingsForm> =
|
||||||
Yup.object().shape({
|
Yup.object().shape({
|
||||||
allow: Yup.array().nullable(),
|
allow: Yup.array().nullable(),
|
||||||
|
@ -165,8 +165,7 @@ async function getJobs(
|
|||||||
'',
|
'',
|
||||||
account,
|
account,
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined
|
||||||
false
|
|
||||||
)) as ComputeJob[]
|
)) as ComputeJob[]
|
||||||
|
|
||||||
// means the provider uri is not good, so we ignore it and move on
|
// means the provider uri is not good, so we ignore it and move on
|
||||||
|
Loading…
x
Reference in New Issue
Block a user