diff --git a/src/app/MlHub/Datasets/DatasetDetails.module.scss b/src/app/MlHub/Datasets/DatasetDetails.module.scss new file mode 100644 index 00000000..6744c1a3 --- /dev/null +++ b/src/app/MlHub/Datasets/DatasetDetails.module.scss @@ -0,0 +1,63 @@ +.dataset-details { + padding-left: 1em; + padding-right: 1em; +} + +.buttons-container { + display: flex; + flex-direction: column; + position: absolute; + top: 0px; + right: 0px; + gap: 20px; +} + +.dataset-details-wrapper { + display: flex; + flex-direction: row; + width: 100%; + position: relative; +} + +.dataset-details { + display: flex; + flex-direction: column; + gap: 16px; + flex: 1; +} + +.dataset-title { + padding-bottom: 8px; + margin-left: 10px; +} + +.dataset-detail { + display: flex; + flex-direction: row; +} + +.dataset-title { + font-weight: bold; + width: 10vw; +} + +.detail-info { + margin-left: 8px; + text-align: left; +} + +.dataset-title-container { + border-bottom: 1px solid black; + margin-bottom: 8px; +} + +.download-links { + flex-grow: 1; + display: flex; + flex-direction: column; + padding-bottom: 5px; +} + +.download-url-button { + height: 40px; +} diff --git a/src/app/MlHub/Datasets/DatasetDetails.tsx b/src/app/MlHub/Datasets/DatasetDetails.tsx new file mode 100644 index 00000000..f15982ec --- /dev/null +++ b/src/app/MlHub/Datasets/DatasetDetails.tsx @@ -0,0 +1,238 @@ +import React, { useState } from 'react'; +import { Datasets } from '@tapis/tapis-typescript'; +import { MLHub as Hooks } from '@tapis/tapisui-hooks'; +import { QueryWrapper } from '@tapis/tapisui-common'; +import { Button } from 'reactstrap'; +import styles from './DatasetDetails.module.scss'; +import { Icon, JSONDisplay, GenericModal } from '@tapis/tapisui-common'; + +type DatasetDetailsProps = { + datasetId: string; +}; + +const DatasetDetails: React.FC = ({ datasetId }) => { + const { data, isLoading, error } = Hooks.Datasets.useDetails({ datasetId }); + const dataset: Datasets.DatasetFullInfo = data?.result ?? {}; + return ( + +
+
+ {datasetId} +
+
+
+
+ {dataset.author && ( +
+
author:
+
+ {dataset.author} +
+
+ )} + + {dataset.downloads && ( +
+
downloads:
+
+ {dataset.downloads} +
+
+ )} + + {dataset.created_at && ( +
+
created_at:
+
+ {dataset.created_at} +
+
+ )} + + {dataset.last_modified && ( +
+
last_modified:
+
+ {dataset.last_modified} +
+
+ )} + + {dataset.tags && ( +
+
tags:
+
{dataset.tags}
+
+ )} + + {dataset.sha && ( +
+
sha:
+
{dataset.sha}
+
+ )} + + {dataset.repository_content && ( +
+
+ repository_content: +
+ +
+ {dataset.repository_content && ( + + )} +
+
+ )} + + {dataset.description && ( +
+
description:
+
+ {dataset.description} +
+
+ )} + + {dataset.paperswithcode_id && ( +
+
+ paperswithcode_id: +
+
+ {dataset.paperswithcode_id} +
+
+ )} + + {dataset.citation && ( +
+
citation:
+
+ {dataset.citation} +
+
+ )} +
+ +
+
+ ); +}; + +const Buttons: React.FC<{ datasetId: string }> = ({ datasetId }) => { + const [currentDataset, setCurrentDataset] = useState( + undefined + ); + + const { data, error, isLoading } = Hooks.Datasets.useDetails({ datasetId }); + + const datasetCardDetails: Datasets.DatasetFullInfo = data?.result ?? {}; + + const { + data: downloadLinkData, + error: downloadLinkError, + isLoading: downloadLinkIsLoading, + } = Hooks.Datasets.useDownloadLinks({ datasetId }); + + const downloadLinkInfo: Datasets.DatasetDownloadInfo = + downloadLinkData?.result ?? {}; + + const downloadOnClick = (url: string, filename: string) => { + fetch(url).then((response) => { + response.blob().then((blob) => { + const fileURL = window.URL.createObjectURL(blob); + let alink = document.createElement('a'); + alink.href = fileURL; + alink.download = filename; + document.body.appendChild(alink); + alink.click(); + document.body.removeChild(alink); + + window.URL.revokeObjectURL(fileURL); + }); + }); + }; + + return ( +
+ + + + + {currentDataset === 'datasetcard' && ( + { + setCurrentDataset(undefined); + }} + title="Dataset Card" + body={ +
+ {datasetId} + {datasetCardDetails.card_data && ( + + )} +
+ } + /> + )} + + {currentDataset === 'downloaddataset' && ( + { + setCurrentDataset(undefined); + }} + title="Download Dataset" + body={ +
+ {downloadLinkInfo?.download_links && + Object.entries(downloadLinkInfo.download_links).map( + ([filename, url]) => { + return ( +
+
{filename}:
+
+
+ +
+
+ ); + } + )} +
+ } + /> + )} +
+ ); +}; + +export default DatasetDetails; diff --git a/src/app/MlHub/Datasets/_Router/Router.tsx b/src/app/MlHub/Datasets/_Router/Router.tsx index 80ae9ab1..1a371f79 100644 --- a/src/app/MlHub/Datasets/_Router/Router.tsx +++ b/src/app/MlHub/Datasets/_Router/Router.tsx @@ -6,6 +6,7 @@ import { RouteComponentProps, } from 'react-router-dom'; import Datasets from '../Datasets'; +import DatasetDetails from '../DatasetDetails'; const Router: React.FC = () => { const { path } = useRouteMatch(); @@ -14,6 +15,17 @@ const Router: React.FC = () => { + + ) => { + return ; + }} + /> ); }; diff --git a/src/app/MlHub/Models/InferenceServerInfo.module.scss b/src/app/MlHub/Models/InferenceServerInfo.module.scss new file mode 100644 index 00000000..f36037c5 --- /dev/null +++ b/src/app/MlHub/Models/InferenceServerInfo.module.scss @@ -0,0 +1,63 @@ +.model-details { + padding-left: 1em; + padding-right: 1em; +} + +.buttons-container { + display: flex; + flex-direction: column; + position: absolute; + top: 0px; + right: 0px; + gap: 20px; +} + +.model-details-wrapper { + display: flex; + flex-direction: row; + width: 100%; + position: relative; +} + +.model-details { + display: flex; + flex-direction: column; + gap: 16px; + flex: 1; +} + +.model-title { + padding-bottom: 8px; + margin-left: 10px; +} + +.model-detail { + display: flex; + flex-direction: row; +} + +.detail-title { + font-weight: bold; + width: 15vw; +} + +.detail-info { + margin-left: 8px; + text-align: left; +} + +.model-title-container { + border-bottom: 1px solid black; + margin-bottom: 8px; +} + +.download-links { + flex-grow: 1; + display: flex; + flex-direction: column; + padding-bottom: 5px; +} + +.download-url-button { + height: 40px; +} diff --git a/src/app/MlHub/Models/InferenceServerInfo.tsx b/src/app/MlHub/Models/InferenceServerInfo.tsx index 777bc683..4968efde 100644 --- a/src/app/MlHub/Models/InferenceServerInfo.tsx +++ b/src/app/MlHub/Models/InferenceServerInfo.tsx @@ -1,9 +1,9 @@ import React from 'react'; import { MLHub as Hooks } from '@tapis/tapisui-hooks'; import { JSONDisplay } from '@tapis/tapisui-common'; -import styles from './ModelDetails.module.scss'; import { QueryWrapper } from '@tapis/tapisui-common'; import { Link, useRouteMatch } from 'react-router-dom'; +import styles from './InferenceServerInfo.module.scss'; type InferenceServerInfoProps = { modelId: string; @@ -87,7 +87,9 @@ const InferenceServerInfo: React.FC = ({ inference_server_possible:
- {String(serverInfo.result?.inference_server_possible)} + {!!serverInfo.result?.inference_server_possible === false + ? 'false' + : 'true'}