@seedtactics/insight-client 16.4.0

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 (298) hide show
  1. package/README.md +37 -0
  2. package/dist/cell-status/buffers.d.ts +36 -0
  3. package/dist/cell-status/buffers.js +127 -0
  4. package/dist/cell-status/current-status.d.ts +30 -0
  5. package/dist/cell-status/current-status.js +200 -0
  6. package/dist/cell-status/estimated-cycle-times.d.ts +41 -0
  7. package/dist/cell-status/estimated-cycle-times.js +257 -0
  8. package/dist/cell-status/inspections.d.ts +55 -0
  9. package/dist/cell-status/inspections.js +213 -0
  10. package/dist/cell-status/loading.d.ts +26 -0
  11. package/dist/cell-status/loading.js +112 -0
  12. package/dist/cell-status/material-details.d.ts +116 -0
  13. package/dist/cell-status/material-details.js +422 -0
  14. package/dist/cell-status/material-summary.d.ts +52 -0
  15. package/dist/cell-status/material-summary.js +312 -0
  16. package/dist/cell-status/names.d.ts +19 -0
  17. package/dist/cell-status/names.js +134 -0
  18. package/dist/cell-status/pallet-cycles.d.ts +24 -0
  19. package/dist/cell-status/pallet-cycles.js +78 -0
  20. package/dist/cell-status/rebookings.d.ts +30 -0
  21. package/dist/cell-status/rebookings.js +139 -0
  22. package/dist/cell-status/scheduled-jobs.d.ts +18 -0
  23. package/dist/cell-status/scheduled-jobs.js +94 -0
  24. package/dist/cell-status/sim-day-usage.d.ts +14 -0
  25. package/dist/cell-status/sim-day-usage.js +54 -0
  26. package/dist/cell-status/sim-production.d.ts +22 -0
  27. package/dist/cell-status/sim-production.js +91 -0
  28. package/dist/cell-status/sim-station-use.d.ts +25 -0
  29. package/dist/cell-status/sim-station-use.js +71 -0
  30. package/dist/cell-status/station-cycles.d.ts +34 -0
  31. package/dist/cell-status/station-cycles.js +145 -0
  32. package/dist/cell-status/tool-replacements.d.ts +44 -0
  33. package/dist/cell-status/tool-replacements.js +155 -0
  34. package/dist/cell-status/tool-usage.d.ts +25 -0
  35. package/dist/cell-status/tool-usage.js +95 -0
  36. package/dist/components/App.d.ts +15 -0
  37. package/dist/components/App.js +549 -0
  38. package/dist/components/AxisAndGrid.d.ts +51 -0
  39. package/dist/components/AxisAndGrid.js +47 -0
  40. package/dist/components/BarcodeScanning.d.ts +6 -0
  41. package/dist/components/BarcodeScanning.js +150 -0
  42. package/dist/components/ChartTooltip.d.ts +28 -0
  43. package/dist/components/ChartTooltip.js +95 -0
  44. package/dist/components/ChooseMode.d.ts +18 -0
  45. package/dist/components/ChooseMode.js +136 -0
  46. package/dist/components/ChooseOperator.d.ts +1 -0
  47. package/dist/components/ChooseOperator.js +93 -0
  48. package/dist/components/ErrorsAndLoading.d.ts +9 -0
  49. package/dist/components/ErrorsAndLoading.js +55 -0
  50. package/dist/components/LoadingIcon.d.ts +1 -0
  51. package/dist/components/LoadingIcon.js +48 -0
  52. package/dist/components/LogEntry.d.ts +16 -0
  53. package/dist/components/LogEntry.js +365 -0
  54. package/dist/components/ManualSerialEntry.d.ts +5 -0
  55. package/dist/components/ManualSerialEntry.js +91 -0
  56. package/dist/components/MonthSelect.d.ts +6 -0
  57. package/dist/components/MonthSelect.js +67 -0
  58. package/dist/components/Navigation.d.ts +23 -0
  59. package/dist/components/Navigation.js +120 -0
  60. package/dist/components/VerboseLogging.d.ts +1 -0
  61. package/dist/components/VerboseLogging.js +47 -0
  62. package/dist/components/analysis/AnalysisSelectToolbar.d.ts +1 -0
  63. package/dist/components/analysis/AnalysisSelectToolbar.js +55 -0
  64. package/dist/components/analysis/BufferChart.d.ts +1 -0
  65. package/dist/components/analysis/BufferChart.js +139 -0
  66. package/dist/components/analysis/CostPerPiece.d.ts +2 -0
  67. package/dist/components/analysis/CostPerPiece.js +175 -0
  68. package/dist/components/analysis/CycleChart.d.ts +42 -0
  69. package/dist/components/analysis/CycleChart.js +281 -0
  70. package/dist/components/analysis/DataTable.d.ts +83 -0
  71. package/dist/components/analysis/DataTable.js +215 -0
  72. package/dist/components/analysis/EfficiencyPage.d.ts +2 -0
  73. package/dist/components/analysis/EfficiencyPage.js +138 -0
  74. package/dist/components/analysis/HeatChart.d.ts +22 -0
  75. package/dist/components/analysis/HeatChart.js +161 -0
  76. package/dist/components/analysis/InspectionDataTable.d.ts +10 -0
  77. package/dist/components/analysis/InspectionDataTable.js +148 -0
  78. package/dist/components/analysis/InspectionSankey.d.ts +12 -0
  79. package/dist/components/analysis/InspectionSankey.js +140 -0
  80. package/dist/components/analysis/PalletCycleCards.d.ts +1 -0
  81. package/dist/components/analysis/PalletCycleCards.js +137 -0
  82. package/dist/components/analysis/PartCycleCards.d.ts +2 -0
  83. package/dist/components/analysis/PartCycleCards.js +331 -0
  84. package/dist/components/analysis/QualityPage.d.ts +1 -0
  85. package/dist/components/analysis/QualityPage.js +49 -0
  86. package/dist/components/analysis/ScheduleHistory.d.ts +3 -0
  87. package/dist/components/analysis/ScheduleHistory.js +108 -0
  88. package/dist/components/analysis/StationDataTable.d.ts +25 -0
  89. package/dist/components/analysis/StationDataTable.js +246 -0
  90. package/dist/components/analysis/ToolReplacements.d.ts +1 -0
  91. package/dist/components/analysis/ToolReplacements.js +370 -0
  92. package/dist/components/operations/AllMaterial.d.ts +5 -0
  93. package/dist/components/operations/AllMaterial.js +267 -0
  94. package/dist/components/operations/ChartRangeEdit.d.ts +4 -0
  95. package/dist/components/operations/ChartRangeEdit.js +148 -0
  96. package/dist/components/operations/CloseoutReport.d.ts +2 -0
  97. package/dist/components/operations/CloseoutReport.js +172 -0
  98. package/dist/components/operations/CompletedParts.d.ts +2 -0
  99. package/dist/components/operations/CompletedParts.js +286 -0
  100. package/dist/components/operations/CurrentWorkorders.d.ts +3 -0
  101. package/dist/components/operations/CurrentWorkorders.js +368 -0
  102. package/dist/components/operations/Dashboard.d.ts +2 -0
  103. package/dist/components/operations/Dashboard.js +90 -0
  104. package/dist/components/operations/OEEChart.d.ts +10 -0
  105. package/dist/components/operations/OEEChart.js +173 -0
  106. package/dist/components/operations/Outliers.d.ts +4 -0
  107. package/dist/components/operations/Outliers.js +69 -0
  108. package/dist/components/operations/ProgramHighlight.d.ts +1 -0
  109. package/dist/components/operations/ProgramHighlight.js +9 -0
  110. package/dist/components/operations/Programs.d.ts +5 -0
  111. package/dist/components/operations/Programs.js +363 -0
  112. package/dist/components/operations/Rebookings.d.ts +1 -0
  113. package/dist/components/operations/Rebookings.js +213 -0
  114. package/dist/components/operations/RecentCycleChart.d.ts +4 -0
  115. package/dist/components/operations/RecentCycleChart.js +240 -0
  116. package/dist/components/operations/RecentProduction.d.ts +2 -0
  117. package/dist/components/operations/RecentProduction.js +213 -0
  118. package/dist/components/operations/RecentSchedules.d.ts +12 -0
  119. package/dist/components/operations/RecentSchedules.js +180 -0
  120. package/dist/components/operations/RecentStationCycles.d.ts +4 -0
  121. package/dist/components/operations/RecentStationCycles.js +159 -0
  122. package/dist/components/operations/ShiftSettings.d.ts +6 -0
  123. package/dist/components/operations/ShiftSettings.js +134 -0
  124. package/dist/components/operations/SimDayUsage.d.ts +1 -0
  125. package/dist/components/operations/SimDayUsage.js +133 -0
  126. package/dist/components/operations/ToolReport.d.ts +3 -0
  127. package/dist/components/operations/ToolReport.js +233 -0
  128. package/dist/components/operations/WorkorderGantt.d.ts +1 -0
  129. package/dist/components/operations/WorkorderGantt.js +124 -0
  130. package/dist/components/quality/QualityMaterial.d.ts +2 -0
  131. package/dist/components/quality/QualityMaterial.js +169 -0
  132. package/dist/components/quality/QualityPaths.d.ts +1 -0
  133. package/dist/components/quality/QualityPaths.js +53 -0
  134. package/dist/components/quality/RecentFailedInspections.d.ts +1 -0
  135. package/dist/components/quality/RecentFailedInspections.js +123 -0
  136. package/dist/components/routes.d.ts +170 -0
  137. package/dist/components/routes.js +301 -0
  138. package/dist/components/station-monitor/BulkRawMaterial.d.ts +11 -0
  139. package/dist/components/station-monitor/BulkRawMaterial.js +251 -0
  140. package/dist/components/station-monitor/Closeout.d.ts +5 -0
  141. package/dist/components/station-monitor/Closeout.js +162 -0
  142. package/dist/components/station-monitor/CustomStationMonitorDialog.d.ts +1 -0
  143. package/dist/components/station-monitor/CustomStationMonitorDialog.js +55 -0
  144. package/dist/components/station-monitor/Inspection.d.ts +8 -0
  145. package/dist/components/station-monitor/Inspection.js +164 -0
  146. package/dist/components/station-monitor/InvalidateCycle.d.ts +33 -0
  147. package/dist/components/station-monitor/InvalidateCycle.js +262 -0
  148. package/dist/components/station-monitor/JobDetails.d.ts +7 -0
  149. package/dist/components/station-monitor/JobDetails.js +108 -0
  150. package/dist/components/station-monitor/LoadStation.d.ts +10 -0
  151. package/dist/components/station-monitor/LoadStation.js +450 -0
  152. package/dist/components/station-monitor/Material.d.ts +77 -0
  153. package/dist/components/station-monitor/Material.js +489 -0
  154. package/dist/components/station-monitor/MoveMaterialArrows.d.ts +11 -0
  155. package/dist/components/station-monitor/MoveMaterialArrows.js +118 -0
  156. package/dist/components/station-monitor/PrintedLabel.d.ts +29 -0
  157. package/dist/components/station-monitor/PrintedLabel.js +166 -0
  158. package/dist/components/station-monitor/QuarantineButton.d.ts +4 -0
  159. package/dist/components/station-monitor/QuarantineButton.js +184 -0
  160. package/dist/components/station-monitor/Queues.d.ts +23 -0
  161. package/dist/components/station-monitor/Queues.js +312 -0
  162. package/dist/components/station-monitor/QueuesAddMaterial.d.ts +30 -0
  163. package/dist/components/station-monitor/QueuesAddMaterial.js +248 -0
  164. package/dist/components/station-monitor/SelectInspType.d.ts +2 -0
  165. package/dist/components/station-monitor/SelectInspType.js +99 -0
  166. package/dist/components/station-monitor/SelectWorkorder.d.ts +4 -0
  167. package/dist/components/station-monitor/SelectWorkorder.js +100 -0
  168. package/dist/components/station-monitor/StationToolbar.d.ts +3 -0
  169. package/dist/components/station-monitor/StationToolbar.js +168 -0
  170. package/dist/components/station-monitor/SystemOverview.d.ts +46 -0
  171. package/dist/components/station-monitor/SystemOverview.js +439 -0
  172. package/dist/components/station-monitor/Whiteboard.d.ts +10 -0
  173. package/dist/components/station-monitor/Whiteboard.js +67 -0
  174. package/dist/data/all-material-bins.d.ts +45 -0
  175. package/dist/data/all-material-bins.js +224 -0
  176. package/dist/data/chart-times.d.ts +20 -0
  177. package/dist/data/chart-times.js +99 -0
  178. package/dist/data/cost-per-piece.d.ts +32 -0
  179. package/dist/data/cost-per-piece.js +183 -0
  180. package/dist/data/current-cycles.d.ts +13 -0
  181. package/dist/data/current-cycles.js +144 -0
  182. package/dist/data/inspection-sankey.d.ts +15 -0
  183. package/dist/data/inspection-sankey.js +147 -0
  184. package/dist/data/move-arrows.d.ts +48 -0
  185. package/dist/data/move-arrows.js +217 -0
  186. package/dist/data/operators.d.ts +2 -0
  187. package/dist/data/operators.js +44 -0
  188. package/dist/data/part-summary.d.ts +17 -0
  189. package/dist/data/part-summary.js +107 -0
  190. package/dist/data/path-lookup.d.ts +13 -0
  191. package/dist/data/path-lookup.js +107 -0
  192. package/dist/data/queue-material.d.ts +46 -0
  193. package/dist/data/queue-material.js +256 -0
  194. package/dist/data/results.bufferchart.d.ts +10 -0
  195. package/dist/data/results.bufferchart.js +90 -0
  196. package/dist/data/results.completed-parts.d.ts +26 -0
  197. package/dist/data/results.completed-parts.js +181 -0
  198. package/dist/data/results.cycles.d.ts +86 -0
  199. package/dist/data/results.cycles.js +454 -0
  200. package/dist/data/results.inspection.d.ts +36 -0
  201. package/dist/data/results.inspection.js +188 -0
  202. package/dist/data/results.oee.d.ts +40 -0
  203. package/dist/data/results.oee.js +330 -0
  204. package/dist/data/results.schedules.d.ts +23 -0
  205. package/dist/data/results.schedules.js +157 -0
  206. package/dist/data/tools-programs.d.ts +78 -0
  207. package/dist/data/tools-programs.js +376 -0
  208. package/dist/index.d.ts +1 -0
  209. package/dist/index.js +60 -0
  210. package/dist/network/api.d.ts +1390 -0
  211. package/dist/network/api.js +4971 -0
  212. package/dist/network/backend-mock.d.ts +11 -0
  213. package/dist/network/backend-mock.js +512 -0
  214. package/dist/network/backend.d.ts +57 -0
  215. package/dist/network/backend.js +77 -0
  216. package/dist/network/load-specific-month.d.ts +13 -0
  217. package/dist/network/load-specific-month.js +77 -0
  218. package/dist/network/server-settings.d.ts +12 -0
  219. package/dist/network/server-settings.js +92 -0
  220. package/dist/network/websocket.d.ts +4 -0
  221. package/dist/network/websocket.js +165 -0
  222. package/dist/renderer.d.ts +8 -0
  223. package/dist/renderer.js +55 -0
  224. package/dist/seedtactics-logo.d.ts +2 -0
  225. package/dist/seedtactics-logo.js +4 -0
  226. package/dist/util/chart-colors.d.ts +1 -0
  227. package/dist/util/chart-colors.js +116 -0
  228. package/dist/util/chart-helpers.d.ts +3 -0
  229. package/dist/util/chart-helpers.js +51 -0
  230. package/dist/util/parseISODuration.d.ts +4 -0
  231. package/dist/util/parseISODuration.js +40 -0
  232. package/docs/client-efficiency.md +355 -0
  233. package/docs/client-engineering.md +54 -0
  234. package/docs/client-launch.md +55 -0
  235. package/docs/client-operations.md +88 -0
  236. package/docs/client-quality.md +74 -0
  237. package/docs/client-sales.md +61 -0
  238. package/docs/client-scanners.md +41 -0
  239. package/docs/client-station-monitor.md +149 -0
  240. package/docs/client-tools-programs.md +74 -0
  241. package/docs/improve-fms.md +141 -0
  242. package/docs/makino.md +40 -0
  243. package/docs/material-quarantine.md +82 -0
  244. package/docs/material-tracking.md +236 -0
  245. package/docs/mazak.md +115 -0
  246. package/docs/niigata.md +228 -0
  247. package/docs/operator-procedures.md +106 -0
  248. package/docs/part-instructions.md +63 -0
  249. package/docs/screenshots/insight-all-material.png +0 -0
  250. package/docs/screenshots/insight-analysis-pallets.png +0 -0
  251. package/docs/screenshots/insight-analysis-part-completed.png +0 -0
  252. package/docs/screenshots/insight-analysis-sankey.png +0 -0
  253. package/docs/screenshots/insight-analysis-station-oee.png +0 -0
  254. package/docs/screenshots/insight-buffer-occupancy.png +0 -0
  255. package/docs/screenshots/insight-choose-analysis-month.png +0 -0
  256. package/docs/screenshots/insight-closeout.png +0 -0
  257. package/docs/screenshots/insight-cost-percentages.png +0 -0
  258. package/docs/screenshots/insight-dashboard.png +0 -0
  259. package/docs/screenshots/insight-event-custom-view.jpg +0 -0
  260. package/docs/screenshots/insight-event-viewer.jpg +0 -0
  261. package/docs/screenshots/insight-inspection.png +0 -0
  262. package/docs/screenshots/insight-load-station-details.png +0 -0
  263. package/docs/screenshots/insight-load-station.png +0 -0
  264. package/docs/screenshots/insight-loadcycle-graph.png +0 -0
  265. package/docs/screenshots/insight-loadstation-small.jpg +0 -0
  266. package/docs/screenshots/insight-machinecycle-graph.png +0 -0
  267. package/docs/screenshots/insight-machinecycle-table.png +0 -0
  268. package/docs/screenshots/insight-machinecycles.png +0 -0
  269. package/docs/screenshots/insight-machinehours.png +0 -0
  270. package/docs/screenshots/insight-machineoutliers.png +0 -0
  271. package/docs/screenshots/insight-monthly-schedules.png +0 -0
  272. package/docs/screenshots/insight-operations-material.png +0 -0
  273. package/docs/screenshots/insight-operations-overview.png +0 -0
  274. package/docs/screenshots/insight-operations-reports.png +0 -0
  275. package/docs/screenshots/insight-part-cost.png +0 -0
  276. package/docs/screenshots/insight-program-report.png +0 -0
  277. package/docs/screenshots/insight-quality-material-details.png +0 -0
  278. package/docs/screenshots/insight-quality-material.png +0 -0
  279. package/docs/screenshots/insight-quality-quarantine.png +0 -0
  280. package/docs/screenshots/insight-quality-sankey.png +0 -0
  281. package/docs/screenshots/insight-quality-similar-paths.png +0 -0
  282. package/docs/screenshots/insight-queue-details.png +0 -0
  283. package/docs/screenshots/insight-queues-jobs-table.png +0 -0
  284. package/docs/screenshots/insight-queues.png +0 -0
  285. package/docs/screenshots/insight-sim-day-usage.png +0 -0
  286. package/docs/screenshots/insight-station-system-overview-buttons.png +0 -0
  287. package/docs/screenshots/insight-station-system-overview.png +0 -0
  288. package/docs/screenshots/insight-system-overview.png +0 -0
  289. package/docs/screenshots/insight-tool-replacements.png +0 -0
  290. package/docs/screenshots/insight-tool-report.png +0 -0
  291. package/docs/screenshots/insight-toolbar-btns.png +0 -0
  292. package/docs/screenshots/insight-workorder-gantt.png +0 -0
  293. package/docs/screenshots/insight-workorders.png +0 -0
  294. package/docs/security.md +131 -0
  295. package/docs/server-config.md +56 -0
  296. package/docs/server-errors.md +44 -0
  297. package/package.json +90 -0
  298. package/src/index.ts +65 -0
@@ -0,0 +1,439 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ /* Copyright (c) 2024, John Lenz
3
+
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ * Redistributions of source code must retain the above copyright
10
+ notice, this list of conditions and the following disclaimer.
11
+
12
+ * Redistributions in binary form must reproduce the above
13
+ copyright notice, this list of conditions and the following
14
+ disclaimer in the documentation and/or other materials provided
15
+ with the distribution.
16
+
17
+ * Neither the name of John Lenz, Black Maple Software, SeedTactics,
18
+ nor the names of other contributors may be used to endorse or
19
+ promote products derived from this software without specific
20
+ prior written permission.
21
+
22
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
+ */
34
+ import { useState, useRef, memo } from "react";
35
+ import { Paper, ButtonBase, Box, Typography, Collapse, Stack, Menu, MenuItem, LinearProgress, Badge, Button, Dialog, DialogContent, AppBar, Toolbar, IconButton, useTheme, } from "@mui/material";
36
+ import { Close as CloseIcon } from "@mui/icons-material";
37
+ import { InProcMaterial, MaterialAction, MaterialDialog, PartIdenticon } from "./Material.js";
38
+ import { ActionType, LocType, PalletLocationEnum, } from "../../network/api.js";
39
+ import { currentStatus, secondsSinceEpochAtom } from "../../cell-status/current-status.js";
40
+ import { LazySeq, OrderedMap } from "@seedtactics/immutable-collections";
41
+ import { materialDialogOpen } from "../../cell-status/material-details.js";
42
+ import { last30Jobs } from "../../cell-status/scheduled-jobs.js";
43
+ import { addDays } from "date-fns";
44
+ import { durationToSeconds } from "../../util/parseISODuration.js";
45
+ import { InvalidateCycleDialogButton, InvalidateCycleDialogContent, SwapMaterialButtons, SwapMaterialDialogContent, } from "./InvalidateCycle.js";
46
+ import { QuarantineMatButton } from "./QuarantineButton.js";
47
+ import { SelectInspTypeDialog, SignalInspectionButton } from "./SelectInspType.js";
48
+ import { useSetTitle } from "../routes.js";
49
+ import { useAtomValue, useSetAtom } from "jotai";
50
+ const CollapsedIconSize = 45;
51
+ const rowSize = CollapsedIconSize + 10; // each material row has 5px above and 5px below for padding
52
+ function useCellOverview() {
53
+ const currentSt = useAtomValue(currentStatus);
54
+ const jobs = useAtomValue(last30Jobs);
55
+ const matByPal = LazySeq.of(currentSt.material)
56
+ .filter((m) => m.location.type === LocType.OnPallet || m.action.type === ActionType.Loading)
57
+ .toRLookup((m) => m.location.palletNum ?? m.action.loadOntoPalletNum ?? 0);
58
+ let loads = LazySeq.ofObject(currentSt.pallets)
59
+ .filter(([_, p]) => p.currentPalletLocation.loc === PalletLocationEnum.LoadUnload)
60
+ .toOrderedMap(([_, p]) => [
61
+ p.currentPalletLocation.num,
62
+ {
63
+ lulNum: p.currentPalletLocation.num,
64
+ pal: { pallet: p, mats: matByPal.get(p.palletNum) ?? [] },
65
+ },
66
+ ]);
67
+ let machines = LazySeq.ofObject(currentSt.pallets)
68
+ .filter(([, p]) => p.currentPalletLocation.loc === PalletLocationEnum.Machine ||
69
+ p.currentPalletLocation.loc === PalletLocationEnum.MachineQueue)
70
+ .map(([_, p]) => p)
71
+ .groupBy((p) => p.currentPalletLocation.group, (p) => p.currentPalletLocation.num)
72
+ .toLookupOrderedMap(([[statGroup, _statNum], _pals]) => statGroup, ([[_statGroup, statNum], _pals]) => statNum, ([[statGroup, statNum], pals]) => {
73
+ const worktable = pals.find((p) => p.currentPalletLocation.loc === PalletLocationEnum.Machine);
74
+ const worktableMats = worktable ? (matByPal.get(worktable.palletNum) ?? []) : null;
75
+ const rotary = pals.find((p) => p.currentPalletLocation.loc === PalletLocationEnum.MachineQueue);
76
+ const rotaryMats = rotary ? (matByPal.get(rotary.palletNum) ?? []) : null;
77
+ let isInbound = true;
78
+ const rotaryMat0 = rotaryMats?.[0];
79
+ if (rotaryMat0 &&
80
+ rotaryMat0.lastCompletedMachiningRouteStopIndex !== null &&
81
+ rotaryMat0.lastCompletedMachiningRouteStopIndex !== undefined) {
82
+ const stop = currentSt.jobs[rotaryMat0.jobUnique]?.procsAndPaths?.[rotaryMat0.process - 1]?.paths?.[rotaryMat0.path - 1]?.stops?.[rotaryMat0.lastCompletedMachiningRouteStopIndex];
83
+ if (stop.stationGroup === statGroup && stop.stationNums.includes(statNum)) {
84
+ isInbound = false;
85
+ }
86
+ }
87
+ if (isInbound) {
88
+ return {
89
+ name: statGroup + " " + statNum.toString(),
90
+ inbound: rotary ? { pallet: rotary, mats: rotaryMats ?? [] } : null,
91
+ worktable: worktable ? { pallet: worktable, mats: worktableMats ?? [] } : null,
92
+ outbound: null,
93
+ };
94
+ }
95
+ else {
96
+ return {
97
+ name: statGroup + " " + statNum.toString(),
98
+ inbound: null,
99
+ worktable: worktable ? { pallet: worktable, mats: worktableMats ?? [] } : null,
100
+ outbound: rotary ? { pallet: rotary, mats: rotaryMats ?? [] } : null,
101
+ };
102
+ }
103
+ });
104
+ const stockerPals = LazySeq.ofObject(currentSt.pallets)
105
+ .filter(([_, p]) => p.currentPalletLocation.loc === PalletLocationEnum.Buffer ||
106
+ p.currentPalletLocation.loc === PalletLocationEnum.Cart)
107
+ .collect(([_, p]) => {
108
+ const mats = matByPal.get(p.palletNum);
109
+ if (!mats || mats.length === 0)
110
+ return null;
111
+ return { pallet: p, mats };
112
+ })
113
+ .toOrderedMap((p) => [p.pallet.palletNum, p]);
114
+ let maxLoadNum = 1;
115
+ let maxNumFacesOnPallet = 1;
116
+ const cutoff = addDays(new Date(), -7);
117
+ // now add empty locations
118
+ const allPaths = jobs
119
+ .valuesToLazySeq()
120
+ .filter((j) => j.routeEndUTC > cutoff)
121
+ .concat(LazySeq.ofObject(currentSt.jobs).map(([_, j]) => j))
122
+ .flatMap((j) => j.procsAndPaths)
123
+ .flatMap((p) => p.paths);
124
+ for (const path of allPaths) {
125
+ for (const lul of path.load.concat(path.unload)) {
126
+ maxLoadNum = Math.max(maxLoadNum, lul);
127
+ }
128
+ if (path.face) {
129
+ maxNumFacesOnPallet = Math.max(maxNumFacesOnPallet, path.face);
130
+ }
131
+ for (const stop of path.stops) {
132
+ machines = machines.alter(stop.stationGroup, (stationStatuses) => {
133
+ stationStatuses = stationStatuses ?? OrderedMap.empty();
134
+ for (const num of stop.stationNums) {
135
+ stationStatuses = stationStatuses.alter(num, (status) => {
136
+ if (status)
137
+ return status;
138
+ return {
139
+ name: stop.stationGroup + " " + num.toString(),
140
+ inbound: null,
141
+ worktable: null,
142
+ outbound: null,
143
+ };
144
+ });
145
+ }
146
+ return stationStatuses;
147
+ });
148
+ }
149
+ }
150
+ for (let i = 1; i <= maxLoadNum; i++) {
151
+ loads = loads.alter(i, (status) => {
152
+ if (status)
153
+ return status;
154
+ return {
155
+ lulNum: i,
156
+ pal: null,
157
+ };
158
+ });
159
+ }
160
+ for (const pal of Object.values(currentSt.pallets)) {
161
+ maxNumFacesOnPallet = Math.max(maxNumFacesOnPallet, pal.numFaces);
162
+ }
163
+ for (const mat of currentSt.material) {
164
+ if (mat.location.face !== null && mat.location.face !== undefined) {
165
+ maxNumFacesOnPallet = Math.max(maxNumFacesOnPallet, mat.location.face);
166
+ }
167
+ }
168
+ let machAtLoad = OrderedMap.empty();
169
+ if (currentSt.machineLocations && currentSt.machineLocations.length > 0) {
170
+ for (const mach of currentSt.machineLocations) {
171
+ // remove machine status
172
+ machines = machines.alter(mach.machineGroup, (old) => {
173
+ if (!old || mach.machineNum === undefined)
174
+ return old;
175
+ const n = old.delete(mach.machineNum);
176
+ if (n.size === 0)
177
+ return undefined;
178
+ return n;
179
+ });
180
+ for (const lulNum of mach.possibleLoadStations) {
181
+ // remove and lookup old load status
182
+ let lul;
183
+ loads = loads.alter(lulNum, (s) => {
184
+ lul = s;
185
+ return undefined;
186
+ });
187
+ const allMats = LazySeq.of(lul?.pal?.mats ?? []).toLookup((m) => {
188
+ if (m.action.type === ActionType.Machining)
189
+ return "Machining";
190
+ if (m.action.type !== ActionType.Waiting)
191
+ return "Loading";
192
+ if (m.lastCompletedMachiningRouteStopIndex !== null &&
193
+ m.lastCompletedMachiningRouteStopIndex !== undefined) {
194
+ const stop = currentSt.jobs[m.jobUnique]?.procsAndPaths?.[m.process - 1]?.paths?.[m.path - 1]?.stops?.[m.lastCompletedMachiningRouteStopIndex];
195
+ if (!stop ||
196
+ (stop.stationGroup === mach.machineGroup && stop.stationNums.includes(mach.machineNum))) {
197
+ return "Loading";
198
+ }
199
+ }
200
+ return "Ready";
201
+ });
202
+ const newStatus = {
203
+ lulNum,
204
+ machineMoving: mach.moving,
205
+ machineCurrentlyAtLoad: lulNum === mach.currentLoadStation ? { group: mach.machineGroup, num: mach.machineNum } : null,
206
+ readyMats: allMats.get("Ready") ?? [],
207
+ machiningMats: allMats.get("Machining") ?? [],
208
+ loadingMats: allMats.get("Loading") ?? [],
209
+ };
210
+ machAtLoad = machAtLoad.set(lulNum, newStatus);
211
+ }
212
+ }
213
+ }
214
+ return {
215
+ machines: machines.mapValues((group) => group.valuesToAscLazySeq().toRArray()),
216
+ loads: loads.valuesToAscLazySeq().toRArray(),
217
+ stockerPals: stockerPals.valuesToAscLazySeq().toRArray(),
218
+ machineAtLoad: machAtLoad.valuesToAscLazySeq().toRArray(),
219
+ maxNumFacesOnPallet,
220
+ };
221
+ }
222
+ function MaterialIcon({ mats }) {
223
+ const [open, setOpen] = useState(false);
224
+ const closeTimeout = useRef(null);
225
+ const btnRef = useRef(null);
226
+ const [menuOpen, setMenuOpen] = useState(false);
227
+ const setMatToShow = useSetAtom(materialDialogOpen);
228
+ const curSt = useAtomValue(currentStatus);
229
+ function enter() {
230
+ if (closeTimeout.current !== null) {
231
+ clearTimeout(closeTimeout.current);
232
+ closeTimeout.current = null;
233
+ }
234
+ setOpen(true);
235
+ }
236
+ function leave() {
237
+ closeTimeout.current = setTimeout(() => {
238
+ setOpen(false);
239
+ closeTimeout.current = null;
240
+ }, 200);
241
+ }
242
+ function click() {
243
+ if (mats.length === 1) {
244
+ setMatToShow({ type: "MatDetails", details: mats[0] });
245
+ }
246
+ else {
247
+ setMenuOpen(true);
248
+ }
249
+ }
250
+ function faceName(pallet, faceNum) {
251
+ if (faceNum === null || faceNum === undefined)
252
+ return null;
253
+ const name = pallet != null && pallet != undefined ? curSt.pallets[pallet]?.faceNames?.[faceNum - 1] : null;
254
+ return name ?? "Face: " + faceNum.toString();
255
+ }
256
+ return (_jsxs(Box, { sx: { width: CollapsedIconSize, height: CollapsedIconSize, overflow: "visible" }, children: [_jsx(Paper, { elevation: 4, onPointerEnter: enter, onPointerLeave: leave, sx: { position: "relative", zIndex: open ? 10 : 0, width: "max-content", height: "max-content" }, children: _jsx(Badge, { badgeContent: mats.length > 1 ? mats.length : 0, color: "secondary", children: _jsx(ButtonBase, { focusRipple: true, onClick: click, ref: btnRef, children: _jsx(Collapse, { orientation: "horizontal", in: open, collapsedSize: CollapsedIconSize, children: _jsxs(Box, { display: "flex", children: [_jsx(PartIdenticon, { part: mats[0].partName, size: CollapsedIconSize }), _jsx(Box, { marginLeft: "10px", marginRight: "10px", whiteSpace: "nowrap", textAlign: "left", children: _jsx(Collapse, { in: open, collapsedSize: CollapsedIconSize, children: _jsxs(Stack, { direction: "column", marginBottom: "0.2em", children: [_jsxs(Typography, { variant: "h6", children: [mats[0].partName, "-", mats[0].process] }), _jsx("div", { children: _jsx("small", { children: faceName(mats[0].location.palletNum, mats[0].location.face) ??
257
+ faceName(mats[0].action.loadOntoPalletNum, mats[0].action.loadOntoFace) }) }), LazySeq.of(mats).collect((mat) => mat.serial ? (_jsx("div", { children: _jsxs("small", { children: ["Serial: ", mat.serial] }) }, mat.materialID)) : undefined), _jsx("div", { children: _jsx(MaterialAction, { mat: mats[0] }) })] }) }) })] }) }) }) }) }), _jsx(Menu, { anchorEl: btnRef.current, open: menuOpen, onClose: () => setMenuOpen(false), anchorOrigin: { vertical: "top", horizontal: "left" }, children: LazySeq.of(mats).map((mat, idx) => (_jsx(MenuItem, { onClick: () => {
258
+ setMenuOpen(false);
259
+ setMatToShow({ type: "MatDetails", details: mat });
260
+ }, children: mat.serial && mat.serial !== "" ? mat.serial : (idx + 1).toString() }, mat.materialID))) })] }));
261
+ }
262
+ function PalletFaces({ maxNumFaces, mats, loadingOntoPallet, noFilter, showExpanded, }) {
263
+ if (showExpanded && maxNumFaces === 1) {
264
+ return (_jsx(Box, { display: "flex", flexDirection: "column", flexWrap: "wrap", children: mats.map((mat) => (_jsx(InProcMaterial, { mat: mat }, mat.materialID))) }));
265
+ }
266
+ else {
267
+ const byFace = loadingOntoPallet
268
+ ? LazySeq.of(mats)
269
+ .filter((m) => noFilter || m.location.type !== LocType.OnPallet)
270
+ .orderedGroupBy((m) => m.action.loadOntoFace ?? 1)
271
+ : LazySeq.of(mats)
272
+ .filter((m) => noFilter || m.location.type === LocType.OnPallet)
273
+ .orderedGroupBy((m) => m.action.type === ActionType.Loading ? (m.action.loadOntoFace ?? 1) : (m.location.face ?? 1));
274
+ return (_jsx(Box, { display: "grid", gridTemplateRows: `${CollapsedIconSize}px`, gridTemplateColumns: `repeat(${maxNumFaces}, ${CollapsedIconSize}px)`, columnGap: "5px", height: "100%", alignContent: "center", justifyContent: "center", children: byFace.map(([face, mats]) => (_jsx(Box, { gridColumn: face, gridRow: 1, children: _jsx(MaterialIcon, { mats: mats }) }, face))) }));
275
+ }
276
+ }
277
+ function gridTemplateColumns(maxNumFaces, includeLabelCol) {
278
+ // each material column is at least CollapsedIconSize * (maxNumFaces) for the icon + 5px * (maxNumFaces + 1) for the columnGap in PalletFaces
279
+ const colSize = CollapsedIconSize * maxNumFaces + 5 * (maxNumFaces + 1);
280
+ if (includeLabelCol) {
281
+ return `60px ${Math.max(colSize, 100)}px`;
282
+ }
283
+ else {
284
+ return `${Math.max(colSize, 100)}px`;
285
+ }
286
+ }
287
+ export function formatSeconds(totalSeconds) {
288
+ totalSeconds = Math.round(totalSeconds);
289
+ const secs = Math.abs(totalSeconds) % 60;
290
+ const totalMins = Math.floor(Math.abs(totalSeconds) / 60);
291
+ const mins = totalMins % 60;
292
+ const hours = Math.floor(totalMins / 60);
293
+ if (hours > 0) {
294
+ return `${totalSeconds < 0 ? "-" : ""}${hours}:${mins.toString().padStart(2, "0")}:${secs
295
+ .toString()
296
+ .padStart(2, "0")}`;
297
+ }
298
+ else {
299
+ return `${totalSeconds < 0 ? "-" : ""}${mins}:${secs.toString().padStart(2, "0")}`;
300
+ }
301
+ }
302
+ function useRemainingMachineTime(material) {
303
+ const mat = material?.find((m) => m.action.type === ActionType.Machining);
304
+ const elapsedDurationFromCurSt = mat?.action?.elapsedMachiningTime;
305
+ const remainingDurationFromCurSt = mat?.action.expectedRemainingMachiningTime;
306
+ const currentStTime = useAtomValue(currentStatus).timeOfCurrentStatusUTC;
307
+ const secondsSinceEpoch = useAtomValue(secondsSinceEpochAtom);
308
+ let remainingSecs = null;
309
+ if (remainingDurationFromCurSt) {
310
+ const remainingSecsInCurSt = durationToSeconds(remainingDurationFromCurSt);
311
+ remainingSecs = remainingSecsInCurSt - (secondsSinceEpoch - Math.floor(currentStTime.getTime() / 1000));
312
+ }
313
+ let elapsedSecs = null;
314
+ if (elapsedDurationFromCurSt) {
315
+ const elapsedSecsInCurSt = durationToSeconds(elapsedDurationFromCurSt);
316
+ elapsedSecs = elapsedSecsInCurSt + (secondsSinceEpoch - Math.floor(currentStTime.getTime() / 1000));
317
+ }
318
+ if (remainingSecs !== null && elapsedSecs !== null) {
319
+ return [
320
+ true,
321
+ `${formatSeconds(elapsedSecs)} / ${formatSeconds(remainingSecs)}`,
322
+ remainingSecs < 0 ? -1 : (elapsedSecs / (elapsedSecs + remainingSecs)) * 100,
323
+ ];
324
+ }
325
+ else if (remainingSecs !== null) {
326
+ return [true, " / " + formatSeconds(remainingSecs), remainingSecs < 0 ? -1 : null];
327
+ }
328
+ else if (elapsedSecs !== null) {
329
+ return [true, formatSeconds(elapsedSecs), null];
330
+ }
331
+ else {
332
+ return [!!mat, "Idle", null];
333
+ }
334
+ }
335
+ function MachineLabel({ machine }) {
336
+ const [machining, status, elapsed] = useRemainingMachineTime(machine.worktable?.mats);
337
+ return (_jsxs("div", { children: [_jsx(Typography, { variant: "h5", children: machine.name }), _jsx(Typography, { variant: "subtitle1", children: status }), machining ? (elapsed === null ? (_jsx(LinearProgress, {})) : elapsed < 0 ? (_jsx(LinearProgress, { color: "error" })) : (_jsx(LinearProgress, { variant: "determinate", value: elapsed }))) : undefined] }));
338
+ }
339
+ function Machine({ maxNumFaces, machine }) {
340
+ return (_jsxs(Box, { display: "grid", border: "1px solid black", margin: "5px", gridTemplateRows: `auto ${rowSize}px ${rowSize}px ${rowSize}px`, gridTemplateColumns: gridTemplateColumns(maxNumFaces, true), gridTemplateAreas: `"machname machname" "inboundpal inboundmat" "worktablepal worktablemat" "outboundpal outboundmat"`, children: [_jsx(Box, { gridArea: "machname", padding: "0.2em", borderBottom: "1px solid black", children: _jsx(MachineLabel, { machine: machine }) }), _jsx(Box, { gridArea: "inboundpal", borderRight: "1px solid black", borderBottom: "1px solid black", padding: "2px", children: _jsxs(Stack, { children: [_jsx(Typography, { variant: "body1", textAlign: "center", children: "In" }), machine.inbound ? (_jsx(Typography, { variant: "h6", textAlign: "center", children: machine.inbound.pallet.palletNum })) : undefined] }) }), _jsx(Box, { gridArea: "inboundmat", borderBottom: "1px solid black", children: machine.inbound ? _jsx(PalletFaces, { mats: machine.inbound.mats, maxNumFaces: maxNumFaces }) : undefined }), _jsx(Box, { gridArea: "worktablepal", borderRight: "1px solid black", borderBottom: "1px solid black", padding: "2px", children: _jsxs(Stack, { children: [_jsx(Typography, { variant: "body1", textAlign: "center", children: "Work" }), machine.worktable ? (_jsx(Typography, { variant: "h6", textAlign: "center", children: machine.worktable.pallet.palletNum })) : undefined] }) }), _jsx(Box, { gridArea: "worktablemat", borderBottom: "1px solid black", children: machine.worktable ? (_jsx(PalletFaces, { mats: machine.worktable.mats, maxNumFaces: maxNumFaces })) : undefined }), _jsx(Box, { gridArea: "outboundpal", borderRight: "1px solid black", padding: "2px", children: _jsxs(Stack, { children: [_jsx(Typography, { variant: "body1", textAlign: "center", children: "Out" }), machine.outbound ? (_jsx(Typography, { variant: "h6", textAlign: "center", children: machine.outbound.pallet.palletNum })) : undefined] }) }), _jsx(Box, { gridArea: "outboundmat", children: machine.outbound ? (_jsx(PalletFaces, { mats: machine.outbound.mats, maxNumFaces: maxNumFaces })) : undefined })] }));
341
+ }
342
+ function useElapsedLoadTime(material) {
343
+ const mat = material?.find((m) => m.action.type === ActionType.Loading ||
344
+ m.action.type === ActionType.UnloadToCompletedMaterial ||
345
+ m.action.type === ActionType.UnloadToInProcess);
346
+ const elapsedDurationFromCurSt = mat?.action?.elapsedLoadUnloadTime;
347
+ const currentStTime = useAtomValue(currentStatus).timeOfCurrentStatusUTC;
348
+ const secondsSinceEpoch = useAtomValue(secondsSinceEpochAtom);
349
+ let elapsedSecs = null;
350
+ if (elapsedDurationFromCurSt) {
351
+ const elapsedSecsInCurSt = durationToSeconds(elapsedDurationFromCurSt);
352
+ elapsedSecs = elapsedSecsInCurSt + (secondsSinceEpoch - Math.floor(currentStTime.getTime() / 1000));
353
+ }
354
+ if (elapsedSecs !== null) {
355
+ return formatSeconds(elapsedSecs);
356
+ }
357
+ else {
358
+ return "Idle";
359
+ }
360
+ }
361
+ function LoadStationLabel({ load }) {
362
+ const status = useElapsedLoadTime(load.pal?.mats);
363
+ return (_jsxs(Box, { display: "flex", justifyContent: "space-between", alignItems: "baseline", children: [_jsxs(Typography, { variant: "h5", children: ["L/U ", load.lulNum] }), _jsx(Typography, { variant: "body1", children: status })] }));
364
+ }
365
+ function LoadStation({ maxNumFaces, load }) {
366
+ return (_jsxs(Box, { display: "grid", border: "1px solid black", margin: "5px", gridTemplateRows: `auto ${rowSize}px ${rowSize}px`, gridTemplateColumns: gridTemplateColumns(maxNumFaces, true), gridTemplateAreas: `"lulname lulname" "loading loadingmat" "currentpal currentmat"`, children: [_jsx(Box, { gridArea: "lulname", padding: "0.2em", borderBottom: "1px solid black", children: _jsx(LoadStationLabel, { load: load }) }), _jsx(Box, { gridArea: "loading", borderRight: "1px solid black", borderBottom: "1px solid black", padding: "2px", children: _jsxs(Stack, { children: [_jsx(Typography, { variant: "body1", textAlign: "center", children: "To" }), _jsx(Typography, { variant: "body1", textAlign: "center", children: "Load" })] }) }), _jsx(Box, { sx: { gridArea: "loadingmat", borderBottom: "1px solid black" }, children: load.pal ? (_jsx(PalletFaces, { mats: load.pal.mats, maxNumFaces: maxNumFaces, loadingOntoPallet: true })) : undefined }), _jsx(Box, { gridArea: "currentpal", borderRight: "1px solid black", padding: "2px", children: _jsxs(Stack, { children: [_jsx(Typography, { variant: "body1", textAlign: "center", children: "Pallet" }), load.pal ? (_jsx(Typography, { variant: "h6", textAlign: "center", children: load.pal.pallet.palletNum })) : undefined] }) }), _jsx(Box, { gridArea: "currentmat", children: load.pal ? _jsx(PalletFaces, { mats: load.pal.mats, maxNumFaces: maxNumFaces }) : undefined })] }));
367
+ }
368
+ function MachineAtLoadLabel({ status }) {
369
+ const lulStatus = useElapsedLoadTime(status.loadingMats);
370
+ const [machining, mcStatus, mcElapsed] = useRemainingMachineTime(status.machiningMats);
371
+ return (_jsxs("div", { children: [_jsxs(Typography, { variant: "h5", children: ["Station ", status.lulNum] }), status.machineCurrentlyAtLoad ? (_jsxs(_Fragment, { children: [_jsxs(Typography, { variant: "h5", children: [status.machineCurrentlyAtLoad.group, " ", status.machineCurrentlyAtLoad.num] }), _jsx(Typography, { variant: "subtitle1", children: mcStatus === "Idle" ? lulStatus : mcStatus }), machining ? (mcElapsed === null ? (_jsx(LinearProgress, {})) : mcElapsed < 0 ? (_jsx(LinearProgress, { color: "error" })) : (_jsx(LinearProgress, { variant: "determinate", value: mcElapsed }))) : undefined] })) : (_jsxs(_Fragment, { children: [status.machineMoving ? _jsx(Typography, { variant: "subtitle2", children: "Machine Moving" }) : undefined, _jsxs(Typography, { variant: "subtitle1", children: ["Loading ", lulStatus] })] }))] }));
372
+ }
373
+ function MachineAtLoad({ maxNumFaces, status }) {
374
+ return (_jsxs(Box, { display: "grid", border: "1px solid black", margin: "5px", gridTemplateRows: `minmax(104px, max-content) repeat(3, ${maxNumFaces > 1 ? rowSize.toString() + "px" : "minmax(110px, max-content)"})`, gridTemplateColumns: maxNumFaces === 1 ? "60px minmax(230px, max-content)" : gridTemplateColumns(maxNumFaces, true), gridTemplateAreas: `"name name" "ready readymat" "machining machiningmat" "loadstation loadstationmat"`, children: [_jsx(Box, { gridArea: "name", padding: "0.2em", borderBottom: "1px solid black", children: _jsx(MachineAtLoadLabel, { status: status }) }), _jsx(Box, { gridArea: "ready", borderRight: "1px solid black", borderBottom: "1px solid black", padding: "2px", children: _jsx(Typography, { variant: "body1", textAlign: "center", children: "Ready" }) }), _jsx(Box, { gridArea: "readymat", borderBottom: "1px solid black", display: "flex", flexDirection: "column", justifyContent: "center", children: _jsx(PalletFaces, { mats: status.readyMats, maxNumFaces: maxNumFaces, showExpanded: true }) }), _jsx(Box, { gridArea: "machining", borderRight: "1px solid black", borderBottom: "1px solid black", padding: "2px", children: _jsx(Typography, { variant: "body1", textAlign: "center", children: "Work" }) }), _jsx(Box, { gridArea: "machiningmat", borderBottom: "1px solid black", display: "flex", flexDirection: "column", justifyContent: "center", children: _jsx(PalletFaces, { mats: status.machiningMats, maxNumFaces: maxNumFaces, showExpanded: true }) }), _jsx(Box, { gridArea: "loadstation", borderRight: "1px solid black", padding: "2px", children: _jsxs(Stack, { children: [_jsx(Typography, { variant: "body1", textAlign: "center", children: "Load" }), _jsx(Typography, { variant: "body1", textAlign: "center", children: "Station" })] }) }), _jsx(Box, { gridArea: "loadstationmat", display: "flex", flexDirection: "column", justifyContent: "center", children: _jsx(PalletFaces, { mats: status.loadingMats, maxNumFaces: maxNumFaces, showExpanded: true, noFilter: true }) })] }));
375
+ }
376
+ function StockerPallet({ maxNumFaces, pallet }) {
377
+ return (_jsxs(Box, { display: "grid", border: "1px solid black", margin: "5px", gridTemplateRows: `auto ${rowSize}px`, gridTemplateColumns: gridTemplateColumns(maxNumFaces, false), gridTemplateAreas: `"palname" "palmat"`, children: [_jsxs(Typography, { variant: "h5", gridArea: "palname", padding: "0.2em", borderBottom: "1px solid black", children: ["Pallet ", pallet.pallet.palletNum] }), _jsx(Box, { gridArea: "palmat", children: _jsx(PalletFaces, { mats: pallet.mats, maxNumFaces: maxNumFaces }) })] }));
378
+ }
379
+ export const SystemOverview = memo(function SystemOverview({ overview }) {
380
+ return (_jsxs("div", { children: [overview.machines.toAscLazySeq().map(([group, machines]) => (_jsx(Box, { display: "flex", flexWrap: "wrap", justifyContent: "space-evenly", children: machines.map((machine) => (_jsx(Machine, { machine: machine, maxNumFaces: overview.maxNumFacesOnPallet }, machine.name))) }, group))), overview.loads.length > 0 ? (_jsx(Box, { display: "flex", flexWrap: "wrap", justifyContent: "space-evenly", children: overview.loads.map((machine) => (_jsx(LoadStation, { load: machine, maxNumFaces: overview.maxNumFacesOnPallet }, machine.lulNum))) })) : undefined, overview.machineAtLoad.length > 0 ? (_jsx(Box, { display: "flex", flexWrap: "wrap", justifyContent: "space-evenly", children: overview.machineAtLoad.map((status) => (_jsx(MachineAtLoad, { status: status, maxNumFaces: overview.maxNumFacesOnPallet }, status.lulNum))) })) : undefined, overview.stockerPals.length > 0 ? (_jsx(Box, { display: "flex", flexWrap: "wrap", justifyContent: "space-evenly", children: overview.stockerPals.map((pal) => (_jsx(StockerPallet, { pallet: pal, maxNumFaces: overview.maxNumFacesOnPallet }, pal.pallet.palletNum))) })) : undefined] }));
381
+ });
382
+ const SystemOverviewMaterialDialog = memo(function SystemOverviewMaterialDialog({ ignoreOperator, }) {
383
+ const [swapSt, setSwapSt] = useState(null);
384
+ const [invalidateSt, setInvalidateSt] = useState(null);
385
+ function onClose() {
386
+ setSwapSt(null);
387
+ setInvalidateSt(null);
388
+ }
389
+ return (_jsx(MaterialDialog, { onClose: onClose, allowNote: true, highlightProcsGreaterOrEqualTo: invalidateSt?.process ?? undefined, extraDialogElements: _jsxs(_Fragment, { children: [_jsx(SwapMaterialDialogContent, { st: swapSt, setState: setSwapSt }), invalidateSt !== null ? (_jsx(InvalidateCycleDialogContent, { st: invalidateSt, setState: setInvalidateSt })) : null] }), buttons: _jsxs(_Fragment, { children: [_jsx(QuarantineMatButton, { ignoreOperator: ignoreOperator }), _jsx(SignalInspectionButton, {}), _jsx(SwapMaterialButtons, { st: swapSt, setState: setSwapSt, onClose: onClose, ignoreOperator: ignoreOperator }), _jsx(InvalidateCycleDialogButton, { st: invalidateSt, setState: setInvalidateSt, onClose: onClose, ignoreOperator: ignoreOperator })] }) }));
390
+ });
391
+ export function SystemOverviewPage({ ignoreOperator, whiteBackground, }) {
392
+ useSetTitle("System Overview");
393
+ const overview = useCellOverview();
394
+ return (_jsxs("main", { style: {
395
+ padding: "10px",
396
+ minHeight: "calc(100vh - 64px)",
397
+ backgroundColor: whiteBackground ? "white" : "#F8F8F8",
398
+ }, children: [_jsx(SystemOverview, { overview: overview }), _jsx(SystemOverviewMaterialDialog, { ignoreOperator: ignoreOperator }), _jsx(SelectInspTypeDialog, {})] }));
399
+ }
400
+ const StatusIconSize = 30;
401
+ function MachineIcon({ machine }) {
402
+ const theme = useTheme();
403
+ const [, , elapsed] = useRemainingMachineTime(machine.worktable?.mats);
404
+ return (_jsxs(_Fragment, { children: [_jsx("rect", { x: 3, y: 3, width: 24, height: 24, stroke: "black" }), ";", _jsx("rect", { x: 3, y: 3, width: 24, height: 8, fill: machine.inbound === null ? "white" : theme.palette.secondary.main }), _jsx("rect", { x: 3, y: 11, width: 24, height: 8, fill: machine.worktable === null
405
+ ? "white"
406
+ : elapsed != null && elapsed < 0
407
+ ? theme.palette.error.main
408
+ : theme.palette.secondary.main }), _jsx("rect", { x: 3, y: 19, width: 24, height: 8, fill: machine.outbound === null ? "white" : theme.palette.secondary.main })] }));
409
+ }
410
+ function LoadStationIcon({ load }) {
411
+ const theme = useTheme();
412
+ return (_jsx("polygon", { points: "3,27 27,27 15,3", fill: load.pal === null ? "white" : theme.palette.secondary.main, stroke: "black" }));
413
+ }
414
+ function MachineAtLoadIcon({ status }) {
415
+ const theme = useTheme();
416
+ const [, , elapsed] = useRemainingMachineTime(status.machiningMats);
417
+ return (_jsxs(_Fragment, { children: [_jsx("rect", { x: 3, y: 3, width: 24, height: 24, stroke: "black" }), ";", _jsx("rect", { x: 3, y: 3, width: 24, height: 8, fill: status.readyMats.length === 0 ? "white" : theme.palette.secondary.main }), _jsx("rect", { x: 3, y: 11, width: 24, height: 8, fill: status.machiningMats.length === 0
418
+ ? "white"
419
+ : elapsed != null && elapsed < 0
420
+ ? theme.palette.error.main
421
+ : theme.palette.secondary.main }), _jsx("rect", { x: 3, y: 19, width: 24, height: 8, fill: status.loadingMats.length === 0 ? "white" : theme.palette.secondary.main })] }));
422
+ }
423
+ const StatusIcons = memo(function StatusIcons({ overview }) {
424
+ const numMachines = overview.machines.toAscLazySeq().sumBy(([, machines]) => machines.length);
425
+ return (_jsx(Box, { sx: {
426
+ height: "1.5em",
427
+ "&:hover": {
428
+ backgroundColor: "primary.light",
429
+ },
430
+ }, children: _jsxs("svg", { viewBox: `0 0 ${(numMachines + overview.loads.length + overview.machineAtLoad.length) * StatusIconSize} ${StatusIconSize}`, preserveAspectRatio: "none", width: "140px", height: "1.5em", children: [_jsx("g", { children: overview.machines
431
+ .toAscLazySeq()
432
+ .flatMap(([, machines]) => machines)
433
+ .map((machine, idx) => (_jsx("g", { transform: `translate(${idx * StatusIconSize})`, children: _jsx(MachineIcon, { machine: machine }) }, machine.name))) }), _jsx("g", { transform: `translate(${numMachines * StatusIconSize})`, children: overview.loads.map((load, idx) => (_jsx("g", { transform: `translate(${idx * StatusIconSize})`, children: _jsx(LoadStationIcon, { load: load }) }, load.lulNum))) }), _jsx("g", { transform: `translate(${(numMachines + overview.loads.length) * StatusIconSize})`, children: overview.machineAtLoad.map((status, idx) => (_jsx("g", { transform: `translate(${idx * StatusIconSize})`, children: _jsx(MachineAtLoadIcon, { status: status }) }, status.lulNum))) })] }) }));
434
+ });
435
+ export const SystemOverviewDialogButton = memo(function SystemOverviewDialogButton({ full, }) {
436
+ const [open, setOpen] = useState(false);
437
+ const overview = useCellOverview();
438
+ return (_jsxs(_Fragment, { children: [_jsx(Button, { onClick: () => setOpen(true), children: _jsx(StatusIcons, { overview: overview }) }), _jsxs(Dialog, { open: open, onClose: () => setOpen(false), maxWidth: "xl", fullScreen: full, children: [full ? (_jsx(AppBar, { sx: { position: "relative" }, children: _jsxs(Toolbar, { children: [_jsx(IconButton, { edge: "start", color: "inherit", onClick: () => setOpen(false), "aria-label": "close", children: _jsx(CloseIcon, {}) }), _jsx(Typography, { sx: { ml: 2, flex: 1 }, variant: "h6", component: "div", children: "System Overview" })] }) })) : undefined, _jsx(DialogContent, { children: _jsx(Box, { paddingBottom: "2em", paddingLeft: "5em", paddingRight: "5em", children: _jsx(SystemOverview, { overview: overview }) }) })] })] }));
439
+ });
@@ -0,0 +1,10 @@
1
+ import { ReactNode } from "react";
2
+ import { IInProcessMaterial } from "../../network/api.js";
3
+ export interface SortableRegionProps {
4
+ readonly matIds: ReadonlyArray<number>;
5
+ readonly direction: "vertical" | "rect";
6
+ readonly queueName: string;
7
+ readonly renderDragOverlay: (mat: Readonly<IInProcessMaterial>) => ReactNode;
8
+ readonly children?: ReactNode;
9
+ }
10
+ export declare const SortableRegion: import("react").NamedExoticComponent<SortableRegionProps>;
@@ -0,0 +1,67 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /* Copyright (c) 2022, John Lenz
3
+
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ * Redistributions of source code must retain the above copyright
10
+ notice, this list of conditions and the following disclaimer.
11
+
12
+ * Redistributions in binary form must reproduce the above
13
+ copyright notice, this list of conditions and the following
14
+ disclaimer in the documentation and/or other materials provided
15
+ with the distribution.
16
+
17
+ * Neither the name of John Lenz, Black Maple Software, SeedTactics,
18
+ nor the names of other contributors may be used to endorse or
19
+ promote products derived from this software without specific
20
+ prior written permission.
21
+
22
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
+ */
34
+ import { memo, useState } from "react";
35
+ import { closestCenter, DndContext, DragOverlay, KeyboardSensor, PointerSensor, useSensor, useSensors, } from "@dnd-kit/core";
36
+ import { rectSortingStrategy, SortableContext, sortableKeyboardCoordinates, verticalListSortingStrategy, } from "@dnd-kit/sortable";
37
+ import { useAddExistingMaterialToQueue } from "../../cell-status/material-details.js";
38
+ import { reorderQueuedMatInCurrentStatus } from "../../cell-status/current-status.js";
39
+ import { currentOperator } from "../../data/operators.js";
40
+ import { useAtomValue, useSetAtom } from "jotai";
41
+ export const SortableRegion = memo(function SortableRegion(props) {
42
+ const [activeMat, setActiveMat] = useState(undefined);
43
+ const [addExistingMatToQueue] = useAddExistingMaterialToQueue();
44
+ const reorderQueuedMat = useSetAtom(reorderQueuedMatInCurrentStatus);
45
+ const operator = useAtomValue(currentOperator);
46
+ const sensors = useSensors(useSensor(PointerSensor), useSensor(KeyboardSensor, {
47
+ coordinateGetter: sortableKeyboardCoordinates,
48
+ }));
49
+ return (_jsx(DndContext, { sensors: sensors, collisionDetection: closestCenter, onDragStart: ({ active }) => setActiveMat(active.data.current.mat), onDragCancel: () => setActiveMat(undefined), onDragEnd: ({ active, over }) => {
50
+ if (over && active.id !== over.id) {
51
+ const activeMatId = active.id;
52
+ const overIdx = props.matIds.indexOf(over.id);
53
+ addExistingMatToQueue({
54
+ materialId: active.id,
55
+ queue: props.queueName,
56
+ queuePosition: overIdx,
57
+ operator: operator,
58
+ });
59
+ reorderQueuedMat({
60
+ queue: props.queueName,
61
+ matId: activeMatId,
62
+ newIdx: overIdx,
63
+ });
64
+ }
65
+ setActiveMat(undefined);
66
+ }, children: _jsxs(SortableContext, { items: props.matIds, strategy: props.direction === "vertical" ? verticalListSortingStrategy : rectSortingStrategy, children: [props.children, _jsx(DragOverlay, { children: activeMat !== undefined ? props.renderDragOverlay(activeMat) : undefined })] }) }));
67
+ });
@@ -0,0 +1,45 @@
1
+ import * as api from "../network/api.js";
2
+ export type MaterialList = ReadonlyArray<Readonly<api.IInProcessMaterial>>;
3
+ export type MaterialBinId = string;
4
+ export declare const LoadStationBinId: MaterialBinId;
5
+ export declare const PalletsBinId: MaterialBinId;
6
+ export declare const ActiveQueuesBinId: MaterialBinId;
7
+ export interface MaterialBinState {
8
+ readonly curBinOrder: ReadonlyArray<MaterialBinId>;
9
+ }
10
+ export declare const currentMaterialBinOrder: import("jotai").WritableAtom<readonly string[], [readonly string[] | typeof import("jotai/utils").RESET | ((prev: readonly string[]) => readonly string[] | typeof import("jotai/utils").RESET)], void>;
11
+ export declare function moveMaterialBin(curBinOrder: ReadonlyArray<MaterialBinId>, oldIdx: number, newIdx: number): ReadonlyArray<MaterialBinId>;
12
+ export declare enum MaterialBinType {
13
+ LoadStations = "Bin_LoadStations",
14
+ Pallets = "Bin_Pallets",
15
+ ActiveQueues = "Bin_ActiveQueues",
16
+ QuarantineQueues = "Bin_Quarantine"
17
+ }
18
+ export type MaterialBin = {
19
+ readonly type: MaterialBinType.LoadStations;
20
+ readonly binId: MaterialBinId;
21
+ readonly byLul: ReadonlyMap<number, MaterialList>;
22
+ } | {
23
+ readonly type: MaterialBinType.Pallets;
24
+ readonly binId: MaterialBinId;
25
+ readonly byPallet: ReadonlyMap<string, MaterialList>;
26
+ } | {
27
+ readonly type: MaterialBinType.ActiveQueues;
28
+ readonly binId: MaterialBinId;
29
+ readonly byQueue: ReadonlyMap<string, MaterialList>;
30
+ } | {
31
+ readonly type: MaterialBinType.QuarantineQueues;
32
+ readonly binId: MaterialBinId;
33
+ readonly queueName: string;
34
+ readonly material: MaterialList;
35
+ };
36
+ export declare function selectAllMaterialIntoBins(curSt: Readonly<api.ICurrentStatus>, curBinOrder: ReadonlyArray<MaterialBinId>): ReadonlyArray<MaterialBin>;
37
+ export declare function moveMaterialInBin(bins: ReadonlyArray<MaterialBin>, mat: Readonly<api.IInProcessMaterial>, queue: string, queuePosition: number): ReadonlyArray<MaterialBin>;
38
+ export interface QuarantineBinAndIndex {
39
+ readonly bin: Extract<MaterialBin, {
40
+ type: MaterialBinType.QuarantineQueues;
41
+ }>;
42
+ readonly idx: number;
43
+ }
44
+ export declare function findMaterialInQuarantineQueues(matId: number, bins: ReadonlyArray<MaterialBin>): QuarantineBinAndIndex | null;
45
+ export declare function findQueueInQuarantineQueues(queue: string, bins: ReadonlyArray<MaterialBin>): QuarantineBinAndIndex | null;