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

small refactor

This commit is contained in:
Matthias Kretschmann 2020-05-19 10:28:02 +02:00
parent 7d09350967
commit 2884015678
Signed by: m
GPG Key ID: 606EEEF3C479A91F

View File

@ -14,14 +14,14 @@ interface JobsProps {
ddo: DDO ddo: DDO
} }
export default function AssetsJobs({ ddo, ocean }: JobsProps) { const rawAlgorithmMeta = {
const rawAlgorithmMeta = {
rawcode: `console.log('Hello world'!)`, rawcode: `console.log('Hello world'!)`,
format: 'docker-image', format: 'docker-image',
version: '0.1', version: '0.1',
container: {} container: {}
} }
export default function AssetsJobs({ ddo, ocean }: JobsProps) {
const [isJobStarting, setIsJobStarting] = useState(false) const [isJobStarting, setIsJobStarting] = useState(false)
const [step, setStep] = useState(99) const [step, setStep] = useState(99)
const [error, setError] = useState('') const [error, setError] = useState('')
@ -37,6 +37,7 @@ export default function AssetsJobs({ ddo, ocean }: JobsProps) {
const fileText = await readFileContent(files[0]) const fileText = await readFileContent(files[0])
setAlgorithmRawCode(fileText) setAlgorithmRawCode(fileText)
} }
const handleSelectChange = (event: ChangeEvent<HTMLInputElement>) => { const handleSelectChange = (event: ChangeEvent<HTMLInputElement>) => {
const comType = event.target.value const comType = event.target.value
setComputeType(comType) setComputeType(comType)
@ -83,14 +84,12 @@ export default function AssetsJobs({ ddo, ocean }: JobsProps) {
setFile(null) setFile(null)
} catch (error) { } catch (error) {
setError('Failed to start job!') setError('Failed to start job!')
console.log(error) console.error(error)
} }
setIsJobStarting(false) setIsJobStarting(false)
} }
return ( return (
<>
<div>
<div> <div>
<span className={styles.bold}>New job</span> <span className={styles.bold}>New job</span>
<div className={styles.dataType}> <div className={styles.dataType}>
@ -118,13 +117,8 @@ export default function AssetsJobs({ ddo, ocean }: JobsProps) {
</div> </div>
)} )}
{file !== null && ( {file !== null && (
<div <div className={styles.filleddragndrop}>
className={ You selected: {(file as any).path}
styles.filleddragndrop
}
>
You selected:{' '}
{(file as any).path}
</div> </div>
)} )}
</div> </div>
@ -136,9 +130,7 @@ export default function AssetsJobs({ ddo, ocean }: JobsProps) {
primary primary
onClick={() => startJob()} onClick={() => startJob()}
disabled={ disabled={
isJobStarting || isJobStarting || file === null || computeType === ''
file === null ||
computeType === ''
} }
name="Purchase access" name="Purchase access"
> >
@ -147,9 +139,7 @@ export default function AssetsJobs({ ddo, ocean }: JobsProps) {
</div> </div>
</div> </div>
{isJobStarting ? <Spinner message={messages[step]} /> : ''} {isJobStarting ? <Spinner message={messages[step]} /> : ''}
{error !== '' && ( {error !== '' && <div className={styles.error}>{error}</div>}
<div className={styles.error}>{error}</div>
)}
{isPublished ? ( {isPublished ? (
<div className={styles.success}> <div className={styles.success}>
<p>Your job started!</p> <p>Your job started!</p>
@ -161,7 +151,5 @@ export default function AssetsJobs({ ddo, ocean }: JobsProps) {
'' ''
)} )}
</div> </div>
</div>
</>
) )
} }