From f4a31ef393c2ea02f179720b48e6b3a4ecbaf8af Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Thu, 22 Oct 2020 14:09:42 +0200 Subject: [PATCH] visual tweaks, refactoring --- .../pages/History/ComputeDetails.module.css | 3 ++ ...uteDetailsModal.tsx => ComputeDetails.tsx} | 54 +++++++++++-------- .../pages/History/ComputeJobs.module.css | 8 +++ src/components/pages/History/ComputeJobs.tsx | 44 +++++++-------- src/components/pages/History/Empty.module.css | 7 +++ src/components/pages/History/Empty.tsx | 6 +++ .../pages/History/PoolTransactions.module.css | 8 --- .../pages/History/PoolTransactions.tsx | 12 +++-- 8 files changed, 85 insertions(+), 57 deletions(-) create mode 100644 src/components/pages/History/ComputeDetails.module.css rename src/components/pages/History/{ComputeDetailsModal.tsx => ComputeDetails.tsx} (54%) create mode 100644 src/components/pages/History/ComputeJobs.module.css create mode 100644 src/components/pages/History/Empty.module.css create mode 100644 src/components/pages/History/Empty.tsx diff --git a/src/components/pages/History/ComputeDetails.module.css b/src/components/pages/History/ComputeDetails.module.css new file mode 100644 index 000000000..7fbc3bc43 --- /dev/null +++ b/src/components/pages/History/ComputeDetails.module.css @@ -0,0 +1,3 @@ +.title { + margin-bottom: calc(var(--spacer) / 4); +} diff --git a/src/components/pages/History/ComputeDetailsModal.tsx b/src/components/pages/History/ComputeDetails.tsx similarity index 54% rename from src/components/pages/History/ComputeDetailsModal.tsx rename to src/components/pages/History/ComputeDetails.tsx index 12e125444..f7bca49f4 100644 --- a/src/components/pages/History/ComputeDetailsModal.tsx +++ b/src/components/pages/History/ComputeDetails.tsx @@ -3,9 +3,11 @@ import { useOcean } from '@oceanprotocol/react' import React, { ReactElement, useEffect, useState } from 'react' import Loader from '../../atoms/Loader' import Modal from '../../atoms/Modal' -import { ComputeJobMetaData } from '@types/ComputeJobMetaData' +import { ComputeJobMetaData } from '../../../@types/ComputeJobMetaData' import Time from '../../atoms/Time' import shortid from 'shortid' +import styles from './ComputeDetails.module.css' +import { Status } from './ComputeJobs' export default function ComputeDetailsModal({ computeJob, @@ -19,9 +21,11 @@ export default function ComputeDetailsModal({ const { ocean, status, account } = useOcean() const [isLoading, setIsLoading] = useState(false) + const isFinished = computeJob.dateFinished !== null + useEffect(() => { async function getDetails() { - if (!account || !ocean || !computeJob || !isOpen) return + if (!account || !ocean || !computeJob || !isOpen || !isFinished) return try { setIsLoading(true) @@ -32,7 +36,7 @@ export default function ComputeDetailsModal({ ) if (job && job.length > 0) { computeJob.algorithmLogUrl = job[0].algorithmLogUrl - //hack because ComputeJob returns resultsUrl instead of resultsUrls, issue created already + // hack because ComputeJob returns resultsUrl instead of resultsUrls, issue created already computeJob.resultsUrls = (job[0] as any).resultsUrl !== '' ? (job[0] as any).resultsUrl : [] } @@ -43,7 +47,7 @@ export default function ComputeDetailsModal({ } } getDetails() - }, [ocean, status, account, isOpen]) + }, [ocean, status, account, isOpen, computeJob, isFinished]) return ( - {isLoading ? ( - - ) : ( - <> -

{computeJob.assetName}

-

-

-

-

-

{computeJob.statusText}

-

{computeJob.algorithmLogUrl}

-

- {computeJob.resultsUrls?.map((url) => { - return {url} - })}{' '} -

- +

{computeJob.assetName}

+

+ Created on

+ {computeJob.statusText} + {computeJob.dateFinished && ( +

+ Finished on

)} + + {isFinished && + (isLoading ? ( + + ) : ( + <> +

{computeJob.algorithmLogUrl}

+

+ {computeJob.resultsUrls?.map((url) => { + return {url} + })}{' '} +

+ + ))}
) } diff --git a/src/components/pages/History/ComputeJobs.module.css b/src/components/pages/History/ComputeJobs.module.css new file mode 100644 index 000000000..1e648c17b --- /dev/null +++ b/src/components/pages/History/ComputeJobs.module.css @@ -0,0 +1,8 @@ +.status { + text-transform: uppercase; + color: var(--color-secondary); +} + +.table { + composes: table from './PoolTransactions.module.css'; +} diff --git a/src/components/pages/History/ComputeJobs.tsx b/src/components/pages/History/ComputeJobs.tsx index a734fc137..73efd6cd7 100644 --- a/src/components/pages/History/ComputeJobs.tsx +++ b/src/components/pages/History/ComputeJobs.tsx @@ -2,24 +2,26 @@ import { useOcean } from '@oceanprotocol/react' import React, { ReactElement, useEffect, useState } from 'react' import DataTable from 'react-data-table-component' import Time from '../../atoms/Time' -import styles from './PoolTransactions.module.css' +import styles from './ComputeJobs.module.css' import Loader from '../../atoms/Loader' import Tooltip from '../../atoms/Tooltip' import Button from '../../atoms/Button' -import ComputeDetailsModal from './ComputeDetailsModal' -import { ComputeJobMetaData } from '@types/ComputeJobMetaData' +import ComputeDetails from './ComputeDetails' +import { ComputeJobMetaData } from '../../../@types/ComputeJobMetaData' import { Link } from 'gatsby' import { Logger } from '@oceanprotocol/lib' +import Empty from './Empty' +import Dotdotdot from 'react-dotdotdot' function DetailsButton({ row }: { row: ComputeJobMetaData }): ReactElement { const [isDialogOpen, setIsDialogOpen] = useState(false) return ( <> - - setIsDialogOpen(false)} @@ -28,15 +30,25 @@ function DetailsButton({ row }: { row: ComputeJobMetaData }): ReactElement { ) } -function Empty() { - return
No results found
+export function Status({ children }: { children: string }): ReactElement { + return
{children}
} const columns = [ + { + name: 'Data Set', + selector: function getAssetRow(row: ComputeJobMetaData) { + return ( + + {row.assetName} + + ) + } + }, { name: 'Created', selector: function getTimeRow(row: ComputeJobMetaData) { - return