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

job styling

This commit is contained in:
mihaisc 2020-04-02 15:10:27 +03:00
parent b5eb2e2ddf
commit aff63caf9a
8 changed files with 108 additions and 50 deletions

View File

@ -1,7 +1,6 @@
@import '../../styles/variables';
.assetList {
color: $brand-grey-dark;
border-bottom: 1px solid $brand-grey-lighter;
padding-top: $spacer / 2;
@ -14,7 +13,7 @@
}
}
.listRow{
.listRow {
display: flex;
justify-content: space-between;
align-items: center;
@ -24,4 +23,3 @@
font-size: $font-size-small;
color: $brand-grey-light;
}

View File

@ -1,29 +1,31 @@
import React, { useEffect, useState, useContext } from 'react'
import { User } from '../../context';
import moment from 'moment';
import { User } from '../../context'
import moment from 'moment'
import styles from './JobTeaser.module.scss'
import Dotdotdot from 'react-dotdotdot'
export default function JobTeaser({ job }: { job: any }) {
const { ocean } = useContext(User);
const { ocean } = useContext(User)
const [assetName, setAssetName] = useState()
useEffect(() => {
async function getAsset() {
try {
const { did } = await (ocean as any).keeper.agreementStoreManager.getAgreement(job.agreementId)
const {
did
} = await (ocean as any).keeper.agreementStoreManager.getAgreement(
job.agreementId
)
const asset = await (ocean as any).assets.resolve(did)
const { attributes } = asset.findServiceByType('metadata')
const { main } = attributes
setAssetName(main.name)
} catch (error) {
console.log(error)
}
}
getAsset()
}, [ocean,job.agreementId])
}, [ocean, job.agreementId])
return (
<article className={styles.assetList}>
@ -40,7 +42,25 @@ export default function JobTeaser({ job }: { job: any }) {
<div>Job status</div>
<div>{job.statusText}</div>
</div>
<div>{job.resultsUrl}</div>
<div>
{job.algorithmLogUrl ? (
<a href={job.algorithmLogUrl}> Algorithm log</a>
) : (
''
)}
</div>
<div>
{job.resultsUrl ? (
<>
<div>Output URL</div>
{job.resultsUrl.map((result: string) => (
<a href={result}> {result.substring(0, 52)}...</a>
))}
</>
) : (
''
)}
</div>
</article>
)
}

View File

@ -1,13 +1,11 @@
import React, { useEffect, useState } from 'react'
import { getUserJobs } from '../../utils/getUserJobs'
import { User } from '../../context';
import { User } from '../../context'
import Spinner from '../atoms/Spinner'
import JobTeaser from '../molecules/JobTeaser';
import JobTeaser from '../molecules/JobTeaser'
export default function JobsUser() {
const { ocean, account } = React.useContext(User);
const { ocean, account } = React.useContext(User)
const [jobList, setJobList] = useState<any[]>([])
const [isLoading, setIsLoading] = useState(false)
useEffect(() => {
@ -18,22 +16,19 @@ export default function JobsUser() {
setIsLoading(false)
}
getJobs()
}, [account,ocean])
}, [account, ocean])
return (
<>
{isLoading ?
{isLoading ? (
<Spinner />
: jobList.length ?
jobList.map((job: any) =>
(
<JobTeaser key={job.jobId} job={job} />
)
) : ''
}
) : jobList.length ? (
jobList
.reverse()
.map((job: any) => <JobTeaser key={job.jobId} job={job} />)
) : (
''
)}
</>
)
}

View File

@ -63,3 +63,40 @@
color: $red;
font-size: $font-size-small;
}
.message {
margin-bottom: $spacer;
}
.success {
margin-top: $spacer / 1.5;
composes: message;
background: $green;
padding: $spacer / 1.5;
border-radius: $border-radius;
color: $brand-white;
font-weight: $font-weight-bold;
text-align: center;
&,
a,
button {
color: $brand-white;
}
a,
button {
transition: color .2s ease-out;
&:hover,
&:focus {
color: $brand-pink;
transform: none;
}
}
a {
display: inline-block;
margin-right: $spacer;
}
}

View File

@ -29,7 +29,7 @@ export default function AssetsJobs({ ddo, ocean }: JobsProps) {
const [computeType, setComputeType] = useState('')
const [computeValue, setComputeValue] = useState({})
const [algorithmRawCode, setAlgorithmRawCode] = useState('')
const [isPublished, setIsPublished] = useState(false)
const [file, setFile] = useState(null)
const onDrop = async (files: any) => {
@ -51,6 +51,7 @@ export default function AssetsJobs({ ddo, ocean }: JobsProps) {
const startJob = async () => {
try {
setIsJobStarting(true)
setIsPublished(false)
setError('')
const accounts = await ocean.accounts.list()
const ComputeOutput = {
@ -78,8 +79,11 @@ export default function AssetsJobs({ ddo, ocean }: JobsProps) {
rawAlgorithmMeta,
ComputeOutput
)
setIsPublished(true)
setFile(null)
} catch (error) {
setError('Failed to start job!')
console.log(error)
}
setIsJobStarting(false)
}
@ -146,6 +150,16 @@ export default function AssetsJobs({ ddo, ocean }: JobsProps) {
{error !== '' && (
<div className={styles.error}>{error}</div>
)}
{isPublished ? (
<div className={styles.success}>
<p>Your job started!</p>
<Button link to={'/history/'}>
Watch the progress in the history page.
</Button>
</div>
) : (
''
)}
</div>
</div>
</>

View File

@ -63,13 +63,7 @@ class Asset extends Component<AssetProps, AssetState> {
}
public render() {
const {
metadata,
ddo,
error,
isLoading,
ocean
} = this.state
const { metadata, ddo, error, isLoading, ocean } = this.state
const { main, additionalInformation } = metadata
const hasError = error !== ''