@olenbetong/synergi-react 5.3.1 → 5.5.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.
- package/dist/styles/styles.css +1 -1
- package/dist/styles/styles.css.map +1 -1
- package/es/charts/CallOffDeliveries/TicketScanDialog.d.ts +7 -0
- package/es/charts/CallOffDeliveries/TicketScanDialog.js +47 -0
- package/es/charts/CallOffDeliveries/chartOptions.d.ts +8 -0
- package/es/charts/CallOffDeliveries/chartOptions.js +138 -0
- package/es/charts/CallOffDeliveries/data.d.ts +35 -0
- package/es/charts/CallOffDeliveries/data.js +30 -0
- package/es/charts/CallOffDeliveries/index.css +1 -0
- package/es/charts/CallOffDeliveries/index.d.ts +24 -0
- package/es/charts/CallOffDeliveries/index.js +115 -0
- package/es/charts/CallOffDeliveries/model.d.ts +37 -0
- package/es/charts/CallOffDeliveries/model.js +59 -0
- package/es/charts/ProductionPlan/PlanValueDialog.d.ts +14 -0
- package/es/charts/ProductionPlan/PlanValueDialog.js +47 -0
- package/es/charts/ProductionPlan/chartOptions.d.ts +20 -0
- package/es/charts/ProductionPlan/chartOptions.js +353 -0
- package/es/charts/ProductionPlan/data.d.ts +105 -0
- package/es/charts/ProductionPlan/data.js +61 -0
- package/es/charts/ProductionPlan/index.css +1 -0
- package/es/charts/ProductionPlan/index.d.ts +31 -0
- package/es/charts/ProductionPlan/index.js +203 -0
- package/es/charts/ProductionPlan/model.d.ts +29 -0
- package/es/charts/ProductionPlan/model.js +65 -0
- package/es/charts/Pumping/chartOptions.d.ts +12 -0
- package/es/charts/Pumping/chartOptions.js +197 -0
- package/es/charts/Pumping/data.d.ts +65 -0
- package/es/charts/Pumping/data.js +20 -0
- package/es/charts/Pumping/index.css +1 -0
- package/es/charts/Pumping/index.d.ts +27 -0
- package/es/charts/Pumping/index.js +124 -0
- package/es/charts/Pumping/model.d.ts +34 -0
- package/es/charts/Pumping/model.js +88 -0
- package/es/charts/UnboundPreview/chartOptions.d.ts +3 -0
- package/es/charts/UnboundPreview/chartOptions.js +126 -0
- package/es/charts/UnboundPreview/index.css +1 -0
- package/es/charts/UnboundPreview/index.d.ts +20 -0
- package/es/charts/UnboundPreview/index.js +55 -0
- package/es/charts/UnboundPreview/model.d.ts +49 -0
- package/es/charts/UnboundPreview/model.js +67 -0
- package/es/charts/VehicleDeliveries/chartOptions.d.ts +13 -0
- package/es/charts/VehicleDeliveries/chartOptions.js +270 -0
- package/es/charts/VehicleDeliveries/data.d.ts +71 -0
- package/es/charts/VehicleDeliveries/data.js +20 -0
- package/es/charts/VehicleDeliveries/deliveryXRange.d.ts +4 -0
- package/es/charts/VehicleDeliveries/deliveryXRange.js +62 -0
- package/es/charts/VehicleDeliveries/index.css +1 -0
- package/es/charts/VehicleDeliveries/index.d.ts +24 -0
- package/es/charts/VehicleDeliveries/index.js +129 -0
- package/es/charts/VehicleDeliveries/model.d.ts +24 -0
- package/es/charts/VehicleDeliveries/model.js +106 -0
- package/es/charts/format.d.ts +12 -0
- package/es/charts/format.js +34 -0
- package/es/charts/index.d.ts +5 -0
- package/es/charts/index.js +5 -0
- package/es/charts/storage.d.ts +5 -0
- package/es/charts/storage.js +35 -0
- package/es/components/ColorCard/index.css +8 -8
- package/es/components/ImageEditor/ImageEditor.d.ts +6 -0
- package/es/components/ImageEditor/ImageEditor.js +6 -2
- package/es/components/ImageEditor/ResponsiveButton.d.ts +2 -1
- package/es/components/ImageEditor/ResponsiveButton.js +3 -3
- package/es/components/ImageEditor/plugins/cropPlugin/CropContext.d.ts +2 -1
- package/es/components/ImageEditor/plugins/cropPlugin/CropContext.js +2 -2
- package/es/components/ImageEditor/plugins/cropPlugin/CropToolbar.js +27 -7
- package/es/components/ImageEditor/types.d.ts +5 -0
- package/es/index.css +1 -1
- package/es/vehicles/VehicleInfoDialog/OutOfServiceForm.d.ts +4 -0
- package/es/vehicles/VehicleInfoDialog/OutOfServiceForm.js +51 -0
- package/es/vehicles/VehicleInfoDialog/data/dsDeliveryTickets.d.ts +99 -0
- package/es/vehicles/VehicleInfoDialog/data/dsDeliveryTickets.js +499 -0
- package/es/vehicles/VehicleInfoDialog/data/dsDriverStatus.d.ts +13 -0
- package/es/vehicles/VehicleInfoDialog/data/dsDriverStatus.js +69 -0
- package/es/vehicles/VehicleInfoDialog/data/dsVehicleInfo.d.ts +33 -0
- package/es/vehicles/VehicleInfoDialog/data/dsVehicleInfo.js +164 -0
- package/es/vehicles/VehicleInfoDialog/data/dsVehicleInfoLog.d.ts +15 -0
- package/es/vehicles/VehicleInfoDialog/data/dsVehicleInfoLog.js +80 -0
- package/es/vehicles/VehicleInfoDialog/formatting.d.ts +13 -0
- package/es/vehicles/VehicleInfoDialog/formatting.js +48 -0
- package/es/vehicles/VehicleInfoDialog/index.css +1 -0
- package/es/vehicles/VehicleInfoDialog/index.d.ts +11 -0
- package/es/vehicles/VehicleInfoDialog/index.js +46 -0
- package/es/vehicles/VehicleInfoDialog/tabs.d.ts +6 -0
- package/es/vehicles/VehicleInfoDialog/tabs.js +85 -0
- package/es/vehicles/index.d.ts +1 -0
- package/es/vehicles/index.js +1 -0
- package/package.json +19 -10
- package/src/charts/CallOffDeliveries/TicketScanDialog.tsx +79 -0
- package/src/charts/CallOffDeliveries/chartOptions.ts +160 -0
- package/src/charts/CallOffDeliveries/data.ts +67 -0
- package/src/charts/CallOffDeliveries/index.scss +51 -0
- package/src/charts/CallOffDeliveries/index.tsx +217 -0
- package/src/charts/CallOffDeliveries/model.test.ts +90 -0
- package/src/charts/CallOffDeliveries/model.ts +87 -0
- package/src/charts/ProductionPlan/PlanValueDialog.tsx +107 -0
- package/src/charts/ProductionPlan/chartOptions.ts +406 -0
- package/src/charts/ProductionPlan/data.ts +170 -0
- package/src/charts/ProductionPlan/index.scss +148 -0
- package/src/charts/ProductionPlan/index.tsx +432 -0
- package/src/charts/ProductionPlan/model.test.ts +132 -0
- package/src/charts/ProductionPlan/model.ts +102 -0
- package/src/charts/Pumping/chartOptions.ts +224 -0
- package/src/charts/Pumping/data.ts +91 -0
- package/src/charts/Pumping/index.scss +42 -0
- package/src/charts/Pumping/index.tsx +222 -0
- package/src/charts/Pumping/model.test.ts +122 -0
- package/src/charts/Pumping/model.ts +104 -0
- package/src/charts/UnboundPreview/chartOptions.ts +137 -0
- package/src/charts/UnboundPreview/index.scss +17 -0
- package/src/charts/UnboundPreview/index.tsx +100 -0
- package/src/charts/UnboundPreview/model.test.ts +129 -0
- package/src/charts/UnboundPreview/model.ts +110 -0
- package/src/charts/VehicleDeliveries/chartOptions.ts +311 -0
- package/src/charts/VehicleDeliveries/data.ts +98 -0
- package/src/charts/VehicleDeliveries/deliveryXRange.ts +80 -0
- package/src/charts/VehicleDeliveries/index.scss +43 -0
- package/src/charts/VehicleDeliveries/index.tsx +262 -0
- package/src/charts/VehicleDeliveries/model.test.ts +117 -0
- package/src/charts/VehicleDeliveries/model.ts +139 -0
- package/src/charts/format.ts +38 -0
- package/src/charts/index.ts +20 -0
- package/src/charts/storage.ts +36 -0
- package/src/components/ColorCard/index.css +8 -8
- package/src/components/ImageEditor/ImageEditor.test.tsx +103 -0
- package/src/components/ImageEditor/ImageEditor.tsx +18 -2
- package/src/components/ImageEditor/ResponsiveButton.tsx +4 -3
- package/src/components/ImageEditor/plugins/cropPlugin/CropContext.tsx +5 -2
- package/src/components/ImageEditor/plugins/cropPlugin/CropToolbar.test.tsx +118 -0
- package/src/components/ImageEditor/plugins/cropPlugin/CropToolbar.tsx +52 -18
- package/src/components/ImageEditor/types.ts +5 -0
- package/src/vehicles/VehicleInfoDialog/OutOfServiceForm.tsx +127 -0
- package/src/vehicles/VehicleInfoDialog/data/dsDeliveryTickets.ts +600 -0
- package/src/vehicles/VehicleInfoDialog/data/dsDriverStatus.ts +84 -0
- package/src/vehicles/VehicleInfoDialog/data/dsVehicleInfo.ts +198 -0
- package/src/vehicles/VehicleInfoDialog/data/dsVehicleInfoLog.ts +97 -0
- package/src/vehicles/VehicleInfoDialog/formatting.test.ts +57 -0
- package/src/vehicles/VehicleInfoDialog/formatting.ts +58 -0
- package/src/vehicles/VehicleInfoDialog/index.scss +131 -0
- package/src/vehicles/VehicleInfoDialog/index.tsx +106 -0
- package/src/vehicles/VehicleInfoDialog/tabs.tsx +188 -0
- package/src/vehicles/index.ts +1 -0
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Alert, Button, Heading, Paragraph, Spinner } from "@digdir/designsystemet-react";
|
|
3
|
+
import { ArrowsCirclepathIcon, TruckIcon } from "@navikt/aksel-icons";
|
|
4
|
+
import Highcharts from "highcharts";
|
|
5
|
+
// In this order: draggable-points only sets up the drag behaviour of series types that already exist.
|
|
6
|
+
import "highcharts/modules/xrange";
|
|
7
|
+
import "highcharts/modules/draggable-points";
|
|
8
|
+
import { useCallback, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
9
|
+
import { getLocalizedString, localize } from "../../i18n.js";
|
|
10
|
+
import { formatTime } from "../format.js";
|
|
11
|
+
import { getDeliveriesChartOptions, getVehiclesChartOptions, getVolumeChartOptions, METHOD_COLORS, } from "./chartOptions.js";
|
|
12
|
+
import { procCreateAutoPlan, procCreateAutoVehicles, procMovePlannedDelivery, procProdPlan, procProdVolume, procUpdatePlannedDeliveryParam, } from "./data.js";
|
|
13
|
+
import { getChartHeight, getPlanData } from "./model.js";
|
|
14
|
+
import { ConfirmResetDialog, PlanValueDialog } from "./PlanValueDialog.js";
|
|
15
|
+
import "./index.css";
|
|
16
|
+
import { writeStored, readOffset } from "../storage.js";
|
|
17
|
+
function getErrorMessage(reason) {
|
|
18
|
+
return reason instanceof Error ? reason.message : String(reason);
|
|
19
|
+
}
|
|
20
|
+
function formatDay(date) {
|
|
21
|
+
let text = new Intl.DateTimeFormat(globalThis.af?.userSession?.culture, {
|
|
22
|
+
weekday: "long",
|
|
23
|
+
day: "2-digit",
|
|
24
|
+
month: "2-digit",
|
|
25
|
+
year: "numeric",
|
|
26
|
+
timeZone: "UTC",
|
|
27
|
+
}).format(date);
|
|
28
|
+
return text.charAt(0).toUpperCase() + text.slice(1);
|
|
29
|
+
}
|
|
30
|
+
function PlanChart({ options, minHeight, onClick, onRendered, }) {
|
|
31
|
+
let container = useRef(null);
|
|
32
|
+
let zoom = useRef(null);
|
|
33
|
+
useLayoutEffect(() => {
|
|
34
|
+
let chart = new Highcharts.Chart(container.current, options);
|
|
35
|
+
if (zoom.current) {
|
|
36
|
+
chart.xAxis[0].setExtremes(zoom.current.min, zoom.current.max, true, false);
|
|
37
|
+
chart.showResetZoom();
|
|
38
|
+
}
|
|
39
|
+
onRendered?.();
|
|
40
|
+
return () => {
|
|
41
|
+
let { userMin, userMax } = chart.xAxis[0].getExtremes();
|
|
42
|
+
zoom.current = userMin !== undefined && userMax !== undefined ? { min: userMin, max: userMax } : null;
|
|
43
|
+
chart.destroy();
|
|
44
|
+
};
|
|
45
|
+
}, [options, onRendered]);
|
|
46
|
+
// Reserved up front, so the page keeps its scroll position while a chart is replaced.
|
|
47
|
+
// oxlint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions -- the clicks come from links in the chart
|
|
48
|
+
return _jsx("div", { ref: container, className: "ObProductionPlan-chart", style: { minHeight }, onClick: onClick });
|
|
49
|
+
}
|
|
50
|
+
function PlantSection({ plan, settings, onRendered, onLabelClick, onResetPlan, onSpreadVehicles, }) {
|
|
51
|
+
let volumeOptions = useMemo(() => getVolumeChartOptions(plan, settings), [plan, settings]);
|
|
52
|
+
let vehiclesOptions = useMemo(() => getVehiclesChartOptions(plan, settings), [plan, settings]);
|
|
53
|
+
let deliveriesOptions = useMemo(() => getDeliveriesChartOptions(plan, settings), [plan, settings]);
|
|
54
|
+
let plantId = plan.plant.PlantID;
|
|
55
|
+
return (_jsxs("section", { className: "ObProductionPlan-plant", children: [_jsxs("div", { className: "ObProductionPlan-header", children: [_jsx(Heading, { level: 2, "data-size": "2xs", children: formatDay(settings.date) }), _jsxs(Heading, { level: 2, "data-size": "2xs", className: "ObProductionPlan-plantname", children: [plantId, " - ", plan.plant.Description] }), _jsx("div", { className: "ObProductionPlan-actions", children: !settings.readOnly && plan.deliveries.length > 0 && (_jsxs(_Fragment, { children: [_jsxs(Button, { "data-size": "sm", variant: "secondary", title: getLocalizedString("Plan all the call-offs again (manual changes are discarded)"), onClick: () => onResetPlan(plantId), children: [_jsx(ArrowsCirclepathIcon, { "aria-hidden": true }), getLocalizedString("Update/reset all")] }), _jsxs(Button, { "data-size": "sm", variant: "secondary", title: getLocalizedString("Spreads all the planned loads on as few vehicles as possible"), onClick: () => onSpreadVehicles(plantId), children: [_jsx(TruckIcon, { "aria-hidden": true }), getLocalizedString("Update spread on vehicles")] })] })) })] }), plan.volume.length > 0 && _jsx(PlanChart, { options: volumeOptions, minHeight: 150, onRendered: onRendered }), plan.vehicleCounts.length > 0 && _jsx(PlanChart, { options: vehiclesOptions, minHeight: 150, onRendered: onRendered }), plan.deliveries.length > 0 && (_jsx(PlanChart, { options: deliveriesOptions, minHeight: getChartHeight(plan.deliveries.length), onRendered: onRendered, onClick: (event) => onLabelClick(plan, event) })), _jsx("hr", {})] }));
|
|
56
|
+
}
|
|
57
|
+
function Legend() {
|
|
58
|
+
let items = [
|
|
59
|
+
["pump", getLocalizedString("Pump")],
|
|
60
|
+
["telescopic", getLocalizedString("Telescopic chute")],
|
|
61
|
+
["conveyor", getLocalizedString("Conveyor belt")],
|
|
62
|
+
["none", getLocalizedString("No equipment")],
|
|
63
|
+
];
|
|
64
|
+
return (_jsxs(Paragraph, { "data-size": "xs", className: "ObProductionPlan-legend", children: [_jsxs("span", { children: [getLocalizedString("Delivery method"), ":"] }), items.map(([method, label]) => (_jsxs("span", { className: "ObProductionPlan-legend-item", children: [_jsx("span", { className: "ObProductionPlan-legend-icon", style: { backgroundColor: METHOD_COLORS[method] } }), label] }, method)))] }));
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The production plan of a day: the planned production volume, the number of vehicles out and the
|
|
68
|
+
* planned loads of every call-off, one set of charts per plant. Unless `readOnly` is set, loads can be
|
|
69
|
+
* dragged to another time, and the arrival, interval, driving and unloading times changed from the
|
|
70
|
+
* columns left of the loads.
|
|
71
|
+
*/
|
|
72
|
+
export function ProductionPlan({ plants, date, readOnly = false, storageKey, onRendered, onVehiclesReassigned, ref, }) {
|
|
73
|
+
let [minOffset, setMinOffset] = useState(() => readOffset(`${storageKey}_minoffset`, -2));
|
|
74
|
+
let [maxOffset, setMaxOffset] = useState(() => readOffset(`${storageKey}_maxoffset`, 28));
|
|
75
|
+
let [result, setResult] = useState(null);
|
|
76
|
+
let [error, setError] = useState(null);
|
|
77
|
+
let [reloadCount, setReloadCount] = useState(0);
|
|
78
|
+
let [loadedKey, setLoadedKey] = useState(null);
|
|
79
|
+
let [pending, setPending] = useState(0);
|
|
80
|
+
let [editing, setEditing] = useState(null);
|
|
81
|
+
let [resetPlant, setResetPlant] = useState(null);
|
|
82
|
+
let reload = useCallback(() => setReloadCount((count) => count + 1), []);
|
|
83
|
+
let plantsKey = plants.join(",");
|
|
84
|
+
let dateKey = date.getTime();
|
|
85
|
+
let requestKey = `${plantsKey}|${dateKey}|${reloadCount}`;
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
if (!plantsKey)
|
|
88
|
+
return;
|
|
89
|
+
let controller = new AbortController();
|
|
90
|
+
// The windows app sends the plants and the date as separate messages.
|
|
91
|
+
let timeout = setTimeout(async () => {
|
|
92
|
+
let parameters = {
|
|
93
|
+
PlantIDs: plantsKey.split(",").map((plant) => [Number(plant)]),
|
|
94
|
+
Date: new Date(dateKey),
|
|
95
|
+
};
|
|
96
|
+
try {
|
|
97
|
+
let [volume, plan] = await Promise.all([procProdVolume.execute(parameters), procProdPlan.execute(parameters)]);
|
|
98
|
+
if (!controller.signal.aborted) {
|
|
99
|
+
setResult({ volume, plan });
|
|
100
|
+
setError(null);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
catch (reason) {
|
|
104
|
+
if (!controller.signal.aborted)
|
|
105
|
+
setError(getErrorMessage(reason));
|
|
106
|
+
}
|
|
107
|
+
if (!controller.signal.aborted)
|
|
108
|
+
setLoadedKey(requestKey);
|
|
109
|
+
}, 100);
|
|
110
|
+
return () => {
|
|
111
|
+
controller.abort();
|
|
112
|
+
clearTimeout(timeout);
|
|
113
|
+
};
|
|
114
|
+
}, [plantsKey, dateKey, requestKey]);
|
|
115
|
+
useImperativeHandle(ref, () => ({
|
|
116
|
+
reload,
|
|
117
|
+
setOffsets(min, max) {
|
|
118
|
+
writeStored(`${storageKey}_minoffset`, min === undefined ? null : String(min));
|
|
119
|
+
writeStored(`${storageKey}_maxoffset`, max === undefined ? null : String(max));
|
|
120
|
+
if (min !== undefined)
|
|
121
|
+
setMinOffset(min);
|
|
122
|
+
if (max !== undefined)
|
|
123
|
+
setMaxOffset(max);
|
|
124
|
+
},
|
|
125
|
+
}), [reload, storageKey]);
|
|
126
|
+
/** Runs a change to the plan and fetches the plan again, after a refused change as well. */
|
|
127
|
+
let runAction = useCallback(async (action) => {
|
|
128
|
+
setPending((count) => count + 1);
|
|
129
|
+
try {
|
|
130
|
+
await action();
|
|
131
|
+
setError(null);
|
|
132
|
+
}
|
|
133
|
+
catch (reason) {
|
|
134
|
+
setError(getErrorMessage(reason));
|
|
135
|
+
}
|
|
136
|
+
setPending((count) => count - 1);
|
|
137
|
+
reload();
|
|
138
|
+
}, [reload]);
|
|
139
|
+
let onMove = useCallback((delivery, prodTime) => void runAction(() => procMovePlannedDelivery.execute({ PrimKey: delivery.PrimKey, ProdDateTime: prodTime })), [runAction]);
|
|
140
|
+
let data = useMemo(() => (result ? getPlanData(result.volume, result.plan, plantsKey.split(",").map(Number)) : null), [result, plantsKey]);
|
|
141
|
+
let settings = useMemo(() => ({ date: new Date(dateKey), minOffset, maxOffset, readOnly, onMove }), [dateKey, minOffset, maxOffset, readOnly, onMove]);
|
|
142
|
+
let onLabelClick = useCallback((plan, event) => {
|
|
143
|
+
let link = event.target.closest('a[href^="#plan-"]');
|
|
144
|
+
if (!link)
|
|
145
|
+
return;
|
|
146
|
+
event.preventDefault();
|
|
147
|
+
let match = /^#plan-(reset|arrival|interval|drivetime|unloadtime)-(.+)$/.exec(link.hash);
|
|
148
|
+
if (!match)
|
|
149
|
+
return;
|
|
150
|
+
let [, action, id] = match;
|
|
151
|
+
if (action === "reset") {
|
|
152
|
+
void runAction(() => procCreateAutoPlan.execute({ CallOffID: Number(id), DeleteExisting: true }));
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
let row = plan.deliveries.find((delivery) => delivery.PrimKey === id);
|
|
156
|
+
if (!row)
|
|
157
|
+
return;
|
|
158
|
+
let value = {
|
|
159
|
+
arrival: formatTime(row.Arrival),
|
|
160
|
+
interval: String(row.DeliveryInterval ?? ""),
|
|
161
|
+
drivetime: String(row.DriveToSiteTime ?? ""),
|
|
162
|
+
unloadtime: String(row.UnloadTime ?? ""),
|
|
163
|
+
}[action];
|
|
164
|
+
setEditing({ parameter: action, row, value });
|
|
165
|
+
}, [runAction]);
|
|
166
|
+
let saveValue = (value) => {
|
|
167
|
+
if (!editing)
|
|
168
|
+
return;
|
|
169
|
+
let { parameter, row } = editing;
|
|
170
|
+
setEditing(null);
|
|
171
|
+
void runAction(() => procUpdatePlannedDeliveryParam.execute({
|
|
172
|
+
PrimKey: row.PrimKey,
|
|
173
|
+
DriveTime: parameter === "drivetime" ? Number(value) : null,
|
|
174
|
+
Interval: parameter === "interval" ? Number(value) : null,
|
|
175
|
+
UnloadTime: parameter === "unloadtime" ? Number(value) : null,
|
|
176
|
+
Arrival: parameter === "arrival" ? String(value) : null,
|
|
177
|
+
}));
|
|
178
|
+
};
|
|
179
|
+
let onResetPlan = useCallback((plantId) => setResetPlant(plantId), []);
|
|
180
|
+
let onSpreadVehicles = useCallback((plantId) => void runAction(async () => {
|
|
181
|
+
await procCreateAutoVehicles.execute({ PlantID: plantId, Date: new Date(dateKey), ResetExisting: true });
|
|
182
|
+
onVehiclesReassigned?.();
|
|
183
|
+
}), [runAction, dateKey, onVehiclesReassigned]);
|
|
184
|
+
let generateUnplanned = () => {
|
|
185
|
+
if (!data)
|
|
186
|
+
return;
|
|
187
|
+
let plantIds = data.plants.map((plan) => plan.plant.PlantID);
|
|
188
|
+
void runAction(async () => {
|
|
189
|
+
for (let plantId of plantIds) {
|
|
190
|
+
await procCreateAutoPlan.execute({ PlantID: plantId, Date: new Date(dateKey) });
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
};
|
|
194
|
+
if (plants.length === 0) {
|
|
195
|
+
return _jsx(Alert, { "data-color": "warning", children: getLocalizedString("No plant specified") });
|
|
196
|
+
}
|
|
197
|
+
let loading = loadedKey !== requestKey || pending > 0;
|
|
198
|
+
return (_jsxs("div", { className: "ObProductionPlan", children: [_jsxs("div", { className: "ObProductionPlan-options", children: [_jsx("div", { className: "ObProductionPlan-status", children: loading && _jsx(Spinner, { "data-size": "sm", "aria-label": getLocalizedString("Loading") }) }), _jsx(Legend, {})] }), error && _jsx(Alert, { "data-color": "danger", children: error }), data && data.unplanned > 0 && (_jsx(Paragraph, { className: "ObProductionPlan-unplanned", children: readOnly ? (localize `${data.unplanned} call-offs are not planned yet.`) : (_jsx(Button, { variant: "tertiary", "data-size": "sm", onClick: generateUnplanned, children: localize `${data.unplanned} call-offs are not planned yet. Click here to generate a plan...` })) })), data?.plants.map((plan) => (_jsx(PlantSection, { plan: plan, settings: settings, onRendered: onRendered, onLabelClick: onLabelClick, onResetPlan: onResetPlan, onSpreadVehicles: onSpreadVehicles }, `${dateKey}-${plan.plant.PlantID}`))), editing && (_jsx(PlanValueDialog, { parameter: editing.parameter, initialValue: editing.value, onCancel: () => setEditing(null), onSubmit: saveValue })), resetPlant !== null && (_jsx(ConfirmResetDialog, { onCancel: () => setResetPlant(null), onConfirm: () => {
|
|
199
|
+
let plantId = resetPlant;
|
|
200
|
+
setResetPlant(null);
|
|
201
|
+
void runAction(() => procCreateAutoPlan.execute({ PlantID: plantId, Date: new Date(dateKey), DeleteExisting: true }));
|
|
202
|
+
} }))] }));
|
|
203
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { PlannedDeliveryRecord, PlantRecord, ProdPlanResult, ProdVolumeRecord, ProdVolumeResult, VehicleCountRecord } from "./data.js";
|
|
2
|
+
export type PlantPlan = {
|
|
3
|
+
plant: PlantRecord;
|
|
4
|
+
volume: ProdVolumeRecord[];
|
|
5
|
+
vehicleCounts: VehicleCountRecord[];
|
|
6
|
+
deliveries: PlannedDeliveryRecord[];
|
|
7
|
+
/** The warnings of each call-off, joined into one text. */
|
|
8
|
+
warnings: Map<number, string>;
|
|
9
|
+
};
|
|
10
|
+
export type PlanData = {
|
|
11
|
+
plants: PlantPlan[];
|
|
12
|
+
/** Call-offs of the day without planned loads, for all the plants together. */
|
|
13
|
+
unplanned: number;
|
|
14
|
+
};
|
|
15
|
+
export type DeliveryMethod = "pump" | "telescopic" | "conveyor" | "none";
|
|
16
|
+
/** The values the user can change on a planned load, from the columns left of the chart. */
|
|
17
|
+
export type PlanParameter = "arrival" | "interval" | "drivetime" | "unloadtime";
|
|
18
|
+
export declare function getPlanData(volume: ProdVolumeResult, plan: ProdPlanResult, selectedPlants: number[]): PlanData;
|
|
19
|
+
export declare function getDeliveryMethod(row: Pick<PlannedDeliveryRecord, "Pumping" | "Telescopic" | "ConveyorBelt">): DeliveryMethod;
|
|
20
|
+
/** The call-off's name and quantity are only shown on its first load. */
|
|
21
|
+
export declare function isFirstLoad(deliveries: PlannedDeliveryRecord[], index: number): boolean;
|
|
22
|
+
/** The top of a value axis: the largest value rounded up to the step, never below one step. */
|
|
23
|
+
export declare function getAxisMax(values: number[], step: number): number;
|
|
24
|
+
/**
|
|
25
|
+
* Reads what the user typed for a planning value. Minutes must be a whole number; the arrival a
|
|
26
|
+
* time of day, which also accepts "7.30" and "0730". Returns null when the text is not valid.
|
|
27
|
+
*/
|
|
28
|
+
export declare function parsePlanValue(parameter: PlanParameter, text: string): number | string | null;
|
|
29
|
+
export declare function getChartHeight(deliveryCount: number): number;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export function getPlanData(volume, plan, selectedPlants) {
|
|
2
|
+
let plants = [...plan.Table3, ...volume.Table1];
|
|
3
|
+
return {
|
|
4
|
+
unplanned: Number(plan.Table2[0]?.Unplanned ?? 0),
|
|
5
|
+
plants: selectedPlants.flatMap((plantId) => {
|
|
6
|
+
let plant = plants.find((candidate) => candidate.PlantID === plantId);
|
|
7
|
+
if (!plant)
|
|
8
|
+
return [];
|
|
9
|
+
let warnings = new Map();
|
|
10
|
+
for (let warning of plan.Table4.filter((row) => row.PlantID === plantId)) {
|
|
11
|
+
let current = warnings.get(warning.CallOffID);
|
|
12
|
+
warnings.set(warning.CallOffID, current ? `${current}\n${warning.WarningText}` : warning.WarningText);
|
|
13
|
+
}
|
|
14
|
+
return [
|
|
15
|
+
{
|
|
16
|
+
plant,
|
|
17
|
+
volume: volume.Table.filter((row) => row.PlantID === plantId),
|
|
18
|
+
vehicleCounts: plan.Table.filter((row) => row.PlantID === plantId),
|
|
19
|
+
deliveries: plan.Table1.filter((row) => row.PlantID === plantId),
|
|
20
|
+
warnings,
|
|
21
|
+
},
|
|
22
|
+
];
|
|
23
|
+
}),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export function getDeliveryMethod(row) {
|
|
27
|
+
if (row.Pumping)
|
|
28
|
+
return "pump";
|
|
29
|
+
if (row.Telescopic)
|
|
30
|
+
return "telescopic";
|
|
31
|
+
if (row.ConveyorBelt)
|
|
32
|
+
return "conveyor";
|
|
33
|
+
return "none";
|
|
34
|
+
}
|
|
35
|
+
/** The call-off's name and quantity are only shown on its first load. */
|
|
36
|
+
export function isFirstLoad(deliveries, index) {
|
|
37
|
+
return index === 0 || deliveries[index - 1]?.CallOffID !== deliveries[index]?.CallOffID;
|
|
38
|
+
}
|
|
39
|
+
/** The top of a value axis: the largest value rounded up to the step, never below one step. */
|
|
40
|
+
export function getAxisMax(values, step) {
|
|
41
|
+
return Math.max(Math.ceil(Math.max(0, ...values) / step) * step, step);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Reads what the user typed for a planning value. Minutes must be a whole number; the arrival a
|
|
45
|
+
* time of day, which also accepts "7.30" and "0730". Returns null when the text is not valid.
|
|
46
|
+
*/
|
|
47
|
+
export function parsePlanValue(parameter, text) {
|
|
48
|
+
let value = text.trim();
|
|
49
|
+
if (parameter === "arrival") {
|
|
50
|
+
let match = /^(\d{1,2})[:.]?(\d{2})$/.exec(value);
|
|
51
|
+
if (!match)
|
|
52
|
+
return null;
|
|
53
|
+
let hours = Number(match[1]);
|
|
54
|
+
let minutes = Number(match[2]);
|
|
55
|
+
if (hours > 23 || minutes > 59)
|
|
56
|
+
return null;
|
|
57
|
+
return `${String(hours).padStart(2, "0")}:${String(minutes).padStart(2, "0")}`;
|
|
58
|
+
}
|
|
59
|
+
if (!/^\d+$/.test(value))
|
|
60
|
+
return null;
|
|
61
|
+
return Number(value);
|
|
62
|
+
}
|
|
63
|
+
export function getChartHeight(deliveryCount) {
|
|
64
|
+
return deliveryCount * 20 + 110;
|
|
65
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import Highcharts from "highcharts";
|
|
2
|
+
import type { PumpBookingRecord } from "./data.js";
|
|
3
|
+
import { type ChartData } from "./model.js";
|
|
4
|
+
export type MoveBooking = (booking: PumpBookingRecord, pumpNo: number, start: Date, end: Date) => void;
|
|
5
|
+
export type ChartSettings = {
|
|
6
|
+
date: Date;
|
|
7
|
+
minOffset: number;
|
|
8
|
+
maxOffset: number;
|
|
9
|
+
readOnly: boolean;
|
|
10
|
+
onMove: MoveBooking;
|
|
11
|
+
};
|
|
12
|
+
export declare function getChartOptions(data: ChartData, settings: ChartSettings): Highcharts.Options;
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { getLocalizedString, localize } from "../../i18n.js";
|
|
2
|
+
import { getBookingPlant, getChartHeight, getPumpFeature, getPumpHome } from "./model.js";
|
|
3
|
+
import { formatTime, escapeHtml, barColor, PLANT_COLORS } from "../format.js";
|
|
4
|
+
const HOUR = 3600000;
|
|
5
|
+
function plantColor(colorIndex, plantId) {
|
|
6
|
+
return PLANT_COLORS[(colorIndex.get(plantId) ?? 0) % PLANT_COLORS.length];
|
|
7
|
+
}
|
|
8
|
+
function pumpLabelHtml(data, pumpNo) {
|
|
9
|
+
let pump = data.pumps.find((candidate) => candidate.ObjectNo === pumpNo);
|
|
10
|
+
if (!pump)
|
|
11
|
+
return "";
|
|
12
|
+
let feature = getPumpFeature(pump);
|
|
13
|
+
let { show, home } = getPumpHome(pump, data.plants, data.merged);
|
|
14
|
+
return [
|
|
15
|
+
`<div style="min-width:95px">`,
|
|
16
|
+
`<a href="#vehicle-${pumpNo}">${pumpNo}</a>`,
|
|
17
|
+
feature
|
|
18
|
+
? `<span style="background:${feature.color};margin-left:4px;padding:0 2px;color:#000">${feature.label}</span>`
|
|
19
|
+
: "",
|
|
20
|
+
show ? ` (${escapeHtml(home ?? "E")})` : "",
|
|
21
|
+
`</div>`,
|
|
22
|
+
].join("");
|
|
23
|
+
}
|
|
24
|
+
function bookingTooltip(data, booking, point) {
|
|
25
|
+
let pump = data.pumps.find((candidate) => candidate.ObjectNo === point.objectNo);
|
|
26
|
+
let { show, home } = getPumpHome(pump ?? { LocationID: null }, data.plants, data.merged);
|
|
27
|
+
let plant = getBookingPlant(booking, data.merged);
|
|
28
|
+
let vehicle = `${getLocalizedString("Vehicle")} ${point.objectNo}`;
|
|
29
|
+
if (show)
|
|
30
|
+
vehicle += ` (${home === null ? getLocalizedString("external") : localize `from plant ${home}`})`;
|
|
31
|
+
let callOff = `${getLocalizedString("Call-off")} ${booking.CallOffID}`;
|
|
32
|
+
if (plant !== null)
|
|
33
|
+
callOff += ` (${getLocalizedString("Plant")}: ${plant})`;
|
|
34
|
+
return `<div style="font-size:10px">
|
|
35
|
+
<div>${vehicle}</div>
|
|
36
|
+
<div>${getLocalizedString("Pumping at")} ${formatTime(point.x)} - ${formatTime(point.x2)}</div>
|
|
37
|
+
<div style="color:var(--ds-color-info-text-subtle)">
|
|
38
|
+
<div>${callOff}</div>
|
|
39
|
+
<div>${escapeHtml(booking.CustomerName)}</div>
|
|
40
|
+
<div>${escapeHtml(booking.Site)}</div>
|
|
41
|
+
</div>
|
|
42
|
+
</div>`;
|
|
43
|
+
}
|
|
44
|
+
export function getChartOptions(data, settings) {
|
|
45
|
+
let { date, minOffset, maxOffset, readOnly, onMove } = settings;
|
|
46
|
+
let midnight = date.getTime();
|
|
47
|
+
let min = midnight + minOffset * HOUR;
|
|
48
|
+
let max = midnight + maxOffset * HOUR;
|
|
49
|
+
let categories = data.pumps.map((pump) => pump.ObjectNo);
|
|
50
|
+
let bookings = new Map(data.bookings.map((row) => [`${row.PlantID}-${row.CallOffID}`, row]));
|
|
51
|
+
let pumpTimes = data.bookings.map((row) => {
|
|
52
|
+
let color = row.IndirectBooking
|
|
53
|
+
? barColor("#bbb", 0.4)
|
|
54
|
+
: barColor(data.merged ? plantColor(data.colorIndex, row.PlantID) : PLANT_COLORS[0], 0.6);
|
|
55
|
+
return {
|
|
56
|
+
y: categories.indexOf(row.ObjectNo),
|
|
57
|
+
x: row.PumpStart.getTime(),
|
|
58
|
+
x2: row.PumpEnd.getTime(),
|
|
59
|
+
bookingKey: `${row.PlantID}-${row.CallOffID}`,
|
|
60
|
+
objectNo: row.ObjectNo,
|
|
61
|
+
...color,
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
let outOfService = data.outOfService.map((row) => ({
|
|
65
|
+
y: categories.indexOf(row.ObjectNo),
|
|
66
|
+
x: row.FromDateTime.getTime(),
|
|
67
|
+
x2: row.ToDateTime.getTime(),
|
|
68
|
+
caption: row.Comment,
|
|
69
|
+
...barColor("#ff9999", 0.6),
|
|
70
|
+
}));
|
|
71
|
+
let subtitle = data.merged
|
|
72
|
+
? data.plants
|
|
73
|
+
.map((plant) => `<span style="color:${plantColor(data.colorIndex, plant.PlantID)}">●</span> ${plant.PlantID} - ${escapeHtml(plant.Description)}`)
|
|
74
|
+
.join(" ")
|
|
75
|
+
: `${data.plants[0].PlantID} - ${escapeHtml(data.plants[0].Description)}`;
|
|
76
|
+
let band = (from, to) => ({ color: "var(--ds-color-neutral-background-tinted)", from, to });
|
|
77
|
+
return {
|
|
78
|
+
chart: {
|
|
79
|
+
type: "xrange",
|
|
80
|
+
backgroundColor: "transparent",
|
|
81
|
+
zooming: { type: "x" },
|
|
82
|
+
height: getChartHeight(categories.length, data.merged),
|
|
83
|
+
marginTop: data.merged ? 100 : 70,
|
|
84
|
+
marginBottom: 40,
|
|
85
|
+
},
|
|
86
|
+
accessibility: { enabled: false },
|
|
87
|
+
credits: { enabled: false },
|
|
88
|
+
title: { text: undefined },
|
|
89
|
+
subtitle: { useHTML: true, text: subtitle },
|
|
90
|
+
xAxis: [
|
|
91
|
+
{
|
|
92
|
+
type: "datetime",
|
|
93
|
+
min,
|
|
94
|
+
max,
|
|
95
|
+
dateTimeLabelFormats: { hour: "%H", day: "%d.%m" },
|
|
96
|
+
tickInterval: HOUR,
|
|
97
|
+
minorTickInterval: 0.5 * HOUR,
|
|
98
|
+
plotBands: [band(min - 24 * HOUR, midnight + 6 * HOUR), band(midnight + 18 * HOUR, max + 24 * HOUR)],
|
|
99
|
+
plotLines: [
|
|
100
|
+
{
|
|
101
|
+
color: "#ffcc00",
|
|
102
|
+
width: 2,
|
|
103
|
+
dashStyle: "Dot",
|
|
104
|
+
// The bars are wall clock times carried as UTC, so "now" has to be as well.
|
|
105
|
+
value: Date.now() - new Date().getTimezoneOffset() * 60000,
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
},
|
|
109
|
+
{ type: "datetime", linkedTo: 0, opposite: true, dateTimeLabelFormats: { hour: "%H", day: "%d.%m" } },
|
|
110
|
+
],
|
|
111
|
+
yAxis: {
|
|
112
|
+
categories: categories.map(String),
|
|
113
|
+
reversed: true,
|
|
114
|
+
min: 0,
|
|
115
|
+
max: categories.length - 1,
|
|
116
|
+
title: { text: "" },
|
|
117
|
+
tickInterval: 1,
|
|
118
|
+
gridLineColor: "var(--ds-color-neutral-border-subtle)",
|
|
119
|
+
labels: {
|
|
120
|
+
useHTML: true,
|
|
121
|
+
formatter() {
|
|
122
|
+
return pumpLabelHtml(data, Number(this.value));
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
tooltip: {
|
|
127
|
+
useHTML: true,
|
|
128
|
+
formatter() {
|
|
129
|
+
if (this.series.name !== "PumpTimes")
|
|
130
|
+
return false;
|
|
131
|
+
let booking = bookings.get(this.point.bookingKey);
|
|
132
|
+
return booking ? bookingTooltip(data, booking, this.point) : false;
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
plotOptions: {
|
|
136
|
+
xrange: {
|
|
137
|
+
animation: false,
|
|
138
|
+
grouping: false,
|
|
139
|
+
groupPadding: 0.065,
|
|
140
|
+
colorByPoint: false,
|
|
141
|
+
borderWidth: 1,
|
|
142
|
+
borderColor: "#888",
|
|
143
|
+
borderRadius: 0,
|
|
144
|
+
dataLabels: {
|
|
145
|
+
enabled: true,
|
|
146
|
+
color: "var(--ds-color-neutral-text-default)",
|
|
147
|
+
align: "left",
|
|
148
|
+
y: 2,
|
|
149
|
+
style: { fontWeight: "normal", fontSize: "10px", textOutline: "none" },
|
|
150
|
+
formatter() {
|
|
151
|
+
if (this.series.name !== "PumpTimes")
|
|
152
|
+
return this.point.caption;
|
|
153
|
+
return `${formatTime(this.point.x)}-${formatTime(this.point.x2)}`;
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
dragDrop: {
|
|
157
|
+
draggableX: !readOnly,
|
|
158
|
+
draggableY: !readOnly,
|
|
159
|
+
draggableX1: false,
|
|
160
|
+
draggableX2: false,
|
|
161
|
+
dragPrecisionX: 5 * 60 * 1000,
|
|
162
|
+
liveRedraw: true,
|
|
163
|
+
},
|
|
164
|
+
point: {
|
|
165
|
+
events: {
|
|
166
|
+
dragStart() {
|
|
167
|
+
if (this.series.name !== "PumpTimes" || !bookings.has(this.bookingKey))
|
|
168
|
+
return false;
|
|
169
|
+
},
|
|
170
|
+
drag(event) {
|
|
171
|
+
if (this.series.name !== "PumpTimes" || !event.newPoint)
|
|
172
|
+
return false;
|
|
173
|
+
// The tooltip follows the pump the booking is dragged to.
|
|
174
|
+
if (event.newPoint.y !== undefined)
|
|
175
|
+
this.objectNo = categories[event.newPoint.y];
|
|
176
|
+
},
|
|
177
|
+
drop(event) {
|
|
178
|
+
let booking = bookings.get(this.bookingKey);
|
|
179
|
+
if (this.series.name !== "PumpTimes" || !event.newPoint || !booking) {
|
|
180
|
+
event.preventDefault();
|
|
181
|
+
return false;
|
|
182
|
+
}
|
|
183
|
+
let { x = this.x, x2 = this.x2, y = this.y } = event.newPoint;
|
|
184
|
+
onMove(booking, categories[y], new Date(x), new Date(x2));
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
series: { states: { inactive: { opacity: 1 } } },
|
|
190
|
+
},
|
|
191
|
+
legend: { enabled: false },
|
|
192
|
+
series: [
|
|
193
|
+
{ type: "xrange", name: "PumpTimes", data: pumpTimes, cursor: readOnly ? undefined : "move" },
|
|
194
|
+
{ type: "xrange", name: "OosTimes", data: outOfService },
|
|
195
|
+
],
|
|
196
|
+
};
|
|
197
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { ProcedureAPI } from "@olenbetong/appframe-data";
|
|
2
|
+
export type PlantRecord = {
|
|
3
|
+
PlantID: number;
|
|
4
|
+
Description: string;
|
|
5
|
+
};
|
|
6
|
+
export type PumpRecord = {
|
|
7
|
+
LocationID: number | null;
|
|
8
|
+
ObjectNo: number;
|
|
9
|
+
Model: string | null;
|
|
10
|
+
MixerCapacity: number | null;
|
|
11
|
+
BoomLength: number | null;
|
|
12
|
+
IsTruck: boolean | null;
|
|
13
|
+
IsPump: boolean | null;
|
|
14
|
+
BigPump: boolean | null;
|
|
15
|
+
Telescopic: boolean | null;
|
|
16
|
+
ConveyorBelt: boolean | null;
|
|
17
|
+
};
|
|
18
|
+
export type PumpBookingRecord = {
|
|
19
|
+
/** The plant whose chart shows the booking; for an indirect booking, the plant the pump belongs to. */
|
|
20
|
+
PlantID: number;
|
|
21
|
+
CallOffID: number;
|
|
22
|
+
ObjectNo: number;
|
|
23
|
+
/** A booking from a plant that is not shown, included to show when the pump is busy. */
|
|
24
|
+
IndirectBooking: boolean;
|
|
25
|
+
/** The plant the call-off of an indirect booking belongs to. */
|
|
26
|
+
IndirectPlantID: number | null;
|
|
27
|
+
CustomerName: string | null;
|
|
28
|
+
Qty: number | null;
|
|
29
|
+
DeliveredQty: number | null;
|
|
30
|
+
Site: string | null;
|
|
31
|
+
SiteAddress: string | null;
|
|
32
|
+
SiteCity: string | null;
|
|
33
|
+
SitePosition: string | null;
|
|
34
|
+
PumpStart: Date;
|
|
35
|
+
PumpEnd: Date;
|
|
36
|
+
Comment: string | null;
|
|
37
|
+
HoseLength: number | null;
|
|
38
|
+
ContactInfo: string | null;
|
|
39
|
+
};
|
|
40
|
+
export type OutOfServiceRecord = {
|
|
41
|
+
ObjectNo: number;
|
|
42
|
+
ObjectID: number;
|
|
43
|
+
FromDateTime: Date;
|
|
44
|
+
ToDateTime: Date;
|
|
45
|
+
Comment: string | null;
|
|
46
|
+
};
|
|
47
|
+
export type PumpBookingsParams = {
|
|
48
|
+
PlantIDs: [number][];
|
|
49
|
+
Date: Date;
|
|
50
|
+
PlantsMerged: boolean;
|
|
51
|
+
};
|
|
52
|
+
export type PumpBookingsResult = {
|
|
53
|
+
Table: PlantRecord[];
|
|
54
|
+
Table1: PumpRecord[];
|
|
55
|
+
Table2: PumpBookingRecord[];
|
|
56
|
+
Table3: OutOfServiceRecord[];
|
|
57
|
+
};
|
|
58
|
+
export type MovePumpBookingParams = {
|
|
59
|
+
CallOffID: number;
|
|
60
|
+
PumpNo: number;
|
|
61
|
+
StartDateTime: Date;
|
|
62
|
+
EndDateTime: Date;
|
|
63
|
+
};
|
|
64
|
+
export declare const procPumpBookings: ProcedureAPI<PumpBookingsParams, PumpBookingsResult>;
|
|
65
|
+
export declare const procMovePumpBooking: ProcedureAPI<MovePumpBookingParams, unknown>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ProcedureAPI } from "@olenbetong/appframe-data";
|
|
2
|
+
export const procPumpBookings = new ProcedureAPI({
|
|
3
|
+
procedureId: "astp_Plant_CallOffs_PumpBookings",
|
|
4
|
+
parameters: [
|
|
5
|
+
{ name: "PlantIDs", type: "string", hasDefault: false, required: true },
|
|
6
|
+
{ name: "Date", type: "date", hasDefault: false, required: true },
|
|
7
|
+
{ name: "PlantsMerged", type: "boolean", hasDefault: false, required: true },
|
|
8
|
+
],
|
|
9
|
+
timeout: 30000,
|
|
10
|
+
});
|
|
11
|
+
export const procMovePumpBooking = new ProcedureAPI({
|
|
12
|
+
procedureId: "astp_Plant_CallOffs_MovePumpBooking",
|
|
13
|
+
parameters: [
|
|
14
|
+
{ name: "CallOffID", type: "number", hasDefault: false, required: true },
|
|
15
|
+
{ name: "PumpNo", type: "number", hasDefault: false, required: true },
|
|
16
|
+
{ name: "StartDateTime", type: "date", hasDefault: false, required: true },
|
|
17
|
+
{ name: "EndDateTime", type: "date", hasDefault: false, required: true },
|
|
18
|
+
],
|
|
19
|
+
timeout: 30000,
|
|
20
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.ObPumping{padding-block:.5rem}.ObPumping-options{display:flex;gap:.5rem 1rem;justify-content:flex-end;position:sticky;top:0;z-index:1;padding:5px;background-color:var(--ds-color-neutral-background-default)}.ObPumping-status{position:absolute;inset-block:0;inset-inline-start:5px;display:flex;align-items:center;pointer-events:none}.ObPumping-chart .highcharts-container{color-scheme:inherit}.ObPumping-chart a{color:var(--ds-color-info-text-subtle)}.ObPumping-legend{color:var(--ds-color-neutral-text-subtle)}.ObPumping hr{border:0;border-block-start:1px solid var(--ds-color-neutral-border-subtle)}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import "highcharts/modules/xrange";
|
|
2
|
+
import "highcharts/modules/draggable-points";
|
|
3
|
+
import type { Ref } from "react";
|
|
4
|
+
import "./index.css";
|
|
5
|
+
export type PumpingHandle = {
|
|
6
|
+
/** Fetches the data again, keeping the zoom. */
|
|
7
|
+
reload: () => void;
|
|
8
|
+
/** Sets the hours shown around the day. An undefined offset forgets the stored one. */
|
|
9
|
+
setOffsets: (min?: number, max?: number) => void;
|
|
10
|
+
};
|
|
11
|
+
export type PumpingProps = {
|
|
12
|
+
plants: number[];
|
|
13
|
+
/** Midnight UTC of the day to show. */
|
|
14
|
+
date: Date;
|
|
15
|
+
readOnly?: boolean;
|
|
16
|
+
/** Prefix of the settings in localStorage. */
|
|
17
|
+
storageKey: string;
|
|
18
|
+
/** Called after the charts have drawn, when the height of the page may have changed. */
|
|
19
|
+
onRendered?: () => void;
|
|
20
|
+
ref?: Ref<PumpingHandle>;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* The pump bookings per pump through a day, one chart per plant or one for all of them. Grey bars
|
|
24
|
+
* are bookings from other plants, which show when a pump is busy. Bookings can be dragged to another
|
|
25
|
+
* time or pump unless `readOnly` is set.
|
|
26
|
+
*/
|
|
27
|
+
export declare function Pumping({ plants, date, readOnly, storageKey, onRendered, ref }: PumpingProps): import("react").JSX.Element;
|