Skip to content

Commit

Permalink
Merge pull request #282 from orppst/266-review-landing-page
Browse files Browse the repository at this point in the history
review landing page to include some overview information rather than an image
  • Loading branch information
pahjbo authored Nov 25, 2024
2 parents acc17df + a73f70c commit 1038ccb
Show file tree
Hide file tree
Showing 6 changed files with 169 additions and 11 deletions.
Binary file removed src/main/webui/public/temporary-ufo-landing.png
Binary file not shown.
Binary file removed src/main/webui/public/ufo-mother-ship-earth.png
Binary file not shown.
15 changes: 4 additions & 11 deletions src/main/webui/src/App2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ import ObservationFieldsPanel from "./ProposalEditorView/observationFields/Obser
import AssignReviewersPanel from "./ProposalManagerView/assignReviewers/AssignReviewersPanel.tsx";
import ErrorPage from "./errorHandling/error-page.jsx"
import {PanelFrame} from "./commonPanel/appearance.tsx";
import TacCycles from "./ProposalManagerView/landingPage/tacCycles.tsx";
import EditorLandingPage from "./ProposalEditorView/landingPage/editorLandingPage.tsx";

/**
Expand Down Expand Up @@ -485,17 +486,9 @@ function App2(): ReactElement {

function PSTManagerStart() : ReactElement {
return(
<Container pt={10}>

<Text fz={"lg"} fw={"bold"} c={"teal.7"}>
Polaris Management Page
</Text>

<img src={"/pst/gui/ufo-mother-ship-earth.png"}
alt={"welcome image of a mother-ship orbiting Earth"}
width={"100%"}
/>
</Container>
<PanelFrame>
<TacCycles />
</PanelFrame>
)
}

Expand Down
Empty file.
165 changes: 165 additions & 0 deletions src/main/webui/src/ProposalManagerView/landingPage/tacCycles.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
import {ReactElement} from "react";
import {Box, List, Table, Tooltip} from "@mantine/core";
import {
useProposalCyclesResourceGetProposalCycleDates,
useProposalCyclesResourceGetProposalCycles,
useSubmittedProposalResourceGetSubmittedProposals, useTACResourceGetCommitteeMembers,
} from "../../generated/proposalToolComponents.ts";
import {JSON_SPACES} from "../../constants.tsx";
import {PanelHeader} from "../../commonPanel/appearance.tsx";
import {randomId} from "@mantine/hooks";

type CycleRowProps = {
cycleId: number
inReview?: boolean
}

function GetCountSubmittedProposals(props:CycleRowProps) {
const {data, error, isLoading} = useSubmittedProposalResourceGetSubmittedProposals({pathParams:{cycleCode: props.cycleId}});

if(error) {
return (<pre>{JSON.stringify(error, null, JSON_SPACES)}</pre>)
}

if (isLoading) {
return (`??`);
} else if(data?.length !== undefined && data?.length > 0) {
return data?.length;
} else {
return "None";
}
}

// TODO: Change this from a count of committee members to a count of reviewers
function GetReviewers(props:CycleRowProps) {
const {data, error, isLoading} = useTACResourceGetCommitteeMembers({pathParams:{cycleCode: props.cycleId}});

if(error) {
return (<pre>{JSON.stringify(error, null, JSON_SPACES)}</pre>)
}

if (isLoading) {
return (`??`);
} else if(data?.length !== undefined && data?.length > 0) {
return data?.length;
} else {
return "None";
}
}

function TacCycleTableRow(props:CycleRowProps) {
const {data, error, isLoading} = useProposalCyclesResourceGetProposalCycleDates(
{pathParams: {cycleCode: props.cycleId}});

const tooltip = data?.observatory?.telescopes?.length + " telescopes";

if (error) {
return (
<Table.Tr><Table.Td>
<pre>{JSON.stringify(error, null, JSON_SPACES)}</pre>
</Table.Td></Table.Tr>
);
}

const today = new Date();

if(isLoading)
return <Table.Tr><Table.Td>Loading...</Table.Td></Table.Tr>;
else {
const deadlineDate = new Date(data!.submissionDeadline!.substring(0,10));
const endDate = new Date(data!.observationSessionEnd!.substring(0,10));
//Open cycles
if(!props.inReview && deadlineDate > today){
return <Table.Tr><Tooltip label={tooltip}><Table.Td>{data?.observatory?.name}</Table.Td></Tooltip>
<Table.Td>{data?.title}</Table.Td>
{<Table.Td>{data?.submissionDeadline?.substring(0, 10)}</Table.Td>}
<Table.Td>{data?.observationSessionStart?.substring(0, 10)}</Table.Td>
<Table.Td>{data?.observationSessionEnd?.substring(0, 10)}</Table.Td>
<Table.Td><GetCountSubmittedProposals cycleId={props.cycleId} /></Table.Td>
</Table.Tr>;
}

//Closed cycles that haven't finished observing
if(props.inReview
&& deadlineDate < today
&& endDate > today){
return <Table.Tr><Tooltip label={tooltip}><Table.Td>{data?.observatory?.name}</Table.Td></Tooltip>
<Table.Td>{data?.title}</Table.Td>
<Table.Td>{data?.observationSessionStart?.substring(0, 10)}</Table.Td>
<Table.Td>{data?.observationSessionEnd?.substring(0, 10)}</Table.Td>
<Table.Td><GetCountSubmittedProposals cycleId={props.cycleId} /></Table.Td>
<Table.Td><GetReviewers cycleId={props.cycleId} /></Table.Td>
</Table.Tr>;
}
}
}

function TacCycles (): ReactElement {
const { data , error, isLoading } = useProposalCyclesResourceGetProposalCycles({
queryParams: {includeClosed: true}
});

if (error) {
return (
<Box>
<pre>{JSON.stringify(error, null, JSON_SPACES)}</pre>
</Box>
);
}

const listOpenCycles = () => {
if(data?.length == 0) {
return <List key={randomId()}>There are no open proposal cycles</List>
}
return <Table>
<Table.Thead>
<Table.Tr>
<Table.Th>Observatory</Table.Th>
<Table.Th>Name</Table.Th>
<Table.Th>Deadline</Table.Th>
<Table.Th>Observing start</Table.Th>
<Table.Th>Observing end</Table.Th>
<Table.Th>Submitted proposals</Table.Th>
</Table.Tr>
</Table.Thead>
<Table.Tbody>
{data?.map((cycle) => {
return <TacCycleTableRow key={cycle.dbid} cycleId={cycle.dbid!} inReview={false}/>;
})}
</Table.Tbody>
</Table>
};

const listClosedCycles = () => {
if(data?.length == 0) {
return <List key={randomId()}>There are no closed proposal cycles</List>
}
return <Table>
<Table.Thead>
<Table.Tr>
<Table.Th>Observatory</Table.Th>
<Table.Th>Name</Table.Th>
<Table.Th>Observing start</Table.Th>
<Table.Th>Observing end</Table.Th>
<Table.Th>Submitted proposals</Table.Th>
<Table.Th>TAC members</Table.Th>
</Table.Tr>
</Table.Thead>
<Table.Tbody>
{data?.map((cycle) => {
return <TacCycleTableRow key={cycle.dbid} cycleId={cycle.dbid!} inReview={true}/>;
})}
</Table.Tbody>
</Table>
};

return <>
<PanelHeader itemName={"Observing Cycles"} panelHeading={"Open"}/>
{isLoading? 'Loading' : listOpenCycles()}
<PanelHeader itemName={"Observing Cycles"} panelHeading={"Closed"}/>
{isLoading? 'Loading' : listClosedCycles()}
</>;

}

export default TacCycles
Empty file.

0 comments on commit 1038ccb

Please sign in to comment.