From 3f8d5b2675d6e71a3ccec9b593f6c05f271c0ed2 Mon Sep 17 00:00:00 2001 From: Darren Walker Date: Wed, 6 Nov 2024 14:54:27 +0000 Subject: [PATCH 1/5] update generated proposalTool* stuff to use latest API changes, update Add_@types.patch due to problems --- src/main/webui/Add_@types.patch | 135 ++++-------------- .../src/generated/proposalToolComponents.ts | 10 +- .../src/generated/proposalToolSchemas.ts | 2 +- 3 files changed, 33 insertions(+), 114 deletions(-) diff --git a/src/main/webui/Add_@types.patch b/src/main/webui/Add_@types.patch index 6253273..43fd032 100644 --- a/src/main/webui/Add_@types.patch +++ b/src/main/webui/Add_@types.patch @@ -1,6 +1,6 @@ ---- proposalToolSchemas.ts.orig 2024-10-30 13:50:57 -+++ proposalToolSchemas.ts 2024-10-30 13:55:30 -@@ -7,12 +7,14 @@ +--- proposalToolSchemas.ts.orig 2024-11-06 14:48:05 ++++ proposalToolSchemas.ts 2024-11-06 14:50:42 +@@ -7,6 +7,8 @@ * A block of resources that have been allocated */ export type AllocatedBlock = { @@ -9,13 +9,6 @@ /** * A resource that will be consumed by allocating an observation from a proposal */ - resource?: Resource; - /** -- * a configuration that has been chosen to observe with. -+ * a configuration can be used to observe with. - */ - mode?: ObservingMode; - /** @@ -25,6 +27,7 @@ * an instance of a proposal that is allocated observing time */ @@ -105,15 +98,6 @@ /** * any constraints on the observation */ -@@ -741,7 +752,7 @@ - */ - observation?: Observation[]; - /** -- * a configuration that has been chosen to observe with. -+ * a configuration can be used to observe with. - */ - mode?: ObservingMode; - }; @@ -750,6 +761,9 @@ * An organisation that can perform astronomical observations */ @@ -124,48 +108,15 @@ xmlId?: string; /** * The name of the organization -@@ -765,6 +779,10 @@ - */ - wikiId?: WikiDataId; - /** -+ * the home page for the Observatory -+ */ -+ homePage?: string; -+ /** - * the telescopes that the observatory controls - */ - telescopes?: Telescope[]; -@@ -788,9 +806,10 @@ - export type ObservingConstraint = Record; - - /** -- * a configuration that has been chosen to observe with. -+ * a configuration can be used to observe with. +@@ -795,6 +809,7 @@ + * a configuration can be used to observe with. */ export type ObservingMode = { + _id?: number; /** * human readable name for the mode */ -@@ -800,17 +819,6 @@ - */ - description?: string; - /** -- * A particular observation combination that is possible -- */ -- configuration?: ObservingModeConfiguration; -- xmlId?: string; --}; -- --/** -- * A particular observation combination that is possible -- */ --export type ObservingModeConfiguration = { -- /** - * Available filters /bandpasses for intruments - */ - filter?: Filter; -@@ -840,6 +848,7 @@ +@@ -833,6 +848,7 @@ * a complete proposal */ export type ObservingProposal = { @@ -173,7 +124,7 @@ /** * the proposal title */ -@@ -893,6 +902,8 @@ +@@ -886,6 +902,8 @@ * An institution that is a collection of people */ export type Organization = { @@ -182,7 +133,7 @@ /** * The name of the organization */ -@@ -1117,11 +1128,17 @@ +@@ -1110,6 +1128,8 @@ * Defines collection of resources and proposals for a particular observing season */ export type ProposalCycle = { @@ -191,16 +142,7 @@ /** * a human readable description of the cycle */ - title?: string; - /** -+ * pointer to more detailed instructions about the cycle -+ */ -+ instructions?: string; -+ /** - * the date by which observing proposals must be submitted to be considered for this cycle - * - * @format date -@@ -1186,6 +1203,7 @@ +@@ -1183,6 +1203,7 @@ * A review of a proposal */ export type ProposalReview = { @@ -208,7 +150,7 @@ /** * Description */ -@@ -1268,6 +1286,7 @@ +@@ -1265,6 +1286,7 @@ * A real value with a unit. */ export type RealQuantity = { @@ -216,7 +158,7 @@ /** * Must conform to definition of unit in VOUnit spec. */ -@@ -1299,6 +1318,8 @@ +@@ -1296,6 +1318,8 @@ * A resource that will be consumed by allocating an observation from a proposal */ export type Resource = { @@ -225,16 +167,7 @@ /** * The amount of the resource * -@@ -1320,7 +1341,7 @@ - */ - resource?: Resource; - /** -- * a configuration that has been chosen to observe with. -+ * a configuration can be used to observe with. - */ - mode?: ObservingMode; - }; -@@ -1329,6 +1350,7 @@ +@@ -1326,6 +1350,7 @@ * a type of resource */ export type ResourceType = { @@ -242,7 +175,7 @@ /** * the name of the resource type */ -@@ -1341,6 +1363,7 @@ +@@ -1338,6 +1363,7 @@ * assigned to review the proposal */ export type Reviewer = { @@ -250,7 +183,7 @@ /** * person connected with the proposal */ -@@ -1372,6 +1395,8 @@ +@@ -1369,6 +1395,8 @@ /** * Science oriented definition of a spectral window. */ @@ -259,7 +192,7 @@ spectralWindowSetup?: SpectralWindowSetup; expectedSpectralLine?: ExpectedSpectralLine[]; }; -@@ -1416,6 +1441,7 @@ +@@ -1413,6 +1441,7 @@ * A SpaceFrame is specified by its reference frame (orientation), and a reference position (origin). Currently only standard reference frames are allowed. An equinox MUST be provided for pre-ICRS reference frames. A planetary ephemeris MAY be provided if relevant. If needed, but not provided, it is assumed to be 'DE405'. */ export type SpaceFrame = { @@ -267,7 +200,7 @@ /** * RefLocation defines the origin of the spatial coordinate space. This location is represented either by a standard reference position (for which the absolute location in phase space is known by definition), or a specified point in another Spatial frame. This object is used as the origin of the SpaceFrame here, but also to specify the Spatial Reference Position (refPosition) associated with other domain Frames. For example, in the Time domain, the Spatial Reference Position indicates that the 'time' values are the time that the 'event' occured at that location, which might be different from the detector location. */ -@@ -1438,6 +1464,7 @@ +@@ -1435,6 +1464,7 @@ * Specialized coordinate system for the Spatial domain. This object SHOULD include an appropriate SpaceFrame. In Appendix B, we define two standard spatial coordinate space instances (Spherical and Cartesian), which may be referenced in serializations. If a CoordSpace is not provided, it is assumed to be represented by a Standard Spherical Coordinate Space. */ export type SpaceSys = { @@ -275,7 +208,7 @@ xmlId?: string; /** * Abstract head of coordinate spaces related to physical properties. -@@ -1521,7 +1548,7 @@ +@@ -1518,7 +1548,7 @@ /** * person connected with the proposal */ @@ -284,7 +217,7 @@ uid?: string; inKeycloakRealm?: boolean; }; -@@ -1541,6 +1568,7 @@ +@@ -1538,6 +1568,7 @@ * an instance of a proposal that has been submitted */ export type SubmittedProposal = { @@ -292,27 +225,7 @@ /** * the date that the proposal was submitted * -@@ -1559,15 +1587,15 @@ - * @example "2022-03-10T00:00:00.000Z" - */ - reviewsCompleteDate?: Date; -- /** -- * a complete proposal -- */ -- proposal?: ObservingProposal; - config?: ObservationConfiguration[]; - /** - * the reviews - */ - reviews?: ProposalReview[]; -+ /** -+ * a complete proposal -+ */ -+ proposal?: ObservingProposal; - xmlId?: string; - }; - -@@ -1604,17 +1632,20 @@ +@@ -1601,17 +1632,20 @@ * A target source */ export type Target = { @@ -333,7 +246,7 @@ xmlId?: string; name?: string; }; -@@ -1623,6 +1654,7 @@ +@@ -1620,6 +1654,7 @@ * an observation of the scientific target */ export type TargetObservation = { @@ -341,7 +254,7 @@ xmlId?: string; /** * any constraints on the observation -@@ -1651,10 +1683,12 @@ +@@ -1648,10 +1683,12 @@ */ performance?: PerformanceParameters; spectrum?: ScienceSpectralWindow[]; @@ -354,7 +267,7 @@ xmlId?: string; /** * telescope name -@@ -1674,6 +1708,7 @@ +@@ -1671,6 +1708,7 @@ * a set of telescopes that are operated together for an observation */ export type TelescopeArray = { @@ -362,7 +275,7 @@ xmlId?: string; /** * the array name -@@ -1755,6 +1790,10 @@ +@@ -1752,6 +1790,10 @@ * particular time range */ export type TimingWindow = { @@ -373,7 +286,7 @@ note?: string; isAvoidConstraint?: boolean; /** -@@ -1777,13 +1816,6 @@ +@@ -1774,13 +1816,6 @@ }; /** diff --git a/src/main/webui/src/generated/proposalToolComponents.ts b/src/main/webui/src/generated/proposalToolComponents.ts index a898af8..e986c32 100644 --- a/src/main/webui/src/generated/proposalToolComponents.ts +++ b/src/main/webui/src/generated/proposalToolComponents.ts @@ -1,7 +1,7 @@ /** * Generated by @openapi-codegen * - * @version 0.3 + * @version 0.4 */ import * as reactQuery from "@tanstack/react-query"; import { @@ -5910,6 +5910,11 @@ export type SubmittedProposalResourceGetSubmittedProposalsPathParams = { cycleCode: number; }; +export type SubmittedProposalResourceGetSubmittedProposalsQueryParams = { + investigatorName?: string; + title?: string; +}; + export type SubmittedProposalResourceGetSubmittedProposalsError = Fetcher.ErrorWrapper; @@ -5918,6 +5923,7 @@ export type SubmittedProposalResourceGetSubmittedProposalsResponse = export type SubmittedProposalResourceGetSubmittedProposalsVariables = { pathParams: SubmittedProposalResourceGetSubmittedProposalsPathParams; + queryParams?: SubmittedProposalResourceGetSubmittedProposalsQueryParams; } & ProposalToolContext["fetcherOptions"]; export const fetchSubmittedProposalResourceGetSubmittedProposals = ( @@ -5929,7 +5935,7 @@ export const fetchSubmittedProposalResourceGetSubmittedProposals = ( SubmittedProposalResourceGetSubmittedProposalsError, undefined, {}, - {}, + SubmittedProposalResourceGetSubmittedProposalsQueryParams, SubmittedProposalResourceGetSubmittedProposalsPathParams >({ url: "/pst/api/proposalCycles/{cycleCode}/submittedProposals", diff --git a/src/main/webui/src/generated/proposalToolSchemas.ts b/src/main/webui/src/generated/proposalToolSchemas.ts index 6937d05..a89bd6d 100644 --- a/src/main/webui/src/generated/proposalToolSchemas.ts +++ b/src/main/webui/src/generated/proposalToolSchemas.ts @@ -1,7 +1,7 @@ /** * Generated by @openapi-codegen * - * @version 0.3 + * @version 0.4 */ /** * A block of resources that have been allocated From 856c227fe8b9945006c8ad84c77512983b3b8829 Mon Sep 17 00:00:00 2001 From: Darren Walker Date: Wed, 6 Nov 2024 17:50:18 +0000 Subject: [PATCH 2/5] work-in-progress to list proposals with submitted information --- src/main/webui/src/App2.tsx | 8 +- .../landingPage/editorLandingPage.tsx | 27 +++++++ .../landingPage/observatoriesCycles.tsx | 8 +- .../landingPage/proposalsAccordion.tsx | 75 +++++++++++++++++++ .../landingPage/proposalsStatus.tsx | 55 -------------- .../src/ProposalEditorView/proposal/New.tsx | 2 +- src/main/webui/src/commonPanel/appearance.tsx | 12 ++- .../panelFeatureInterfaceProps.tsx | 2 +- 8 files changed, 121 insertions(+), 68 deletions(-) create mode 100644 src/main/webui/src/ProposalEditorView/landingPage/editorLandingPage.tsx create mode 100644 src/main/webui/src/ProposalEditorView/landingPage/proposalsAccordion.tsx delete mode 100644 src/main/webui/src/ProposalEditorView/landingPage/proposalsStatus.tsx diff --git a/src/main/webui/src/App2.tsx b/src/main/webui/src/App2.tsx index f444ab1..c4d6cc1 100644 --- a/src/main/webui/src/App2.tsx +++ b/src/main/webui/src/App2.tsx @@ -74,9 +74,8 @@ import CycleTitlePanel from "./ProposalManagerView/proposalCycle/title.tsx"; import ObservationFieldsPanel from "./ProposalEditorView/observationFields/ObservationFieldsPanel.tsx"; import AssignReviewersPanel from "./ProposalManagerView/assignReviewers/AssignReviewersPanel.tsx"; import ErrorPage from "./errorHandling/error-page.jsx" -import ObservatoriesCyclesPanel from "./ProposalEditorView/landingPage/observatoriesCycles.tsx"; import {PanelFrame} from "./commonPanel/appearance.tsx"; -import ProposalsStatus from "./ProposalEditorView/landingPage/proposalsStatus.tsx"; +import EditorLandingPage from "./ProposalEditorView/landingPage/editorLandingPage.tsx"; /** * defines the user context type. @@ -404,8 +403,6 @@ function App2(): ReactElement { - - @@ -475,8 +472,7 @@ function App2(): ReactElement { function PSTStart(): ReactElement { return ( - - + ); } diff --git a/src/main/webui/src/ProposalEditorView/landingPage/editorLandingPage.tsx b/src/main/webui/src/ProposalEditorView/landingPage/editorLandingPage.tsx new file mode 100644 index 0000000..b56e9b4 --- /dev/null +++ b/src/main/webui/src/ProposalEditorView/landingPage/editorLandingPage.tsx @@ -0,0 +1,27 @@ +import {ReactElement, useContext} from "react"; +import ObservatoriesCyclesPanel from "./observatoriesCycles.tsx"; +import ProposalsAccordion from "./proposalsAccordion.tsx"; +import {Fieldset, Space} from "@mantine/core"; +import {PanelHeader} from "../../commonPanel/appearance.tsx"; +import {ProposalContext} from "../../App2.tsx"; + +export default +function EditorLandingPage() : ReactElement { + + const context = useContext(ProposalContext); + + return ( + <> + + +
+ +
+ + + + + + + ) +} \ No newline at end of file diff --git a/src/main/webui/src/ProposalEditorView/landingPage/observatoriesCycles.tsx b/src/main/webui/src/ProposalEditorView/landingPage/observatoriesCycles.tsx index fc4826b..fb65fcb 100644 --- a/src/main/webui/src/ProposalEditorView/landingPage/observatoriesCycles.tsx +++ b/src/main/webui/src/ProposalEditorView/landingPage/observatoriesCycles.tsx @@ -4,7 +4,6 @@ import { useProposalCyclesResourceGetProposalCycleDates, useProposalCyclesResourceGetProposalCycles, } from "../../generated/proposalToolComponents.ts"; import {JSON_SPACES} from "../../constants.tsx"; -import {PanelHeader} from "../../commonPanel/appearance.tsx"; import {randomId} from "@mantine/hooks"; type CycleRowProps = { @@ -71,10 +70,11 @@ function ObservatoriesCyclesPanel (): ReactElement { }; - return <> - + return ( + <> {isLoading? 'Loading' : listCycles()} - ; + + ) } diff --git a/src/main/webui/src/ProposalEditorView/landingPage/proposalsAccordion.tsx b/src/main/webui/src/ProposalEditorView/landingPage/proposalsAccordion.tsx new file mode 100644 index 0000000..b76a1c9 --- /dev/null +++ b/src/main/webui/src/ProposalEditorView/landingPage/proposalsAccordion.tsx @@ -0,0 +1,75 @@ +import {ReactElement} from "react"; +import {Accordion, Fieldset, Grid, Group, Loader, ScrollArea, Text} from "@mantine/core"; +import {useProposalResourceGetProposals} from "../../generated/proposalToolComponents.ts"; +import {notifyError} from "../../commonPanel/notifications.tsx"; +import getErrorMessage from "../../errorHandling/getErrorMessage.tsx"; +import {ProposalSynopsis} from "../../generated/proposalToolSchemas.ts"; + +export default +function ProposalsAccordion() : ReactElement { + + const proposals = useProposalResourceGetProposals({}) + + if (proposals.isError) { + notifyError("Error fetching proposals", getErrorMessage(proposals.error)) + return <> + } + + if (proposals.isLoading) { + return + } + + + const proposalSummary = (summary: string) => { + return ( +
+ + {summary} + +
+ ) + } + + + const proposalDetails = (proposal: ProposalSynopsis) => { + return ( + + + + + {'\"' + proposal.title + '\"'} + + + {proposal.kind} + + + Submitted to 0 cycles + + + + + + + {proposalSummary(proposal.summary!)} + + + Submitted details here + + + + + ) + } + + return ( + proposals.data?.length === 0 ? + Please create a proposal + : + + {proposals.data?.map(proposal => (proposalDetails(proposal)))} + + ) +} \ No newline at end of file diff --git a/src/main/webui/src/ProposalEditorView/landingPage/proposalsStatus.tsx b/src/main/webui/src/ProposalEditorView/landingPage/proposalsStatus.tsx deleted file mode 100644 index da0c40c..0000000 --- a/src/main/webui/src/ProposalEditorView/landingPage/proposalsStatus.tsx +++ /dev/null @@ -1,55 +0,0 @@ -import {PanelHeader} from "../../commonPanel/appearance.tsx"; -import { - useProposalResourceGetProposals -} from "../../generated/proposalToolComponents.ts"; -import {List, Table} from "@mantine/core"; -import {randomId} from "@mantine/hooks"; - -type ProposalRowProps = { - title: string - kind: string -} - -function ProposalsTableRow(props: ProposalRowProps) { - return - {props.title} - {props.kind} - - -} - -function ProposalsStatus () { - const {data, error, isLoading} = useProposalResourceGetProposals({}); - - if(error) { - return <> - } - - const listProposals = () => { - if(data?.length == 0) { - return Please create a proposal - } - return - - - Title - Type - - - - {data?.map((proposal) => { - return ; - })} - -
- } - - return <> - {isLoading?'Loading...':listProposals()} - - -} - -export default ProposalsStatus \ No newline at end of file diff --git a/src/main/webui/src/ProposalEditorView/proposal/New.tsx b/src/main/webui/src/ProposalEditorView/proposal/New.tsx index 6f57ad8..04b1d98 100644 --- a/src/main/webui/src/ProposalEditorView/proposal/New.tsx +++ b/src/main/webui/src/ProposalEditorView/proposal/New.tsx @@ -110,7 +110,7 @@ const textFormatData = [ return ( - + {submitting && Submitting request } diff --git a/src/main/webui/src/commonPanel/appearance.tsx b/src/main/webui/src/commonPanel/appearance.tsx index 788b7f0..f6007cc 100644 --- a/src/main/webui/src/commonPanel/appearance.tsx +++ b/src/main/webui/src/commonPanel/appearance.tsx @@ -22,7 +22,17 @@ export function PanelHeader(props: headerInterfaceProps): ReactElement { { props.isLoading ? ... : {props.itemName} - } : {props.panelHeading} + } + { + props.panelHeading && + + {props.panelHeading} + + } ); } diff --git a/src/main/webui/src/commonPanel/panelFeatureInterfaceProps.tsx b/src/main/webui/src/commonPanel/panelFeatureInterfaceProps.tsx index c96704b..9afe9f1 100644 --- a/src/main/webui/src/commonPanel/panelFeatureInterfaceProps.tsx +++ b/src/main/webui/src/commonPanel/panelFeatureInterfaceProps.tsx @@ -1,7 +1,7 @@ export interface headerInterfaceProps { isLoading?: boolean itemName: string - panelHeading: string + panelHeading?: string } export interface editorPanelHeaderInterfaceProps { From 8c1922d8712d1a03f5489779f6f2641032241b76 Mon Sep 17 00:00:00 2001 From: Darren Walker Date: Thu, 7 Nov 2024 11:40:51 +0000 Subject: [PATCH 3/5] add 'alertErrorMessage' and 'textErrorMessage' helpers, lift-up state to editorLandingPage.tsx --- .../landingPage/editorLandingPage.tsx | 43 ++++++- .../landingPage/observatoriesCycles.tsx | 119 ++++++++++-------- .../landingPage/proposalsAccordion.tsx | 27 ++-- .../src/errorHandling/alertErrorMessage.tsx | 18 +++ .../src/errorHandling/textErrorMessage.tsx | 17 +++ 5 files changed, 147 insertions(+), 77 deletions(-) create mode 100644 src/main/webui/src/errorHandling/alertErrorMessage.tsx create mode 100644 src/main/webui/src/errorHandling/textErrorMessage.tsx diff --git a/src/main/webui/src/ProposalEditorView/landingPage/editorLandingPage.tsx b/src/main/webui/src/ProposalEditorView/landingPage/editorLandingPage.tsx index b56e9b4..6f62c6c 100644 --- a/src/main/webui/src/ProposalEditorView/landingPage/editorLandingPage.tsx +++ b/src/main/webui/src/ProposalEditorView/landingPage/editorLandingPage.tsx @@ -1,27 +1,64 @@ import {ReactElement, useContext} from "react"; import ObservatoriesCyclesPanel from "./observatoriesCycles.tsx"; import ProposalsAccordion from "./proposalsAccordion.tsx"; -import {Fieldset, Space} from "@mantine/core"; +import {Fieldset, Loader, Space} from "@mantine/core"; import {PanelHeader} from "../../commonPanel/appearance.tsx"; import {ProposalContext} from "../../App2.tsx"; +import { + useProposalCyclesResourceGetProposalCycles, + useProposalResourceGetProposals +} from "../../generated/proposalToolComponents.ts"; +import AlertErrorMessage from "../../errorHandling/alertErrorMessage.tsx"; export default function EditorLandingPage() : ReactElement { const context = useContext(ProposalContext); + const proposalCycles = + useProposalCyclesResourceGetProposalCycles({}) + + const proposals = + useProposalResourceGetProposals({}) + + if (proposals.isError) { + return ( + + ) + } + + if (proposalCycles.isError) { + return( + + ) + } + + if (proposals.isLoading || proposalCycles.isLoading) { + return + } + + return ( <>
- +
- + ) } \ No newline at end of file diff --git a/src/main/webui/src/ProposalEditorView/landingPage/observatoriesCycles.tsx b/src/main/webui/src/ProposalEditorView/landingPage/observatoriesCycles.tsx index fb65fcb..5db11ea 100644 --- a/src/main/webui/src/ProposalEditorView/landingPage/observatoriesCycles.tsx +++ b/src/main/webui/src/ProposalEditorView/landingPage/observatoriesCycles.tsx @@ -1,81 +1,92 @@ import {ReactElement} from "react"; -import {Box, List, Table, Tooltip} from "@mantine/core"; +import {List, Loader, Table, Tooltip} from "@mantine/core"; import { - useProposalCyclesResourceGetProposalCycleDates, useProposalCyclesResourceGetProposalCycles, + useProposalCyclesResourceGetProposalCycleDates, } from "../../generated/proposalToolComponents.ts"; -import {JSON_SPACES} from "../../constants.tsx"; import {randomId} from "@mantine/hooks"; +import {ObjectIdentifier} from "../../generated/proposalToolSchemas.ts"; +import TextErrorMessage from "../../errorHandling/textErrorMessage.tsx"; type CycleRowProps = { cycleId: number } function ProposalCycleTableRow(props:CycleRowProps) { - const {data, error, isLoading} = useProposalCyclesResourceGetProposalCycleDates( + const cycleDates = useProposalCyclesResourceGetProposalCycleDates( {pathParams: {cycleCode: props.cycleId}}); - const tooltip = data?.observatory?.telescopes?.length + " telescopes"; + const tooltip = cycleDates.data?.observatory?.telescopes?.length + " telescopes"; - if (error) { + if (cycleDates.isError) { return ( - -
{JSON.stringify(error, null, JSON_SPACES)}
-
+ + + + + ); } - if(isLoading) - return Loading...; - else - return {data?.observatory?.name} - {data?.title} - {data?.submissionDeadline?.substring(0,10)} - {data?.observationSessionStart?.substring(0,10)} - {data?.observationSessionEnd?.substring(0,10)} - ; -} + if(cycleDates.isLoading) { + return ( + + + + + + ) + } + return ( + + + + {cycleDates.data?.observatory?.name} + + + + {cycleDates.data?.title} + + + {cycleDates.data?.submissionDeadline?.substring(0,10)} + + + {cycleDates.data?.observationSessionStart?.substring(0,10)} + + + {cycleDates.data?.observationSessionEnd?.substring(0,10)} + + + ) -function ObservatoriesCyclesPanel (): ReactElement { - const { data , error, isLoading } = useProposalCyclesResourceGetProposalCycles({queryParams: {}}); +} - if (error) { - return ( - -
{JSON.stringify(error, null, JSON_SPACES)}
-
- ); - } +export default +function ObservatoriesCyclesPanel (props: {cycles: ObjectIdentifier[]}): ReactElement { const listCycles = () => { - if(data?.length == 0) { + if(props.cycles.length == 0) { return There are no proposal cycles currently available } - return - - - Observatory - Name - Deadline - Observing start - Observing end - - - - {data?.map((cycle) => { - return ; - })} - -
+ return ( + + + + Observatory + Name + Deadline + Observing start + Observing end + + + + {props.cycles.map((cycle) => { + return ; + })} + +
+ ) }; - - return ( - <> - {isLoading? 'Loading' : listCycles()} - - ) - + return listCycles() } - -export default ObservatoriesCyclesPanel \ No newline at end of file diff --git a/src/main/webui/src/ProposalEditorView/landingPage/proposalsAccordion.tsx b/src/main/webui/src/ProposalEditorView/landingPage/proposalsAccordion.tsx index b76a1c9..c85a1a9 100644 --- a/src/main/webui/src/ProposalEditorView/landingPage/proposalsAccordion.tsx +++ b/src/main/webui/src/ProposalEditorView/landingPage/proposalsAccordion.tsx @@ -1,23 +1,11 @@ import {ReactElement} from "react"; -import {Accordion, Fieldset, Grid, Group, Loader, ScrollArea, Text} from "@mantine/core"; -import {useProposalResourceGetProposals} from "../../generated/proposalToolComponents.ts"; -import {notifyError} from "../../commonPanel/notifications.tsx"; -import getErrorMessage from "../../errorHandling/getErrorMessage.tsx"; -import {ProposalSynopsis} from "../../generated/proposalToolSchemas.ts"; +import {Accordion, Fieldset, Grid, Group, ScrollArea, Text} from "@mantine/core"; +import {ObjectIdentifier, ProposalSynopsis} from "../../generated/proposalToolSchemas.ts"; export default -function ProposalsAccordion() : ReactElement { - - const proposals = useProposalResourceGetProposals({}) - - if (proposals.isError) { - notifyError("Error fetching proposals", getErrorMessage(proposals.error)) - return <> - } - - if (proposals.isLoading) { - return - } +function ProposalsAccordion( + props: {proposals: ProposalSynopsis[], cycles: ObjectIdentifier[]}) + : ReactElement { const proposalSummary = (summary: string) => { @@ -30,7 +18,6 @@ function ProposalsAccordion() : ReactElement { ) } - const proposalDetails = (proposal: ProposalSynopsis) => { return ( Please create a proposal : - {proposals.data?.map(proposal => (proposalDetails(proposal)))} + {props.proposals.map(proposal => (proposalDetails(proposal)))} ) } \ No newline at end of file diff --git a/src/main/webui/src/errorHandling/alertErrorMessage.tsx b/src/main/webui/src/errorHandling/alertErrorMessage.tsx new file mode 100644 index 0000000..ec1ac72 --- /dev/null +++ b/src/main/webui/src/errorHandling/alertErrorMessage.tsx @@ -0,0 +1,18 @@ +import {ReactElement} from "react"; +import {Alert} from "@mantine/core"; +import {IconInfoHexagon} from "@tabler/icons-react"; +import getErrorMessage from "./getErrorMessage.tsx"; + +export default +function AlertErrorMessage(props: {title: string, error: unknown}): ReactElement { + return ( + } + > + {getErrorMessage(props.error)} + + ) +} \ No newline at end of file diff --git a/src/main/webui/src/errorHandling/textErrorMessage.tsx b/src/main/webui/src/errorHandling/textErrorMessage.tsx new file mode 100644 index 0000000..209546b --- /dev/null +++ b/src/main/webui/src/errorHandling/textErrorMessage.tsx @@ -0,0 +1,17 @@ +import {ReactElement} from "react"; +import {Group, Text} from "@mantine/core"; +import getErrorMessage from "./getErrorMessage.tsx"; + +export default +function TextErrorMessage(props: {error: unknown, preamble?: string }) : ReactElement { + return ( + + { + props.preamble && + {props.preamble} + } + {getErrorMessage(props.error)} + + + ) +} \ No newline at end of file From 8fdb2b9d01dc6741ef8cd973b2dba56fcfeabf65 Mon Sep 17 00:00:00 2001 From: Darren Walker Date: Fri, 8 Nov 2024 13:12:03 +0000 Subject: [PATCH 4/5] style alertErrorMessage.tsx with a container, proposals accordion shows cycles to which the proposal has been submitted and when. --- .../landingPage/editorLandingPage.tsx | 6 +- .../landingPage/proposalsAccordion.tsx | 84 ++++++++++++++++--- .../src/errorHandling/alertErrorMessage.tsx | 20 +++-- 3 files changed, 90 insertions(+), 20 deletions(-) diff --git a/src/main/webui/src/ProposalEditorView/landingPage/editorLandingPage.tsx b/src/main/webui/src/ProposalEditorView/landingPage/editorLandingPage.tsx index 6f62c6c..269e2c7 100644 --- a/src/main/webui/src/ProposalEditorView/landingPage/editorLandingPage.tsx +++ b/src/main/webui/src/ProposalEditorView/landingPage/editorLandingPage.tsx @@ -6,10 +6,13 @@ import {PanelHeader} from "../../commonPanel/appearance.tsx"; import {ProposalContext} from "../../App2.tsx"; import { useProposalCyclesResourceGetProposalCycles, - useProposalResourceGetProposals + useProposalResourceGetProposals, } from "../../generated/proposalToolComponents.ts"; import AlertErrorMessage from "../../errorHandling/alertErrorMessage.tsx"; + + + export default function EditorLandingPage() : ReactElement { @@ -58,6 +61,7 @@ function EditorLandingPage() : ReactElement { ) diff --git a/src/main/webui/src/ProposalEditorView/landingPage/proposalsAccordion.tsx b/src/main/webui/src/ProposalEditorView/landingPage/proposalsAccordion.tsx index c85a1a9..859efcb 100644 --- a/src/main/webui/src/ProposalEditorView/landingPage/proposalsAccordion.tsx +++ b/src/main/webui/src/ProposalEditorView/landingPage/proposalsAccordion.tsx @@ -1,13 +1,20 @@ -import {ReactElement} from "react"; -import {Accordion, Fieldset, Grid, Group, ScrollArea, Text} from "@mantine/core"; +import {ReactElement, useEffect, useState} from "react"; +import {Accordion, Fieldset, Grid, Group, ScrollArea, Table, Text} from "@mantine/core"; import {ObjectIdentifier, ProposalSynopsis} from "../../generated/proposalToolSchemas.ts"; +import {fetchSubmittedProposalResourceGetSubmittedProposals} from "../../generated/proposalToolComponents.ts"; +import {randomId} from "@mantine/hooks"; + +type SubmissionDetail = { + cycleName: string, + submissionDate: string +} + export default function ProposalsAccordion( - props: {proposals: ProposalSynopsis[], cycles: ObjectIdentifier[]}) + props: {proposals: ProposalSynopsis[], cycles: ObjectIdentifier[], investigatorName: string}) : ReactElement { - const proposalSummary = (summary: string) => { return (
@@ -25,25 +32,43 @@ function ProposalsAccordion( key={proposal.code} > - + {'\"' + proposal.title + '\"'} {proposal.kind} - - Submitted to 0 cycles - - + {proposalSummary(proposal.summary!)} - Submitted details here + + + + Submitted to: + Submission date + + + + { + props.cycles.map((cycle) => { + return( + + ) + }) + } + +
@@ -59,4 +84,43 @@ function ProposalsAccordion( {props.proposals.map(proposal => (proposalDetails(proposal)))} ) +} + +function CycleSubmissionDetail(props: { + cycle: ObjectIdentifier, + investigatorName: string, + proposalTitle: string +}): ReactElement { + + const [submissionDetail, setSubmissionDetail] = + useState (null); + + useEffect(() => { + fetchSubmittedProposalResourceGetSubmittedProposals({ + pathParams: {cycleCode: props.cycle.dbid!}, + //find exact proposal title and investigator name + queryParams: {title: props.proposalTitle, investigatorName: props.investigatorName} + }) + .then((data: ObjectIdentifier[]) => { + if (data.length > 0) { + setSubmissionDetail( + { + cycleName: props.cycle.name!, + //assume a distinct proposal is submitted once only to a particular cycle + submissionDate: data.at(0)!.code!,} + ) + } + }) + }, []) + + return( + submissionDetail ? + + {submissionDetail.cycleName} + {submissionDetail.submissionDate} + + : + <> + ) + } \ No newline at end of file diff --git a/src/main/webui/src/errorHandling/alertErrorMessage.tsx b/src/main/webui/src/errorHandling/alertErrorMessage.tsx index ec1ac72..4989c74 100644 --- a/src/main/webui/src/errorHandling/alertErrorMessage.tsx +++ b/src/main/webui/src/errorHandling/alertErrorMessage.tsx @@ -1,18 +1,20 @@ import {ReactElement} from "react"; -import {Alert} from "@mantine/core"; +import {Alert, Container} from "@mantine/core"; import {IconInfoHexagon} from "@tabler/icons-react"; import getErrorMessage from "./getErrorMessage.tsx"; export default function AlertErrorMessage(props: {title: string, error: unknown}): ReactElement { return ( - } - > - {getErrorMessage(props.error)} - + + } + > + {getErrorMessage(props.error)} + + ) } \ No newline at end of file From 413586043466a45d7167aa6f21041a8c39ddc40b Mon Sep 17 00:00:00 2001 From: Darren Walker Date: Fri, 8 Nov 2024 13:29:04 +0000 Subject: [PATCH 5/5] remove the randomId key from Table row; parent element has the key property --- .../src/ProposalEditorView/landingPage/proposalsAccordion.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/webui/src/ProposalEditorView/landingPage/proposalsAccordion.tsx b/src/main/webui/src/ProposalEditorView/landingPage/proposalsAccordion.tsx index 859efcb..08c22ec 100644 --- a/src/main/webui/src/ProposalEditorView/landingPage/proposalsAccordion.tsx +++ b/src/main/webui/src/ProposalEditorView/landingPage/proposalsAccordion.tsx @@ -2,7 +2,6 @@ import {ReactElement, useEffect, useState} from "react"; import {Accordion, Fieldset, Grid, Group, ScrollArea, Table, Text} from "@mantine/core"; import {ObjectIdentifier, ProposalSynopsis} from "../../generated/proposalToolSchemas.ts"; import {fetchSubmittedProposalResourceGetSubmittedProposals} from "../../generated/proposalToolComponents.ts"; -import {randomId} from "@mantine/hooks"; type SubmissionDetail = { cycleName: string, @@ -115,7 +114,7 @@ function CycleSubmissionDetail(props: { return( submissionDetail ? - + {submissionDetail.cycleName} {submissionDetail.submissionDate}