Skip to content

Commit

Permalink
Updated reports app
Browse files Browse the repository at this point in the history
  • Loading branch information
kyle-flynn committed Apr 8, 2024
1 parent 67d89c3 commit 88b44de
Show file tree
Hide file tree
Showing 28 changed files with 158 additions and 126 deletions.
36 changes: 29 additions & 7 deletions front-end/src/AppRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,35 @@ const JBApp = lazy(() =>
import('./apps/jb-app').then((m) => ({ default: m.JBApp }))
);

// Streaming Routes
const Streaming = lazy(() =>
import('./apps/stream').then((m) => ({ default: m.StreamApp }))
);

// Audience Display Routes
const AudienceDisplayManager = lazy(() =>
import('./apps/audience-display-manager').then((m) => ({
default: m.AudienceDisplayManager
}))
);

// Field Monitor Routes
const FrcFmsFieldMonitorApp = lazy(() =>
import('./apps/field-monitor').then((m) => ({
default: m.FrcFmsFieldMonitorApp
}))
);

// Queueing Display Routes
const QueueingDisplay = lazy(() =>
import('./apps/queueing').then((m) => ({ default: m.QueueingDisplay }))
);

// Report Routes
const Reports = lazy(() =>
import('./apps/reports').then((m) => ({ default: m.Reports }))
);

const SettingsApp = lazy(() => import('./apps/Settings'));
const GlobalSettingsApp = lazy(() => import('./apps/Settings/GlobalSettings'));

Expand All @@ -58,13 +87,6 @@ const RefereeApp = lazy(() => import('./apps/Referee/Referee'));
const RedReferee = lazy(() => import('./apps/Referee/RedReferee'));
const BlueReferee = lazy(() => import('./apps/Referee/BlueReferee'));
const HeadReferee = lazy(() => import('./apps/Referee/HeadReferee'));
const Reports = lazy(() => import('./apps/Reports'));
const FrcFmsFieldMonitorApp = lazy(() => import('./apps/FrcFmsFieldMonitor'));
const QueueingDisplay = lazy(() => import('./apps/QueueingDisplay'));
const Streaming = lazy(() => import('./apps/Streaming/Streaming'));
const AudienceDisplayManager = lazy(
() => import('./apps/AudienceDisplayManager')
);
// const AccountManager = lazy(() => import('./apps/AccountManager'));
// const RefereeApp = lazy(() => import('./apps/Referee/Referee'));
// const ScoreKeeper = lazy(() => import('./apps/Referee/ScoreKeeper'));
Expand Down
12 changes: 12 additions & 0 deletions front-end/src/api/use-ranking-data.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { apiFetcher } from '@toa-lib/client';
import { Team, Ranking, rankingZod } from '@toa-lib/models';
import useSWR from 'swr';

export const createRankings = (
tournamentKey: string,
Expand Down Expand Up @@ -34,3 +35,14 @@ export const recalculatePlayoffsRankings = (

export const deleteRankings = (eventKey: string, tournamentKey: string) =>
apiFetcher(`ranking/${eventKey}/${tournamentKey}`, 'DELETE');

export const useRankingsForTournament = (
eventKey: string | null | undefined,
tournamentKey: string | null | undefined
) =>
useSWR<Ranking[]>(
eventKey && tournamentKey
? `ranking/${eventKey}/${tournamentKey}`
: undefined,
(url) => apiFetcher(url, 'GET', undefined, rankingZod.array().parse)
);
3 changes: 0 additions & 3 deletions front-end/src/apps/AudienceDisplayManager/index.ts

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions front-end/src/apps/QueueingDisplay/index.ts

This file was deleted.

7 changes: 0 additions & 7 deletions front-end/src/apps/Reports/components/ScheduleReport.tsx

This file was deleted.

6 changes: 4 additions & 2 deletions front-end/src/apps/Reports/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { ReactNode } from 'react';
import Reports from './Reports';
import { Reports } from './reports-app';

export interface ReportProps {
eventKey: string | null | undefined;
tournamentKey?: string | null | undefined;
onGenerate: (c: ReactNode) => void;
}

export default Reports;
export { Reports };
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
updateSocketClient
} from 'src/api/use-socket-data';

const AudienceDisplayManager: FC = () => {
export const AudienceDisplayManager: FC = () => {
const [clients, setClients] = useRecoilState(socketClientsAtom);
const [dialogOpen, setDialogOpen] = useState(false);
const [dialogContext, setDialogContext] = useState<any>(null);
Expand Down Expand Up @@ -206,5 +206,3 @@ const AudienceDisplayManager: FC = () => {
</PaperLayout>
);
};

export default AudienceDisplayManager;
3 changes: 3 additions & 0 deletions front-end/src/apps/audience-display-manager/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { AudienceDisplayManager } from './audience-display-manager';

export { AudienceDisplayManager };
26 changes: 26 additions & 0 deletions front-end/src/apps/field-monitor/components/prestart-status.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import CheckCircleOutline from '@mui/icons-material/CheckCircleOutline';
import ErrorOutline from '@mui/icons-material/ErrorOutline';
import PauseCircleOutline from '@mui/icons-material/PauseCircleOutline';
import { CircularProgress, Grid, Typography } from '@mui/material';
import { HardwareInfo, PrestartState } from '@toa-lib/models';

export const PrestartStatus = ({ hw }: { hw: HardwareInfo }) => {
return (
<Grid item xs={1} title={hw.lastLog ?? ''}>
{hw.state === PrestartState.Prestarting ? (
<CircularProgress size='23px' />
) : null}
{hw.state === PrestartState.Success ? (
<CheckCircleOutline sx={{ color: 'green' }} />
) : null}
{hw.state === PrestartState.Fail ? (
<ErrorOutline sx={{ color: 'red' }} />
) : null}
{hw.state === PrestartState.NotReady ? (
<PauseCircleOutline sx={{ color: 'red' }} />
) : null}
<br />
<Typography variant='caption'>{hw.name}</Typography>
</Grid>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ interface IProps {
ds: DriverstationStatus;
}

const TeamRow: FC<IProps> = ({ ds }: IProps) => {
export const TeamRow: FC<IProps> = ({ ds }: IProps) => {
const [dataOpen, setDataOpen] = useState<boolean>(false);

const friendlyStation =
Expand Down Expand Up @@ -390,5 +390,3 @@ const DataPopup = ({
</Dialog>
);
};

export default TeamRow;
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import {
PrestartState,
PrestartStatus
} from '@toa-lib/models';
import TeamRow from './components/TeamRow';
import PrestartStatusIcon from './components/PrestartStatus';
import { TeamRow } from './components/team-row';
import { PrestartStatus as PrestartStatusIcon } from './components/prestart-status';
import ConnectionChip from 'src/components/util/ConnectionChip/ConnectionChip';
import { useSocket } from 'src/api/use-socket';

const FrcFmsFieldMonitorApp: FC = () => {
export const FrcFmsFieldMonitorApp: FC = () => {
const [monitor, setMonitor] = useState<DriverstationMonitor>({
dsStatuses: [],
matchStatus: MatchMode.PRESTART,
Expand Down Expand Up @@ -168,5 +168,3 @@ const FrcFmsFieldMonitorApp: FC = () => {
</DefaultLayout>
);
};

export default FrcFmsFieldMonitorApp;
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const FieldColumn: FC<{ field: number; tournamentKey: string | null }> = ({
);
};

const QueueingDisplay: FC = () => {
export const QueueingDisplay: FC = () => {
const refreshMatches = useRecoilRefresher_UNSTABLE(
matchesByTournamentSelector
);
Expand Down Expand Up @@ -87,5 +87,3 @@ const QueueingDisplay: FC = () => {
</ChromaLayout>
);
};

export default QueueingDisplay;
3 changes: 3 additions & 0 deletions front-end/src/apps/queueing/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { QueueingDisplay } from './QueueingDisplay';

export { QueueingDisplay };
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import TableRow from '@mui/material/TableRow';
import TableCell from '@mui/material/TableCell';
import TableBody from '@mui/material/TableBody';
import { Match, Team } from '@toa-lib/models';
import Report from './Report';
import { Report } from './report-container';
import { DateTime } from 'luxon';

interface Props {
Expand All @@ -15,7 +15,11 @@ interface Props {
identifier?: keyof Team;
}

const MatchByTeamReport: FC<Props> = ({ teams, matches, identifier }) => {
export const MatchByTeamReport: FC<Props> = ({
teams,
matches,
identifier
}) => {
const allianceSize = matches?.[0]?.participants?.length
? matches[0].participants.length / 2
: 3;
Expand Down Expand Up @@ -89,5 +93,3 @@ const MatchByTeamReport: FC<Props> = ({ teams, matches, identifier }) => {
</>
);
};

export default MatchByTeamReport;
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import TableRow from '@mui/material/TableRow';
import TableCell from '@mui/material/TableCell';
import TableBody from '@mui/material/TableBody';
import { Match, Team } from '@toa-lib/models';
import Report from './Report';
import { Report } from './report-container';
import { DateTime } from 'luxon';
import { useRecoilValue } from 'recoil';
import {
Expand All @@ -21,7 +21,7 @@ interface Props {
identifier?: keyof Team;
}

const MatchReport: FC<Props> = ({ matches, identifier }) => {
export const MatchReport: FC<Props> = ({ matches, identifier }) => {
const tournament = useRecoilValue(currentTournamentSelector);
const teams = useRecoilValue(currentTeamsByEventSelector);
const items = useRecoilValue(currentScheduleItemsByTournamentSelector);
Expand Down Expand Up @@ -114,5 +114,3 @@ const MatchReport: FC<Props> = ({ matches, identifier }) => {
</>
);
};

export default MatchReport;
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface Props {
pagebreak?: boolean;
}

const Report: FC<Props> = ({ name, children, pagebreak }) => {
export const Report: FC<Props> = ({ name, children, pagebreak }) => {
const eventName = useRecoilValue(currentEventSelector)?.eventName;

return (
Expand All @@ -36,5 +36,3 @@ const Report: FC<Props> = ({ name, children, pagebreak }) => {
</Box>
);
};

export default Report;
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface Props {
children?: ReactNode;
}

const ReportView: FC<Props> = ({ onReturn, children }) => {
export const ReportView: FC<Props> = ({ onReturn, children }) => {
const reportRef = useRef(null);
const handlePrint = useReactToPrint({
content: () => reportRef.current
Expand All @@ -27,5 +27,3 @@ const ReportView: FC<Props> = ({ onReturn, children }) => {
</Box>
);
};

export default ReportView;
5 changes: 5 additions & 0 deletions front-end/src/apps/reports/components/schedule-report.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { FC } from 'react';

export const ScheduleReport: FC = () => {
return null;
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import TableRow from '@mui/material/TableRow';
import TableCell from '@mui/material/TableCell';
import TableBody from '@mui/material/TableBody';
import { Team } from '@toa-lib/models';
import Report from './Report';
import { Report } from './report-container';

interface Props {
teams: Team[];
}

const TeamsReport: FC<Props> = ({ teams }) => {
export const TeamsReport: FC<Props> = ({ teams }) => {
return (
<Report name='Competing Teams'>
<TableContainer>
Expand Down Expand Up @@ -52,5 +52,3 @@ const TeamsReport: FC<Props> = ({ teams }) => {
</Report>
);
};

export default TeamsReport;
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { FC } from 'react';
import { useRecoilValue } from 'recoil';
import Button from '@mui/material/Button';
import Grid from '@mui/material/Grid';
import TeamsReport from './components/TeamsReport';
import { TeamsReport } from './components/teams-report';
import { ReportProps } from '.';
import { currentTeamsByEventSelector } from 'src/stores/NewRecoil';
import { useTeamsForEvent } from 'src/api/use-team-data';

const GeneralReports: FC<ReportProps> = ({ onGenerate }) => {
const teams = useRecoilValue(currentTeamsByEventSelector);
export const GeneralReports: FC<ReportProps> = ({ eventKey, onGenerate }) => {
const { data: teams } = useTeamsForEvent(eventKey);

const generateTeamReport = () => onGenerate(<TeamsReport teams={teams} />);
const generateTeamReport = () => {
if (!teams) return;
onGenerate(<TeamsReport teams={teams} />);
};

return (
<Grid container spacing={3}>
Expand All @@ -21,5 +23,3 @@ const GeneralReports: FC<ReportProps> = ({ onGenerate }) => {
</Grid>
);
};

export default GeneralReports;
Loading

0 comments on commit 88b44de

Please sign in to comment.