From 69ecfd71ebd9fee87309cb02c00ff1d1228800ad Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Tue, 22 Sep 2020 12:25:08 +0000 Subject: [PATCH] remove compute job lists for now --- .../pages/History/JobDetailsDialog.module.css | 14 -- .../pages/History/JobDetailsDialog.tsx | 67 --------- src/components/pages/History/JobsList.tsx | 139 ------------------ src/components/pages/History/index.tsx | 1 - tests/unit/__fixtures__/job.ts | 20 --- tests/unit/__mocks__/@oceanprotocol/lib.ts | 11 +- 6 files changed, 5 insertions(+), 247 deletions(-) delete mode 100644 src/components/pages/History/JobDetailsDialog.module.css delete mode 100644 src/components/pages/History/JobDetailsDialog.tsx delete mode 100644 src/components/pages/History/JobsList.tsx delete mode 100644 tests/unit/__fixtures__/job.ts diff --git a/src/components/pages/History/JobDetailsDialog.module.css b/src/components/pages/History/JobDetailsDialog.module.css deleted file mode 100644 index 2ed1b3eba..000000000 --- a/src/components/pages/History/JobDetailsDialog.module.css +++ /dev/null @@ -1,14 +0,0 @@ -.metaGrid { - border-radius: var(--border-radius); - display: grid; - gap: calc(var(--spacer) / 2); - grid-template-columns: 1fr 1fr; -} - -.metaRow { - padding-top: calc(var(--spacer) / 2); - border-radius: var(--border-radius); - display: grid; - gap: calc(var(--spacer) / 2); - grid-template-columns: auto; -} diff --git a/src/components/pages/History/JobDetailsDialog.tsx b/src/components/pages/History/JobDetailsDialog.tsx deleted file mode 100644 index 46e1d0f9a..000000000 --- a/src/components/pages/History/JobDetailsDialog.tsx +++ /dev/null @@ -1,67 +0,0 @@ -import React, { ReactElement } from 'react' -import { ComputeItem } from '@oceanprotocol/react' -import BaseDialog from '../../atoms/BaseDialog' -import styles from './JobDetailsDialog.module.css' -import MetaItem from '../../organisms/AssetContent/MetaItem' -import Time from '../../atoms/Time' -import shortid from 'shortid' -import { Link } from 'gatsby' - -export default function JobDetailsDialog({ - computeItem, - isOpen, - onClose -}: { - computeItem: ComputeItem | undefined - isOpen: boolean - onClose: () => void -}): ReactElement { - if (!computeItem) return null - - const { attributes } = computeItem.ddo.findServiceByType('metadata') - const { name } = attributes.main - const { - dateCreated, - dateFinished, - statusText, - jobId, - resultsUrls, - algorithmLogUrl - } = computeItem.job - - return ( - -
- } /> - - } - /> - -
-
- {resultsUrls && ( - ( - - {url} - - ))} - /> - )} - {algorithmLogUrl && ( - {algorithmLogUrl}} - /> - )} - {name}} - /> -
-
- ) -} diff --git a/src/components/pages/History/JobsList.tsx b/src/components/pages/History/JobsList.tsx deleted file mode 100644 index 65200dbaf..000000000 --- a/src/components/pages/History/JobsList.tsx +++ /dev/null @@ -1,139 +0,0 @@ -import React, { useState, ReactElement } from 'react' -import Loader from '../../atoms/Loader' -import { useOcean } from '@oceanprotocol/react' - -import Price from '../../atoms/Price' -import { fromWei } from 'web3-utils' -import Table from '../../atoms/Table' -import Button from '../../atoms/Button' -import { MetadataMain, Logger } from '@oceanprotocol/lib' -import DateCell from '../../atoms/Table/DateCell' -import DdoLinkCell from '../../atoms/Table/DdoLinkCell' -import shortid from 'shortid' -import ActionsCell from '../../atoms/Table/ActionsCell' -import JobDetailsDialog from './JobDetailsDialog' - -const columns = [ - { - name: 'Created', - selector: 'dateCreated', - sortable: true, - cell: function getCell(row: any) { - return - } - }, - { - name: 'Finished', - selector: 'dateFinished', - sortable: true, - cell: function getCell(row: any) { - return - } - }, - { - name: 'Name', - selector: 'name', - sortable: true, - cell: function getCell(row: any) { - return - } - }, - { - name: 'Price', - selector: 'price', - sortable: true, - cell: function getCell(row: any) { - return - } - }, - { - name: 'Status', - selector: 'status' - }, - { - name: 'Actions', - selector: 'actions', - cell: function getCell(row: any) { - return ( - - ) - } - } -] - -export default function JobsList(): ReactElement { - const { ocean, status, accountId } = useOcean() - - const [jobList, setJobList] = useState([]) - const [isLoading, setIsLoading] = useState(false) - const [userAgreed, setUserAgreed] = useState(false) - const { getComputeItems } = useSearch() - const [isOpen, setIsOpen] = useState(false) - const [detailsComputeItem, setDetailsComputeItem] = useState() - - const onClickViewJobDetails = (compute: ComputeItem) => { - setDetailsComputeItem(compute) - setIsOpen(true) - } - const dialogClose = () => { - setIsOpen(false) - } - - const getJobs = async () => { - if (!accountId || !ocean || status !== OceanConnectionStatus.CONNECTED) - return - setIsLoading(true) - setUserAgreed(true) - try { - const computeItems = await getComputeItems() - if (!computeItems) return - const data = computeItems.map((item) => { - const { attributes } = item.ddo.findServiceByType('metadata') - const { name, price } = attributes.main as MetadataMain - return { - dateCreated: item.job.dateCreated, - dateFinished: item.job.dateFinished, - status: item.job.statusText, - name: name, - price: price, - did: item.ddo.id, - id: shortid.generate(), - onClickViewJobDetails: () => onClickViewJobDetails(item) - } - }) - - setJobList(data) - setIsLoading(false) - } catch (err) { - Logger.error(err) - // TODO: no error handling - } finally { - setIsLoading(false) - } - } - - return isLoading ? ( - - ) : accountId && ocean ? ( - userAgreed ? ( - <> - - - - ) : ( - <> -
- -
- - ) - ) : ( -
Connect your wallet to see your compute jobs.
- ) -} diff --git a/src/components/pages/History/index.tsx b/src/components/pages/History/index.tsx index 0a1ca7e90..78b5a3ee7 100644 --- a/src/components/pages/History/index.tsx +++ b/src/components/pages/History/index.tsx @@ -1,7 +1,6 @@ import React, { ReactElement, ReactNode } from 'react' import styles from './index.module.css' import PublishedList from './PublishedList' -import JobsList from './JobsList' const sections = [ { diff --git a/tests/unit/__fixtures__/job.ts b/tests/unit/__fixtures__/job.ts deleted file mode 100644 index 0cc2a453b..000000000 --- a/tests/unit/__fixtures__/job.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { ComputeJob } from '@oceanprotocol/lib' - -// ComputeJob need to be updated in squid -const job: Partial = { - agreementId: - 'ccc60b8d33ae4986b224551b69f521761171159994474debbb5353f45286e206', - algorithmLogUrl: - 'https://compute-publish.s3.amazonaws.com/605fb38b076844b7a2ee912b229a3f73/data/logs/algorithm.log', - dateCreated: '1585828421.03217', - dateFinished: '1585828541.73514', - jobId: '605fb38b076844b7a2ee912b229a3f7333', - owner: '0x4D156A2ef69ffdDC55838176C6712C90f60a2285', - resultsUrls: [ - 'https://compute-publish.s3.amazonaws.com/605fb38b076844b7a2ee912b229a3f73/data/outputs/output.log' - ], - status: 70, - statusText: 'Job finished' -} - -export default job diff --git a/tests/unit/__mocks__/@oceanprotocol/lib.ts b/tests/unit/__mocks__/@oceanprotocol/lib.ts index 9f7131596..f939f5acb 100644 --- a/tests/unit/__mocks__/@oceanprotocol/lib.ts +++ b/tests/unit/__mocks__/@oceanprotocol/lib.ts @@ -1,5 +1,4 @@ import ddo from '../../__fixtures__/ddo' -import job from '../../__fixtures__/job' const metadataStore = { queryMetadata: () => { @@ -19,11 +18,11 @@ const libMock = { list: () => ['xxx', 'xxx'] }, metadataStore, - compute: { - status: (account: string) => { - return [job] - } - }, + // compute: { + // status: (account: string) => { + // return [job] + // } + // }, assets: { query: () => { return {