@seedtactics/insight-client 17.0.2 → 17.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/README.md +14 -2
  2. package/dist/assets/ProgramHighlight-C5uXGNDz.js +3 -0
  3. package/dist/assets/index-B0B_a7c8.js +366 -0
  4. package/dist/cell-status/alarms.d.ts +16 -0
  5. package/dist/cell-status/alarms.js +71 -0
  6. package/dist/cell-status/loading.js +5 -0
  7. package/dist/cell-status/material-details.d.ts +1 -0
  8. package/dist/cell-status/material-details.js +10 -1
  9. package/dist/components/App.js +0 -1
  10. package/dist/components/Navigation.js +10 -5
  11. package/dist/components/station-monitor/BasketLoadStationWork.js +15 -8
  12. package/dist/components/station-monitor/BulkRawMaterial.js +31 -18
  13. package/dist/components/station-monitor/CancelLoadButton.js +8 -4
  14. package/dist/components/station-monitor/InvalidateCycle.js +23 -18
  15. package/dist/components/station-monitor/LoadStation.js +21 -17
  16. package/dist/components/station-monitor/Material.js +34 -29
  17. package/dist/components/station-monitor/MoveMaterialArrows.js +13 -2
  18. package/dist/components/station-monitor/QuarantineButton.js +12 -4
  19. package/dist/components/station-monitor/QueuesAddMaterial.js +54 -49
  20. package/dist/components/station-monitor/SystemAlarmTooltip.d.ts +6 -0
  21. package/dist/components/station-monitor/SystemAlarmTooltip.js +5 -0
  22. package/dist/fms-insight-api.json +4786 -0
  23. package/dist/index.html +1 -1
  24. package/dist/network/api.d.ts +28 -0
  25. package/dist/network/api.js +54 -0
  26. package/dist/network/current-status-session.d.ts +13 -1
  27. package/dist/network/current-status-session.js +15 -0
  28. package/package.json +12 -11
  29. package/dist/assets/ProgramHighlight-mKbZxoXO.js +0 -3
  30. package/dist/assets/index-Cjt4dPv7.js +0 -367
@@ -45,6 +45,7 @@ import { currentOperator } from "../../data/operators.js";
45
45
  import { DisplayLoadingAndError } from "../ErrorsAndLoading.js";
46
46
  import { ErrorBoundary } from "react-error-boundary";
47
47
  import { currentStatus } from "../../cell-status/current-status.js";
48
+ import { alarmsBlockingMaterialChanges, materialActionIsSuspended, } from "../../cell-status/alarms.js";
48
49
  import { useAtom, useAtomValue, useSetAtom } from "jotai";
49
50
  import { last30Rebookings } from "../../cell-status/rebookings.js";
50
51
  import { fmsInformation } from "../../network/server-settings.js";
@@ -173,22 +174,28 @@ export function MaterialAction({ mat, displayActionForSinglePallet, displayActio
173
174
  const curSt = useAtomValue(currentStatus);
174
175
  const fmsInfo = useAtomValue(fmsInformation);
175
176
  const basketName = basketDisplayName(fmsInfo.basketName);
177
+ const description = materialActionDescription(mat, curSt, basketName, displayActionForSinglePallet, displayActionForSingleBasket);
178
+ if (description === null)
179
+ return null;
180
+ return (_jsx(MatCardDetail, { fsize: fsize, children: materialActionIsSuspended(curSt, mat) ? "System alarm" : description }));
181
+ }
182
+ function materialActionDescription(mat, curSt, basketName, displayActionForSinglePallet, displayActionForSingleBasket) {
176
183
  switch (mat.action.type) {
177
184
  case api.ActionType.Loading:
178
185
  // Check if loading from basket
179
186
  if (mat.action.loadFromBasketId) {
180
187
  if (mat.action.loadOntoPalletNum === null || mat.action.loadOntoPalletNum === undefined) {
181
- return (_jsxs(MatCardDetail, { fsize: fsize, children: ["Load into ", basketName, " ", mat.action.loadFromBasketId] }));
188
+ return (_jsxs(_Fragment, { children: ["Load into ", basketName, " ", mat.action.loadFromBasketId] }));
182
189
  }
183
190
  else if (displayActionForSinglePallet === undefined) {
184
- return (_jsxs(MatCardDetail, { fsize: fsize, children: ["Load from ", basketName, " ", mat.action.loadFromBasketId, " to pal", " ", mat.action.loadOntoPalletNum ?? ""] }));
191
+ return (_jsxs(_Fragment, { children: ["Load from ", basketName, " ", mat.action.loadFromBasketId, " to pal", " ", mat.action.loadOntoPalletNum ?? ""] }));
185
192
  }
186
193
  else if (displayActionForSinglePallet === mat.action.loadOntoPalletNum) {
187
194
  const faceNum = mat.action.loadOntoFace ?? 0;
188
195
  const faceName = mat.action.loadOntoPalletNum
189
196
  ? curSt.pallets[mat.action.loadOntoPalletNum]?.faceNames?.[faceNum - 1]
190
197
  : null;
191
- return (_jsxs(MatCardDetail, { fsize: fsize, children: ["Load from ", basketName, " ", mat.action.loadFromBasketId, " to", " ", faceName ?? `face ${faceNum}`] }));
198
+ return (_jsxs(_Fragment, { children: ["Load from ", basketName, " ", mat.action.loadFromBasketId, " to", " ", faceName ?? `face ${faceNum}`] }));
192
199
  }
193
200
  else {
194
201
  return null;
@@ -202,7 +209,7 @@ export function MaterialAction({ mat, displayActionForSinglePallet, displayActio
202
209
  mat.action.loadOntoFace === mat.location.face) {
203
210
  // material is not moving, just having some manual work done on it
204
211
  if (mat.action.processAfterLoad && mat.action.processAfterLoad !== mat.process) {
205
- return (_jsxs(MatCardDetail, { fsize: fsize, children: ["Reclamp material to process # ", mat.action.processAfterLoad] }));
212
+ return _jsxs(_Fragment, { children: ["Reclamp material to process # ", mat.action.processAfterLoad] });
206
213
  }
207
214
  else {
208
215
  return null;
@@ -213,7 +220,7 @@ export function MaterialAction({ mat, displayActionForSinglePallet, displayActio
213
220
  const faceName = mat.location.palletNum
214
221
  ? curSt.pallets[mat.location.palletNum]?.faceNames?.[faceNum - 1]
215
222
  : null;
216
- return (_jsxs(MatCardDetail, { fsize: fsize, children: ["Transfer to ", faceName ?? `face ${faceNum}`] }));
223
+ return _jsxs(_Fragment, { children: ["Transfer to ", faceName ?? `face ${faceNum}`] });
217
224
  }
218
225
  }
219
226
  else {
@@ -225,10 +232,10 @@ export function MaterialAction({ mat, displayActionForSinglePallet, displayActio
225
232
  ? curSt.pallets[mat.action.loadOntoPalletNum]?.faceNames?.[faceNum - 1]
226
233
  : null;
227
234
  if (displayActionForSinglePallet === undefined) {
228
- return (_jsxs(MatCardDetail, { fsize: fsize, children: ["Load to ", faceName ?? `face ${faceNum}`, " of pal ", mat.action.loadOntoPalletNum ?? ""] }));
235
+ return (_jsxs(_Fragment, { children: ["Load to ", faceName ?? `face ${faceNum}`, " of pal ", mat.action.loadOntoPalletNum ?? ""] }));
229
236
  }
230
237
  else if (displayActionForSinglePallet === mat.action.loadOntoPalletNum) {
231
- return (_jsxs(MatCardDetail, { fsize: fsize, children: ["Load to ", faceName ?? `face ${faceNum}`] }));
238
+ return _jsxs(_Fragment, { children: ["Load to ", faceName ?? `face ${faceNum}`] });
232
239
  }
233
240
  else {
234
241
  return null;
@@ -240,11 +247,11 @@ export function MaterialAction({ mat, displayActionForSinglePallet, displayActio
240
247
  if (displayActionForSingleBasket !== undefined &&
241
248
  displayActionForSingleBasket === mat.action.loadToBasketId &&
242
249
  mat.action.loadToBasketSlot !== undefined) {
243
- return (_jsxs(MatCardDetail, { fsize: fsize, children: ["Load into slot ", basketSlotLabel(mat.action.loadToBasketSlot), mat.action.processAfterLoad !== undefined
250
+ return (_jsxs(_Fragment, { children: ["Load into slot ", basketSlotLabel(mat.action.loadToBasketSlot), mat.action.processAfterLoad !== undefined
244
251
  ? ` for process ${mat.action.processAfterLoad}`
245
252
  : ""] }));
246
253
  }
247
- return (_jsxs(MatCardDetail, { fsize: fsize, children: ["Load into ", basketName, " ", mat.action.loadToBasketId ?? "", mat.action.loadToBasketSlot !== undefined
254
+ return (_jsxs(_Fragment, { children: ["Load into ", basketName, " ", mat.action.loadToBasketId ?? "", mat.action.loadToBasketSlot !== undefined
248
255
  ? ` slot ${basketSlotLabel(mat.action.loadToBasketSlot)}`
249
256
  : "", mat.action.processAfterLoad !== undefined
250
257
  ? ` for process ${mat.action.processAfterLoad}`
@@ -252,38 +259,38 @@ export function MaterialAction({ mat, displayActionForSinglePallet, displayActio
252
259
  case api.ActionType.UnloadToInProcess:
253
260
  case api.ActionType.UnloadToCompletedMaterial:
254
261
  if (mat.action.unloadToBasketId) {
255
- return (_jsxs(MatCardDetail, { fsize: fsize, children: ["Unload to ", basketName, " ", mat.action.unloadToBasketId, mat.action.unloadToBasketSlot !== undefined
262
+ return (_jsxs(_Fragment, { children: ["Unload to ", basketName, " ", mat.action.unloadToBasketId, mat.action.unloadToBasketSlot !== undefined
256
263
  ? ` slot ${basketSlotLabel(mat.action.unloadToBasketSlot)}`
257
264
  : ""] }));
258
265
  }
259
266
  else if (mat.action.unloadIntoQueue) {
260
- return (_jsxs(MatCardDetail, { fsize: fsize, children: ["Unload into queue ", mat.action.unloadIntoQueue] }));
267
+ return _jsxs(_Fragment, { children: ["Unload into queue ", mat.action.unloadIntoQueue] });
261
268
  }
262
269
  else if (mat.action.type === api.ActionType.UnloadToCompletedMaterial &&
263
270
  mat.location.type === api.LocType.InBasket) {
264
- return (_jsxs(MatCardDetail, { fsize: fsize, children: ["Unload completed from ", basketName, " ", mat.location.basketId] }));
271
+ return (_jsxs(_Fragment, { children: ["Unload completed from ", basketName, " ", mat.location.basketId] }));
265
272
  }
266
273
  else if (mat.location.type === api.LocType.InBasket) {
267
- return (_jsxs(MatCardDetail, { fsize: fsize, children: ["Unload from ", basketName, " ", mat.location.basketId] }));
274
+ return (_jsxs(_Fragment, { children: ["Unload from ", basketName, " ", mat.location.basketId] }));
268
275
  }
269
276
  else {
270
- return _jsx(MatCardDetail, { fsize: fsize, children: "Unload from pallet" });
277
+ return _jsx(_Fragment, { children: "Unload from pallet" });
271
278
  }
272
279
  case api.ActionType.Waiting:
273
280
  if (mat.location.type === api.LocType.InQueue && !!mat.jobUnique && mat.jobUnique !== "") {
274
- return (_jsxs(MatCardDetail, { fsize: fsize, children: ["Waiting; next process is #", mat.process + 1] }));
281
+ return _jsxs(_Fragment, { children: ["Waiting; next process is #", mat.process + 1] });
275
282
  }
276
283
  else if (mat.location.type === api.LocType.InBasket) {
277
- return (_jsxs(MatCardDetail, { fsize: fsize, children: ["In ", basketName, " ", mat.location.basketId] }));
284
+ return (_jsxs(_Fragment, { children: ["In ", basketName, " ", mat.location.basketId] }));
278
285
  }
279
286
  else if (mat.location.type === api.LocType.OnPallet &&
280
287
  (mat.lastCompletedMachiningRouteStopIndex === null ||
281
288
  mat.lastCompletedMachiningRouteStopIndex === undefined)) {
282
- return _jsx(MatCardDetail, { fsize: fsize, children: "Waiting for machining" });
289
+ return _jsx(_Fragment, { children: "Waiting for machining" });
283
290
  }
284
291
  break;
285
292
  case api.ActionType.Machining:
286
- return (_jsxs(MatCardDetail, { fsize: fsize, children: ["Machining program ", mat.action.program ?? ""] }));
293
+ return _jsxs(_Fragment, { children: ["Machining program ", mat.action.program ?? ""] });
287
294
  }
288
295
  return null;
289
296
  }
@@ -413,7 +420,9 @@ export const InProcMaterial = memo(function InProcMaterial(props) {
413
420
  return (_jsx(MatCard, { mat: inproc_mat_to_summary(props.mat), materialCount: props.materialCount, inProcMat: props.mat, displayActionForSinglePallet: props.displayActionForSinglePallet, displayActionForSingleBasket: props.displayActionForSingleBasket, fsize: props.fsize, hideAvatar: props.hideAvatar, displayJob: props.displayJob, showDragHandle: props.showHandle, hideEmptySerial: props.hideEmptySerial, showRawMaterial: props.showRawMaterial, showJobComment: props.showJobComment, shake: props.shake }));
414
421
  });
415
422
  export const SortableInProcMaterial = memo(function SortableInProcMaterial(props) {
416
- const canDrag = canReorderQueuedMaterial(props.mat) || canAddOrMoveMaterialToQueue(props.mat);
423
+ const changesSuspended = alarmsBlockingMaterialChanges(useAtomValue(currentStatus), [props.mat]).length > 0;
424
+ const canDrag = !changesSuspended &&
425
+ (canReorderQueuedMaterial(props.mat) || canAddOrMoveMaterialToQueue(props.mat));
417
426
  const d = { mat: props.mat };
418
427
  const { active, isDragging, attributes, listeners, setNodeRef, setActivatorNodeRef, transform, transition, } = useSortable({
419
428
  id: props.mat.materialID,
@@ -434,7 +443,7 @@ export const SortableInProcMaterial = memo(function SortableInProcMaterial(props
434
443
  : undefined,
435
444
  transition: active !== null ? transition : undefined,
436
445
  };
437
- return (_jsx(MatCard, { ref: setNodeRef, dragRootProps: { style }, showDragHandle: canDrag, dragHandleProps: handleProps, setDragHandleRef: setActivatorNodeRef, isActiveDrag: isDragging, mat: inproc_mat_to_summary(props.mat), materialCount: props.materialCount, inProcMat: props.mat, displayActionForSinglePallet: props.displayActionForSinglePallet, displayActionForSingleBasket: props.displayActionForSingleBasket, hideAvatar: props.hideAvatar, displayJob: props.displayJob, hideEmptySerial: props.hideEmptySerial, fsize: props.fsize, shake: active ? undefined : props.shake, showRawMaterial: props.showRawMaterial, showJobComment: props.showJobComment }));
446
+ return (_jsx(MatCard, { ref: setNodeRef, dragRootProps: { style }, showDragHandle: canDrag, dragHandleProps: handleProps, setDragHandleRef: setActivatorNodeRef, isActiveDrag: isDragging, mat: inproc_mat_to_summary(props.mat), materialCount: props.materialCount, inProcMat: props.mat, displayActionForSinglePallet: props.displayActionForSinglePallet, displayActionForSingleBasket: props.displayActionForSingleBasket, hideAvatar: props.hideAvatar, displayJob: props.displayJob, hideEmptySerial: props.hideEmptySerial, fsize: props.fsize, shake: active || changesSuspended ? undefined : props.shake, showRawMaterial: props.showRawMaterial, showJobComment: props.showJobComment }));
438
447
  });
439
448
  export function DragOverlayInProcMaterial(props) {
440
449
  return (_jsx(MatCard, { mat: inproc_mat_to_summary(props.mat), materialCount: props.materialCount, inProcMat: props.mat, displayActionForSinglePallet: props.displayActionForSinglePallet, displayActionForSingleBasket: props.displayActionForSingleBasket, showDragHandle: true, hideAvatar: props.hideAvatar, displayJob: props.displayJob, fsize: props.fsize, hideEmptySerial: props.hideEmptySerial, isDragOverlay: true }));
@@ -557,15 +566,11 @@ function RebookingNote() {
557
566
  }
558
567
  function MaterialOperationNotice() {
559
568
  const material = useAtomValue(matDetails.inProcessMaterialInDialog);
560
- if (material === null)
561
- return null;
562
- if (material.quarantineAfterUnload) {
563
- return (_jsx(Typography, { variant: "caption", component: "p", children: "Quarantine requested" }));
564
- }
565
- const state = materialOperationState(material);
566
- if (state.kind !== "ActiveLoadStationOperation" || state.cancellationId !== null)
567
- return null;
568
- return (_jsx(Typography, { variant: "caption", component: "p", children: "This material is part of the current load/unload operation. Complete the operation or cancel it at the machine control before making other changes." }));
569
+ const alarms = matDetails.useMaterialBlockingAlarms();
570
+ const state = material ? materialOperationState(material) : null;
571
+ return (_jsx(_Fragment, { children: material?.quarantineAfterUnload ? (_jsx(Typography, { variant: "caption", component: "p", children: "Quarantine requested" })) : alarms.length === 0 &&
572
+ state?.kind === "ActiveLoadStationOperation" &&
573
+ state.cancellationId === null ? (_jsx(Typography, { variant: "caption", component: "p", children: "This material is part of the current load/unload operation. Complete the operation or cancel it at the machine control before making other changes." })) : null }));
569
574
  }
570
575
  export const MaterialDetailContent = memo(function MaterialDetailContent({ highlightProcsGreaterOrEqualTo, }) {
571
576
  const toShow = useAtomValue(matDetails.materialDialogOpen);
@@ -34,6 +34,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
34
  import { memo, useState, useEffect, createContext, useRef, useMemo, useContext, } from "react";
35
35
  import { computeArrows, uniqueIdForNodeKind, memoPropsForNodeKind, } from "../../data/move-arrows.js";
36
36
  import { HashMap } from "@seedtactics/immutable-collections";
37
+ import { useAtomValue } from "jotai";
38
+ import { currentStatus } from "../../cell-status/current-status.js";
39
+ import { materialActionIsSuspended } from "../../cell-status/alarms.js";
40
+ import { MoveMaterialNodeKindType } from "../../data/move-arrows.js";
37
41
  function elementToRect(e) {
38
42
  const r = e.getBoundingClientRect();
39
43
  return {
@@ -66,6 +70,7 @@ function arrowToPath(arr) {
66
70
  return `M${arr.fromX},${arr.fromY} Q ${cx} ${cy} ${arr.toX} ${arr.toY}`;
67
71
  }
68
72
  const MoveMaterialArrows = memo(function MoveMaterialArrows({ container, arrowsWithRefs, }) {
73
+ const status = useAtomValue(currentStatus);
69
74
  const [, setDims] = useState({
70
75
  height: window.innerHeight,
71
76
  width: window.innerWidth,
@@ -77,8 +82,14 @@ const MoveMaterialArrows = memo(function MoveMaterialArrows({ container, arrowsW
77
82
  window.addEventListener("resize", handleResize);
78
83
  return () => window.removeEventListener("resize", handleResize);
79
84
  }, [setDims]);
80
- const arrows = computeArrows(container.current ? elementToRect(container.current) : null, arrowsWithRefs.collectValues((r) => r.elem.current ? { ...r, elem: elementToRect(r.elem.current) } : null));
81
- return (_jsx("g", { children: arrows.map((arr, idx) => (_jsx("path", { style: { fill: "none", stroke: "rgba(0,0,0,0.15)", strokeWidth: 2 }, d: arrowToPath(arr), markerEnd: `url(#arrow)` }, idx))) }));
85
+ const arrows = computeArrows(container.current ? elementToRect(container.current) : null, arrowsWithRefs.collectValues((r) => {
86
+ if (r.type === MoveMaterialNodeKindType.Material &&
87
+ r.material &&
88
+ materialActionIsSuspended(status, r.material))
89
+ return null;
90
+ return r.elem.current ? { ...r, elem: elementToRect(r.elem.current) } : null;
91
+ }));
92
+ return (_jsx("g", { children: arrows.map((arr, idx) => (_jsx("path", { "data-testid": "material-movement-arrow", style: { fill: "none", stroke: "rgba(0,0,0,0.15)", strokeWidth: 2 }, d: arrowToPath(arr), markerEnd: `url(#arrow)` }, idx))) }));
82
93
  });
83
94
  const MoveMaterialArrowCtx = createContext(undefined);
84
95
  export const MoveMaterialArrowContainer = memo(function MoveMaterialArrowContainer({ children, hideArrows, whiteBackground, }) {
@@ -32,13 +32,15 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
32
  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
33
  */
34
34
  import { useState } from "react";
35
- import { Button, Dialog, DialogActions, DialogContent, DialogTitle, TextField, Tooltip, } from "@mui/material";
35
+ import { Button, Dialog, DialogActions, DialogContent, DialogTitle, TextField, } from "@mui/material";
36
36
  import { LazySeq } from "@seedtactics/immutable-collections";
37
37
  import { currentStatus } from "../../cell-status/current-status.js";
38
+ import { alarmsBlockingMaterialChanges } from "../../cell-status/alarms.js";
38
39
  import { inProcessMaterialInDialog, materialDialogOpen, useQuarantineQueuedMaterial, useRemoveFromQueue, useSignalForQuarantine, } from "../../cell-status/material-details.js";
39
40
  import { currentOperator } from "../../data/operators.js";
40
41
  import { LocType, QueueRole } from "../../network/api.js";
41
42
  import { apiErrorMessage } from "../../network/api-errors.js";
43
+ import { SystemAlarmTooltip } from "./SystemAlarmTooltip.js";
42
44
  import { fmsInformation } from "../../network/server-settings.js";
43
45
  import { useAtomValue, useSetAtom } from "jotai";
44
46
  import { canDirectlyQuarantine, canRemoveFromQueue, canSignalQuarantine, quarantineRoute, } from "../../data/material-operation-policy.js";
@@ -122,7 +124,10 @@ function RemoveFromQueuesButton({ material, removeFromQueues, removing, }) {
122
124
  const [open, setOpen] = useState(false);
123
125
  const [error, setError] = useState(null);
124
126
  const setMatToShow = useSetAtom(materialDialogOpen);
127
+ const alarms = alarmsBlockingMaterialChanges(useAtomValue(currentStatus), [material]);
125
128
  async function remove() {
129
+ if (alarms.length > 0)
130
+ return;
126
131
  setError(null);
127
132
  try {
128
133
  await removeFromQueues();
@@ -144,7 +149,7 @@ function RemoveFromQueuesButton({ material, removeFromQueues, removing, }) {
144
149
  setError(null);
145
150
  setOpen(true);
146
151
  }
147
- return (_jsxs(_Fragment, { children: [_jsx(Tooltip, { title: "Remove from the current queue so it can be rescanned", children: _jsx(Button, { color: "primary", disabled: removing, onClick: openRemoval, children: "Remove from Queue" }) }), _jsxs(Dialog, { open: open, onClose: () => setOpen(false), children: [_jsx(DialogTitle, { children: "Remove Material from Queue" }), _jsxs(DialogContent, { children: [_jsx("p", { children: "Remove this material from its current queue. Its production history will remain available. You can scan it again to correct its history or assignment and then add it back to a queue." }), error ? _jsx("p", { role: "alert", children: error }) : null] }), _jsxs(DialogActions, { children: [_jsx(Button, { color: "primary", disabled: removing, onClick: remove, children: "Remove from Queue" }), _jsx(Button, { color: "secondary", disabled: removing, onClick: () => setOpen(false), children: "Cancel" })] })] })] }));
152
+ return (_jsxs(_Fragment, { children: [_jsx(SystemAlarmTooltip, { suspended: alarms.length > 0, title: "Remove from the current queue so it can be rescanned", children: _jsx(Button, { color: "primary", disabled: removing || alarms.length > 0, onClick: openRemoval, children: "Remove from Queue" }) }), _jsxs(Dialog, { open: open, onClose: () => setOpen(false), children: [_jsx(DialogTitle, { children: "Remove Material from Queue" }), _jsxs(DialogContent, { children: [_jsx("p", { children: "Remove this material from its current queue. Its production history will remain available. You can scan it again to correct its history or assignment and then add it back to a queue." }), error ? _jsx("p", { role: "alert", children: error }) : null] }), _jsxs(DialogActions, { children: [_jsx(SystemAlarmTooltip, { suspended: alarms.length > 0, children: _jsx(Button, { color: "primary", disabled: removing || alarms.length > 0, onClick: remove, children: "Remove from Queue" }) }), _jsx(Button, { color: "secondary", disabled: removing, onClick: () => setOpen(false), children: "Cancel" })] })] })] }));
148
153
  }
149
154
  export function QuarantineMatButton({ onClose, ignoreOperator, }) {
150
155
  const [open, setOpen] = useState(false);
@@ -173,6 +178,9 @@ export function QuarantineMatButton({ onClose, ignoreOperator, }) {
173
178
  operator,
174
179
  };
175
180
  const displayedSnapshot = snapshot ?? currentSnapshot;
181
+ const status = useAtomValue(currentStatus);
182
+ const currentAlarms = alarmsBlockingMaterialChanges(status, currentSnapshot ? [currentSnapshot.material] : []);
183
+ const confirmationAlarms = alarmsBlockingMaterialChanges(status, snapshot ? [snapshot.material] : []);
176
184
  function openQuarantine() {
177
185
  if (currentSnapshot === null)
178
186
  return;
@@ -210,7 +218,7 @@ export function QuarantineMatButton({ onClose, ignoreOperator, }) {
210
218
  break;
211
219
  }
212
220
  async function quarantine() {
213
- if (snapshot === null)
221
+ if (snapshot === null || confirmationAlarms.length > 0)
214
222
  return;
215
223
  setUpdating(true);
216
224
  setError(null);
@@ -258,5 +266,5 @@ export function QuarantineMatButton({ onClose, ignoreOperator, }) {
258
266
  ? quarantiningQueued
259
267
  : removingFromQueue);
260
268
  const removeFromQueues = q?.canRemoveFromQueues === true ? () => removeFromQueue(q.material.materialID, operator) : null;
261
- return (_jsxs(_Fragment, { children: [q ? (_jsx(Tooltip, { title: title, describeChild: displayedSnapshot.operation === "DeferredQuarantine", children: _jsx(Button, { color: "primary", disabled: removing, onClick: openQuarantine, children: btnTxt }) })) : null, removeFromQueues && q ? (_jsx(RemoveFromQueuesButton, { material: q.material, removeFromQueues: removeFromQueues, removing: removingFromQueue })) : null, _jsxs(Dialog, { open: open && snapshot !== null, onClose: closeQuarantine, children: [_jsx(DialogTitle, { children: "Quarantine Material" }), _jsxs(DialogContent, { children: [_jsx("p", { children: title }), _jsx(TextField, { label: "Reason", value: reason, onChange: (e) => setReason(e.target.value), fullWidth: true, autoFocus: true, multiline: true }), error ? _jsx("p", { role: "alert", children: error }) : null] }), _jsxs(DialogActions, { children: [_jsx(Button, { color: "primary", disabled: removing, onClick: quarantine, children: btnTxt }), _jsx(Button, { color: "secondary", disabled: removing, onClick: closeQuarantine, children: "Cancel" })] })] })] }));
269
+ return (_jsxs(_Fragment, { children: [q ? (_jsx(SystemAlarmTooltip, { suspended: currentAlarms.length > 0, title: title, children: _jsx(Button, { color: "primary", disabled: removing || currentAlarms.length > 0, onClick: openQuarantine, children: btnTxt }) })) : null, removeFromQueues && q ? (_jsx(RemoveFromQueuesButton, { material: q.material, removeFromQueues: removeFromQueues, removing: removingFromQueue })) : null, _jsxs(Dialog, { open: open && snapshot !== null, onClose: closeQuarantine, children: [_jsx(DialogTitle, { children: "Quarantine Material" }), _jsxs(DialogContent, { children: [_jsx("p", { children: title }), _jsx(TextField, { label: "Reason", value: reason, onChange: (e) => setReason(e.target.value), fullWidth: true, autoFocus: true, multiline: true }), error ? _jsx("p", { role: "alert", children: error }) : null] }), _jsxs(DialogActions, { children: [_jsx(SystemAlarmTooltip, { suspended: confirmationAlarms.length > 0, children: _jsx(Button, { color: "primary", disabled: removing || confirmationAlarms.length > 0, onClick: quarantine, children: btnTxt }) }), _jsx(Button, { color: "secondary", disabled: removing, onClick: closeQuarantine, children: "Cancel" })] })] })] }));
262
270
  }
@@ -32,7 +32,7 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
32
  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
33
  */
34
34
  import { useState, Fragment, useEffect, useRef } from "react";
35
- import { Button, Collapse, List, ListItem, ListItemButton, ListItemIcon, ListItemText, TextField, Tooltip, Typography, styled, } from "@mui/material";
35
+ import { Button, Collapse, List, ListItem, ListItemButton, ListItemIcon, ListItemText, TextField, Typography, styled, } from "@mui/material";
36
36
  import { ExpandMore as ExpandMoreIcon } from "@mui/icons-material";
37
37
  import { PartIdenticon, WorkorderFromBarcode } from "./Material.js";
38
38
  import * as api from "../../network/api.js";
@@ -44,6 +44,7 @@ import { fmsInformation } from "../../network/server-settings.js";
44
44
  import { useAddNewCastingToQueue } from "../../cell-status/material-details.js";
45
45
  import { useAtomValue, useSetAtom } from "jotai";
46
46
  import { canAddOrMoveMaterialToQueue } from "../../data/material-operation-policy.js";
47
+ import { SystemAlarmTooltip } from "./SystemAlarmTooltip.js";
47
48
  function useAllowAddToQueue(queueNames) {
48
49
  const existingMat = useAtomValue(matDetails.materialInDialogInfo);
49
50
  const inProcMat = useAtomValue(matDetails.inProcessMaterialInDialog);
@@ -178,6 +179,7 @@ export function AddToQueueButton({ st: { enteredOperator, newMaterialTy, toQueue
178
179
  const existingMat = useAtomValue(matDetails.materialInDialogInfo);
179
180
  const inProcMat = useAtomValue(matDetails.inProcessMaterialInDialog);
180
181
  const lastProcMat = useAtomValue(matDetails.materialInDialogLargestUsedProcess);
182
+ const blockingAlarms = matDetails.useMaterialBlockingAlarms();
181
183
  const [addExistingMat, addingExistingMat] = matDetails.useAddExistingMaterialToQueue();
182
184
  const [addNewMat, addingNewMat] = matDetails.useAddNewMaterialToQueue();
183
185
  const [addNewCasting, addingNewCasting] = useAddNewCastingToQueue();
@@ -212,58 +214,61 @@ export function AddToQueueButton({ st: { enteredOperator, newMaterialTy, toQueue
212
214
  withSerialMsg = " With Serial " + newSerial;
213
215
  }
214
216
  const curQueue = inProcMat?.location.currentQueue ?? null;
215
- return (_jsxs(_Fragment, { children: [_jsx(Tooltip, { title: toQueue === null
217
+ return (_jsxs(_Fragment, { children: [_jsx(SystemAlarmTooltip, { suspended: blockingAlarms.length > 0, title: toQueue === null
216
218
  ? "Select a queue to add the material to"
217
219
  : fmsInfo.requireOperatorNamePromptWhenAddingMaterial &&
218
220
  (enteredOperator === null || enteredOperator === "")
219
221
  ? "Please enter an operator name"
220
- : "", children: _jsx("span", { children: _jsx(Button, { color: "primary", disabled: toQueue === null ||
221
- addingExistingMat ||
222
- addingNewMat ||
223
- addingNewCasting ||
224
- (existingMat === null && newMaterialTy === null) ||
225
- (fmsInfo.requireOperatorNamePromptWhenAddingMaterial &&
226
- (enteredOperator === null || enteredOperator === "")), onClick: async () => {
227
- setAddError(null);
228
- try {
229
- if (existingMat) {
230
- await addExistingMat({
231
- materialId: existingMat.materialID,
232
- queue: toQueue ?? "",
233
- queuePosition: -1,
234
- operator: enteredOperator ?? operator,
235
- });
236
- }
237
- else if (newMaterialTy &&
238
- newMaterialTy.kind === "JobAndProc" &&
239
- newMaterialTy.jobUnique) {
240
- await addNewMat({
241
- jobUnique: newMaterialTy.jobUnique,
242
- lastCompletedProcess: newMaterialTy.last_proc,
243
- serial: newSerial ?? undefined,
244
- workorder: newWorkorder ?? newMaterialTy?.workorder,
245
- queue: toQueue ?? "",
246
- queuePosition: -1,
247
- operator: enteredOperator ?? operator,
248
- });
249
- }
250
- else if (newMaterialTy &&
251
- newMaterialTy.kind === "RawMat" &&
252
- newMaterialTy.rawMatName) {
253
- await addNewCasting({
254
- casting: newMaterialTy.rawMatName,
255
- quantity: 1,
256
- queue: toQueue ?? "",
257
- serials: newSerial ? [newSerial] : undefined,
258
- workorder: newWorkorder,
259
- operator: enteredOperator ?? operator,
260
- });
261
- }
262
- setMatToShow(null);
263
- onClose();
222
+ : "", children: _jsx(Button, { color: "primary", disabled: blockingAlarms.length > 0 ||
223
+ toQueue === null ||
224
+ addingExistingMat ||
225
+ addingNewMat ||
226
+ addingNewCasting ||
227
+ (existingMat === null && newMaterialTy === null) ||
228
+ (fmsInfo.requireOperatorNamePromptWhenAddingMaterial &&
229
+ (enteredOperator === null || enteredOperator === "")), onClick: async () => {
230
+ if (blockingAlarms.length > 0)
231
+ return;
232
+ setAddError(null);
233
+ try {
234
+ if (existingMat) {
235
+ await addExistingMat({
236
+ materialId: existingMat.materialID,
237
+ queue: toQueue ?? "",
238
+ queuePosition: -1,
239
+ operator: enteredOperator ?? operator,
240
+ });
264
241
  }
265
- catch (e) {
266
- setAddError(apiErrorMessage(e));
242
+ else if (newMaterialTy &&
243
+ newMaterialTy.kind === "JobAndProc" &&
244
+ newMaterialTy.jobUnique) {
245
+ await addNewMat({
246
+ jobUnique: newMaterialTy.jobUnique,
247
+ lastCompletedProcess: newMaterialTy.last_proc,
248
+ serial: newSerial ?? undefined,
249
+ workorder: newWorkorder ?? newMaterialTy?.workorder,
250
+ queue: toQueue ?? "",
251
+ queuePosition: -1,
252
+ operator: enteredOperator ?? operator,
253
+ });
267
254
  }
268
- }, children: toQueue === null ? ("Add to Queue") : (_jsxs("span", { children: [curQueue !== null ? `Move From ${curQueue} To` : "Add To", " ", toQueue, withSerialMsg, addProcMsg] })) }) }) }), addError ? _jsx("p", { role: "alert", children: addError }) : null] }));
255
+ else if (newMaterialTy &&
256
+ newMaterialTy.kind === "RawMat" &&
257
+ newMaterialTy.rawMatName) {
258
+ await addNewCasting({
259
+ casting: newMaterialTy.rawMatName,
260
+ quantity: 1,
261
+ queue: toQueue ?? "",
262
+ serials: newSerial ? [newSerial] : undefined,
263
+ workorder: newWorkorder,
264
+ operator: enteredOperator ?? operator,
265
+ });
266
+ }
267
+ setMatToShow(null);
268
+ onClose();
269
+ }
270
+ catch (e) {
271
+ setAddError(apiErrorMessage(e));
272
+ }
273
+ }, children: toQueue === null ? ("Add to Queue") : (_jsxs("span", { children: [curQueue !== null ? `Move From ${curQueue} To` : "Add To", " ", toQueue, withSerialMsg, addProcMsg] })) }) }), addError ? _jsx("p", { role: "alert", children: addError }) : null] }));
269
274
  }
@@ -0,0 +1,6 @@
1
+ import type { ReactElement, ReactNode } from "react";
2
+ export declare function SystemAlarmTooltip({ suspended, title, children, }: {
3
+ readonly suspended: boolean;
4
+ readonly title?: ReactNode;
5
+ readonly children: ReactElement;
6
+ }): import("react").JSX.Element;
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Tooltip } from "@mui/material";
3
+ export function SystemAlarmTooltip({ suspended, title = "", children, }) {
4
+ return (_jsx(Tooltip, { title: suspended ? "System alarm" : title, describeChild: true, children: _jsx("span", { style: { display: "inline-flex" }, tabIndex: suspended ? 0 : undefined, children: children }) }));
5
+ }