-
+
{footerContent}
diff --git a/src/components/ui/hint.tsx b/src/components/ui/hint.tsx
index 93331ac..bffe585 100644
--- a/src/components/ui/hint.tsx
+++ b/src/components/ui/hint.tsx
@@ -3,20 +3,27 @@ import { ReactElement } from "react";
import { MdHelpOutline } from "react-icons/md";
interface HintProps {
- children: ReactElement;
- hintContent: ReactElement;
- className?: string;
+ children: ReactElement;
+ hintContent: ReactElement;
+ className?: string;
}
-export const Hint: React.FC
= ({ children, hintContent, className = "" }) => {
- return (
-
- );
-};
+export function Hint(props: HintProps): ReactElement {
+ return (
+
+
{props.children}
+
+
+
+
+
+
+ );
+}
diff --git a/src/components/ui/link.tsx b/src/components/ui/link.tsx
index 671ccf2..7983a71 100644
--- a/src/components/ui/link.tsx
+++ b/src/components/ui/link.tsx
@@ -1,13 +1,20 @@
-import React, { ReactElement } from "react";
+import { ReactElement } from "react";
interface LinkProps {
- children?: ReactElement | string;
- href: string;
+ children?: ReactElement | string;
+ href: string;
}
-export const Link: React.FC = ({ children, href }) => {
- const content = children ?? href
- return
- {content}
+export function Link(props: LinkProps): ReactElement {
+ const content = props.children ?? props.href;
+ return (
+
+ {content}
-}
\ No newline at end of file
+ );
+}
diff --git a/src/components/ui/searchbar.tsx b/src/components/ui/searchbar.tsx
index 0e5adc9..8e15eb4 100644
--- a/src/components/ui/searchbar.tsx
+++ b/src/components/ui/searchbar.tsx
@@ -1,4 +1,4 @@
-import React, { useState } from "react";
+import { ReactElement, useState } from "react";
import { Link } from "react-router-dom";
import classNames from "classnames";
import { Button } from "./button";
@@ -11,27 +11,28 @@ interface SearchBarProps {
showLogo?: boolean;
}
-export const SearchBar: React.FC = ({
- initialValue = "",
- onSearch,
- className,
- logoSize = "large",
- showLogo = true,
-}) => {
+export function SearchBar(props: SearchBarProps): ReactElement {
+ const {
+ initialValue = "",
+ logoSize = "large",
+ showLogo = true,
+ onSearch,
+ className,
+ } = props;
const [searchQuery, setSearchQuery] = useState(initialValue);
- const handleSubmit = () => {
+ function handleSubmit() {
if (searchQuery.trim()) {
onSearch(searchQuery);
}
- };
+ }
return (
{showLogo && (
@@ -70,4 +71,4 @@ export const SearchBar: React.FC = ({
);
-};
+}
diff --git a/src/index.css b/src/index.css
index b51a0e5..610a3cb 100644
--- a/src/index.css
+++ b/src/index.css
@@ -30,4 +30,4 @@ h1 {
color: #213547;
background-color: #ffffff;
}
-}
\ No newline at end of file
+}
diff --git a/src/main.tsx b/src/main.tsx
index bef5202..eff7ccc 100644
--- a/src/main.tsx
+++ b/src/main.tsx
@@ -1,10 +1,10 @@
-import { StrictMode } from 'react'
-import { createRoot } from 'react-dom/client'
-import './index.css'
-import App from './App.tsx'
+import { StrictMode } from "react";
+import { createRoot } from "react-dom/client";
+import "./index.css";
+import App from "./App.tsx";
-createRoot(document.getElementById('root')!).render(
+createRoot(document.getElementById("root")!).render(
,
-)
+);
diff --git a/src/pages/Home.tsx b/src/pages/Home.tsx
index 8932a42..ea8a759 100644
--- a/src/pages/Home.tsx
+++ b/src/pages/Home.tsx
@@ -1,4 +1,4 @@
-import { useNavigate } from "react-router-dom";
+import { NavigateFunction, useNavigate } from "react-router-dom";
import { SearchBar } from "../components/ui/searchbar";
import { ReactElement } from "react";
import { Link } from "../components/ui/link";
@@ -15,16 +15,19 @@ const homePageHint: ReactElement = (
- The search conditions can be concatenated with AND or OR operators. For example:
+ The search conditions can be concatenated with AND or OR operators. For
+ example:
-
- Search by name and PGC number:
+ Search by name and PGC number:{" "}
+
name:IC1445 and pgc:112642
-
- Search by name or PGC number:
+ Search by name or PGC number:{" "}
+
name:IC4445 or pgc:87422
@@ -32,19 +35,21 @@ const homePageHint: ReactElement = (
);
-export const HomePage: React.FC = () => {
- const navigate = useNavigate();
-
- const handleSearch = (query: string) => {
+function searchHandler(navigate: NavigateFunction) {
+ return function f(query: string) {
navigate(`/query?q=${encodeURIComponent(query)}`);
};
+}
+
+export function HomePage(): ReactElement {
+ const navigate = useNavigate();
return (
-
-
-
404
-
- Page Not Found
-
-
- The page you're looking for doesn't exist or has been moved.
-
-
-
-
-
-
+ return (
+
+
+
+
404
+
Page Not Found
+
+ The page you're looking for doesn't exist or has been moved.
+
- );
+
+
+
+
+
+ );
}
diff --git a/src/pages/ObjectDetails.tsx b/src/pages/ObjectDetails.tsx
index baa7602..39e8add 100644
--- a/src/pages/ObjectDetails.tsx
+++ b/src/pages/ObjectDetails.tsx
@@ -1,13 +1,185 @@
-import { useEffect, useState } from "react";
-import { useNavigate, useParams } from "react-router-dom";
+import { ReactElement, useEffect, useState } from "react";
+import { NavigateFunction, useNavigate, useParams } from "react-router-dom";
import { SearchBar } from "../components/ui/searchbar";
import { Button } from "../components/ui/button";
import { AladinViewer } from "../components/ui/aladin";
import { CommonTable } from "../components/ui/common-table";
-import { querySimpleApiV1QuerySimpleGet } from "../clients/backend/sdk.gen"
-import { PgcObject, Schema } from "../clients/backend/types.gen"
+import { querySimpleApiV1QuerySimpleGet } from "../clients/backend/sdk.gen";
+import { PgcObject, Schema } from "../clients/backend/types.gen";
-export const ObjectDetailsPage: React.FC = () => {
+function backToResultsHandler(navigate: NavigateFunction) {
+ return function f() {
+ navigate(-1);
+ };
+}
+
+function searchHandler(navigate: NavigateFunction) {
+ return function f(query: string) {
+ navigate(`/query?q=${encodeURIComponent(query)}`);
+ };
+}
+
+function renderNotFound(navigate: NavigateFunction) {
+ return (
+
+
+
Object not found.
+
+ );
+}
+
+function renderObjectDetails(
+ object: PgcObject,
+ schema: Schema | null,
+): ReactElement {
+ if (!object || !schema) return
;
+
+ const coordinatesColumns = [
+ { name: "Parameter" },
+ { name: "Value" },
+ { name: "Unit" },
+ { name: "Error" },
+ { name: "Error unit" },
+ ];
+
+ const coordinatesData = [
+ {
+ Parameter: "Right ascension",
+ Value: object.catalogs?.coordinates?.equatorial?.ra?.toFixed(6) || "NULL",
+ Unit: schema.units.coordinates?.equatorial?.ra || "NULL",
+ Error:
+ object.catalogs?.coordinates?.equatorial?.e_ra?.toFixed(6) || "NULL",
+ "Error unit": schema.units.coordinates?.equatorial?.e_ra || "NULL",
+ },
+ {
+ Parameter: "Declination",
+ Value:
+ object.catalogs?.coordinates?.equatorial?.dec?.toFixed(6) || "NULL",
+ Unit: schema.units.coordinates?.equatorial?.dec || "NULL",
+ Error:
+ object.catalogs?.coordinates?.equatorial?.e_dec?.toFixed(6) || "NULL",
+ "Error unit": schema.units.coordinates?.equatorial?.e_dec || "NULL",
+ },
+ {
+ Parameter: "Galactic longitude",
+ Value: object.catalogs?.coordinates?.galactic?.lon?.toFixed(6) || "NULL",
+ Unit: schema.units.coordinates?.galactic?.lon || "NULL",
+ Error:
+ object.catalogs?.coordinates?.galactic?.e_lon?.toFixed(6) || "NULL",
+ "Error unit": schema.units.coordinates?.galactic?.e_lon || "NULL",
+ },
+ {
+ Parameter: "Galactic latitude",
+ Value: object.catalogs?.coordinates?.galactic?.lat?.toFixed(6) || "NULL",
+ Unit: schema.units.coordinates?.galactic?.lat || "NULL",
+ Error:
+ object.catalogs?.coordinates?.galactic?.e_lat?.toFixed(6) || "NULL",
+ "Error unit": schema.units.coordinates?.galactic?.e_lat || "NULL",
+ },
+ ];
+
+ const redshiftColumns = [
+ { name: "Parameter" },
+ { name: "Value" },
+ { name: "Error" },
+ ];
+
+ const redshiftData = [
+ {
+ Parameter: "z",
+ Value: object.catalogs?.redshift?.z?.toFixed(6) || "NULL",
+ Error: object.catalogs?.redshift?.e_z?.toFixed(6) || "NULL",
+ },
+ ];
+
+ const velocityColumns = [
+ { name: "Parameter" },
+ { name: "Value" },
+ { name: "Unit" },
+ { name: "Error" },
+ { name: "Error unit" },
+ ];
+
+ const velocityData = [
+ {
+ Parameter: "Heliocentric",
+ Value: object.catalogs?.velocity?.heliocentric?.v?.toFixed(2) || "NULL",
+ Unit: schema.units.velocity?.heliocentric?.v || "NULL",
+ Error: object.catalogs?.velocity?.heliocentric?.e_v?.toFixed(2) || "NULL",
+ "Error unit": schema.units.velocity?.heliocentric?.e_v || "NULL",
+ },
+ {
+ Parameter: "Local Group",
+ Value: object.catalogs?.velocity?.local_group?.v?.toFixed(2) || "NULL",
+ Unit: schema.units.velocity?.local_group?.v || "NULL",
+ Error: object.catalogs?.velocity?.local_group?.e_v?.toFixed(2) || "NULL",
+ "Error unit": schema.units.velocity?.local_group?.e_v || "NULL",
+ },
+ {
+ Parameter: "CMB (old)",
+ Value: object.catalogs?.velocity?.cmb_old?.v?.toFixed(2) || "NULL",
+ Unit: schema.units.velocity?.cmb_old?.v || "NULL",
+ Error: object.catalogs?.velocity?.cmb_old?.e_v?.toFixed(2) || "NULL",
+ "Error unit": schema.units.velocity?.cmb_old?.e_v || "NULL",
+ },
+ {
+ Parameter: "CMB",
+ Value: object.catalogs?.velocity?.cmb?.v?.toFixed(2) || "NULL",
+ Unit: schema.units.velocity?.cmb?.v || "NULL",
+ Error: object.catalogs?.velocity?.cmb?.e_v?.toFixed(2) || "NULL",
+ "Error unit": schema.units.velocity?.cmb?.e_v || "NULL",
+ },
+ ];
+
+ return (
+
+
+ {object.catalogs?.coordinates?.equatorial && (
+
+ )}
+
+
+ {object.catalogs?.designation?.name || `PGC ${object.pgc}`}
+
+
PGC: {object.pgc}
+
+
+
+ {object.catalogs?.coordinates && (
+
+ Coordinates
+ Celestial coordinates of the object
+
+ )}
+
+ {object.catalogs?.redshift && (
+
+ Redshift
+ Redshift measurements
+
+ )}
+
+ {object.catalogs?.velocity && (
+
+ Velocity
+
+ Velocity measurements with respect to different apexes
+
+
+ )}
+
+ );
+}
+
+export function ObjectDetailsPage(): ReactElement {
const { pgcId } = useParams<{ pgcId: string }>();
const [object, setObject] = useState
(null);
const [schema, setSchema] = useState(null);
@@ -15,7 +187,7 @@ export const ObjectDetailsPage: React.FC = () => {
const navigate = useNavigate();
useEffect(() => {
- const fetchObjectDetails = async () => {
+ async function fetchObjectDetails() {
if (!pgcId || isNaN(Number(pgcId))) {
navigate("/");
return;
@@ -25,17 +197,17 @@ export const ObjectDetailsPage: React.FC = () => {
try {
const response = await querySimpleApiV1QuerySimpleGet({
query: {
- pgcs: [Number(pgcId)]
- }
- })
+ pgcs: [Number(pgcId)],
+ },
+ });
- const objects = response.data?.data.objects
- const schema = response.data?.data.schema
+ const objects = response.data?.data.objects;
+ const schema = response.data?.data.schema;
if (objects && objects.length > 0) {
const objectData = objects[0];
setObject(objectData);
- setSchema(schema || null)
+ setSchema(schema || null);
} else {
console.error("Object not found");
}
@@ -44,189 +216,28 @@ export const ObjectDetailsPage: React.FC = () => {
} finally {
setLoading(false);
}
- };
+ }
fetchObjectDetails();
}, [pgcId, navigate]);
- const handleBackToResults = () => {
- navigate(-1);
- };
-
- const handleSearch = (query: string) => {
- navigate(`/query?q=${encodeURIComponent(query)}`);
- };
-
- const renderObjectDetails = () => {
- if (!object || !schema) return null;
-
- const coordinatesColumns = [
- { name: "Parameter" },
- { name: "Value" },
- { name: "Unit" },
- { name: "Error" },
- { name: "Error unit" },
- ];
-
- const coordinatesData = [
- {
- Parameter: "Right ascension",
- Value: object.catalogs?.coordinates?.equatorial?.ra?.toFixed(6) || "NULL",
- Unit: schema.units.coordinates?.equatorial?.ra || "NULL",
- Error: object.catalogs?.coordinates?.equatorial?.e_ra?.toFixed(6) || "NULL",
- "Error unit": schema.units.coordinates?.equatorial?.e_ra || "NULL",
- },
- {
- Parameter: "Declination",
- Value: object.catalogs?.coordinates?.equatorial?.dec?.toFixed(6) || "NULL",
- Unit: schema.units.coordinates?.equatorial?.dec || "NULL",
- Error: object.catalogs?.coordinates?.equatorial?.e_dec?.toFixed(6) || "NULL",
- "Error unit": schema.units.coordinates?.equatorial?.e_dec || "NULL",
- },
- {
- Parameter: "Galactic longitude",
- Value: object.catalogs?.coordinates?.galactic?.lon?.toFixed(6) || "NULL",
- Unit: schema.units.coordinates?.galactic?.lon || "NULL",
- Error: object.catalogs?.coordinates?.galactic?.e_lon?.toFixed(6) || "NULL",
- "Error unit": schema.units.coordinates?.galactic?.e_lon || "NULL",
- },
- {
- Parameter: "Galactic latitude",
- Value: object.catalogs?.coordinates?.galactic?.lat?.toFixed(6) || "NULL",
- Unit: schema.units.coordinates?.galactic?.lat || "NULL",
- Error: object.catalogs?.coordinates?.galactic?.e_lat?.toFixed(6) || "NULL",
- "Error unit": schema.units.coordinates?.galactic?.e_lat || "NULL",
- },
- ];
-
- const redshiftColumns = [
- { name: "Parameter" },
- { name: "Value" },
- { name: "Error" },
- ];
-
- const redshiftData = [
- {
- Parameter: "z",
- Value: object.catalogs?.redshift?.z?.toFixed(6) || "NULL",
- Error: object.catalogs?.redshift?.e_z?.toFixed(6) || "NULL",
- },
- ];
-
- const velocityColumns = [
- { name: "Parameter" },
- { name: "Value" },
- { name: "Unit" },
- { name: "Error" },
- { name: "Error unit" },
- ];
-
- const velocityData = [
- {
- Parameter: "Heliocentric",
- Value: object.catalogs?.velocity?.heliocentric?.v?.toFixed(2) || "NULL",
- Unit: schema.units.velocity?.heliocentric?.v || "NULL",
- Error: object.catalogs?.velocity?.heliocentric?.e_v?.toFixed(2) || "NULL",
- "Error unit": schema.units.velocity?.heliocentric?.e_v || "NULL",
- },
- {
- Parameter: "Local Group",
- Value: object.catalogs?.velocity?.local_group?.v?.toFixed(2) || "NULL",
- Unit: schema.units.velocity?.local_group?.v || "NULL",
- Error: object.catalogs?.velocity?.local_group?.e_v?.toFixed(2) || "NULL",
- "Error unit": schema.units.velocity?.local_group?.e_v || "NULL",
- },
- {
- Parameter: "CMB (old)",
- Value: object.catalogs?.velocity?.cmb_old?.v?.toFixed(2) || "NULL",
- Unit: schema.units.velocity?.cmb_old?.v || "NULL",
- Error: object.catalogs?.velocity?.cmb_old?.e_v?.toFixed(2) || "NULL",
- "Error unit": schema.units.velocity?.cmb_old?.e_v || "NULL",
- },
- {
- Parameter: "CMB",
- Value: object.catalogs?.velocity?.cmb?.v?.toFixed(2) || "NULL",
- Unit: schema.units.velocity?.cmb?.v || "NULL",
- Error: object.catalogs?.velocity?.cmb?.e_v?.toFixed(2) || "NULL",
- "Error unit": schema.units.velocity?.cmb?.e_v || "NULL",
- },
- ];
-
- return (
-
-
- {object.catalogs?.coordinates?.equatorial && (
-
- )}
-
-
- {object.catalogs?.designation?.name || `PGC ${object.pgc}`}
-
-
PGC: {object.pgc}
-
-
-
- {object.catalogs?.coordinates && (
-
- Coordinates
- Celestial coordinates of the object
-
- )}
-
- {object.catalogs?.redshift && (
-
- Redshift
- Redshift measurements
-
- )}
-
- {object.catalogs?.velocity && (
-
- Velocity
- Velocity measurements with respect to different apexes
-
- )}
-
- );
- };
-
- const renderNotFound = () => (
-
-
-
Object not found.
-
- );
-
return (
-
+
{loading ? (
) : object ? (
- renderObjectDetails()
+ renderObjectDetails(object, schema)
) : (
- renderNotFound()
+ renderNotFound(navigate)
)}
);
-};
+}
diff --git a/src/pages/SearchResults.tsx b/src/pages/SearchResults.tsx
index de1f447..1d3af8a 100644
--- a/src/pages/SearchResults.tsx
+++ b/src/pages/SearchResults.tsx
@@ -1,11 +1,39 @@
-import { useEffect, useState } from "react";
-import { useNavigate, useSearchParams } from "react-router-dom";
-import { backendClient, SearchPGCObject } from "../clients/backend";
+import { ReactElement, useEffect, useState } from "react";
+import {
+ NavigateFunction,
+ useNavigate,
+ useSearchParams,
+} from "react-router-dom";
+import { SearchPGCObject, backendClient } from "../clients/backend";
import { SearchBar } from "../components/ui/searchbar";
import { AladinViewer } from "../components/ui/aladin";
import { Card, CardContent } from "../components/ui/card";
-export const SearchResultsPage: React.FC = () => {
+function objectClickHandler(
+ navigate: NavigateFunction,
+ object: SearchPGCObject,
+) {
+ navigate(`/object/${object.pgc}`);
+}
+
+function searchHandler(navigate: NavigateFunction) {
+ return function f(query: string) {
+ navigate(`/query?q=${encodeURIComponent(query)}`);
+ };
+}
+
+function pageChangeHandler(
+ navigate: NavigateFunction,
+ query: string,
+ pageSize: number,
+ newPage: number,
+) {
+ navigate(
+ `/query?q=${encodeURIComponent(query)}&page=${newPage}&pagesize=${pageSize}`,
+ );
+}
+
+export function SearchResultsPage(): ReactElement {
const [searchParams] = useSearchParams();
const [results, setResults] = useState([]);
const [loading, setLoading] = useState(true);
@@ -15,7 +43,7 @@ export const SearchResultsPage: React.FC = () => {
const pageSize = parseInt(searchParams.get("pagesize") || "10");
useEffect(() => {
- const fetchResults = async () => {
+ async function fetchResults() {
if (!query.trim()) {
navigate("/");
return;
@@ -30,34 +58,16 @@ export const SearchResultsPage: React.FC = () => {
} finally {
setLoading(false);
}
- };
+ }
fetchResults();
}, [query, navigate, pageSize, page]);
- const handleObjectClick = (object: SearchPGCObject) => {
- navigate(`/object/${object.pgc}`);
- };
-
- const handleSearch = (newQuery: string) => {
- if (newQuery.trim()) {
- navigate(`/query?q=${encodeURIComponent(newQuery)}`);
- }
- };
-
- const handlePageChange = (newPage: number) => {
- navigate(
- `/query?q=${encodeURIComponent(
- query
- )}&page=${newPage}&pagesize=${pageSize}`
- );
- };
-
return (
@@ -79,7 +89,7 @@ export const SearchResultsPage: React.FC = () => {
handleObjectClick(object)}
+ onClick={() => objectClickHandler(navigate, object)}
>
PGC {object.pgc}
@@ -100,7 +110,9 @@ export const SearchResultsPage: React.FC = () => {
))}
Page {page}
);
-};
+}
diff --git a/src/pages/TableDetails.tsx b/src/pages/TableDetails.tsx
index 39995c3..1b54d21 100644
--- a/src/pages/TableDetails.tsx
+++ b/src/pages/TableDetails.tsx
@@ -1,184 +1,231 @@
-import React, { ReactElement, useEffect, useState } from "react";
-import { GetTableResponse, HttpValidationError, Bibliography } from "../clients/admin/types.gen";
+import { ReactElement, useEffect, useState } from "react";
+import {
+ Bibliography,
+ GetTableResponse,
+ HttpValidationError,
+} from "../clients/admin/types.gen";
import { getTableAdminApiV1TableGet } from "../clients/admin/sdk.gen";
import { useNavigate, useParams } from "react-router-dom";
-import { CommonTable, Column } from "../components/ui/common-table";
+import {
+ CellPrimitive,
+ Column,
+ CommonTable,
+} from "../components/ui/common-table";
import { CopyButton } from "../components/ui/copy-button";
import { Link } from "../components/ui/link";
function renderBibliography(bib: Bibliography): ReactElement {
- var authors = ""
+ let authors = "";
- if (bib.authors.length >= 1) {
- authors += bib.authors[0]
- }
- if (bib.authors.length >= 2) {
- authors += " et al."
- }
+ if (bib.authors.length >= 1) {
+ authors += bib.authors[0];
+ }
+ if (bib.authors.length >= 2) {
+ authors += " et al.";
+ }
- authors += ` ${bib.year}`
+ authors += ` ${bib.year}`;
- const targetLink = "https://ui.adsabs.harvard.edu/abs/" + bib.bibcode + "/abstract"
+ const targetLink =
+ "https://ui.adsabs.harvard.edu/abs/" + bib.bibcode + "/abstract";
- return
- {bib.bibcode} | {authors}: "{bib.title}"
+ return (
+
+
+ {bib.bibcode} | {authors}: "{bib.title}"
+
+ );
}
function renderTime(time: string): string {
- const dt = new Date(time as string);
+ const dt = new Date(time as string);
- return dt.toString()
+ return dt.toString();
}
-function renderUCD(ucd: string | undefined | null): ReactElement {
- if (!ucd) {
- return
- }
-
- var words: ReactElement[] = []
-
- ucd.split(";").forEach((word, index) => {
- words.push(
- {word}
- )
- });
+function renderUCD(ucd: CellPrimitive): ReactElement {
+ if (!(typeof ucd === "string")) {
+ return ;
+ }
+
+ const words: ReactElement[] = [];
+
+ ucd.split(";").forEach((word, index) => {
+ words.push(
+
+ {word}
+
,
+ );
+ });
- return
- {words}
+ return (
+
+ {words}
+ );
}
-function renderColumnName(name: string): ReactElement {
- return
- {name}
+function renderColumnName(name: CellPrimitive): ReactElement {
+ return (
+
+ {name}
+ );
}
-const renderTableDetails = (tableName: string, table: GetTableResponse) => {
- const infoColumns = [
- { name: "Parameter" },
- { name: "Value" }
- ]
-
- const infoValues = [
- {
- Parameter: "Table ID",
- Value: table.id,
- },
- {
- Parameter: "Source paper",
- Value: renderBibliography(table.bibliography),
- },
- {
- Parameter: "Number of records",
- Value: table.rows_num
- },
- {
- Parameter: "Type of data",
- Value: table.meta.datatype
- },
- {
- Parameter: "Modification time",
- Value: renderTime(table.meta.modification_dt as string)
- }
- ]
-
- const columnInfoColumns: Column[] = [
- { name: "Name", renderCell: renderColumnName },
- { name: "Description" },
- { name: "Unit" },
- {
- name: "UCD",
- renderCell: renderUCD,
- hint:
- Unified Content Descriptor. Describes astronomical quantities in a structured way. For more information
- see IVOA Recommendation.
-
- },
- ]
-
- var columnInfoValues: any[] = []
-
- table.column_info.forEach(col => {
- columnInfoValues.push({
- Name: col.name,
- Description: col.description,
- Unit: col.unit,
- UCD: col.ucd,
- })
- });
-
- return
-
- {table.description}
- {tableName}
-
-
- Column information
-
+function renderTableDetails(
+ tableName: string,
+ table: GetTableResponse,
+): ReactElement {
+ const infoColumns = [{ name: "Parameter" }, { name: "Value" }];
+
+ const infoValues: Record
[] = [
+ {
+ Parameter: "Table ID",
+ Value: table.id,
+ },
+ {
+ Parameter: "Source paper",
+ Value: renderBibliography(table.bibliography),
+ },
+ {
+ Parameter: "Number of records",
+ Value: table.rows_num,
+ },
+ {
+ Parameter: "Type of data",
+ Value: String(table.meta.datatype),
+ },
+ {
+ Parameter: "Modification time",
+ Value: renderTime(table.meta.modification_dt as string),
+ },
+ ];
+
+ const columnInfoColumns: Column[] = [
+ { name: "Name", renderCell: renderColumnName },
+ { name: "Description" },
+ { name: "Unit" },
+ {
+ name: "UCD",
+ renderCell: renderUCD,
+ hint: (
+
+ Unified Content Descriptor. Describes astronomical quantities in a
+ structured way. For more information see{" "}
+
+ IVOA Recommendation
+
+ .
+
+ ),
+ },
+ ];
+
+ const columnInfoValues: Record[] = [];
+
+ table.column_info.forEach((col) => {
+ const colValue: Record = {
+ Name: col.name,
+ };
+
+ if (col.description) {
+ colValue.Description = col.description;
+ }
+ if (col.unit) {
+ colValue.Unit = col.unit;
+ }
+ if (col.ucd) {
+ colValue.UCD = col.ucd;
+ }
+
+ columnInfoValues.push(colValue);
+ });
+
+ return (
+
+
+
+ {table.description}
+
+ {tableName}
+
+
+ Column information
+
+ );
}
-export const TableDetailsPage: React.FC = () => {
- const { tableName } = useParams<{ tableName: string }>();
- const [table, setTable] = useState(null);
- const [error, setError] = useState(null);
- const [loading, setLoading] = useState(true);
- const navigate = useNavigate();
-
- useEffect(() => {
- const fetchData = async () => {
- if (!tableName) {
- navigate("/");
- return;
- }
-
- try {
- const response = await getTableAdminApiV1TableGet({ query: { table_name: tableName } })
- if (response.error) {
- setError(response.error)
- return
- }
-
- if (response.data) {
- setTable(response.data.data)
- }
- } catch (err) {
- console.log("Error fetching table", err)
- } finally {
- setLoading(false);
- }
- }
+function renderNotFound(): ReactElement {
+ return (
+
+ );
+}
- fetchData();
- }, [tableName, navigate])
+function renderError(error: HttpValidationError): ReactElement {
+ return (
+
+
{error.detail?.toString()}
+
+ );
+}
- const renderNotFound = () => (
-
- );
+export function TableDetailsPage(): ReactElement {
+ const { tableName } = useParams<{ tableName: string }>();
+ const [table, setTable] = useState(null);
+ const [error, setError] = useState(null);
+ const [loading, setLoading] = useState(true);
+ const navigate = useNavigate();
+
+ useEffect(() => {
+ async function fetchData() {
+ if (!tableName) {
+ navigate("/");
+ return;
+ }
+
+ try {
+ const response = await getTableAdminApiV1TableGet({
+ query: { table_name: tableName },
+ });
+ if (response.error) {
+ setError(response.error);
+ return;
+ }
- const renderError = (error: HttpValidationError) => (
-
-
{error.detail?.toString()}
-
- );
+ if (response.data) {
+ setTable(response.data.data);
+ }
+ } catch (err) {
+ console.log("Error fetching table", err);
+ } finally {
+ setLoading(false);
+ }
+ }
+
+ fetchData();
+ }, [tableName, navigate]);
- return (
-
- {loading ? (
-
- ) : table ? (
- renderTableDetails(tableName ?? "", table)
- ) : error ? (
- renderError(error)
- ) : (
- renderNotFound()
- )}
+ return (
+
+ {loading ? (
+
- );
-}
\ No newline at end of file
+ ) : table ? (
+ renderTableDetails(tableName ?? "", table)
+ ) : error ? (
+ renderError(error)
+ ) : (
+ renderNotFound()
+ )}
+
+ );
+}