From 288401567886a688a40e6dd25d875570c5dfdfcf Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Tue, 19 May 2020 10:28:02 +0200 Subject: [PATCH] small refactor --- .../components/templates/Asset/AssetJob.tsx | 142 ++++++++---------- 1 file changed, 65 insertions(+), 77 deletions(-) diff --git a/client/src/components/templates/Asset/AssetJob.tsx b/client/src/components/templates/Asset/AssetJob.tsx index 342c3a3..25e2bae 100644 --- a/client/src/components/templates/Asset/AssetJob.tsx +++ b/client/src/components/templates/Asset/AssetJob.tsx @@ -14,14 +14,14 @@ interface JobsProps { ddo: DDO } -export default function AssetsJobs({ ddo, ocean }: JobsProps) { - const rawAlgorithmMeta = { - rawcode: `console.log('Hello world'!)`, - format: 'docker-image', - version: '0.1', - container: {} - } +const rawAlgorithmMeta = { + rawcode: `console.log('Hello world'!)`, + format: 'docker-image', + version: '0.1', + container: {} +} +export default function AssetsJobs({ ddo, ocean }: JobsProps) { const [isJobStarting, setIsJobStarting] = useState(false) const [step, setStep] = useState(99) const [error, setError] = useState('') @@ -37,6 +37,7 @@ export default function AssetsJobs({ ddo, ocean }: JobsProps) { const fileText = await readFileContent(files[0]) setAlgorithmRawCode(fileText) } + const handleSelectChange = (event: ChangeEvent) => { const comType = event.target.value setComputeType(comType) @@ -83,85 +84,72 @@ export default function AssetsJobs({ ddo, ocean }: JobsProps) { setFile(null) } catch (error) { setError('Failed to start job!') - console.log(error) + console.error(error) } setIsJobStarting(false) } return ( - <> +
+ New job +
+ x.name)} + onChange={handleSelectChange} + /> +
-
- New job -
- x.name)} - onChange={handleSelectChange} - /> -
-
-
- onDrop(acceptedFiles)} - > - {({ getRootProps, getInputProps }) => ( -
- - {file === null && ( -
- Click or drop your notebook here -
- )} - {file !== null && ( -
- You selected:{' '} - {(file as any).path} -
- )} +
+ onDrop(acceptedFiles)} + > + {({ getRootProps, getInputProps }) => ( +
+ + {file === null && ( +
+ Click or drop your notebook here
)} - -
-
- -
-
- {isJobStarting ? : ''} - {error !== '' && ( -
{error}
- )} - {isPublished ? ( -
-

Your job started!

- -
- ) : ( - '' - )} + {file !== null && ( +
+ You selected: {(file as any).path} +
+ )} +
+ )} +
+
+
+
- + {isJobStarting ? : ''} + {error !== '' &&
{error}
} + {isPublished ? ( +
+

Your job started!

+ +
+ ) : ( + '' + )} +
) }