From ae58e3c92ebde3078e8cc87d0de2b04c530ca031 Mon Sep 17 00:00:00 2001 From: Allan England Date: Wed, 12 Jun 2024 10:23:31 +0100 Subject: [PATCH 1/4] Change observatory form with + + )} + ) -} \ No newline at end of file +} + + diff --git a/src/main/webui/src/generated/proposalToolComponents.ts b/src/main/webui/src/generated/proposalToolComponents.ts index e89e984b..529f3e6e 100644 --- a/src/main/webui/src/generated/proposalToolComponents.ts +++ b/src/main/webui/src/generated/proposalToolComponents.ts @@ -5298,6 +5298,132 @@ export const useProposalCyclesResourceReplaceCycleAllocationGradeName = ( }); }; +export type ProposalCyclesResourceGetProposalCycleObservatoryPathParams = { + /** + * @format int64 + */ + cycleCode: number; +}; + +export type ProposalCyclesResourceGetProposalCycleObservatoryError = + Fetcher.ErrorWrapper; + +export type ProposalCyclesResourceGetProposalCycleObservatoryVariables = { + pathParams: ProposalCyclesResourceGetProposalCycleObservatoryPathParams; +} & ProposalToolContext["fetcherOptions"]; + +export const fetchProposalCyclesResourceGetProposalCycleObservatory = ( + variables: ProposalCyclesResourceGetProposalCycleObservatoryVariables, + signal?: AbortSignal +) => + proposalToolFetch< + Schemas.Observatory, + ProposalCyclesResourceGetProposalCycleObservatoryError, + undefined, + {}, + {}, + ProposalCyclesResourceGetProposalCycleObservatoryPathParams + >({ + url: "/pst/api/proposalCycles/{cycleCode}/observatory", + method: "get", + ...variables, + signal, + }); + +export const useProposalCyclesResourceGetProposalCycleObservatory = < + TData = Schemas.Observatory +>( + variables: ProposalCyclesResourceGetProposalCycleObservatoryVariables, + options?: Omit< + reactQuery.UseQueryOptions< + Schemas.Observatory, + ProposalCyclesResourceGetProposalCycleObservatoryError, + TData + >, + "queryKey" | "queryFn" | "initialData" + > +) => { + const { fetcherOptions, queryOptions, queryKeyFn } = + useProposalToolContext(options); + return reactQuery.useQuery< + Schemas.Observatory, + ProposalCyclesResourceGetProposalCycleObservatoryError, + TData + >({ + queryKey: queryKeyFn({ + path: "/pst/api/proposalCycles/{cycleCode}/observatory", + operationId: "proposalCyclesResourceGetProposalCycleObservatory", + variables, + }), + queryFn: ({ signal }) => + fetchProposalCyclesResourceGetProposalCycleObservatory( + { ...fetcherOptions, ...variables }, + signal + ), + ...options, + ...queryOptions, + }); +}; + +export type ProposalCyclesResourceReplaceCycleObservatoryPathParams = { + /** + * @format int64 + */ + cycleCode: number; +}; + +export type ProposalCyclesResourceReplaceCycleObservatoryError = + Fetcher.ErrorWrapper; + +export type ProposalCyclesResourceReplaceCycleObservatoryVariables = { + pathParams: ProposalCyclesResourceReplaceCycleObservatoryPathParams; +} & ProposalToolContext["fetcherOptions"]; + +export const fetchProposalCyclesResourceReplaceCycleObservatory = ( + variables: ProposalCyclesResourceReplaceCycleObservatoryVariables, + signal?: AbortSignal +) => + proposalToolFetch< + undefined, + ProposalCyclesResourceReplaceCycleObservatoryError, + undefined, + {}, + {}, + ProposalCyclesResourceReplaceCycleObservatoryPathParams + >({ + url: "/pst/api/proposalCycles/{cycleCode}/observatory", + method: "put", + ...variables, + signal, + }); + +export const useProposalCyclesResourceReplaceCycleObservatory = ( + options?: Omit< + reactQuery.UseMutationOptions< + undefined, + ProposalCyclesResourceReplaceCycleObservatoryError, + ProposalCyclesResourceReplaceCycleObservatoryVariables + >, + "mutationFn" + > +) => { + const { fetcherOptions } = useProposalToolContext(); + return reactQuery.useMutation< + undefined, + ProposalCyclesResourceReplaceCycleObservatoryError, + ProposalCyclesResourceReplaceCycleObservatoryVariables + >({ + mutationFn: ( + variables: ProposalCyclesResourceReplaceCycleObservatoryVariables + ) => + fetchProposalCyclesResourceReplaceCycleObservatory({ + ...fetcherOptions, + ...variables, + }), + ...options, + }); +}; + export type SubmittedProposalResourceGetSubmittedProposalsPathParams = { /** * @format int64 @@ -11361,6 +11487,11 @@ export type QueryOperation = operationId: "proposalCyclesResourceGetCycleAllocatedGrade"; variables: ProposalCyclesResourceGetCycleAllocatedGradeVariables; } + | { + path: "/pst/api/proposalCycles/{cycleCode}/observatory"; + operationId: "proposalCyclesResourceGetProposalCycleObservatory"; + variables: ProposalCyclesResourceGetProposalCycleObservatoryVariables; + } | { path: "/pst/api/proposalCycles/{cycleCode}/submittedProposals"; operationId: "submittedProposalResourceGetSubmittedProposals"; diff --git a/src/main/webui/src/generated/proposalToolSchemas.ts b/src/main/webui/src/generated/proposalToolSchemas.ts index ea3ec341..cadb85dd 100644 --- a/src/main/webui/src/generated/proposalToolSchemas.ts +++ b/src/main/webui/src/generated/proposalToolSchemas.ts @@ -1136,7 +1136,6 @@ export type ProposalKind = "Standard" | "ToO" | "Survey"; * A review of a proposal */ export type ProposalReview = { - _id?: number; /** * Description */ @@ -1490,7 +1489,6 @@ export type SubjectMap = { * an instance of a proposal that has been submitted */ export type SubmittedProposal = { - _id?: number; /** * the date that the proposal was submitted * From 8b07544e139774aa2e422fbbb7ebf18e38f387c8 Mon Sep 17 00:00:00 2001 From: Allan England Date: Wed, 12 Jun 2024 12:03:25 +0100 Subject: [PATCH 2/4] Put observatory in summary, try to get Select working, fix (a similar) issue with add investigators --- .../ProposalEditorView/investigators/New.tsx | 2 +- .../proposalCycle/observatory.tsx | 43 +++++++------------ .../proposalCycle/overview.tsx | 13 ++++++ 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/main/webui/src/ProposalEditorView/investigators/New.tsx b/src/main/webui/src/ProposalEditorView/investigators/New.tsx index 9f4e89f8..ce00e8e0 100644 --- a/src/main/webui/src/ProposalEditorView/investigators/New.tsx +++ b/src/main/webui/src/ProposalEditorView/investigators/New.tsx @@ -36,7 +36,7 @@ function AddInvestigatorPanel(): ReactElement { selectedInvestigator: 0}, validate: { selectedInvestigator: (value) => ( - value === 0 ? 'Please select an investigator' : null) + value === 0 || value === null ? 'Please select an investigator' : null) } }); const typeData = [{value: "COI", label: "CO-I"}, {value: "PI", label: "PI"}]; diff --git a/src/main/webui/src/ProposalManagerView/proposalCycle/observatory.tsx b/src/main/webui/src/ProposalManagerView/proposalCycle/observatory.tsx index d0d46ffb..9e6a4e85 100644 --- a/src/main/webui/src/ProposalManagerView/proposalCycle/observatory.tsx +++ b/src/main/webui/src/ProposalManagerView/proposalCycle/observatory.tsx @@ -3,12 +3,11 @@ import {Select, Text} from "@mantine/core"; import {ManagerPanelHeader, PanelFrame} from "../../commonPanel/appearance.tsx"; import {useParams} from "react-router-dom"; import { - fetchProposalCyclesResourceGetProposalCycle, fetchProposalCyclesResourceGetProposalCycleObservatory, fetchProposalCyclesResourceReplaceCycleObservatory, ProposalCyclesResourceReplaceCycleObservatoryVariables, useObservatoryResourceGetObservatories } from "../../generated/proposalToolComponents.ts"; -import {notifyError} from "../../commonPanel/notifications.tsx"; +import {notifyError, notifySuccess} from "../../commonPanel/notifications.tsx"; import getErrorMessage from "../../errorHandling/getErrorMessage.tsx"; import {useForm} from "@mantine/form"; import {SubmitButton} from "../../commonButtons/save.tsx"; @@ -17,35 +16,21 @@ export default function CycleObservatoryPanel() : ReactElement { const {selectedCycleCode} = useParams(); const [observatorySearchData, setSearchData] = useState([]); const [formReady, setFormReady] = useState(false); - let defaultObservatory = ""; const form = useForm({ initialValues: {selectedObservatory: 0}, validate: { selectedObservatory: (value) => ( - value === 0 ? 'Please select an observatory' : null) + value === 0 || value === null ? 'Please select an observatory' : null) } }); const observatories = useObservatoryResourceGetObservatories({}); -/* const proposalCycle = useProposalCyclesResourceGetProposalCycle({pathParams: {cycleCode: Number(selectedCycleCode)}}); - if(proposalCycle.error) { - notifyError("Failed to load proposal cycle details", - getErrorMessage(proposalCycle.error)); - } -*/ if(observatories.error) { notifyError("Failed to load list of observatories", getErrorMessage(observatories.error)); } -/* - useEffect(() => { - if(proposalCycle.status === 'success') { - console.log("Observatory is " + proposalCycle.data.observatory?.name); - form.values.selectedObservatory = Number(proposalCycle.data.observatory?._id); - } - }, [proposalCycle.status, proposalCycle.data]); -*/ + useEffect(() => { if(observatories.status === 'success') { console.log("Got list of " + observatories.data.length + " observatories"); @@ -56,10 +41,10 @@ export default function CycleObservatoryPanel() : ReactElement { value: String(item.dbid), label: item.name}]) )); - fetchProposalCyclesResourceGetProposalCycle({pathParams: {cycleCode: Number(selectedCycleCode)}}) - .then((data) => { - form.values.selectedObservatory = Number(data.observatory?._id); - defaultObservatory = data.observatory?.name!; + fetchProposalCyclesResourceGetProposalCycleObservatory( + {pathParams: {cycleCode: Number(selectedCycleCode)}}) + .then((observatory) => { + form.values.selectedObservatory = Number(observatory?._id); setFormReady(true); }) .catch((error) => notifyError("Failed to load proposal cycle details", @@ -78,8 +63,12 @@ export default function CycleObservatoryPanel() : ReactElement { headers: {"Content-Type": "text/plain"} }; + console.log(JSON.stringify(newObservatory,null,2)); + fetchProposalCyclesResourceReplaceCycleObservatory(newObservatory) - .then() + .then(()=> + notifySuccess("Update observatory", "Changes saved") + ) .catch((error) => { notifyError("Error updating observatory", "Cause: "+getErrorMessage(error)) }) @@ -93,9 +82,9 @@ export default function CycleObservatoryPanel() : ReactElement { {formReady && (
Date: Fri, 14 Jun 2024 08:59:32 +0100 Subject: [PATCH 4/4] Fix proposalToolSchemas and update patch file --- src/main/webui/Add_@types.patch | 46 ++++++++++++------- .../src/generated/proposalToolSchemas.ts | 2 + 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/src/main/webui/Add_@types.patch b/src/main/webui/Add_@types.patch index 6b38c239..e92d0265 100644 --- a/src/main/webui/Add_@types.patch +++ b/src/main/webui/Add_@types.patch @@ -1,5 +1,5 @@ --- proposalToolSchemas.ts.orig 2024-04-24 10:15:03 -+++ proposalToolSchemas.ts 2024-06-13 16:44:15 ++++ proposalToolSchemas.ts 2024-06-14 08:55:06 @@ -129,6 +129,7 @@ * An observation that is intended for calibration */ @@ -150,7 +150,7 @@ * the proposals that have been successful and allocated time */ allocatedProposals?: AllocatedProposal[]; -@@ -1119,7 +1130,7 @@ +@@ -1119,12 +1130,13 @@ observationSessionEnd?: Date; }; @@ -159,7 +159,13 @@ /** * A review of a proposal -@@ -1207,6 +1218,7 @@ + */ + export type ProposalReview = { ++ _id?: number; + /** + * Description + */ +@@ -1207,6 +1219,7 @@ * A real value with a unit. */ export type RealQuantity = { @@ -167,7 +173,7 @@ /** * Must conform to definition of unit in VOUnit spec. */ -@@ -1238,6 +1250,8 @@ +@@ -1238,6 +1251,8 @@ * A resource that will be consumed by allocating an observation from a proposal */ export type Resource = { @@ -176,7 +182,7 @@ /** * The amount of the resource * -@@ -1268,6 +1282,7 @@ +@@ -1268,6 +1283,7 @@ * a type of resource */ export type ResourceType = { @@ -184,7 +190,7 @@ /** * the name of the resource type */ -@@ -1277,52 +1292,10 @@ +@@ -1277,52 +1293,10 @@ }; /** @@ -238,7 +244,7 @@ /** * person connected with the proposal */ -@@ -1354,6 +1327,8 @@ +@@ -1354,6 +1328,8 @@ /** * Science oriented definition of a spectral window. */ @@ -247,7 +253,7 @@ spectralWindowSetup?: SpectralWindowSetup; expectedSpectralLine?: ExpectedSpectralLine[]; }; -@@ -1398,6 +1373,7 @@ +@@ -1398,6 +1374,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 = { @@ -255,7 +261,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. */ -@@ -1420,6 +1396,7 @@ +@@ -1420,6 +1397,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 = { @@ -263,7 +269,7 @@ xmlId?: string; /** * Abstract head of coordinate spaces related to physical properties. -@@ -1503,7 +1480,7 @@ +@@ -1503,7 +1481,7 @@ /** * person connected with the proposal */ @@ -272,7 +278,15 @@ uid?: string; inKeycloakRealm?: boolean; }; -@@ -1519,6 +1496,21 @@ +@@ -1512,6 +1490,7 @@ + * an instance of a proposal that has been submitted + */ + export type SubmittedProposal = { ++ _id?: number; + /** + * the date that the proposal was submitted + * +@@ -1519,6 +1498,21 @@ * @example "2022-03-10T00:00:00.000Z" */ submissionDate?: Date; @@ -294,7 +308,7 @@ /** * a complete proposal */ -@@ -1553,23 +1545,26 @@ +@@ -1553,23 +1547,26 @@ /** * A role within the timeAllocation committee */ @@ -322,7 +336,7 @@ xmlId?: string; name?: string; }; -@@ -1578,6 +1573,7 @@ +@@ -1578,6 +1575,7 @@ * an observation of the scientific target */ export type TargetObservation = { @@ -330,7 +344,7 @@ /** * any constraints on the observation */ -@@ -1605,6 +1601,7 @@ +@@ -1605,6 +1603,7 @@ */ performance?: PerformanceParameters; spectrum?: ScienceSpectralWindow[]; @@ -338,7 +352,7 @@ xmlId?: string; }; -@@ -1645,7 +1642,7 @@ +@@ -1645,7 +1644,7 @@ /** * acceptable text formats for document submission */ @@ -347,7 +361,7 @@ /** * A TimeFrame SHALL include a time scale and reference position. It MAY also include a reference direction. -@@ -1708,6 +1705,10 @@ +@@ -1708,6 +1707,10 @@ * particular time range */ export type TimingWindow = { diff --git a/src/main/webui/src/generated/proposalToolSchemas.ts b/src/main/webui/src/generated/proposalToolSchemas.ts index cadb85dd..ea3ec341 100644 --- a/src/main/webui/src/generated/proposalToolSchemas.ts +++ b/src/main/webui/src/generated/proposalToolSchemas.ts @@ -1136,6 +1136,7 @@ export type ProposalKind = "Standard" | "ToO" | "Survey"; * A review of a proposal */ export type ProposalReview = { + _id?: number; /** * Description */ @@ -1489,6 +1490,7 @@ export type SubjectMap = { * an instance of a proposal that has been submitted */ export type SubmittedProposal = { + _id?: number; /** * the date that the proposal was submitted *