@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,138 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /* Copyright (c) 2020, 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 { useMemo } from "react";
35
+ import { addMonths, addDays, startOfToday } from "date-fns";
36
+ import { selectedAnalysisPeriod } from "../../network/load-specific-month.js";
37
+ import { SelectableHeatChart } from "./HeatChart.js";
38
+ import { binSimStationUseByDayAndStat, copyOeeHeatmapToClipboard, binActiveCyclesByDayAndStat, binOccupiedCyclesByDayAndStat, binDowntimeToDayAndStat, } from "../../data/results.oee.js";
39
+ import { binCyclesByDayAndPart, binSimProductionByDayAndPart, copyCompletedPartsHeatmapToClipboard, } from "../../data/results.completed-parts.js";
40
+ import { last30SimStationUse, specificMonthSimStationUse } from "../../cell-status/sim-station-use.js";
41
+ import { last30SimProduction, specificMonthSimProduction, } from "../../cell-status/sim-production.js";
42
+ import { last30MaterialSummary, specificMonthMaterialSummary, } from "../../cell-status/material-summary.js";
43
+ import { last30StationCycles, specificMonthStationCycles, } from "../../cell-status/station-cycles.js";
44
+ import { LazySeq } from "@seedtactics/immutable-collections";
45
+ import { useSetTitle } from "../routes.js";
46
+ import { atom, useAtom, useAtomValue } from "jotai";
47
+ function dayAndStatToHeatmapPoints(pts, downtime) {
48
+ return LazySeq.of(pts)
49
+ .map(([dayAndStat, val]) => {
50
+ const downMins = downtime.get(dayAndStat) ?? 0;
51
+ const pct = downMins < 24 * 60 ? Math.max(val / (24 * 60 - downMins), 0) : 0;
52
+ return {
53
+ x: dayAndStat.day,
54
+ y: dayAndStat.station,
55
+ color: Math.min(pct, 1),
56
+ label: downMins < 24 * 60 ? (pct * 100).toFixed(1) + "%" : "Planned Downtime",
57
+ };
58
+ })
59
+ .toSortedArray((p) => p.x.getTime(), { desc: (p) => p.y });
60
+ }
61
+ const selectedStationOeeHeatmapType = atom("Standard OEE");
62
+ export function StationOeeHeatmap() {
63
+ useSetTitle("Station OEE");
64
+ const [selected, setSelected] = useAtom(selectedStationOeeHeatmapType);
65
+ const period = useAtomValue(selectedAnalysisPeriod);
66
+ const dateRange = period.type === "Last30"
67
+ ? [addDays(startOfToday(), -29), addDays(startOfToday(), 1)]
68
+ : [period.month, addMonths(period.month, 1)];
69
+ const cycles = useAtomValue(period.type === "Last30" ? last30StationCycles : specificMonthStationCycles);
70
+ const statUse = useAtomValue(period.type === "Last30" ? last30SimStationUse : specificMonthSimStationUse);
71
+ const points = useMemo(() => {
72
+ const downtime = binDowntimeToDayAndStat(statUse);
73
+ if (selected === "Standard OEE") {
74
+ return dayAndStatToHeatmapPoints(binActiveCyclesByDayAndStat(cycles.valuesToLazySeq()), downtime);
75
+ }
76
+ else if (selected === "Occupied") {
77
+ return dayAndStatToHeatmapPoints(binOccupiedCyclesByDayAndStat(cycles.valuesToLazySeq()), downtime);
78
+ }
79
+ else {
80
+ return dayAndStatToHeatmapPoints(binSimStationUseByDayAndStat(statUse), downtime);
81
+ }
82
+ }, [selected, cycles, statUse]);
83
+ return (_jsx(SelectableHeatChart, { label: "Station Usage Per Day", y_title: "Station", label_title: selected === "Occupied" ? "Occupied" : "OEE", dateRange: dateRange, cur_selected: selected, options: ["Standard OEE", "Occupied", "Planned OEE"], setSelected: setSelected, points: points, onExport: () => copyOeeHeatmapToClipboard("Station", points) }));
84
+ }
85
+ const selectedCompletedPartsHeatmapType = atom("Completed");
86
+ function partsCompletedPoints(partCycles, matsById, start, end) {
87
+ const pts = binCyclesByDayAndPart(partCycles, matsById, start, end);
88
+ return LazySeq.of(pts)
89
+ .map(([dayAndPart, val]) => {
90
+ return {
91
+ x: dayAndPart.day,
92
+ y: dayAndPart.part,
93
+ color: val.activeMachineMins,
94
+ label: val.count.toFixed(0) + " (" + (val.activeMachineMins / 60).toFixed(1) + " hours)",
95
+ count: val.count,
96
+ activeMachineMins: val.activeMachineMins,
97
+ };
98
+ })
99
+ .toSortedArray((p) => p.x.getTime(), { desc: (p) => p.y });
100
+ }
101
+ function partsPlannedPoints(prod) {
102
+ const pts = binSimProductionByDayAndPart(prod);
103
+ return LazySeq.of(pts)
104
+ .map(([dayAndPart, val]) => {
105
+ return {
106
+ x: dayAndPart.day,
107
+ y: dayAndPart.part,
108
+ color: val.activeMachineMins,
109
+ label: val.count.toFixed(0) + " (" + (val.activeMachineMins / 60).toFixed(1) + " hours)",
110
+ count: val.count,
111
+ activeMachineMins: val.activeMachineMins,
112
+ };
113
+ })
114
+ .toSortedArray((p) => p.x.getTime(), { desc: (p) => p.y });
115
+ }
116
+ export function CompletedCountHeatmap() {
117
+ useSetTitle("Part Production");
118
+ const [selected, setSelected] = useAtom(selectedCompletedPartsHeatmapType);
119
+ const period = useAtomValue(selectedAnalysisPeriod);
120
+ const dateRange = period.type === "Last30"
121
+ ? [addDays(startOfToday(), -29), addDays(startOfToday(), 1)]
122
+ : [period.month, addMonths(period.month, 1)];
123
+ const cycles = useAtomValue(period.type === "Last30" ? last30StationCycles : specificMonthStationCycles);
124
+ const productionCounts = useAtomValue(period.type === "Last30" ? last30SimProduction : specificMonthSimProduction);
125
+ const matSummary = useAtomValue(period.type === "Last30" ? last30MaterialSummary : specificMonthMaterialSummary);
126
+ const points = useMemo(() => {
127
+ if (selected === "Completed") {
128
+ const today = startOfToday();
129
+ const start = period.type === "Last30" ? addDays(today, -30) : period.month;
130
+ const endD = period.type === "Last30" ? addDays(today, 1) : addMonths(period.month, 1);
131
+ return partsCompletedPoints(cycles.valuesToLazySeq(), matSummary.matsById, start, endD);
132
+ }
133
+ else {
134
+ return partsPlannedPoints(productionCounts);
135
+ }
136
+ }, [selected, cycles, matSummary, productionCounts, period]);
137
+ return (_jsx(SelectableHeatChart, { label: "Part Production Per Day", y_title: "Part", label_title: selected, dateRange: dateRange, cur_selected: selected, options: ["Completed", "Planned"], setSelected: setSelected, points: points, onExport: () => copyCompletedPartsHeatmapToClipboard(points) }));
138
+ }
@@ -0,0 +1,22 @@
1
+ export type HeatChartYType = "Station" | "Part";
2
+ export interface HeatChartPoint {
3
+ readonly x: Date;
4
+ readonly y: string;
5
+ readonly color: number;
6
+ readonly label: string;
7
+ }
8
+ export interface HeatChartProps {
9
+ readonly points: ReadonlyArray<HeatChartPoint>;
10
+ readonly y_title: HeatChartYType;
11
+ readonly dateRange: [Date, Date];
12
+ readonly label_title: string;
13
+ }
14
+ export interface SelectableHeatCardProps<T extends string> {
15
+ readonly label: string;
16
+ readonly onExport: () => void;
17
+ readonly cur_selected: T;
18
+ readonly setSelected?: (p: T) => void;
19
+ readonly options: ReadonlyArray<T>;
20
+ }
21
+ export type SelectableHeatChartProps<T extends string> = HeatChartProps & SelectableHeatCardProps<T>;
22
+ export declare function SelectableHeatChart<T extends string>(props: SelectableHeatChartProps<T>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,161 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, 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 { useMemo, memo, useRef, useCallback } from "react";
35
+ import { addDays } from "date-fns";
36
+ import { Select, MenuItem, Tooltip, IconButton, Stack, Box, Typography, FormControl } from "@mui/material";
37
+ import { ImportExport } from "@mui/icons-material";
38
+ import { scaleBand, scaleLinear } from "d3-scale";
39
+ import { LazySeq } from "@seedtactics/immutable-collections";
40
+ import { localPoint } from "../../util/chart-helpers.js";
41
+ import { AxisBottom, AxisLeft } from "../AxisAndGrid.js";
42
+ import { measureSvgString } from "../../util/chart-helpers.js";
43
+ import { atom, useSetAtom } from "jotai";
44
+ import { ChartWithTooltip } from "../ChartTooltip.js";
45
+ const marginBottom = 20;
46
+ const marginTop = 10;
47
+ const marginRight = 2;
48
+ const color1 = "#E8F5E9";
49
+ const color2 = "#1B5E20";
50
+ function useScales({ yType, dateRange, containerWidth, points, }) {
51
+ const width = containerWidth === null || containerWidth === undefined || containerWidth === 0 ? 400 : containerWidth;
52
+ const maxStatLen = useMemo(() => LazySeq.of(points)
53
+ .map((p) => p.y)
54
+ .distinct()
55
+ .map(measureSvgString)
56
+ .maxBy((w) => w ?? 0) ?? 20, [points]);
57
+ const marginLeft = maxStatLen + 5;
58
+ const xMax = width - marginLeft - marginRight;
59
+ const dateRangeStart = dateRange[0];
60
+ const dateRangeEnd = dateRange[1];
61
+ const xScale = useMemo(() => {
62
+ const xValues = [];
63
+ if (dateRangeEnd < dateRangeStart) {
64
+ // should never happen, just do something in case
65
+ xValues.push(dateRangeStart);
66
+ }
67
+ else {
68
+ let d = dateRangeStart;
69
+ while (d < dateRangeEnd) {
70
+ xValues.push(d);
71
+ d = addDays(d, 1);
72
+ }
73
+ }
74
+ return scaleBand().domain(xValues).range([0, xMax]).align(0).padding(0.05);
75
+ }, [dateRangeStart, dateRangeEnd, xMax]);
76
+ const { yScale, height, colorScale } = useMemo(() => {
77
+ const yValues = new Set();
78
+ for (const pt of points) {
79
+ yValues.add(pt.y);
80
+ }
81
+ const yMax = 60 * yValues.size;
82
+ const height = yMax + marginTop + marginBottom;
83
+ const yScale = scaleBand()
84
+ .domain(Array.from(yValues).sort((a, b) => a.localeCompare(b)))
85
+ .range([0, yMax])
86
+ .align(0)
87
+ .padding(0.05);
88
+ let colorScale;
89
+ if (yType === "Station") {
90
+ colorScale = scaleLinear().domain([0, 1]).range([color1, color2]);
91
+ }
92
+ else {
93
+ const maxCnt = LazySeq.of(points).maxBy((pt) => pt.color)?.color ?? 1;
94
+ colorScale = scaleLinear().domain([0, maxCnt]).range([color1, color2]);
95
+ }
96
+ return { yScale, height, colorScale };
97
+ }, [points, yType]);
98
+ return { height, width, xScale, yScale, colorScale, marginLeft };
99
+ }
100
+ const HeatAxis = memo(function HeatAxis({ xScale, yScale }) {
101
+ return (_jsxs(_Fragment, { children: [_jsx(AxisBottom, { scale: xScale, top: yScale.range()[1], tickFormat: (d) => d.toLocaleDateString(undefined, { month: "short", day: "numeric" }) }), _jsx(AxisLeft, { scale: yScale, left: xScale.range()[0] })] }));
102
+ });
103
+ const HeatSeries = memo(function HeatSeries({ points, xScale, yScale, colorScale, setTooltip, }) {
104
+ const hideRef = useRef(null);
105
+ const pointerEnter = useCallback((e) => {
106
+ const pt = localPoint(e);
107
+ if (pt === null)
108
+ return;
109
+ if (hideRef.current !== null) {
110
+ clearTimeout(hideRef.current);
111
+ hideRef.current = null;
112
+ }
113
+ const idxS = e.target.dataset.idx;
114
+ if (idxS === undefined)
115
+ return;
116
+ const heatPoint = points[parseInt(idxS)];
117
+ setTooltip({ left: pt.x, top: pt.y, data: heatPoint });
118
+ }, [points, setTooltip]);
119
+ const pointerLeave = useCallback(() => {
120
+ if (hideRef.current === null) {
121
+ hideRef.current = window.setTimeout(() => {
122
+ hideRef.current = null;
123
+ setTooltip(null);
124
+ }, 100);
125
+ }
126
+ }, [setTooltip]);
127
+ return (_jsx("g", { children: points.map((pt, idx) => {
128
+ return (_jsx("rect", { "data-idx": idx, x: xScale(pt.x) ?? 0, width: xScale.bandwidth(), y: yScale(pt.y) ?? 0, height: yScale.bandwidth(), rx: 6, fill: colorScale(pt.color), onPointerEnter: pointerEnter, onPointerLeave: pointerLeave }, idx));
129
+ }) }));
130
+ });
131
+ const HeatTooltip = memo(function HeatTooltip({ yType, seriesLabel, tooltip, }) {
132
+ if (tooltip === null)
133
+ return null;
134
+ return (_jsxs(Stack, { direction: "column", spacing: 0.6, children: [_jsxs("div", { children: [yType, ": ", tooltip.data.y] }), _jsxs("div", { children: ["Day: ", tooltip.data.x.toDateString()] }), _jsxs("div", { children: [seriesLabel, ": ", tooltip.data.label] })] }));
135
+ });
136
+ function HeatChart(props) {
137
+ const { width, height, xScale, yScale, colorScale, marginLeft } = useScales({
138
+ yType: props.y_title,
139
+ points: props.points,
140
+ dateRange: props.dateRange,
141
+ containerWidth: props.parentWidth,
142
+ });
143
+ return (_jsx("svg", { width: width, height: height, children: _jsxs("g", { transform: `translate(${marginLeft}, ${marginTop})`, children: [_jsx(HeatSeries, { points: props.points, xScale: xScale, yScale: yScale, colorScale: colorScale, setTooltip: props.setTooltip }), _jsx(HeatAxis, { xScale: xScale, yScale: yScale, colorScale: colorScale })] }) }));
144
+ }
145
+ function ChartToolbar(props) {
146
+ const setSelected = props.setSelected;
147
+ return (_jsxs(Box, { component: "nav", sx: {
148
+ display: "flex",
149
+ minHeight: "2.5em",
150
+ alignItems: "center",
151
+ maxWidth: "calc(100vw - 24px - 24px)",
152
+ }, children: [_jsx(Typography, { variant: "subtitle1", children: props.label }), _jsx(Box, { flexGrow: 1 }), setSelected ? (_jsx(FormControl, { size: "small", children: _jsx(Select, { autoWidth: true, displayEmpty: true, value: props.cur_selected, onChange: (e) => setSelected(e.target.value), children: props.options.map((v, idx) => (_jsx(MenuItem, { value: v, children: v }, idx))) }) })) : undefined, _jsx(Tooltip, { title: "Copy to Clipboard", children: _jsx(IconButton, { onClick: props.onExport, style: { height: "25px", paddingTop: 0, paddingBottom: 0 }, size: "large", children: _jsx(ImportExport, {}) }) })] }));
153
+ }
154
+ export function SelectableHeatChart(props) {
155
+ const tooltipAtom = useMemo(() => atom(null), []);
156
+ const setTooltip = useSetAtom(tooltipAtom);
157
+ const pointerLeave = useCallback(() => {
158
+ setTooltip(null);
159
+ }, [setTooltip]);
160
+ return (_jsxs(Box, { paddingLeft: "24px", paddingRight: "24px", paddingTop: "10px", children: [_jsx(ChartToolbar, { label: props.label, setSelected: props.setSelected, cur_selected: props.cur_selected, onExport: props.onExport, options: props.options }), _jsx("main", { onPointerLeave: pointerLeave, children: _jsx(ChartWithTooltip, { sx: { width: "100%" }, tooltipAtom: tooltipAtom, autoHeight: true, chart: ({ width }) => (_jsx(HeatChart, { points: props.points, y_title: props.y_title, dateRange: props.dateRange, parentWidth: width, setTooltip: setTooltip })), TooltipContent: ({ tooltip }) => (_jsx(HeatTooltip, { yType: props.y_title, seriesLabel: props.label_title, tooltip: tooltip })) }) })] }));
161
+ }
@@ -0,0 +1,10 @@
1
+ import { InspectionLogEntry } from "../../cell-status/inspections.js";
2
+ export interface InspectionDataTableProps {
3
+ readonly points: Iterable<InspectionLogEntry>;
4
+ readonly default_date_range: Date[];
5
+ readonly zoomType?: "Last30Days" | "ZoomIntoRange" | "ExtendDays";
6
+ readonly extendDateRange?: (numDays: number) => void;
7
+ readonly hideOpenDetailColumn?: boolean;
8
+ }
9
+ declare const _default: import("react").NamedExoticComponent<InspectionDataTableProps>;
10
+ export default _default;
@@ -0,0 +1,148 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /* Copyright (c) 2019, 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 } from "react";
35
+ import { Table } from "@mui/material";
36
+ import { Accordion } from "@mui/material";
37
+ import { AccordionDetails } from "@mui/material";
38
+ import { AccordionSummary } from "@mui/material";
39
+ import { ExpandMore as ExpandMoreIcon } from "@mui/icons-material";
40
+ import { DataTableHead, DataTableActions, DataTableBody, useColSort, } from "./DataTable.js";
41
+ import { Typography } from "@mui/material";
42
+ import { groupInspectionsByPath } from "../../data/results.inspection.js";
43
+ import { addDays, addHours } from "date-fns";
44
+ import { materialDialogOpen } from "../../cell-status/material-details.js";
45
+ import { LazySeq, HashMap } from "@seedtactics/immutable-collections";
46
+ import { useSetAtom } from "jotai";
47
+ var ColumnId;
48
+ (function (ColumnId) {
49
+ ColumnId[ColumnId["Date"] = 0] = "Date";
50
+ ColumnId[ColumnId["Serial"] = 1] = "Serial";
51
+ ColumnId[ColumnId["Workorder"] = 2] = "Workorder";
52
+ ColumnId[ColumnId["Inspected"] = 3] = "Inspected";
53
+ ColumnId[ColumnId["Failed"] = 4] = "Failed";
54
+ })(ColumnId || (ColumnId = {}));
55
+ const columns = [
56
+ {
57
+ id: ColumnId.Date,
58
+ numeric: false,
59
+ label: "Date",
60
+ getDisplay: (c) => c.time.toLocaleString(),
61
+ getForSort: (c) => c.time.getTime(),
62
+ },
63
+ {
64
+ id: ColumnId.Serial,
65
+ numeric: false,
66
+ label: "Serial",
67
+ getDisplay: (c) => c.serial || "",
68
+ },
69
+ {
70
+ id: ColumnId.Workorder,
71
+ numeric: false,
72
+ label: "Workorder",
73
+ getDisplay: (c) => c.workorder || "",
74
+ },
75
+ {
76
+ id: ColumnId.Inspected,
77
+ numeric: false,
78
+ label: "Inspected",
79
+ getDisplay: (c) => (c.toInspect ? "inspected" : ""),
80
+ },
81
+ {
82
+ id: ColumnId.Failed,
83
+ numeric: false,
84
+ label: "Failed",
85
+ getDisplay: (c) => (c.failed ? "failed" : ""),
86
+ },
87
+ ];
88
+ function useZoom(zoomType, extendDateRange, default_date_range) {
89
+ const [curZoom, setCurZoom] = useState(undefined);
90
+ let zoom;
91
+ if (zoomType && zoomType === "Last30Days") {
92
+ zoom = {
93
+ type: "Last30Days",
94
+ set_days_back: (numDaysBack) => {
95
+ if (numDaysBack) {
96
+ const now = new Date();
97
+ setCurZoom({ start: addDays(now, -numDaysBack), end: addHours(now, 1) });
98
+ }
99
+ else {
100
+ setCurZoom(undefined);
101
+ }
102
+ },
103
+ };
104
+ }
105
+ else if (zoomType && zoomType === "ZoomIntoRange") {
106
+ zoom = {
107
+ type: "ZoomIntoRange",
108
+ default_date_range,
109
+ current_date_zoom: curZoom,
110
+ set_date_zoom_range: setCurZoom,
111
+ };
112
+ }
113
+ else if (zoomType && extendDateRange && zoomType === "ExtendDays") {
114
+ zoom = {
115
+ type: "ExtendDays",
116
+ curStart: default_date_range[0],
117
+ curEnd: default_date_range[1],
118
+ extend: extendDateRange,
119
+ };
120
+ }
121
+ return { zoom, zoomRange: curZoom };
122
+ }
123
+ export default memo(function InspDataTable(props) {
124
+ const setMatToShow = useSetAtom(materialDialogOpen);
125
+ const sort = useColSort(ColumnId.Date, columns);
126
+ const [pages, setPages] = useState(HashMap.empty());
127
+ const [rowsPerPage, setRowsPerPage] = useState(10);
128
+ const [curPath, setCurPathOpen] = useState(undefined);
129
+ const tzoom = useZoom(props.zoomType, props.extendDateRange, props.default_date_range);
130
+ const groups = groupInspectionsByPath(props.points, tzoom.zoomRange, sort.sortOn);
131
+ const paths = LazySeq.of(groups).toSortedArray(([x]) => x);
132
+ return (_jsx("div", { style: { width: "100%", marginTop: "1em" }, children: paths.map(([path, points]) => {
133
+ const page = Math.min(pages.get(path) ?? 0, Math.ceil(points.material.length / rowsPerPage));
134
+ return (_jsxs(Accordion, { expanded: path === curPath, onChange: (_evt, open) => setCurPathOpen(open ? path : undefined), children: [_jsxs(AccordionSummary, { expandIcon: _jsx(ExpandMoreIcon, {}), children: [_jsx(Typography, { variant: "h6", style: { flexBasis: "33.33%", flexShrink: 0 }, children: path }), _jsxs(Typography, { variant: "caption", children: [points.material.length, " total parts, ", points.failedCnt, " failed"] })] }), _jsx(AccordionDetails, { children: _jsxs("div", { style: { width: "100%" }, children: [_jsxs(Table, { children: [_jsx(DataTableHead, { columns: columns, sort: sort, showDetailsCol: true }), _jsx(DataTableBody, { columns: columns, pageData: LazySeq.of(points.material)
135
+ .drop(page * rowsPerPage)
136
+ .take(rowsPerPage), rowsPerPage: rowsPerPage, onClickDetails: props.hideOpenDetailColumn
137
+ ? undefined
138
+ : (_, row) => setMatToShow({
139
+ type: "MatSummary",
140
+ summary: {
141
+ materialID: row.materialID,
142
+ partName: row.partName,
143
+ serial: row.serial,
144
+ workorderId: row.workorder,
145
+ },
146
+ }) })] }), _jsx(DataTableActions, { tpage: { page, rowsPerPage, setPage: (p) => setPages(pages.set(path, p)), setRowsPerPage }, count: points.material.length, zoom: tzoom.zoom })] }) })] }, path));
147
+ }) }));
148
+ });
@@ -0,0 +1,12 @@
1
+ import { InspectionsByPartAndType } from "../../cell-status/inspections.js";
2
+ export interface InspectionSankeyProps {
3
+ readonly inspectionlogs: InspectionsByPartAndType;
4
+ readonly default_date_range: Date[];
5
+ readonly zoomType?: "Last30Days" | "ZoomIntoRange" | "ExtendDays";
6
+ readonly subtitle?: string;
7
+ readonly restrictToPart?: string;
8
+ readonly onlyTable?: boolean;
9
+ readonly extendDateRange?: (numDays: number) => void;
10
+ readonly hideOpenDetailColumn?: boolean;
11
+ }
12
+ export declare function InspectionSankey(props: InspectionSankeyProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,140 @@
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 { useState, memo, useMemo } from "react";
35
+ import { Select, MenuItem, Tooltip, IconButton, Box, Typography, FormControl } from "@mui/material";
36
+ import { ImportExport } from "@mui/icons-material";
37
+ import { sankey, sankeyJustify, sankeyLinkHorizontal } from "d3-sankey";
38
+ import { PartIdenticon } from "../station-monitor/Material.js";
39
+ import { inspectionDataToSankey } from "../../data/inspection-sankey.js";
40
+ import { PartAndInspType, } from "../../cell-status/inspections.js";
41
+ import InspectionDataTable from "./InspectionDataTable.js";
42
+ import { copyInspectionEntriesToClipboard } from "../../data/results.inspection.js";
43
+ import { isDemoAtom } from "../routes.js";
44
+ import { green } from "@mui/material/colors";
45
+ import { localPoint } from "../../util/chart-helpers.js";
46
+ import { atom, useAtom, useSetAtom } from "jotai";
47
+ import { atomWithDefault } from "jotai/utils";
48
+ import { ChartWithTooltip } from "../ChartTooltip.js";
49
+ const marginLeft = 20;
50
+ const marginTop = 20;
51
+ const marginRight = 120;
52
+ const marginBottom = 20;
53
+ function LinkDisplay({ link, path, strokeWidth, setTooltip, }) {
54
+ const [over, setOver] = useState(false);
55
+ if (path === null)
56
+ return null;
57
+ function pointerOver(e) {
58
+ const pt = localPoint(e);
59
+ if (pt === null)
60
+ return;
61
+ setTooltip({ left: pt.x, top: pt.y, data: link });
62
+ setOver(true);
63
+ }
64
+ function pointerOut() {
65
+ setOver(false);
66
+ setTooltip(null);
67
+ }
68
+ return (_jsx("path", { d: path, stroke: over ? green[600] : green[300], strokeWidth: strokeWidth, opacity: 0.2, fill: "none", onMouseMove: pointerOver, onMouseLeave: pointerOut }));
69
+ }
70
+ function NodeDisplay({ node }) {
71
+ if (node.x1 === undefined || node.x0 === undefined || node.y1 === undefined || node.y0 === undefined)
72
+ return null;
73
+ return (_jsxs("g", { transform: `translate(${node.x0}, ${node.y0})`, children: [_jsx("rect", { width: node.x1 - node.x0, height: node.y1 - node.y0, fill: green[800], opacity: 0.8, stroke: "none" }), _jsx("text", { x: 18, y: (node.y1 - node.y0) / 2, children: node.name })] }));
74
+ }
75
+ const SankeyDisplay = memo(function InspectionSankeyDiagram({ data, setTooltip, parentHeight, parentWidth, }) {
76
+ const { nodes, links } = useMemo(() => {
77
+ const { nodes, links } = inspectionDataToSankey(data);
78
+ if (nodes.length === 0) {
79
+ return { nodes: [], links: [] };
80
+ }
81
+ const generator = sankey()
82
+ .nodeWidth(10)
83
+ .nodePadding(10)
84
+ .nodeAlign(sankeyJustify)
85
+ .extent([
86
+ [marginLeft, marginTop],
87
+ [parentWidth - marginRight, parentHeight - marginBottom - marginTop],
88
+ ]);
89
+ generator({ nodes, links });
90
+ return { nodes: nodes, links: links };
91
+ }, [data, parentWidth, parentHeight]);
92
+ const path = sankeyLinkHorizontal();
93
+ return (_jsxs("svg", { width: parentWidth, height: parentHeight, children: [_jsx("g", { children: nodes.map((node, i) => (_jsx(NodeDisplay, { node: node }, i))) }), _jsx("g", { children: links.map((link, i) => (_jsx(LinkDisplay, { link: link, path: path(link), strokeWidth: Math.max(link.width ?? 1, 1), setTooltip: setTooltip }, i))) })] }));
94
+ });
95
+ function LinkTooltip({ tooltip }) {
96
+ if (tooltip === null)
97
+ return null;
98
+ return (_jsxs("div", { children: [tooltip.data.source.name, " \u279E ", tooltip.data.target.name, ": ", tooltip.data.value, " parts"] }));
99
+ }
100
+ const InspectionDiagram = memo(function InspectionDiagram({ data, }) {
101
+ const tooltipAtom = useMemo(() => atom(null), []);
102
+ const setTooltip = useSetAtom(tooltipAtom);
103
+ return (_jsx("div", { style: { position: "relative" }, children: _jsx(ChartWithTooltip, { sx: {
104
+ height: { xs: "calc(100vh - 230px)", md: "calc(100vh - 182px)", xl: "calc(100vh - 130px)" },
105
+ width: "100%",
106
+ }, chart: ({ height, width }) => (_jsx(SankeyDisplay, { data: data, setTooltip: setTooltip, parentHeight: height, parentWidth: width })), tooltipAtom: tooltipAtom, TooltipContent: LinkTooltip }) }));
107
+ });
108
+ const selectedPartAtom = atomWithDefault((get) => (get(isDemoAtom) ? "aaa" : undefined));
109
+ const selectedInspTypeAtom = atomWithDefault((get) => get(isDemoAtom) ? "CMM" : undefined);
110
+ const showTableAtom = atom(false);
111
+ export function InspectionSankey(props) {
112
+ const [curPart, setSelectedPart] = useAtom(selectedPartAtom);
113
+ const [selectedInspectType, setSelectedInspectType] = useAtom(selectedInspTypeAtom);
114
+ const [showTable, setShowTable] = useAtom(showTableAtom);
115
+ let curData;
116
+ const selectedPart = props.restrictToPart || curPart;
117
+ if (selectedPart && selectedInspectType) {
118
+ curData =
119
+ props.inspectionlogs.get(new PartAndInspType(selectedPart, selectedInspectType))?.valuesToLazySeq() ??
120
+ [];
121
+ }
122
+ const parts = props.inspectionlogs
123
+ .keysToLazySeq()
124
+ .map((x) => x.part)
125
+ .distinct()
126
+ .toSortedArray((x) => x);
127
+ const inspTypes = props.inspectionlogs
128
+ .keysToLazySeq()
129
+ .map((e) => e.inspType)
130
+ .distinct()
131
+ .toSortedArray((x) => x);
132
+ return (_jsxs(Box, { paddingLeft: "24px", paddingRight: "24px", paddingTop: "10px", children: [_jsxs(Box, { component: "nav", sx: {
133
+ display: "flex",
134
+ minHeight: "2.5em",
135
+ alignItems: "center",
136
+ maxWidth: "calc(100vw - 24px - 24px)",
137
+ }, children: [props.subtitle ? _jsx(Typography, { variant: "subtitle1", children: props.subtitle }) : undefined, _jsx(Box, { flexGrow: 1 }), props.onlyTable ? undefined : (_jsx(FormControl, { size: "small", children: _jsxs(Select, { autoWidth: true, value: showTable ? "table" : "sankey", onChange: (e) => setShowTable(e.target.value === "table"), children: [_jsx(MenuItem, { value: "sankey", children: "Sankey" }, "sankey"), _jsx(MenuItem, { value: "table", children: "Table" }, "table")] }) })), _jsx(FormControl, { size: "small", children: _jsxs(Select, { name: "inspection-sankey-select-type", autoWidth: true, displayEmpty: true, style: { marginRight: "1em", marginLeft: "1em" }, value: selectedInspectType || "", onChange: (e) => setSelectedInspectType(e.target.value), children: [selectedInspectType ? undefined : (_jsx(MenuItem, { value: "", children: _jsx("em", { children: "Select Inspection Type" }) }, 0)), inspTypes.map((n) => (_jsx(MenuItem, { value: n, children: n }, n)))] }) }), props.restrictToPart === undefined ? (_jsx(FormControl, { size: "small", children: _jsxs(Select, { name: "inspection-sankey-select-part", autoWidth: true, displayEmpty: true, value: selectedPart || "", onChange: (e) => setSelectedPart(e.target.value), children: [selectedPart ? undefined : (_jsx(MenuItem, { value: "", children: _jsx("em", { children: "Select Part" }) }, 0)), parts.map((n) => (_jsx(MenuItem, { value: n, children: _jsxs("div", { style: { display: "flex", alignItems: "center" }, children: [_jsx(PartIdenticon, { part: n, size: 30 }), _jsx("span", { style: { marginRight: "1em" }, children: n })] }) }, n)))] }) })) : undefined, curData ? (_jsx(Tooltip, { title: "Copy to Clipboard", children: _jsx(IconButton, { onClick: () => curData
138
+ ? copyInspectionEntriesToClipboard(selectedPart || "", selectedInspectType || "", curData)
139
+ : undefined, style: { height: "25px", paddingTop: 0, paddingBottom: 0 }, size: "large", children: _jsx(ImportExport, {}) }) })) : undefined] }), _jsx("main", { children: curData ? (showTable || props.onlyTable ? (_jsx(InspectionDataTable, { zoomType: props.zoomType, points: curData, default_date_range: props.default_date_range, extendDateRange: props.extendDateRange, hideOpenDetailColumn: props.hideOpenDetailColumn })) : (_jsx(InspectionDiagram, { data: curData }))) : undefined })] }));
140
+ }
@@ -0,0 +1 @@
1
+ export declare function PalletCycleChart(): import("react/jsx-runtime").JSX.Element;