Skip to content
Snippets Groups Projects
Verified Commit 37af0a1c authored by Timm Fitschen's avatar Timm Fitschen
Browse files

WIP: list fdo

parent e522077f
Branches
No related tags found
No related merge requests found
Pipeline #48651 passed
......@@ -138,7 +138,7 @@ const App = (props: React.PropsWithChildren) => {
name: 'fdo',
list: '/fdo',
show: '/fdo/show/:id',
create: '/fdo',
create: '/fdo/create',
meta: {
icon: logo
}
......
import React from 'react'
import { FdoCreate } from '../../../src/components/fdos'
import { GetServerSideProps } from 'next'
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
const CreateFDO = () => {
return <FdoCreate/>
}
export default CreateFDO
export const getServerSideProps: GetServerSideProps<{}> = async (context) => {
const translateProps = await serverSideTranslations(context.locale ?? 'en', [
'common'
])
return {
props: {
...translateProps
}
}
}
import React from 'react'
import { FdoCreate } from '../../src/components/fdos'
import { GetServerSideProps } from 'next'
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
const CreateFDO = () => {
return <FdoCreate/>
import { LoggingList } from '../../src/components/fdos'
const ListFdo = () => {
return <LoggingList/>
}
export default CreateFDO
export default ListFdo
export const getServerSideProps: GetServerSideProps<{}> = async (context) => {
const translateProps = await serverSideTranslations(context.locale ?? 'en', [
......
......@@ -3,14 +3,17 @@ import React from 'react'
import { ErrorComponent } from '../../../../src/components/ErrorComponent'
import { GetServerSideProps } from 'next'
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
import { useShow } from '@refinedev/core'
import { useShow, useTranslate } from '@refinedev/core'
import { Show } from '@refinedev/mui'
import { Typography } from '@mui/material'
import CircularProgress from '@mui/material/CircularProgress'
import Box from '@mui/material/Box'
import Stack from '@mui/material/Stack'
import Chip from '@mui/material/Chip'
import Link from '@mui/material/Link'
const ShowFDO = () => {
const t = useTranslate()
const { queryResult: { isError, error, isLoading, data }, showId } = useShow({
errorNotification: () => false,
queryOptions: {
......@@ -20,16 +23,21 @@ const ShowFDO = () => {
if (isError) {
console.log('error', error)
return <ErrorComponent/>
return <ErrorComponent message={t('fdo.show.handle_not_found', 'Handle not found.')} />
}
const handleUrl = `https://hdl.handle.net/${showId}`
return (
<Show
isLoading={isLoading}
title={<Typography variant="h5">{ showId }{ !isLoading && (data?.data?.isFdo ? <Chip label="FDO" color="success" variant="outlined" /> : <Chip label="Not an FDO" color="error" variant="outlined" />)}</Typography>}
>
{ isLoading && <Box sx={{ textAlign: 'center' }}><CircularProgress/></Box>}
<Box>This is FDO { showId }</Box>
<Stack>
<Box><Link href={handleUrl}>To Repository</Link></Box>
<Box><Link href={`${handleUrl}?noredirect`}>View Handle Record</Link></Box>
</Stack>
</Show>
)
......
This diff is collapsed.
/* eslint-disable */
/**
* FDO Manager Service API
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
* The FDO Manager Service API for creating FAIR Digital Objects.
*
* The version of the OpenAPI document: 0.1
*
* Contact: t.fitschen@indiscale.com
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
......
/* eslint-disable */
/**
* FDO Manager Service API
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
* The FDO Manager Service API for creating FAIR Digital Objects.
*
* The version of the OpenAPI document: 0.1
*
* Contact: t.fitschen@indiscale.com
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
......
/* eslint-disable */
/**
* FDO Manager Service API
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
* The FDO Manager Service API for creating FAIR Digital Objects.
*
* The version of the OpenAPI document: 0.1
*
* Contact: t.fitschen@indiscale.com
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
......
/* eslint-disable */
/**
* FDO Manager Service API
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
* The FDO Manager Service API for creating FAIR Digital Objects.
*
* The version of the OpenAPI document: 0.1
*
* Contact: t.fitschen@indiscale.com
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
......
......@@ -9,7 +9,7 @@ import Grid from '@mui/material/Grid'
import Info from '@mui/icons-material/Info'
export const ErrorComponent: React.FC<any> = ({ status = 404, back = undefined }) => {
export const ErrorComponent: React.FC<any> = ({ status = 404, back = undefined, message }) => {
// const [errorMessage, setErrorMessage] = useState<string>();
const { push } = useNavigation()
const go = useGo()
......@@ -18,6 +18,10 @@ export const ErrorComponent: React.FC<any> = ({ status = 404, back = undefined }
// const { resource, action } = useResource();
const translate = useTranslate()
const showErrorMessage = message || translate(
'pages.error.404',
'Sorry, the page you visited does not exist.'
)
/*
useEffect(() => {
......@@ -52,10 +56,7 @@ export const ErrorComponent: React.FC<any> = ({ status = 404, back = undefined }
<Typography variant="h1">{status}</Typography>
<Stack direction="row" spacing="2">
<Typography>
{translate(
'pages.error.404',
'Sorry, the page you visited does not exist.'
)}
{ showErrorMessage }
</Typography>
{/*
......
export * from './create'
export * from './list'
import { IResourceComponentsProps } from '@refinedev/core'
import Link from '@mui/material/Link'
import { List, useDataGrid } from '@refinedev/mui'
import {
DataGrid,
GridColDef,
GridValueFormatterParams
} from '@mui/x-data-grid'
import { OperationsLogRecord } from '../../api/api'
const columns: Array<GridColDef<OperationsLogRecord>> = [
{
field: 'operation',
headerName: 'Operation',
type: 'string',
width: 200
},
{
field: 'id',
headerName: 'FDO',
type: 'string',
width: 200
}
]
export const LoggingList: React.FC<IResourceComponentsProps> = () => {
const { dataGridProps } = useDataGrid<OperationsLogRecord>({
resource: 'fdo'
})
const rows = dataGridProps.rows.map((record: OperationsLogRecord, index) => {
return { id: record?.attributes?.fdo?.pid, operation: record?.attributes?.operation }
})
return (
<List>
<DataGrid {...dataGridProps} rows={rows} columns={columns} autoHeight />
</List>
)
}
import { DataProvider, useOne } from '@refinedev/core'
import dataProvider from '@refinedev/simple-rest'
import { Configuration, ProfilesApi, RepositoriesApi, DefaultApi, GetInfo200Response, ListRepositories200Response } from '../api'
import { Configuration, ProfilesApi, RepositoriesApi, FDOsApi, InfoApi, LoggingApi, GetInfo200Response, ListRepositories200Response } from '../api'
import axios from 'axios'
const getNewlyCreated = async (newLocation: string) => {
......@@ -10,9 +10,11 @@ const getNewlyCreated = async (newLocation: string) => {
const apiDataProvider = (apiUrl: string): DataProvider => {
const config: Configuration = new Configuration({ basePath: apiUrl })
const apiResources: any = {
default: new DefaultApi(config),
info: new InfoApi(config),
fdo: new FDOsApi(config),
profiles: new ProfilesApi(config),
repositories: new RepositoriesApi(config)
repositories: new RepositoriesApi(config),
logging: new LoggingApi(config)
}
const apiOperations: any = {
......@@ -25,11 +27,12 @@ const apiDataProvider = (apiUrl: string): DataProvider => {
get: apiResources.repositories.getRepository
},
info: {
get: apiResources.default.getInfo
get: apiResources.info.getInfo
},
fdo: {
get: apiResources.default.resolvePID,
create: apiResources.default.createFDO
list: apiResources.logging.listLogEvents,
get: apiResources.fdo.resolvePID,
create: apiResources.fdo.createFDO
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment