@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,213 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /* Copyright (c) 2023, 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 { Box, IconButton, Stack, Table, TableCell, TableFooter, TableRow, Tooltip, Typography, } from "@mui/material";
35
+ import { addDays, startOfToday } from "date-fns";
36
+ import { useMemo, memo, useState } from "react";
37
+ import { copyTableToClipboard, DataTableBody, DataTableHead, useColSort, } from "../analysis/DataTable.js";
38
+ import { ShiftStart, useShifts } from "./ShiftSettings.js";
39
+ import { SkipPrevious as SkipPrevIcon, SkipNext as SkipNextIcon, ImportExport } from "@mui/icons-material";
40
+ import { LazySeq, OrderedMap } from "@seedtactics/immutable-collections";
41
+ import { last30SimProduction } from "../../cell-status/sim-production.js";
42
+ import { last30StationCycles } from "../../cell-status/station-cycles.js";
43
+ import { PartIdenticon } from "../station-monitor/Material.js";
44
+ import { useSetTitle } from "../routes.js";
45
+ import { useAtomValue } from "jotai";
46
+ var ColumnId;
47
+ (function (ColumnId) {
48
+ ColumnId[ColumnId["Part"] = 0] = "Part";
49
+ ColumnId[ColumnId["PlannedShift0"] = 1] = "PlannedShift0";
50
+ ColumnId[ColumnId["PlannedShift1"] = 2] = "PlannedShift1";
51
+ ColumnId[ColumnId["PlannedShift2"] = 3] = "PlannedShift2";
52
+ ColumnId[ColumnId["CompletedShift0"] = 4] = "CompletedShift0";
53
+ ColumnId[ColumnId["CompletedShift1"] = 5] = "CompletedShift1";
54
+ ColumnId[ColumnId["CompletedShift2"] = 6] = "CompletedShift2";
55
+ })(ColumnId || (ColumnId = {}));
56
+ function decideShift(f, shifts) {
57
+ return (t) => {
58
+ const time = f(t);
59
+ for (let i = 0; i < shifts.length; i++) {
60
+ const s = shifts[i];
61
+ if (time >= s.start && time < s.end) {
62
+ return { val: t, shift: i };
63
+ }
64
+ }
65
+ return null;
66
+ };
67
+ }
68
+ function binSimProduction(prod, shifts) {
69
+ return LazySeq.of(prod)
70
+ .filter((p) => p.finalProcess)
71
+ .collect(decideShift((p) => p.completeTime, shifts))
72
+ .toLookupOrderedMap((p) => p.val.partName, (p) => p.shift, (p) => p.val.quantity, (a, b) => a + b);
73
+ }
74
+ function binCompleted(cycles, shifts) {
75
+ return cycles
76
+ .valuesToLazySeq()
77
+ .filter((cycle) => cycle.isLabor &&
78
+ cycle.operation === "UNLOAD" &&
79
+ LazySeq.of(cycle.material).some((m) => m.proc === m.numproc))
80
+ .collect(decideShift((c) => c.endTime, shifts))
81
+ .toLookupOrderedMap((p) => p.val.part, (p) => p.shift, (p) => LazySeq.of(p.val.material).sumBy((m) => (m.proc === m.numproc ? 1 : 0)), (a, b) => a + b);
82
+ }
83
+ function useRows(day) {
84
+ const cycles = useAtomValue(last30StationCycles);
85
+ const sim = useAtomValue(last30SimProduction);
86
+ const shifts = useShifts(day);
87
+ return useMemo(() => {
88
+ const planned = binSimProduction(sim, shifts);
89
+ const completed = binCompleted(cycles, shifts);
90
+ return planned
91
+ .mapValues((p) => ({
92
+ planned: p,
93
+ }))
94
+ .adjust(completed, (plan, comp) => ({ ...(plan ?? {}), completed: comp }))
95
+ .toAscLazySeq()
96
+ .map(([partName, { planned, completed }]) => ({
97
+ part: partName,
98
+ planned: planned ?? OrderedMap.empty(),
99
+ completed: completed ?? OrderedMap.empty(),
100
+ }))
101
+ .toRArray();
102
+ }, [cycles, sim, shifts]);
103
+ }
104
+ const fulldayFormat = new Intl.DateTimeFormat(undefined, {
105
+ weekday: "long",
106
+ month: "long",
107
+ day: "numeric",
108
+ year: "numeric",
109
+ });
110
+ function PartCell({ row }) {
111
+ return (_jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [_jsx(PartIdenticon, { part: row.part, size: 25 }), _jsx("span", { children: row.part })] }));
112
+ }
113
+ function useColumns(day) {
114
+ const numShifts = useShifts(day).length;
115
+ return useMemo(() => {
116
+ const cols = [
117
+ {
118
+ id: ColumnId.Part,
119
+ numeric: false,
120
+ label: "Part",
121
+ getDisplay: (c) => c.part,
122
+ getForTotal: () => 0,
123
+ Cell: PartCell,
124
+ },
125
+ {
126
+ id: ColumnId.PlannedShift0,
127
+ numeric: true,
128
+ label: `Shift 1 Planned`,
129
+ getDisplay: (c) => c.planned.get(0)?.toString() ?? "",
130
+ getForSort: (c) => c.planned.get(0) ?? 0,
131
+ getForTotal: (c) => c.planned.get(0) ?? 0,
132
+ },
133
+ {
134
+ id: ColumnId.CompletedShift0,
135
+ numeric: true,
136
+ label: `Shift 1 Completed`,
137
+ getDisplay: (c) => c.completed.get(0)?.toString() ?? "",
138
+ getForSort: (c) => c.completed.get(0) ?? 0,
139
+ getForTotal: (c) => c.completed.get(0) ?? 0,
140
+ },
141
+ ];
142
+ if (numShifts >= 2) {
143
+ cols.push({
144
+ id: ColumnId.PlannedShift1,
145
+ numeric: true,
146
+ label: `Shift 2 Planned`,
147
+ getDisplay: (c) => c.planned.get(1)?.toString() ?? "",
148
+ getForSort: (c) => c.planned.get(1) ?? 0,
149
+ getForTotal: (c) => c.planned.get(1) ?? 0,
150
+ });
151
+ cols.push({
152
+ id: ColumnId.CompletedShift1,
153
+ numeric: true,
154
+ label: `Shift 2 Completed`,
155
+ getDisplay: (c) => c.completed.get(1)?.toString() ?? "",
156
+ getForSort: (c) => c.completed.get(1) ?? 0,
157
+ getForTotal: (c) => c.completed.get(1) ?? 0,
158
+ });
159
+ }
160
+ if (numShifts === 3) {
161
+ cols.push({
162
+ id: ColumnId.PlannedShift2,
163
+ numeric: true,
164
+ label: `Shift 3 Planned`,
165
+ getDisplay: (c) => c.planned.get(2)?.toString() ?? "",
166
+ getForSort: (c) => c.planned.get(2) ?? 0,
167
+ getForTotal: (c) => c.planned.get(2) ?? 0,
168
+ });
169
+ cols.push({
170
+ id: ColumnId.CompletedShift2,
171
+ numeric: true,
172
+ label: `Shift 3 Completed`,
173
+ getDisplay: (c) => c.completed.get(2)?.toString() ?? "",
174
+ getForSort: (c) => c.completed.get(2) ?? 0,
175
+ getForTotal: (c) => c.completed.get(2) ?? 0,
176
+ });
177
+ }
178
+ return cols;
179
+ }, [numShifts]);
180
+ }
181
+ function FooterRow({ columns, rows, }) {
182
+ return (_jsx(TableRow, { children: columns.map((col) => (_jsx(TableCell, { align: col.numeric ? "right" : "left", children: col.id === ColumnId.Part ? "Total" : LazySeq.of(rows).sumBy(col.getForTotal) }, col.id))) }));
183
+ }
184
+ const RecentProductionTable = memo(function RecentSchedules({ columns, rows, }) {
185
+ const sort = useColSort(ColumnId.Part, columns);
186
+ return (_jsx(Box, { sx: { overflowX: "auto" }, children: _jsxs(Table, { stickyHeader: true, children: [_jsx(DataTableHead, { columns: columns, sort: sort, showDetailsCol: false }), _jsx(DataTableBody, { columns: columns, pageData: LazySeq.of(rows).toSortedArray(sort.sortOn, (x) => x.part) }), _jsx(TableFooter, { children: _jsx(FooterRow, { columns: columns, rows: rows }) })] }) }));
187
+ });
188
+ function NavigateDay({ day, setDay, }) {
189
+ const today = startOfToday();
190
+ return (_jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [_jsx(Tooltip, { title: "Previous Day", children: _jsx("div", { children: _jsx(IconButton, { disabled: day <= addDays(today, -28), onClick: () => setDay((d) => addDays(d, -1)), children: _jsx(SkipPrevIcon, {}) }) }) }), _jsx(Typography, { sx: { minWidth: "14em", textAlign: "center" }, children: fulldayFormat.format(day) }), _jsx(Tooltip, { title: "Next Day", children: _jsx("div", { children: _jsx(IconButton, { disabled: day >= today, onClick: () => setDay((d) => addDays(d, 1)), children: _jsx(SkipNextIcon, {}) }) }) })] }));
191
+ }
192
+ const mdGridTemplate = '"shifts day export" auto / 1fr 1fr 1fr';
193
+ const xsGridTemplate = `"shifts export" auto
194
+ "day day" auto / 1fr auto`;
195
+ const RecentProductionToolbar = function RecentProductionToolbar({ day, setDay, columns, rows, }) {
196
+ return (_jsxs(Box, { component: "nav", sx: {
197
+ display: "grid",
198
+ gridTemplate: {
199
+ md: mdGridTemplate,
200
+ xs: xsGridTemplate,
201
+ },
202
+ minHeight: "2.5em",
203
+ alignItems: "center",
204
+ maxWidth: "calc(100vw - 24px - 24px)",
205
+ }, children: [_jsx(Box, { gridArea: "shifts", justifySelf: "flex-start", children: _jsx(ShiftStart, {}) }), _jsx(Box, { gridArea: "day", justifySelf: "center", children: _jsx(NavigateDay, { day: day, setDay: setDay }) }), _jsx(Box, { gridArea: "export", justifySelf: "flex-end", children: _jsx(Tooltip, { title: "Copy to Clipboard", children: _jsx(IconButton, { onClick: () => copyTableToClipboard(columns, rows), children: _jsx(ImportExport, {}) }) }) })] }));
206
+ };
207
+ export function RecentProductionPage() {
208
+ useSetTitle("Recent Completed Parts");
209
+ const [day, setDay] = useState(startOfToday);
210
+ const columns = useColumns(day);
211
+ const rows = useRows(day);
212
+ return (_jsxs(Box, { paddingLeft: "24px", paddingRight: "24px", paddingTop: "10px", children: [_jsx(RecentProductionToolbar, { day: day, setDay: setDay, rows: rows, columns: columns }), _jsx("main", { children: _jsx(RecentProductionTable, { rows: rows, columns: columns }) })] }));
213
+ }
@@ -0,0 +1,12 @@
1
+ import { ReactNode } from "react";
2
+ import { StyledComponent } from "@emotion/styled";
3
+ export declare const JobTableRow: StyledComponent<{
4
+ $darkRow?: boolean;
5
+ children?: ReactNode;
6
+ }>;
7
+ export declare const JobDetailRow: StyledComponent<{
8
+ $darkRow?: boolean;
9
+ children?: ReactNode;
10
+ }>;
11
+ export declare const RecentSchedulesCard: import("react").NamedExoticComponent<object>;
12
+ export declare function RecentSchedulesPage(): ReactNode;
@@ -0,0 +1,180 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } 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 { useState, memo, useMemo } from "react";
35
+ import { Box, styled, TableSortLabel } from "@mui/material";
36
+ import { IconButton } from "@mui/material";
37
+ import { Tooltip } from "@mui/material";
38
+ import { Typography } from "@mui/material";
39
+ import { Table } from "@mui/material";
40
+ import { TableRow } from "@mui/material";
41
+ import { TableCell } from "@mui/material";
42
+ import { TableHead } from "@mui/material";
43
+ import { TableBody } from "@mui/material";
44
+ import { addDays, startOfToday } from "date-fns";
45
+ import { buildScheduledJobs, copyScheduledJobsToClipboard, } from "../../data/results.schedules.js";
46
+ import { PartIdenticon } from "../station-monitor/Material.js";
47
+ import { EditNoteDialog } from "../station-monitor/Queues.js";
48
+ import { KeyboardArrowDown as KeyboardArrowDownIcon, KeyboardArrowUp as KeyboardArrowUpIcon, Edit as EditIcon, ImportExport, Visibility, VisibilityOff, } from "@mui/icons-material";
49
+ import { JobDetails } from "../station-monitor/JobDetails.js";
50
+ import { Collapse } from "@mui/material";
51
+ import { currentStatus } from "../../cell-status/current-status.js";
52
+ import { last30Jobs } from "../../cell-status/scheduled-jobs.js";
53
+ import { last30MaterialSummary } from "../../cell-status/material-summary.js";
54
+ import { LazySeq } from "@seedtactics/immutable-collections";
55
+ import { useSetTitle } from "../routes.js";
56
+ import { useAtomValue } from "jotai";
57
+ export const JobTableRow = styled(TableRow, {
58
+ shouldForwardProp: (prop) => prop.toString()[0] !== "$",
59
+ })((props) => ({
60
+ "& > *": {
61
+ borderBottom: "unset",
62
+ },
63
+ ...(props.$darkRow && { backgroundColor: "#F5F5F5" }),
64
+ }));
65
+ export const JobDetailRow = styled(TableRow, {
66
+ shouldForwardProp: (prop) => prop.toString()[0] !== "$",
67
+ })((props) => ({
68
+ ...(props.$darkRow && { backgroundColor: "#F5F5F5" }),
69
+ }));
70
+ function JobsRow(props) {
71
+ const [open, setOpen] = useState(false);
72
+ let colCnt = 10;
73
+ if (props.showMaterial)
74
+ colCnt += 1;
75
+ const job = props.job;
76
+ return (_jsxs(_Fragment, { children: [_jsxs(JobTableRow, { "$darkRow": props.showDarkRow && job.darkRow, children: [_jsx(TableCell, { children: job.routeStartTime.toLocaleString() }), _jsx(TableCell, { children: _jsxs(Box, { sx: {
77
+ display: "flex",
78
+ alignItems: "center",
79
+ }, children: [_jsx(Box, { sx: { mr: "0.2em" }, children: _jsx(PartIdenticon, { part: job.partName, size: 25 }) }), _jsx("div", { children: _jsx(Typography, { variant: "body2", component: "span", display: "block", children: job.partName }) })] }) }), props.showMaterial ? (_jsx(TableCell, { children: job.casting ? (_jsxs(Box, { sx: {
80
+ display: "flex",
81
+ alignItems: "center",
82
+ }, children: [_jsx(Box, { sx: { mr: "0.2em" }, children: _jsx(PartIdenticon, { part: job.casting, size: 25 }) }), _jsx(Typography, { variant: "body2", display: "block", children: job.casting })] })) : undefined })) : undefined, _jsxs(TableCell, { children: [job.comment, _jsx(Tooltip, { title: "Edit", children: _jsx(IconButton, { size: "small", onClick: () => props.setCurEditNoteJob(job), children: _jsx(EditIcon, {}) }) })] }), _jsx(TableCell, { children: job.inProcJob === null ? "Archived" : "Active" }), _jsx(TableCell, { align: "right", children: job.scheduledQty }), _jsx(TableCell, { align: "right", sx: { backgroundColor: job.decrementedQty > 0 ? "#FF8A65" : undefined }, children: job.decrementedQty }), _jsx(TableCell, { align: "right", children: job.completedQty }), _jsx(TableCell, { align: "right", children: job.inProcessQty }), _jsx(TableCell, { align: "right", children: job.remainingQty }), _jsx(TableCell, { children: _jsx(Tooltip, { title: "Show Details", children: _jsx(IconButton, { size: "small", onClick: () => setOpen(!open), children: open ? _jsx(KeyboardArrowUpIcon, {}) : _jsx(KeyboardArrowDownIcon, {}) }) }) })] }), _jsx(JobDetailRow, { "$darkRow": props.showDarkRow && job.darkRow, children: _jsx(TableCell, { sx: { pb: "0", pt: "0" }, colSpan: colCnt, children: _jsx(Collapse, { in: open, timeout: "auto", unmountOnExit: true, children: _jsx(JobDetails, { job: job.inProcJob ? job.inProcJob : job.historicJob, checkAnalysisMonth: false }) }) }) })] }));
83
+ }
84
+ var SortColumn;
85
+ (function (SortColumn) {
86
+ SortColumn[SortColumn["Date"] = 0] = "Date";
87
+ SortColumn[SortColumn["Part"] = 1] = "Part";
88
+ SortColumn[SortColumn["Material"] = 2] = "Material";
89
+ SortColumn[SortColumn["Note"] = 3] = "Note";
90
+ SortColumn[SortColumn["Scheduled"] = 4] = "Scheduled";
91
+ SortColumn[SortColumn["Removed"] = 5] = "Removed";
92
+ SortColumn[SortColumn["Completed"] = 6] = "Completed";
93
+ SortColumn[SortColumn["InProc"] = 7] = "InProc";
94
+ SortColumn[SortColumn["RemainingToRun"] = 8] = "RemainingToRun";
95
+ })(SortColumn || (SortColumn = {}));
96
+ function sortJobs(jobs, sortBy, order, showArchived) {
97
+ let sortCol;
98
+ switch (sortBy) {
99
+ case SortColumn.Date:
100
+ sortCol = (j) => j.routeStartTime.getTime();
101
+ break;
102
+ case SortColumn.Part:
103
+ sortCol = (j) => j.partName;
104
+ break;
105
+ case SortColumn.Material:
106
+ sortCol = (j) => j.casting;
107
+ break;
108
+ case SortColumn.Note:
109
+ sortCol = (j) => j.comment ?? null;
110
+ break;
111
+ case SortColumn.Scheduled:
112
+ sortCol = (j) => j.scheduledQty;
113
+ break;
114
+ case SortColumn.Removed:
115
+ sortCol = (j) => j.decrementedQty;
116
+ break;
117
+ case SortColumn.Completed:
118
+ sortCol = (j) => j.completedQty;
119
+ break;
120
+ case SortColumn.InProc:
121
+ sortCol = (j) => j.inProcessQty;
122
+ break;
123
+ case SortColumn.RemainingToRun:
124
+ sortCol = (j) => j.remainingQty;
125
+ break;
126
+ }
127
+ const toShow = showArchived ? LazySeq.of(jobs) : LazySeq.of(jobs).filter((j) => j.inProcJob !== null);
128
+ return toShow.toSortedArray(order === "asc" ? { asc: sortCol } : { desc: sortCol });
129
+ }
130
+ function SortColHeader(props) {
131
+ return (_jsx(Tooltip, { title: "Sort", enterDelay: 300, children: _jsx(TableCell, { align: props.align, sortDirection: props.sortBy === props.col ? props.order : false, children: _jsx(TableSortLabel, { active: props.sortBy === props.col, direction: props.order, onClick: () => {
132
+ if (props.col === props.sortBy) {
133
+ props.setOrder(props.order === "asc" ? "desc" : "asc");
134
+ }
135
+ else {
136
+ props.setSortBy(props.col);
137
+ props.setOrder("asc");
138
+ }
139
+ }, children: props.children }) }) }));
140
+ }
141
+ const JobsHeader = memo(function JobsHeader(props) {
142
+ const sort = {
143
+ sortBy: props.sortBy,
144
+ setSortBy: props.setSortBy,
145
+ order: props.order,
146
+ setOrder: props.setOrder,
147
+ };
148
+ return (_jsx(TableHead, { children: _jsxs(TableRow, { children: [_jsx(SortColHeader, { align: "left", col: SortColumn.Date, ...sort, children: "Date" }), _jsx(SortColHeader, { align: "left", col: SortColumn.Part, ...sort, children: "Part" }), props.showMaterial ? (_jsx(SortColHeader, { align: "left", col: SortColumn.Material, ...sort, children: "Material" })) : undefined, _jsx(SortColHeader, { align: "left", col: SortColumn.Note, ...sort, children: "Note" }), _jsxs(TableCell, { align: "left", children: ["Active", _jsx(Tooltip, { title: props.showArchived ? "Hide Archived" : "Show Archived", children: _jsx(IconButton, { size: "small", onClick: (e) => {
149
+ props.setShowArchived((a) => !a);
150
+ e.stopPropagation();
151
+ }, children: props.showArchived ? _jsx(Visibility, {}) : _jsx(VisibilityOff, {}) }) })] }), _jsx(SortColHeader, { align: "right", col: SortColumn.Scheduled, ...sort, children: "Scheduled" }), _jsx(SortColHeader, { align: "right", col: SortColumn.Removed, ...sort, children: "Removed" }), _jsx(SortColHeader, { align: "right", col: SortColumn.Completed, ...sort, children: "Completed" }), _jsx(SortColHeader, { align: "right", col: SortColumn.InProc, ...sort, children: "In Process" }), _jsx(SortColHeader, { align: "right", col: SortColumn.RemainingToRun, ...sort, children: "Remaining To Run" }), _jsx(TableCell, { children: _jsx(Tooltip, { title: "Copy to Clipboard", children: _jsx(IconButton, { style: { height: "25px", paddingTop: 0, paddingBottom: 0 }, onClick: () => copyScheduledJobsToClipboard(props.jobs, props.showMaterial), size: "large", children: _jsx(ImportExport, {}) }) }) })] }) }));
152
+ });
153
+ export const RecentSchedulesCard = memo(function RecentSchedules() {
154
+ const [curEditNoteJob, setCurEditNoteJob] = useState(null);
155
+ const [sortBy, setSortBy] = useState(SortColumn.Date);
156
+ const [order, setOrder] = useState("desc");
157
+ const [showArchived, setShowArchived] = useState(true);
158
+ const matIds = useAtomValue(last30MaterialSummary);
159
+ const schJobs = useAtomValue(last30Jobs);
160
+ const currentSt = useAtomValue(currentStatus);
161
+ const showMaterial = useMemo(() => {
162
+ for (const [, newJob] of schJobs) {
163
+ for (const p of newJob.procsAndPaths[0]?.paths ?? []) {
164
+ if (p.casting !== null && p.casting !== undefined && p.casting !== "") {
165
+ return true;
166
+ }
167
+ }
168
+ }
169
+ return false;
170
+ }, [schJobs]);
171
+ const jobs = useMemo(() => {
172
+ return buildScheduledJobs({ start: addDays(startOfToday(), -6), end: addDays(startOfToday(), 1) }, matIds.matsById, schJobs, currentSt);
173
+ }, [matIds.matsById, schJobs, currentSt]);
174
+ const sorted = useMemo(() => sortJobs(jobs, sortBy, order, showArchived), [jobs, sortBy, order, showArchived]);
175
+ return (_jsxs(_Fragment, { children: [_jsxs(Table, { stickyHeader: true, children: [_jsx(JobsHeader, { jobs: jobs, showMaterial: showMaterial, sortBy: sortBy, setSortBy: setSortBy, order: order, setOrder: setOrder, showArchived: showArchived, setShowArchived: setShowArchived }), _jsx(TableBody, { children: sorted.map((job, jobIdx) => (_jsx(JobsRow, { job: job, showDarkRow: sortBy === SortColumn.Date, showMaterial: showMaterial, setCurEditNoteJob: setCurEditNoteJob }, job.inProcJob?.unique ?? job.historicJob?.unique ?? jobIdx))) })] }), _jsx(EditNoteDialog, { job: curEditNoteJob?.historicJob ?? null, closeDialog: () => setCurEditNoteJob(null) })] }));
176
+ });
177
+ export function RecentSchedulesPage() {
178
+ useSetTitle("Scheduled Jobs");
179
+ return (_jsx("main", { style: { padding: "24px" }, children: _jsx(RecentSchedulesCard, {}) }));
180
+ }
@@ -0,0 +1,4 @@
1
+ export type CycleType = "labor" | "machine";
2
+ export declare function RecentStationCycleChart({ ty }: {
3
+ ty: CycleType;
4
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,159 @@
1
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
+ /* Copyright (c) 2023, 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 { useCallback, useMemo } from "react";
35
+ import { Box, FormControl, Typography } from "@mui/material";
36
+ import { addDays, startOfToday } from "date-fns";
37
+ import { Tooltip } from "@mui/material";
38
+ import { IconButton } from "@mui/material";
39
+ import { Select } from "@mui/material";
40
+ import { MenuItem } from "@mui/material";
41
+ import { ImportExport } from "@mui/icons-material";
42
+ import StationDataTable from "../analysis/StationDataTable.js";
43
+ import { PartIdenticon } from "../station-monitor/Material.js";
44
+ import { filterStationCycles, FilterAnyMachineKey, copyCyclesToClipboard, plannedOperationMinutes, loadOccupancyCycles, FilterAnyLoadKey, } from "../../data/results.cycles.js";
45
+ import * as matDetails from "../../cell-status/material-details.js";
46
+ import { CycleChart } from "../analysis/CycleChart.js";
47
+ import { last30MaterialSummary } from "../../cell-status/material-summary.js";
48
+ import { last30EstimatedCycleTimes, } from "../../cell-status/estimated-cycle-times.js";
49
+ import { last30StationCycles } from "../../cell-status/station-cycles.js";
50
+ import { LazySeq } from "@seedtactics/immutable-collections";
51
+ import { useSetTitle } from "../routes.js";
52
+ import { atom, useAtom, useAtomValue, useSetAtom } from "jotai";
53
+ const lulShowGraphAtom = atom(true);
54
+ const machineShowGraphAtom = atom(true);
55
+ const lulSelectedPartAtom = atom(undefined);
56
+ const machineSelectedPartAtom = atom(undefined);
57
+ const machineSelectedOperation = atom(undefined);
58
+ const lulSelectedPalletAtom = atom(undefined);
59
+ const machineSelectedPalletAtom = atom(undefined);
60
+ const lulChartZoomAtom = atom({});
61
+ const machineChartZoomAtom = atom({});
62
+ const lulYZoomAtom = atom(null);
63
+ const machineYZoomAtom = atom(null);
64
+ export function RecentStationCycleChart({ ty }) {
65
+ useSetTitle(ty === "labor" ? "L/U Cycles" : "Machine Cycles");
66
+ const setMatToShow = useSetAtom(matDetails.materialDialogOpen);
67
+ const extraStationCycleTooltip = useCallback(function extraStationCycleTooltip(point) {
68
+ const partC = point;
69
+ const ret = [];
70
+ if (partC.operations) {
71
+ for (const mat of partC.operations) {
72
+ ret.push({
73
+ title: (mat.mat.serial ? mat.mat.serial : "Material") + " " + mat.operation,
74
+ value: "Open Card",
75
+ link: () => setMatToShow({ type: "LogMat", logMat: mat.mat }),
76
+ });
77
+ }
78
+ }
79
+ else {
80
+ for (const mat of partC.material) {
81
+ ret.push({
82
+ title: mat.serial ? mat.serial : "Material",
83
+ value: "Open Card",
84
+ link: () => setMatToShow({ type: "LogMat", logMat: mat }),
85
+ });
86
+ }
87
+ }
88
+ return ret;
89
+ }, [setMatToShow]);
90
+ const [showGraph, setShowGraph] = useAtom(ty === "labor" ? lulShowGraphAtom : machineShowGraphAtom);
91
+ const [chartZoom, setChartZoom] = useAtom(ty === "labor" ? lulChartZoomAtom : machineChartZoomAtom);
92
+ const [selectedPart, setSelectedPart] = useAtom(ty === "labor" ? lulSelectedPartAtom : machineSelectedPartAtom);
93
+ const [selectedOperation, setSelectedOperation] = useAtom(machineSelectedOperation);
94
+ const [selectedPallet, setSelectedPallet] = useAtom(ty === "labor" ? lulSelectedPalletAtom : machineSelectedPalletAtom);
95
+ const [yZoom, setYZoom] = useAtom(ty === "labor" ? lulYZoomAtom : machineYZoomAtom);
96
+ const estimatedCycleTimes = useAtomValue(last30EstimatedCycleTimes);
97
+ const default_date_range = [addDays(startOfToday(), -4), addDays(startOfToday(), 1)];
98
+ const cycles = useAtomValue(last30StationCycles);
99
+ const matSummary = useAtomValue(last30MaterialSummary);
100
+ const points = useMemo(() => {
101
+ const today = startOfToday();
102
+ if (selectedOperation) {
103
+ return filterStationCycles(cycles.valuesToLazySeq(), {
104
+ zoom: { start: addDays(today, -4), end: addDays(today, 1) },
105
+ partAndProc: selectedPart,
106
+ pallet: selectedPallet,
107
+ operation: selectedOperation,
108
+ });
109
+ }
110
+ else if (ty === "labor" && showGraph) {
111
+ return loadOccupancyCycles(cycles.valuesToLazySeq(), {
112
+ zoom: { start: addDays(today, -4), end: addDays(today, 1) },
113
+ partAndProc: selectedPart,
114
+ pallet: selectedPallet,
115
+ });
116
+ }
117
+ else {
118
+ return filterStationCycles(cycles.valuesToLazySeq(), {
119
+ zoom: { start: addDays(today, -4), end: addDays(today, 1) },
120
+ partAndProc: selectedPart,
121
+ pallet: selectedPallet,
122
+ station: ty === "labor" ? FilterAnyLoadKey : FilterAnyMachineKey,
123
+ });
124
+ }
125
+ }, [cycles, ty, selectedPart, selectedPallet, selectedOperation, showGraph]);
126
+ // If we have selected a part and there is only one operation, default to it.
127
+ const curOperation = selectedPart
128
+ ? (selectedOperation ??
129
+ (points.allMachineOperations.length === 1 ? points.allMachineOperations[0] : undefined))
130
+ : undefined;
131
+ const plannedMinutes = useMemo(() => {
132
+ if (curOperation && ty === "machine") {
133
+ return plannedOperationMinutes(points, false);
134
+ }
135
+ else {
136
+ return undefined;
137
+ }
138
+ }, [points, ty, curOperation]);
139
+ return (_jsxs(Box, { paddingLeft: "24px", paddingRight: "24px", paddingTop: "10px", children: [_jsxs(Box, { component: "nav", sx: {
140
+ display: "flex",
141
+ minHeight: "2.5em",
142
+ alignItems: "center",
143
+ maxWidth: "calc(100vw - 24px - 24px)",
144
+ }, children: [_jsxs(Typography, { variant: "subtitle1", children: ["Recent ", ty === "labor" ? "Load/Unload Occupancy" : "Machine Cycles"] }), _jsx(Box, { flexGrow: 1 }), _jsx(FormControl, { size: "small", children: _jsxs(Select, { name: "Station-Cycles-chart-or-table-select", autoWidth: true, value: showGraph ? "graph" : "table", onChange: (e) => setShowGraph(e.target.value === "graph"), children: [_jsx(MenuItem, { value: "graph", children: "Graph" }, "graph"), _jsx(MenuItem, { value: "table", children: "Table" }, "table")] }) }), _jsx(FormControl, { size: "small", children: _jsxs(Select, { autoWidth: true, displayEmpty: true, value: selectedPart
145
+ ? points.allPartAndProcNames.findIndex((o) => selectedPart.part === o.part && selectedPart.proc === o.proc)
146
+ : -1, style: { marginLeft: "1em" }, onChange: (e) => {
147
+ setSelectedPart(e.target.value === -1 ? undefined : points.allPartAndProcNames[e.target.value]);
148
+ setSelectedOperation(undefined);
149
+ }, children: [_jsx(MenuItem, { value: -1, children: _jsx("em", { children: "Any Part" }) }, 0), points.allPartAndProcNames.map((n, idx) => (_jsx(MenuItem, { value: idx, children: _jsxs("div", { style: { display: "flex", alignItems: "center" }, children: [_jsx(PartIdenticon, { part: n.part, size: 20 }), _jsxs("span", { style: { marginRight: "1em" }, children: [n.part, "-", n.proc] })] }) }, idx)))] }) }), ty === "machine" ? (_jsx(FormControl, { size: "small", children: _jsx(Select, { name: "Station-Cycles-cycle-chart-station-select", autoWidth: true, displayEmpty: true, value: curOperation
150
+ ? points.allMachineOperations.findIndex((o) => curOperation.compare(o) === 0)
151
+ : -1, style: { marginLeft: "1em" }, onChange: (e) => setSelectedOperation(points.allMachineOperations[e.target.value]), children: [
152
+ ...(points.allMachineOperations.length !== 1
153
+ ? [
154
+ _jsx(MenuItem, { value: -1, children: _jsx("em", { children: "Any Operation" }) }, -1),
155
+ ]
156
+ : []),
157
+ ...points.allMachineOperations.map((oper, idx) => (_jsxs(MenuItem, { value: idx, children: [oper.statGroup, " ", oper.operation] }, idx))),
158
+ ] }) })) : undefined, _jsx(FormControl, { size: "small", children: _jsxs(Select, { name: "Station-Cycles-cycle-chart-station-pallet", autoWidth: true, displayEmpty: true, value: selectedPallet || "", style: { marginLeft: "1em" }, onChange: (e) => setSelectedPallet(e.target.value === "" ? undefined : e.target.value), children: [_jsx(MenuItem, { value: "", children: _jsx("em", { children: "Any Pallet" }) }, 0), points.allPalletNames.map((n) => (_jsx(MenuItem, { value: n, children: _jsx("div", { style: { display: "flex", alignItems: "center" }, children: _jsx("span", { style: { marginRight: "1em" }, children: n }) }) }, n)))] }) }), _jsx(Tooltip, { title: "Copy to Clipboard", children: _jsx(IconButton, { onClick: () => copyCyclesToClipboard(points, matSummary.matsById, undefined, ty === "labor"), style: { height: "25px", paddingTop: 0, paddingBottom: 0 }, size: "large", children: _jsx(ImportExport, {}) }) })] }), _jsx("main", { children: showGraph ? (_jsx(CycleChart, { points: points.data, series_label: points.seriesLabel, default_date_range: default_date_range, extra_tooltip: extraStationCycleTooltip, current_date_zoom: chartZoom.zoom, set_date_zoom_range: setChartZoom, yZoom: yZoom, setYZoom: setYZoom, stats: curOperation && ty === "machine" ? estimatedCycleTimes.get(curOperation) : undefined, partCntPerPoint: curOperation ? LazySeq.of(points.data).head()?.[1]?.[0]?.material?.length : undefined, plannedTimeMinutes: plannedMinutes })) : (_jsx(StationDataTable, { points: points.data, matsById: matSummary.matsById, period: { type: "Last30" }, current_date_zoom: undefined, set_date_zoom_range: undefined, showWorkorderAndInspect: true, hideMedian: ty === "labor" })) })] }));
159
+ }
@@ -0,0 +1,6 @@
1
+ export type ShiftStartAndEnd = {
2
+ readonly start: Date;
3
+ readonly end: Date;
4
+ };
5
+ export declare function useShifts(day: Date): ReadonlyArray<ShiftStartAndEnd>;
6
+ export declare function ShiftStart(): import("react/jsx-runtime").JSX.Element;