Skip to content

Commit

Permalink
Merge pull request #173 from SeedTactics:features/allocation-api
Browse files Browse the repository at this point in the history
Features/allocation api
  • Loading branch information
wuzzeb authored Jul 22, 2024
2 parents f3a0b77 + 8244d8b commit f0fbe50
Show file tree
Hide file tree
Showing 28 changed files with 1,303 additions and 915 deletions.
219 changes: 174 additions & 45 deletions client/csharp-api/api.cs

Large diffs are not rendered by default.

334 changes: 0 additions & 334 deletions client/insight/src/cell-status/__snapshots__/jobs.test.ts.snap

Large diffs are not rendered by default.

14 changes: 8 additions & 6 deletions client/insight/src/cell-status/material-details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,14 @@ export const possibleWorkordersForMaterialInDialog = atom<Promise<ReadonlyArray<
const mat = await get(materialInDialogInfo);
if (mat === null || mat.partName === "") return [];

const works = await JobsBackend.mostRecentUnfilledWorkordersForPart(mat.partName);

return LazySeq.of(works).toSortedArray(
(w) => w.dueDate.getTime(),
(w) => -w.priority,
);
const works = get(currentStatus)?.workorders ?? [];

return LazySeq.of(works)
.filter((w) => w.part === mat.partName)
.toSortedArray(
(w) => w.dueDate.getTime(),
(w) => -w.priority,
);
},
);

Expand Down
21 changes: 4 additions & 17 deletions client/insight/src/cell-status/sim-day-usage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,15 @@ import { ServerEventAndTime } from "./loading";
export type LatestSimDayUsage = {
readonly simId: string;
readonly usage: ReadonlyArray<Readonly<ISimulatedDayUsage>>;
readonly warning: string | null;
};

const latestUsageRW = atom<LatestSimDayUsage | null>(null);
export const latestSimDayUsage: Atom<LatestSimDayUsage | null> = latestUsageRW;

function update(
get: Getter,
set: Setter,
schId: string,
usage: ReadonlyArray<Readonly<ISimulatedDayUsage>>,
warning: string | undefined,
) {
function update(get: Getter, set: Setter, schId: string, usage: ReadonlyArray<Readonly<ISimulatedDayUsage>>) {
const old = get(latestSimDayUsage);
if (old === null || old.simId < schId) {
set(latestUsageRW, { simId: schId, usage, warning: warning ?? null });
set(latestUsageRW, { simId: schId, usage });
}
}

Expand All @@ -65,17 +58,11 @@ export const setLatestSimDayUsage = atom(null, (get, set, history: Readonly<IRec
) {
return;
}
update(
get,
set,
history.mostRecentSimulationId,
history.mostRecentSimDayUsage,
history.mostRecentSimDayUsageWarning,
);
update(get, set, history.mostRecentSimulationId, history.mostRecentSimDayUsage);
});

export const updateLatestSimDayUsage = atom(null, (get, set, { evt }: ServerEventAndTime) => {
if (evt.newJobs && evt.newJobs.simDayUsage && evt.newJobs.simDayUsage.length > 0) {
update(get, set, evt.newJobs.scheduleId, evt.newJobs.simDayUsage, evt.newJobs.simDayUsageWarning);
update(get, set, evt.newJobs.scheduleId, evt.newJobs.simDayUsage);
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ import {
import copy from "copy-to-clipboard";
import { atom, useAtom, useAtomValue, useSetAtom } from "jotai";
import { WorkorderGantt } from "./WorkorderGantt.js";
import { latestSimDayUsage } from "../../cell-status/sim-day-usage.js";
import { SelectWorkorderDialog, selectWorkorderDialogOpen } from "../station-monitor/SelectWorkorder.js";

const WorkorderTableRow = styled(TableRow)({
Expand Down Expand Up @@ -423,17 +422,14 @@ function SortColHeader(props: {
const tableOrGantt = atom<"table" | "gantt">("table");

const SimulatedWarning = memo(function SimulatedWarning({ showSim }: { showSim: boolean }) {
const warning = useAtomValue(latestSimDayUsage)?.warning;
const [selected, setSelected] = useAtom(tableOrGantt);

return (
<Stack direction="row" spacing={2} justifyContent="flex-end" alignItems="center">
{showSim ? (
<Stack direction="row" spacing={2} alignItems="center" flexGrow={1}>
<WarningIcon fontSize="small" />
<Typography variant="caption">
{warning ? ` ${warning}` : "Projected dates are estimates"}
</Typography>
<Typography variant="caption">Projected dates are estimates</Typography>
</Stack>
) : undefined}
<FormControl size="small">
Expand Down
3 changes: 1 addition & 2 deletions client/insight/src/components/operations/SimDayUsage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,10 @@ function ShowMonth({
}

function Warning() {
const warning = useAtomValue(latestSimDayUsage)?.warning;
return (
<Stack direction="row" spacing={2} alignItems="center">
<WarningIcon fontSize="small" />
<Typography variant="caption">{warning ? ` ${warning}` : "Projected dates are estimates"}</Typography>
<Typography variant="caption">Projected dates are estimates</Typography>
</Stack>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function WorkorderList() {
const [assignWorkorder] = matDetails.useAssignWorkorder();
return (
<List>
{workorders.map((w) => (
{(workorders ?? []).map((w) => (
<ListItem key={w.workorderId}>
<ListItemButton
onClick={() => {
Expand Down
Loading

0 comments on commit f0fbe50

Please sign in to comment.