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

View File

@ -1,29 +1,31 @@
import React, { useEffect, useState, useContext } from 'react' import React, { useEffect, useState, useContext } from 'react'
import { User } from '../../context'; import { User } from '../../context'
import moment from 'moment'; import moment from 'moment'
import styles from './JobTeaser.module.scss' import styles from './JobTeaser.module.scss'
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()
useEffect(() => { useEffect(() => {
async function getAsset() { async function getAsset() {
try { 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 asset = await (ocean as any).assets.resolve(did)
const { attributes } = asset.findServiceByType('metadata') const { attributes } = asset.findServiceByType('metadata')
const { main } = attributes const { main } = attributes
setAssetName(main.name) setAssetName(main.name)
} catch (error) { } catch (error) {
console.log(error) console.log(error)
} }
} }
getAsset() getAsset()
}, [ocean,job.agreementId]) }, [ocean, job.agreementId])
return ( return (
<article className={styles.assetList}> <article className={styles.assetList}>
@ -37,10 +39,28 @@ export default function JobTeaser({ job }: { job: any }) {
</div> </div>
</div> </div>
<div className={styles.listRow}> <div className={styles.listRow}>
<div>Job status</div> <div>Job status</div>
<div>{job.statusText}</div> <div>{job.statusText}</div>
</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> </div>
<div>{job.resultsUrl}</div>
</article> </article>
) )
} }

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

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

View File

@ -63,3 +63,40 @@
color: $red; color: $red;
font-size: $font-size-small; 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 [computeType, setComputeType] = useState('')
const [computeValue, setComputeValue] = useState({}) const [computeValue, setComputeValue] = useState({})
const [algorithmRawCode, setAlgorithmRawCode] = useState('') const [algorithmRawCode, setAlgorithmRawCode] = useState('')
const [isPublished, setIsPublished] = useState(false)
const [file, setFile] = useState(null) const [file, setFile] = useState(null)
const onDrop = async (files: any) => { const onDrop = async (files: any) => {
@ -51,6 +51,7 @@ export default function AssetsJobs({ ddo, ocean }: JobsProps) {
const startJob = async () => { const startJob = async () => {
try { try {
setIsJobStarting(true) setIsJobStarting(true)
setIsPublished(false)
setError('') setError('')
const accounts = await ocean.accounts.list() const accounts = await ocean.accounts.list()
const ComputeOutput = { const ComputeOutput = {
@ -78,8 +79,11 @@ export default function AssetsJobs({ ddo, ocean }: JobsProps) {
rawAlgorithmMeta, rawAlgorithmMeta,
ComputeOutput ComputeOutput
) )
setIsPublished(true)
setFile(null)
} catch (error) { } catch (error) {
setError('Failed to start job!') setError('Failed to start job!')
console.log(error)
} }
setIsJobStarting(false) setIsJobStarting(false)
} }
@ -146,6 +150,16 @@ export default function AssetsJobs({ ddo, ocean }: JobsProps) {
{error !== '' && ( {error !== '' && (
<div className={styles.error}>{error}</div> <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>
</div> </div>
</> </>

View File

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