@optifye/dashboard-core 6.12.42 → 6.12.44
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/index.d.mts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +115 -32
- package/dist/index.mjs +115 -32
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -2771,6 +2771,11 @@ interface UseDashboardMetricsProps {
|
|
|
2771
2771
|
* Visible workspace and KPI payloads remain scoped to `lineIds`.
|
|
2772
2772
|
*/
|
|
2773
2773
|
blueComparisonLineIds?: string[];
|
|
2774
|
+
/**
|
|
2775
|
+
* Optional complete line set used only to hydrate line-selector signal dots.
|
|
2776
|
+
* Visible workspace and KPI payloads remain scoped to `lineIds`.
|
|
2777
|
+
*/
|
|
2778
|
+
selectorLineIds?: string[];
|
|
2774
2779
|
/**
|
|
2775
2780
|
* Optional callback invoked when underlying line metrics data might have changed,
|
|
2776
2781
|
* suggesting that related components (like a Line KPI display) might need to refresh.
|
|
@@ -2832,10 +2837,11 @@ interface DashboardMetricsMetadata {
|
|
|
2832
2837
|
* }
|
|
2833
2838
|
* ```
|
|
2834
2839
|
*/
|
|
2835
|
-
declare const useDashboardMetrics: ({ onLineMetricsUpdate, lineId, lineIds, blueComparisonLineIds, userAccessibleLineIds, enabled, }: UseDashboardMetricsProps) => {
|
|
2840
|
+
declare const useDashboardMetrics: ({ onLineMetricsUpdate, lineId, lineIds, blueComparisonLineIds, selectorLineIds, userAccessibleLineIds, enabled, }: UseDashboardMetricsProps) => {
|
|
2836
2841
|
workspaceMetrics: WorkspaceMetrics[];
|
|
2837
2842
|
blueComparisonWorkspaceMetrics: WorkspaceMetrics[];
|
|
2838
2843
|
lineMetrics: OverviewLineMetric[];
|
|
2844
|
+
selectorLineMetrics: OverviewLineMetric[];
|
|
2839
2845
|
efficiencyLegend: EfficiencyLegendUpdate;
|
|
2840
2846
|
metadata: DashboardMetricsMetadata | undefined;
|
|
2841
2847
|
isLoading: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -2771,6 +2771,11 @@ interface UseDashboardMetricsProps {
|
|
|
2771
2771
|
* Visible workspace and KPI payloads remain scoped to `lineIds`.
|
|
2772
2772
|
*/
|
|
2773
2773
|
blueComparisonLineIds?: string[];
|
|
2774
|
+
/**
|
|
2775
|
+
* Optional complete line set used only to hydrate line-selector signal dots.
|
|
2776
|
+
* Visible workspace and KPI payloads remain scoped to `lineIds`.
|
|
2777
|
+
*/
|
|
2778
|
+
selectorLineIds?: string[];
|
|
2774
2779
|
/**
|
|
2775
2780
|
* Optional callback invoked when underlying line metrics data might have changed,
|
|
2776
2781
|
* suggesting that related components (like a Line KPI display) might need to refresh.
|
|
@@ -2832,10 +2837,11 @@ interface DashboardMetricsMetadata {
|
|
|
2832
2837
|
* }
|
|
2833
2838
|
* ```
|
|
2834
2839
|
*/
|
|
2835
|
-
declare const useDashboardMetrics: ({ onLineMetricsUpdate, lineId, lineIds, blueComparisonLineIds, userAccessibleLineIds, enabled, }: UseDashboardMetricsProps) => {
|
|
2840
|
+
declare const useDashboardMetrics: ({ onLineMetricsUpdate, lineId, lineIds, blueComparisonLineIds, selectorLineIds, userAccessibleLineIds, enabled, }: UseDashboardMetricsProps) => {
|
|
2836
2841
|
workspaceMetrics: WorkspaceMetrics[];
|
|
2837
2842
|
blueComparisonWorkspaceMetrics: WorkspaceMetrics[];
|
|
2838
2843
|
lineMetrics: OverviewLineMetric[];
|
|
2844
|
+
selectorLineMetrics: OverviewLineMetric[];
|
|
2839
2845
|
efficiencyLegend: EfficiencyLegendUpdate;
|
|
2840
2846
|
metadata: DashboardMetricsMetadata | undefined;
|
|
2841
2847
|
isLoading: boolean;
|
package/dist/index.js
CHANGED
|
@@ -14926,12 +14926,14 @@ var logDebug = (...args) => {
|
|
|
14926
14926
|
if (!DEBUG_DASHBOARD_LOGS) return;
|
|
14927
14927
|
console.log(...args);
|
|
14928
14928
|
};
|
|
14929
|
-
var buildMetricsScopeKey = (lineId, lineIds, blueComparisonLineIds) => {
|
|
14929
|
+
var buildMetricsScopeKey = (lineId, lineIds, blueComparisonLineIds, selectorLineIds) => {
|
|
14930
14930
|
const normalizedLineIds = Array.from(new Set((lineIds || []).filter(Boolean))).sort();
|
|
14931
14931
|
const normalizedBlueComparisonLineIds = Array.from(new Set((blueComparisonLineIds || []).filter(Boolean))).sort();
|
|
14932
|
+
const normalizedSelectorLineIds = Array.from(new Set((selectorLineIds || []).filter(Boolean))).sort();
|
|
14932
14933
|
const lineKey = normalizedLineIds.length > 0 ? normalizedLineIds.join(",") : lineId;
|
|
14933
14934
|
const comparisonKey = normalizedBlueComparisonLineIds.length > 0 ? normalizedBlueComparisonLineIds.join(",") : lineKey;
|
|
14934
|
-
|
|
14935
|
+
const selectorKey = normalizedSelectorLineIds.length > 0 ? normalizedSelectorLineIds.join(",") : "";
|
|
14936
|
+
return `${lineId}|${lineKey}|blue:${comparisonKey}|selector:${selectorKey}`;
|
|
14935
14937
|
};
|
|
14936
14938
|
var parseEfficiencyLegend = (legend) => {
|
|
14937
14939
|
if (!legend) return null;
|
|
@@ -14954,6 +14956,7 @@ var useDashboardMetrics = ({
|
|
|
14954
14956
|
lineId,
|
|
14955
14957
|
lineIds,
|
|
14956
14958
|
blueComparisonLineIds,
|
|
14959
|
+
selectorLineIds,
|
|
14957
14960
|
userAccessibleLineIds,
|
|
14958
14961
|
enabled = true
|
|
14959
14962
|
}) => {
|
|
@@ -14980,6 +14983,10 @@ var useDashboardMetrics = ({
|
|
|
14980
14983
|
() => Array.from(new Set((blueComparisonLineIds || []).filter(Boolean))),
|
|
14981
14984
|
[blueComparisonLineIds]
|
|
14982
14985
|
);
|
|
14986
|
+
const normalizedSelectorLineIds = React147.useMemo(
|
|
14987
|
+
() => Array.from(new Set((selectorLineIds || []).filter(Boolean))),
|
|
14988
|
+
[selectorLineIds]
|
|
14989
|
+
);
|
|
14983
14990
|
const { shiftConfig: staticShiftConfig } = useDashboardConfig();
|
|
14984
14991
|
const {
|
|
14985
14992
|
shiftConfigMap: multiLineShiftConfigMap,
|
|
@@ -15015,9 +15022,9 @@ var useDashboardMetrics = ({
|
|
|
15015
15022
|
const configuredLineMetricsTable = databaseConfig?.tables?.lineMetrics ?? "line_metrics";
|
|
15016
15023
|
const schema = databaseConfig?.schema ?? "public";
|
|
15017
15024
|
const supabase = useSupabase();
|
|
15018
|
-
const [metrics2, setMetrics] = React147.useState({ workspaceMetrics: [], lineMetrics: [] });
|
|
15025
|
+
const [metrics2, setMetrics] = React147.useState({ workspaceMetrics: [], lineMetrics: [], selectorLineMetrics: [] });
|
|
15019
15026
|
const [metricsLineId, setMetricsLineId] = React147.useState(lineId ?? null);
|
|
15020
|
-
const [metricsScopeKey, setMetricsScopeKey] = React147.useState(() => buildMetricsScopeKey(lineId, lineIds, blueComparisonLineIds));
|
|
15027
|
+
const [metricsScopeKey, setMetricsScopeKey] = React147.useState(() => buildMetricsScopeKey(lineId, lineIds, blueComparisonLineIds, selectorLineIds));
|
|
15021
15028
|
const [isLoading, setIsLoading] = React147.useState(true);
|
|
15022
15029
|
const [error, setError] = React147.useState(null);
|
|
15023
15030
|
const lineIdRef = React147.useRef(lineId);
|
|
@@ -15036,6 +15043,7 @@ var useDashboardMetrics = ({
|
|
|
15036
15043
|
const configuredLineIdsRef = React147.useRef(configuredLineIds);
|
|
15037
15044
|
const userAccessibleLineIdsRef = React147.useRef(userAccessibleLineIds);
|
|
15038
15045
|
const explicitLineIdsRef = React147.useRef(lineIds);
|
|
15046
|
+
const selectorLineIdsRef = React147.useRef(selectorLineIds);
|
|
15039
15047
|
React147.useEffect(() => {
|
|
15040
15048
|
onLineMetricsUpdateRef.current = onLineMetricsUpdate;
|
|
15041
15049
|
}, [onLineMetricsUpdate]);
|
|
@@ -15054,6 +15062,9 @@ var useDashboardMetrics = ({
|
|
|
15054
15062
|
React147.useEffect(() => {
|
|
15055
15063
|
explicitLineIdsRef.current = lineIds;
|
|
15056
15064
|
}, [lineIds]);
|
|
15065
|
+
React147.useEffect(() => {
|
|
15066
|
+
selectorLineIdsRef.current = selectorLineIds;
|
|
15067
|
+
}, [selectorLineIds]);
|
|
15057
15068
|
const companySpecificMetricsTable = React147.useMemo(
|
|
15058
15069
|
() => getCompanyMetricsTableName(entityConfig.companyId, "performance_metrics"),
|
|
15059
15070
|
[entityConfig.companyId]
|
|
@@ -15062,9 +15073,10 @@ var useDashboardMetrics = ({
|
|
|
15062
15073
|
() => buildMetricsScopeKey(
|
|
15063
15074
|
lineId,
|
|
15064
15075
|
isFactoryView ? targetFactoryLineIds : void 0,
|
|
15065
|
-
normalizedBlueComparisonLineIds.length ? normalizedBlueComparisonLineIds : void 0
|
|
15076
|
+
normalizedBlueComparisonLineIds.length ? normalizedBlueComparisonLineIds : void 0,
|
|
15077
|
+
normalizedSelectorLineIds.length ? normalizedSelectorLineIds : void 0
|
|
15066
15078
|
),
|
|
15067
|
-
[isFactoryView, lineId, targetFactoryLineIds, normalizedBlueComparisonLineIds]
|
|
15079
|
+
[isFactoryView, lineId, targetFactoryLineIds, normalizedBlueComparisonLineIds, normalizedSelectorLineIds]
|
|
15068
15080
|
);
|
|
15069
15081
|
React147.useEffect(() => {
|
|
15070
15082
|
lineIdRef.current = lineId;
|
|
@@ -15096,13 +15108,15 @@ var useDashboardMetrics = ({
|
|
|
15096
15108
|
const targetLineIdsKey = targetLineIds.slice().sort().join(",");
|
|
15097
15109
|
const effectiveBlueComparisonLineIds = normalizedBlueComparisonLineIds.length ? normalizedBlueComparisonLineIds : targetLineIds;
|
|
15098
15110
|
const blueComparisonLineIdsKey = effectiveBlueComparisonLineIds.slice().sort().join(",");
|
|
15111
|
+
const selectorLineIdsKey = normalizedSelectorLineIds.slice().sort().join(",");
|
|
15099
15112
|
const usesShiftGroups = isFactory && shiftGroups.length > 0;
|
|
15100
15113
|
const singleShiftDetails = usesShiftGroups ? null : shiftConfig ? getCurrentShift(defaultTimezone, shiftConfig) : shiftGroups.length === 1 ? { date: shiftGroups[0].date, shiftId: shiftGroups[0].shiftId } : getCurrentShift(defaultTimezone, staticShiftConfig);
|
|
15101
|
-
const fetchKey = usesShiftGroups ? `factory|${companyId || "unknown"}|${shiftGroupsKey}|blue:${blueComparisonLineIdsKey}` : isFactory ? `factory|${companyId || "unknown"}|${singleShiftDetails?.date}|${singleShiftDetails?.shiftId}|${targetLineIdsKey}|blue:${blueComparisonLineIdsKey}` : `${currentLineIdToUse}|${companyId || "unknown"}|${singleShiftDetails?.date}|${singleShiftDetails?.shiftId}|blue:${blueComparisonLineIdsKey}`;
|
|
15114
|
+
const fetchKey = usesShiftGroups ? `factory|${companyId || "unknown"}|${shiftGroupsKey}|blue:${blueComparisonLineIdsKey}|selector:${selectorLineIdsKey}` : isFactory ? `factory|${companyId || "unknown"}|${singleShiftDetails?.date}|${singleShiftDetails?.shiftId}|${targetLineIdsKey}|blue:${blueComparisonLineIdsKey}|selector:${selectorLineIdsKey}` : `${currentLineIdToUse}|${companyId || "unknown"}|${singleShiftDetails?.date}|${singleShiftDetails?.shiftId}|blue:${blueComparisonLineIdsKey}|selector:${selectorLineIdsKey}`;
|
|
15102
15115
|
const responseScopeKey = buildMetricsScopeKey(
|
|
15103
15116
|
currentLineIdToUse,
|
|
15104
15117
|
isFactory ? targetLineIds : void 0,
|
|
15105
|
-
normalizedBlueComparisonLineIds.length ? normalizedBlueComparisonLineIds : void 0
|
|
15118
|
+
normalizedBlueComparisonLineIds.length ? normalizedBlueComparisonLineIds : void 0,
|
|
15119
|
+
normalizedSelectorLineIds.length ? normalizedSelectorLineIds : void 0
|
|
15106
15120
|
);
|
|
15107
15121
|
logDebug("[useDashboardMetrics] Fetch key details:", {
|
|
15108
15122
|
isFactory,
|
|
@@ -15134,6 +15148,7 @@ var useDashboardMetrics = ({
|
|
|
15134
15148
|
workspaceMetrics: [],
|
|
15135
15149
|
blueComparisonWorkspaceMetrics: [],
|
|
15136
15150
|
lineMetrics: [],
|
|
15151
|
+
selectorLineMetrics: [],
|
|
15137
15152
|
metadata: void 0,
|
|
15138
15153
|
efficiencyLegend: DEFAULT_EFFICIENCY_LEGEND
|
|
15139
15154
|
});
|
|
@@ -15145,6 +15160,7 @@ var useDashboardMetrics = ({
|
|
|
15145
15160
|
let allWorkspaceMetrics = [];
|
|
15146
15161
|
let allBlueComparisonWorkspaceMetrics = [];
|
|
15147
15162
|
let allLineMetrics = [];
|
|
15163
|
+
let allSelectorLineMetrics = [];
|
|
15148
15164
|
let hasFlowBuffers = false;
|
|
15149
15165
|
let idleTimeVlmByLine = {};
|
|
15150
15166
|
let efficiencyLegend;
|
|
@@ -15154,7 +15170,8 @@ var useDashboardMetrics = ({
|
|
|
15154
15170
|
const buildMetricsEndpoint = (params) => {
|
|
15155
15171
|
const lineIdsParam = isFactory ? `line_ids=${params.groupLineIds.join(",")}` : `line_id=${params.groupLineIds[0]}`;
|
|
15156
15172
|
const blueComparisonParam = effectiveBlueComparisonLineIds.length ? `&blue_comparison_line_ids=${effectiveBlueComparisonLineIds.join(",")}` : "";
|
|
15157
|
-
|
|
15173
|
+
const selectorParam = normalizedSelectorLineIds.length ? `&selector_line_ids=${encodeURIComponent(normalizedSelectorLineIds.join(","))}` : "";
|
|
15174
|
+
return `/api/dashboard/metrics?${lineIdsParam}${blueComparisonParam}${selectorParam}&date=${params.date}&shift_id=${params.shiftId}&company_id=${companyId}${forceParam}${qaGreenStreakParams}`;
|
|
15158
15175
|
};
|
|
15159
15176
|
if (usesShiftGroups) {
|
|
15160
15177
|
logDebug("[useDashboardMetrics] Factory view shift groups fetch:", {
|
|
@@ -15210,6 +15227,9 @@ var useDashboardMetrics = ({
|
|
|
15210
15227
|
if (result.line_metrics) {
|
|
15211
15228
|
allLineMetrics.push(...result.line_metrics);
|
|
15212
15229
|
}
|
|
15230
|
+
if (result.selector_line_metrics) {
|
|
15231
|
+
allSelectorLineMetrics.push(...result.selector_line_metrics);
|
|
15232
|
+
}
|
|
15213
15233
|
});
|
|
15214
15234
|
if (allBlueComparisonWorkspaceMetrics.length === 0) {
|
|
15215
15235
|
allBlueComparisonWorkspaceMetrics = allWorkspaceMetrics;
|
|
@@ -15253,6 +15273,7 @@ var useDashboardMetrics = ({
|
|
|
15253
15273
|
allWorkspaceMetrics = backendData.workspace_metrics || [];
|
|
15254
15274
|
allBlueComparisonWorkspaceMetrics = backendData.blue_comparison_workspace_metrics || allWorkspaceMetrics;
|
|
15255
15275
|
allLineMetrics = backendData.line_metrics || [];
|
|
15276
|
+
allSelectorLineMetrics = backendData.selector_line_metrics || [];
|
|
15256
15277
|
hasFlowBuffers = Boolean(backendData?.metadata?.has_flow_buffers);
|
|
15257
15278
|
if (backendData?.metadata?.idle_time_vlm_by_line && typeof backendData.metadata.idle_time_vlm_by_line === "object") {
|
|
15258
15279
|
idleTimeVlmByLine = backendData.metadata.idle_time_vlm_by_line;
|
|
@@ -15284,6 +15305,7 @@ var useDashboardMetrics = ({
|
|
|
15284
15305
|
workspaceMetrics: transformedWorkspaceData,
|
|
15285
15306
|
blueComparisonWorkspaceMetrics: transformedBlueComparisonWorkspaceData.length ? transformedBlueComparisonWorkspaceData : transformedWorkspaceData,
|
|
15286
15307
|
lineMetrics: allLineMetrics || [],
|
|
15308
|
+
selectorLineMetrics: allSelectorLineMetrics || [],
|
|
15287
15309
|
metadata: { hasFlowBuffers, idleTimeVlmByLine },
|
|
15288
15310
|
efficiencyLegend: efficiencyLegend ?? DEFAULT_EFFICIENCY_LEGEND
|
|
15289
15311
|
};
|
|
@@ -15354,6 +15376,7 @@ var useDashboardMetrics = ({
|
|
|
15354
15376
|
configuredLineIds,
|
|
15355
15377
|
targetFactoryLineIds,
|
|
15356
15378
|
normalizedBlueComparisonLineIds,
|
|
15379
|
+
normalizedSelectorLineIds,
|
|
15357
15380
|
isFactoryView,
|
|
15358
15381
|
multiLineShiftConfigMap,
|
|
15359
15382
|
staticShiftConfig,
|
|
@@ -15470,7 +15493,8 @@ var useDashboardMetrics = ({
|
|
|
15470
15493
|
const isFactory = lineId === (entityConfig.factoryViewId || "factory");
|
|
15471
15494
|
if (isFactory && shiftGroups.length === 0) return null;
|
|
15472
15495
|
const shiftGroupsKeyPart = isFactory ? shiftGroups.map((g) => `${g.date}-${g.shiftId}-${g.lineIds.join("_")}`).join("|") : operationalShiftKey;
|
|
15473
|
-
|
|
15496
|
+
const selectorLineIdsKeyPart = (selectorLineIds || []).filter(Boolean).slice().sort().join(",");
|
|
15497
|
+
return `${lineId}|${entityConfig.companyId}|${shiftGroupsKeyPart}|selector:${selectorLineIdsKeyPart}`;
|
|
15474
15498
|
}, [
|
|
15475
15499
|
enabled,
|
|
15476
15500
|
supabase,
|
|
@@ -15480,7 +15504,8 @@ var useDashboardMetrics = ({
|
|
|
15480
15504
|
shiftLoading,
|
|
15481
15505
|
isTimezoneLoading,
|
|
15482
15506
|
shiftGroups,
|
|
15483
|
-
operationalShiftKey
|
|
15507
|
+
operationalShiftKey,
|
|
15508
|
+
selectorLineIds
|
|
15484
15509
|
]);
|
|
15485
15510
|
React147.useEffect(() => {
|
|
15486
15511
|
const currentLineIdToUse = lineIdRef.current;
|
|
@@ -15517,7 +15542,7 @@ var useDashboardMetrics = ({
|
|
|
15517
15542
|
});
|
|
15518
15543
|
const targetFactoryLineIdsForSubscriptions = explicitLineIdsRef.current !== void 0 ? explicitLineIdsRef.current : currentUserAccessibleLineIds !== void 0 ? currentUserAccessibleLineIds : currentConfiguredLineIds;
|
|
15519
15544
|
const targetFactoryLineIdSet = new Set(
|
|
15520
|
-
|
|
15545
|
+
[...targetFactoryLineIdsForSubscriptions || [], ...selectorLineIdsRef.current || []].filter(Boolean)
|
|
15521
15546
|
);
|
|
15522
15547
|
currentShiftGroups.forEach((group, index) => {
|
|
15523
15548
|
const groupLineIds = group.lineIds.filter(
|
|
@@ -15687,7 +15712,10 @@ var useDashboardMetrics = ({
|
|
|
15687
15712
|
const currentShiftDetails = shiftConfig ? getCurrentShift(defaultTimezone, shiftConfig) : getCurrentShift(defaultTimezone, staticShiftConfig);
|
|
15688
15713
|
const operationalDateForSubscription = currentShiftDetails.date;
|
|
15689
15714
|
const targetLineIds = isFactory ? explicitLineIdsRef.current || currentUserAccessibleLineIds || currentConfiguredLineIds : [currentLineIdToUse];
|
|
15690
|
-
const filteredLineIds =
|
|
15715
|
+
const filteredLineIds = Array.from(/* @__PURE__ */ new Set([
|
|
15716
|
+
...targetLineIds,
|
|
15717
|
+
...selectorLineIdsRef.current || []
|
|
15718
|
+
])).filter((id3) => id3 && id3 !== factoryViewIdentifier);
|
|
15691
15719
|
if (filteredLineIds.length === 0) {
|
|
15692
15720
|
logDebug("[useDashboardMetrics] Realtime setup skipped: no line IDs after filtering", {
|
|
15693
15721
|
targetLineIds,
|
|
@@ -15794,11 +15822,12 @@ var useDashboardMetrics = ({
|
|
|
15794
15822
|
const isCurrentScopeResolved = metricsScopeKey === requestedScopeKey;
|
|
15795
15823
|
const hasLastGoodMetrics = metrics2.workspaceMetrics.length > 0 || metrics2.lineMetrics.length > 0;
|
|
15796
15824
|
const canReuseLastGoodMetrics = hasLastGoodMetrics && !isCurrentScopeResolved && (isLoading || !!error);
|
|
15797
|
-
const safeMetrics = isCurrentScopeResolved || canReuseLastGoodMetrics ? metrics2 : { workspaceMetrics: [], blueComparisonWorkspaceMetrics: [], lineMetrics: [], metadata: void 0, efficiencyLegend: DEFAULT_EFFICIENCY_LEGEND };
|
|
15825
|
+
const safeMetrics = isCurrentScopeResolved || canReuseLastGoodMetrics ? metrics2 : { workspaceMetrics: [], blueComparisonWorkspaceMetrics: [], lineMetrics: [], selectorLineMetrics: [], metadata: void 0, efficiencyLegend: DEFAULT_EFFICIENCY_LEGEND };
|
|
15798
15826
|
return {
|
|
15799
15827
|
workspaceMetrics: safeMetrics?.workspaceMetrics || [],
|
|
15800
15828
|
blueComparisonWorkspaceMetrics: safeMetrics?.blueComparisonWorkspaceMetrics || safeMetrics?.workspaceMetrics || [],
|
|
15801
15829
|
lineMetrics: safeMetrics?.lineMetrics || [],
|
|
15830
|
+
selectorLineMetrics: safeMetrics?.selectorLineMetrics || [],
|
|
15802
15831
|
efficiencyLegend: safeMetrics?.efficiencyLegend || DEFAULT_EFFICIENCY_LEGEND,
|
|
15803
15832
|
metadata: safeMetrics?.metadata,
|
|
15804
15833
|
isLoading: enabled ? isLoading || !isCurrentScopeResolved && !canReuseLastGoodMetrics : false,
|
|
@@ -39690,10 +39719,11 @@ var WorkspaceMetricCardsImpl = ({
|
|
|
39690
39719
|
}
|
|
39691
39720
|
return null;
|
|
39692
39721
|
}, [activeSku, skuAware, activeSkuId, liveSkuId, skuBreakdown]);
|
|
39693
|
-
const
|
|
39694
|
-
const
|
|
39695
|
-
const
|
|
39696
|
-
const
|
|
39722
|
+
const metricSku = displaySku;
|
|
39723
|
+
const pphValue = metricSku ? metricSku.avg_pph : workspace.avg_pph;
|
|
39724
|
+
const pphThreshold = metricSku ? metricSku.pph_threshold : workspace.pph_threshold;
|
|
39725
|
+
const cycleValue = metricSku ? metricSku.avg_cycle_time : workspace.avg_cycle_time;
|
|
39726
|
+
const cycleStandard = metricSku ? metricSku.ideal_cycle_time : workspace.ideal_cycle_time;
|
|
39697
39727
|
const displaySkuLabel = displaySku ? getSkuDisplayName(displaySku) : "";
|
|
39698
39728
|
const efficiencyValue = workspace.avg_efficiency || 0;
|
|
39699
39729
|
const efficiencyTarget = effectiveLegend.green_min;
|
|
@@ -55798,8 +55828,9 @@ var WorkspaceCycleTimeMetricCards = ({
|
|
|
55798
55828
|
}
|
|
55799
55829
|
return null;
|
|
55800
55830
|
}, [activeSku, skuAware, activeSkuId, liveSkuId, skuBreakdown]);
|
|
55801
|
-
const
|
|
55802
|
-
const
|
|
55831
|
+
const metricSku = displaySku;
|
|
55832
|
+
const cycleValue = metricSku ? metricSku.avg_cycle_time : workspace.avg_cycle_time;
|
|
55833
|
+
const cycleStandard = metricSku ? metricSku.ideal_cycle_time : workspace.ideal_cycle_time;
|
|
55803
55834
|
const displaySkuLabel = displaySku ? getSkuDisplayName(displaySku) : "";
|
|
55804
55835
|
const efficiencyValue = workspace.avg_efficiency || 0;
|
|
55805
55836
|
const efficiencyTarget = effectiveLegend.green_min;
|
|
@@ -65681,6 +65712,7 @@ var createEmptyState = () => ({
|
|
|
65681
65712
|
workspaceMetrics: [],
|
|
65682
65713
|
blueComparisonWorkspaceMetrics: [],
|
|
65683
65714
|
lineMetrics: [],
|
|
65715
|
+
selectorLineMetrics: [],
|
|
65684
65716
|
kpiTrend: null,
|
|
65685
65717
|
activeBreaks: [],
|
|
65686
65718
|
videoStreamsByWorkspaceId: {},
|
|
@@ -65694,7 +65726,7 @@ var normalizeMetadata = (metadata) => ({
|
|
|
65694
65726
|
cacheStatus: metadata?.cache_status,
|
|
65695
65727
|
warnings: metadata?.warnings ?? []
|
|
65696
65728
|
});
|
|
65697
|
-
var createResolvedScopeLookup = (resolvedScope, workspaces, blueComparisonWorkspaces) => {
|
|
65729
|
+
var createResolvedScopeLookup = (resolvedScope, workspaces, blueComparisonWorkspaces, selectorLineMetrics) => {
|
|
65698
65730
|
const lookup = /* @__PURE__ */ new Set();
|
|
65699
65731
|
const addEntry = (lineId, date, shiftId) => {
|
|
65700
65732
|
if (!lineId || !date || shiftId === void 0 || shiftId === null) return;
|
|
@@ -65703,11 +65735,13 @@ var createResolvedScopeLookup = (resolvedScope, workspaces, blueComparisonWorksp
|
|
|
65703
65735
|
resolvedScope.forEach((entry) => addEntry(entry.line_id, entry.date, entry.shift_id));
|
|
65704
65736
|
workspaces.forEach((workspace) => addEntry(workspace.line_id, workspace.date, workspace.shift_id));
|
|
65705
65737
|
blueComparisonWorkspaces.forEach((workspace) => addEntry(workspace.line_id, workspace.date, workspace.shift_id));
|
|
65738
|
+
selectorLineMetrics.forEach((lineMetric) => addEntry(lineMetric.line_id, lineMetric.date, lineMetric.shift_id));
|
|
65706
65739
|
return lookup;
|
|
65707
65740
|
};
|
|
65708
65741
|
var useLiveMonitorBootstrap = ({
|
|
65709
65742
|
lineIds,
|
|
65710
65743
|
blueComparisonLineIds,
|
|
65744
|
+
selectorLineIds,
|
|
65711
65745
|
companyId,
|
|
65712
65746
|
enabled = true,
|
|
65713
65747
|
appTimezone,
|
|
@@ -65723,6 +65757,7 @@ var useLiveMonitorBootstrap = ({
|
|
|
65723
65757
|
const effectiveTimezone = appTimezone || "Asia/Kolkata";
|
|
65724
65758
|
const rawLineIdsKey = (lineIds || []).filter(Boolean).join(",");
|
|
65725
65759
|
const rawBlueComparisonLineIdsKey = (blueComparisonLineIds || lineIds || []).filter(Boolean).join(",");
|
|
65760
|
+
const rawSelectorLineIdsKey = (selectorLineIds || []).filter(Boolean).join(",");
|
|
65726
65761
|
const normalizedLineIds = React147.useMemo(
|
|
65727
65762
|
() => Array.from(new Set(rawLineIdsKey ? rawLineIdsKey.split(",") : [])),
|
|
65728
65763
|
[rawLineIdsKey]
|
|
@@ -65731,13 +65766,17 @@ var useLiveMonitorBootstrap = ({
|
|
|
65731
65766
|
() => Array.from(new Set(rawBlueComparisonLineIdsKey ? rawBlueComparisonLineIdsKey.split(",") : [])),
|
|
65732
65767
|
[rawBlueComparisonLineIdsKey]
|
|
65733
65768
|
);
|
|
65769
|
+
const normalizedSelectorLineIds = React147.useMemo(
|
|
65770
|
+
() => Array.from(new Set(rawSelectorLineIdsKey ? rawSelectorLineIdsKey.split(",") : [])),
|
|
65771
|
+
[rawSelectorLineIdsKey]
|
|
65772
|
+
);
|
|
65734
65773
|
const realtimeLineIds = React147.useMemo(
|
|
65735
|
-
() => Array.from(new Set([...normalizedLineIds, ...normalizedBlueComparisonLineIds].filter(Boolean))).sort(),
|
|
65736
|
-
[normalizedLineIds, normalizedBlueComparisonLineIds]
|
|
65774
|
+
() => Array.from(new Set([...normalizedLineIds, ...normalizedBlueComparisonLineIds, ...normalizedSelectorLineIds].filter(Boolean))).sort(),
|
|
65775
|
+
[normalizedLineIds, normalizedBlueComparisonLineIds, normalizedSelectorLineIds]
|
|
65737
65776
|
);
|
|
65738
65777
|
const requestKey = React147.useMemo(
|
|
65739
|
-
() => `${normalizedLineIds.slice().sort().join(",")}|blue:${normalizedBlueComparisonLineIds.slice().sort().join(",")}`,
|
|
65740
|
-
[normalizedLineIds, normalizedBlueComparisonLineIds]
|
|
65778
|
+
() => `${normalizedLineIds.slice().sort().join(",")}|blue:${normalizedBlueComparisonLineIds.slice().sort().join(",")}|selector:${normalizedSelectorLineIds.slice().sort().join(",")}`,
|
|
65779
|
+
[normalizedLineIds, normalizedBlueComparisonLineIds, normalizedSelectorLineIds]
|
|
65741
65780
|
);
|
|
65742
65781
|
const realtimeLineIdsKey = React147.useMemo(() => realtimeLineIds.join(","), [realtimeLineIds]);
|
|
65743
65782
|
const companySpecificMetricsTable = React147.useMemo(
|
|
@@ -65769,6 +65808,9 @@ var useLiveMonitorBootstrap = ({
|
|
|
65769
65808
|
if (normalizedBlueComparisonLineIds.length) {
|
|
65770
65809
|
searchParams.set("blue_comparison_line_ids", normalizedBlueComparisonLineIds.join(","));
|
|
65771
65810
|
}
|
|
65811
|
+
if (normalizedSelectorLineIds.length) {
|
|
65812
|
+
searchParams.set("selector_line_ids", normalizedSelectorLineIds.join(","));
|
|
65813
|
+
}
|
|
65772
65814
|
if (force) {
|
|
65773
65815
|
searchParams.set("force_refresh", "true");
|
|
65774
65816
|
}
|
|
@@ -65802,6 +65844,7 @@ var useLiveMonitorBootstrap = ({
|
|
|
65802
65844
|
company_id: resolvedCompanyId,
|
|
65803
65845
|
line_ids: normalizedLineIds,
|
|
65804
65846
|
blue_comparison_line_ids: normalizedBlueComparisonLineIds,
|
|
65847
|
+
selector_line_ids: normalizedSelectorLineIds,
|
|
65805
65848
|
force_refresh: force,
|
|
65806
65849
|
pathname: typeof window !== "undefined" ? window.location.pathname : "unknown"
|
|
65807
65850
|
}
|
|
@@ -65819,6 +65862,7 @@ var useLiveMonitorBootstrap = ({
|
|
|
65819
65862
|
resolvedCompanyId,
|
|
65820
65863
|
normalizedLineIds,
|
|
65821
65864
|
normalizedBlueComparisonLineIds,
|
|
65865
|
+
normalizedSelectorLineIds,
|
|
65822
65866
|
requestKey
|
|
65823
65867
|
]);
|
|
65824
65868
|
const fetchBootstrapRef = React147.useRef(fetchBootstrap);
|
|
@@ -65930,6 +65974,7 @@ var useLiveMonitorBootstrap = ({
|
|
|
65930
65974
|
workspaceMetrics,
|
|
65931
65975
|
blueComparisonWorkspaceMetrics: blueComparisonWorkspaceMetrics.length ? blueComparisonWorkspaceMetrics : workspaceMetrics,
|
|
65932
65976
|
lineMetrics: rawState.response.line_metrics || [],
|
|
65977
|
+
selectorLineMetrics: rawState.response.selector_line_metrics || [],
|
|
65933
65978
|
kpiTrend: rawState.response.kpi_trend || null,
|
|
65934
65979
|
activeBreaks,
|
|
65935
65980
|
videoStreamsByWorkspaceId,
|
|
@@ -65966,8 +66011,9 @@ var useLiveMonitorBootstrap = ({
|
|
|
65966
66011
|
const realtimeScopeKey = React147.useMemo(() => Array.from(createResolvedScopeLookup(
|
|
65967
66012
|
state.resolvedScope,
|
|
65968
66013
|
state.workspaceMetrics,
|
|
65969
|
-
state.blueComparisonWorkspaceMetrics
|
|
65970
|
-
|
|
66014
|
+
state.blueComparisonWorkspaceMetrics,
|
|
66015
|
+
state.selectorLineMetrics
|
|
66016
|
+
)).sort().join("||"), [state.resolvedScope, state.workspaceMetrics, state.blueComparisonWorkspaceMetrics, state.selectorLineMetrics]);
|
|
65971
66017
|
React147.useEffect(() => {
|
|
65972
66018
|
if (!enabled || !resolvedCompanyId || !realtimeLineIdsKey || !supabase) {
|
|
65973
66019
|
return void 0;
|
|
@@ -66073,6 +66119,7 @@ var useLiveMonitorBootstrap = ({
|
|
|
66073
66119
|
workspaceMetrics: state.workspaceMetrics,
|
|
66074
66120
|
blueComparisonWorkspaceMetrics: state.blueComparisonWorkspaceMetrics,
|
|
66075
66121
|
lineMetrics: state.lineMetrics,
|
|
66122
|
+
selectorLineMetrics: state.selectorLineMetrics,
|
|
66076
66123
|
kpiTrend: state.kpiTrend,
|
|
66077
66124
|
activeBreaks: state.activeBreaks,
|
|
66078
66125
|
videoStreamsByWorkspaceId: state.videoStreamsByWorkspaceId,
|
|
@@ -66587,6 +66634,7 @@ function HomeView({
|
|
|
66587
66634
|
workspaceMetrics: legacyWorkspaceMetrics,
|
|
66588
66635
|
blueComparisonWorkspaceMetrics: legacyMetricsBlueComparisonWorkspaceMetrics,
|
|
66589
66636
|
lineMetrics: legacyLineMetrics,
|
|
66637
|
+
selectorLineMetrics: legacySelectorLineMetrics = [],
|
|
66590
66638
|
efficiencyLegend: legacyEfficiencyLegend,
|
|
66591
66639
|
metadata: legacyMetricsMetadata,
|
|
66592
66640
|
isLoading: legacyMetricsLoading,
|
|
@@ -66597,6 +66645,7 @@ function HomeView({
|
|
|
66597
66645
|
lineId: metricsScopeLineId,
|
|
66598
66646
|
lineIds: selectedLineIds,
|
|
66599
66647
|
blueComparisonLineIds,
|
|
66648
|
+
selectorLineIds: visibleLineIds,
|
|
66600
66649
|
onLineMetricsUpdate: handleLineMetricsUpdate,
|
|
66601
66650
|
userAccessibleLineIds: visibleLineIds,
|
|
66602
66651
|
enabled: shouldEnableMetricsFetch && !isBootstrapMonitorMode
|
|
@@ -66652,6 +66701,7 @@ function HomeView({
|
|
|
66652
66701
|
const bootstrapMonitor = useLiveMonitorBootstrap({
|
|
66653
66702
|
lineIds: selectedLineIds,
|
|
66654
66703
|
blueComparisonLineIds,
|
|
66704
|
+
selectorLineIds: visibleLineIds,
|
|
66655
66705
|
companyId: userCompanyId,
|
|
66656
66706
|
enabled: shouldEnableMetricsFetch && !isLegacyMonitorMode,
|
|
66657
66707
|
appTimezone: timezone,
|
|
@@ -66662,12 +66712,32 @@ function HomeView({
|
|
|
66662
66712
|
const currentWorkspaceMetrics = isBootstrapMonitorMode ? bootstrapMonitor.workspaceMetrics : legacyWorkspaceMetrics;
|
|
66663
66713
|
const currentBlueComparisonWorkspaceMetrics = isBootstrapMonitorMode ? bootstrapMonitor.blueComparisonWorkspaceMetrics : legacyMetricsBlueComparisonWorkspaceMetrics;
|
|
66664
66714
|
const currentLineMetrics = isBootstrapMonitorMode ? bootstrapMonitor.lineMetrics : legacyLineMetrics;
|
|
66715
|
+
const currentSelectorLineMetrics = isBootstrapMonitorMode ? bootstrapMonitor.selectorLineMetrics : legacySelectorLineMetrics;
|
|
66665
66716
|
const currentEfficiencyLegend = isBootstrapMonitorMode ? bootstrapMonitor.efficiencyLegend : legacyEfficiencyLegend;
|
|
66666
66717
|
const currentMetricsMetadata = isBootstrapMonitorMode ? bootstrapMonitor.metadata : legacyMetricsMetadata;
|
|
66667
66718
|
const currentMetricsLoading = isBootstrapMonitorMode ? bootstrapMonitor.isLoading : legacyMetricsLoading;
|
|
66668
66719
|
const currentIsCurrentScopeResolved = isBootstrapMonitorMode ? bootstrapMonitor.isCurrentScopeResolved : legacyIsCurrentScopeResolved;
|
|
66669
66720
|
const currentMetricsError = isBootstrapMonitorMode ? bootstrapMonitor.error : legacyMetricsError;
|
|
66670
66721
|
const currentRefetchMetrics = isBootstrapMonitorMode ? bootstrapMonitor.refetch : refetchLegacyMetrics;
|
|
66722
|
+
const lineSelectorSignalStatusByLine = React147.useMemo(() => {
|
|
66723
|
+
const statusByLine = /* @__PURE__ */ new Map();
|
|
66724
|
+
const legend = currentEfficiencyLegend || DEFAULT_EFFICIENCY_LEGEND;
|
|
66725
|
+
const addRows = (rows) => {
|
|
66726
|
+
(rows || []).forEach((row) => {
|
|
66727
|
+
const lineId = typeof row?.line_id === "string" ? row.line_id : "";
|
|
66728
|
+
if (!lineId || statusByLine.has(lineId)) {
|
|
66729
|
+
return;
|
|
66730
|
+
}
|
|
66731
|
+
const status = getKpiSignalStatus(row?.line_signal, legend);
|
|
66732
|
+
if (status) {
|
|
66733
|
+
statusByLine.set(lineId, status);
|
|
66734
|
+
}
|
|
66735
|
+
});
|
|
66736
|
+
};
|
|
66737
|
+
addRows(currentSelectorLineMetrics);
|
|
66738
|
+
addRows(currentLineMetrics);
|
|
66739
|
+
return statusByLine;
|
|
66740
|
+
}, [currentEfficiencyLegend, currentLineMetrics, currentSelectorLineMetrics]);
|
|
66671
66741
|
const metricsDisplayNames = React147.useMemo(() => {
|
|
66672
66742
|
const nextDisplayNames = {};
|
|
66673
66743
|
currentWorkspaceMetrics.forEach((workspace) => {
|
|
@@ -67525,6 +67595,8 @@ function HomeView({
|
|
|
67525
67595
|
] }),
|
|
67526
67596
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "max-h-56 space-y-0.5 overflow-y-auto pr-1", children: visibleLineIds.map((lineId) => {
|
|
67527
67597
|
const isChecked = pendingSelectedLineIds.includes(lineId);
|
|
67598
|
+
const signalStatus = lineSelectorSignalStatusByLine.get(lineId);
|
|
67599
|
+
const signalDotClass = signalStatus === "stable" ? "bg-green-500" : signalStatus === "warning" ? "bg-yellow-400" : signalStatus === "attention" ? "bg-red-500" : "";
|
|
67528
67600
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
67529
67601
|
"label",
|
|
67530
67602
|
{
|
|
@@ -67549,7 +67621,15 @@ function HomeView({
|
|
|
67549
67621
|
}
|
|
67550
67622
|
}
|
|
67551
67623
|
),
|
|
67552
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: mergedLineNames[lineId] || `Line ${lineId.substring(0, 4)}` })
|
|
67624
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 flex-1 truncate", children: mergedLineNames[lineId] || `Line ${lineId.substring(0, 4)}` }),
|
|
67625
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex h-2.5 w-2.5 flex-shrink-0 items-center justify-center", children: signalStatus ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
67626
|
+
"span",
|
|
67627
|
+
{
|
|
67628
|
+
"data-testid": `line-selector-signal-dot-${lineId}`,
|
|
67629
|
+
className: `h-2 w-2 rounded-full ${signalDotClass}`,
|
|
67630
|
+
"aria-hidden": "true"
|
|
67631
|
+
}
|
|
67632
|
+
) : null })
|
|
67553
67633
|
]
|
|
67554
67634
|
},
|
|
67555
67635
|
lineId
|
|
@@ -67578,6 +67658,7 @@ function HomeView({
|
|
|
67578
67658
|
mergedLineNames,
|
|
67579
67659
|
selectedLineIds,
|
|
67580
67660
|
pendingSelectedLineIds,
|
|
67661
|
+
lineSelectorSignalStatusByLine,
|
|
67581
67662
|
visibleLineIds,
|
|
67582
67663
|
updateSelectedLineIds,
|
|
67583
67664
|
isAllLinesSelection
|
|
@@ -80134,6 +80215,8 @@ var WorkspaceDetailView = ({
|
|
|
80134
80215
|
[workspace?.sku_segments]
|
|
80135
80216
|
);
|
|
80136
80217
|
const activeSkuId = selectedSkuId;
|
|
80218
|
+
const shouldUseLiveSkuForMetricCards = !isHistoricView || Boolean(date) && date === calculatedOperationalDate && parsedShiftId !== void 0 && parsedShiftId === calculatedShiftId;
|
|
80219
|
+
const metricCardLiveSkuId = shouldUseLiveSkuForMetricCards ? liveSkuId : null;
|
|
80137
80220
|
const resolvedLineId = effectiveLineId || workspace?.line_id || cachedDetailedMetrics?.line_id || cachedOverviewMetrics?.line_id || overviewFallback?.line_id;
|
|
80138
80221
|
const { timezone: cycleTimeTimezone } = useTimezone({
|
|
80139
80222
|
lineId: resolvedLineId || void 0,
|
|
@@ -81206,7 +81289,7 @@ var WorkspaceDetailView = ({
|
|
|
81206
81289
|
skuAware: isSkuAware,
|
|
81207
81290
|
skuBreakdown: isSkuAware ? realSkuBreakdown : void 0,
|
|
81208
81291
|
activeSkuId,
|
|
81209
|
-
liveSkuId:
|
|
81292
|
+
liveSkuId: metricCardLiveSkuId
|
|
81210
81293
|
}
|
|
81211
81294
|
) : /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
81212
81295
|
WorkspaceMetricCards,
|
|
@@ -81217,7 +81300,7 @@ var WorkspaceDetailView = ({
|
|
|
81217
81300
|
skuAware: isSkuAware,
|
|
81218
81301
|
skuBreakdown: isSkuAware ? realSkuBreakdown : void 0,
|
|
81219
81302
|
activeSkuId,
|
|
81220
|
-
liveSkuId:
|
|
81303
|
+
liveSkuId: metricCardLiveSkuId
|
|
81221
81304
|
}
|
|
81222
81305
|
) })
|
|
81223
81306
|
] }),
|
|
@@ -81388,7 +81471,7 @@ var WorkspaceDetailView = ({
|
|
|
81388
81471
|
skuAware: isSkuAware,
|
|
81389
81472
|
skuBreakdown: isSkuAware ? realSkuBreakdown : void 0,
|
|
81390
81473
|
activeSkuId,
|
|
81391
|
-
liveSkuId:
|
|
81474
|
+
liveSkuId: metricCardLiveSkuId
|
|
81392
81475
|
}
|
|
81393
81476
|
) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: clsx("flex min-h-0", desktopBottomSectionClass), children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
81394
81477
|
WorkspaceMetricCards,
|
|
@@ -81399,7 +81482,7 @@ var WorkspaceDetailView = ({
|
|
|
81399
81482
|
skuAware: isSkuAware,
|
|
81400
81483
|
skuBreakdown: isSkuAware ? realSkuBreakdown : void 0,
|
|
81401
81484
|
activeSkuId,
|
|
81402
|
-
liveSkuId:
|
|
81485
|
+
liveSkuId: metricCardLiveSkuId
|
|
81403
81486
|
}
|
|
81404
81487
|
) })
|
|
81405
81488
|
] })
|
package/dist/index.mjs
CHANGED
|
@@ -14897,12 +14897,14 @@ var logDebug = (...args) => {
|
|
|
14897
14897
|
if (!DEBUG_DASHBOARD_LOGS) return;
|
|
14898
14898
|
console.log(...args);
|
|
14899
14899
|
};
|
|
14900
|
-
var buildMetricsScopeKey = (lineId, lineIds, blueComparisonLineIds) => {
|
|
14900
|
+
var buildMetricsScopeKey = (lineId, lineIds, blueComparisonLineIds, selectorLineIds) => {
|
|
14901
14901
|
const normalizedLineIds = Array.from(new Set((lineIds || []).filter(Boolean))).sort();
|
|
14902
14902
|
const normalizedBlueComparisonLineIds = Array.from(new Set((blueComparisonLineIds || []).filter(Boolean))).sort();
|
|
14903
|
+
const normalizedSelectorLineIds = Array.from(new Set((selectorLineIds || []).filter(Boolean))).sort();
|
|
14903
14904
|
const lineKey = normalizedLineIds.length > 0 ? normalizedLineIds.join(",") : lineId;
|
|
14904
14905
|
const comparisonKey = normalizedBlueComparisonLineIds.length > 0 ? normalizedBlueComparisonLineIds.join(",") : lineKey;
|
|
14905
|
-
|
|
14906
|
+
const selectorKey = normalizedSelectorLineIds.length > 0 ? normalizedSelectorLineIds.join(",") : "";
|
|
14907
|
+
return `${lineId}|${lineKey}|blue:${comparisonKey}|selector:${selectorKey}`;
|
|
14906
14908
|
};
|
|
14907
14909
|
var parseEfficiencyLegend = (legend) => {
|
|
14908
14910
|
if (!legend) return null;
|
|
@@ -14925,6 +14927,7 @@ var useDashboardMetrics = ({
|
|
|
14925
14927
|
lineId,
|
|
14926
14928
|
lineIds,
|
|
14927
14929
|
blueComparisonLineIds,
|
|
14930
|
+
selectorLineIds,
|
|
14928
14931
|
userAccessibleLineIds,
|
|
14929
14932
|
enabled = true
|
|
14930
14933
|
}) => {
|
|
@@ -14951,6 +14954,10 @@ var useDashboardMetrics = ({
|
|
|
14951
14954
|
() => Array.from(new Set((blueComparisonLineIds || []).filter(Boolean))),
|
|
14952
14955
|
[blueComparisonLineIds]
|
|
14953
14956
|
);
|
|
14957
|
+
const normalizedSelectorLineIds = useMemo(
|
|
14958
|
+
() => Array.from(new Set((selectorLineIds || []).filter(Boolean))),
|
|
14959
|
+
[selectorLineIds]
|
|
14960
|
+
);
|
|
14954
14961
|
const { shiftConfig: staticShiftConfig } = useDashboardConfig();
|
|
14955
14962
|
const {
|
|
14956
14963
|
shiftConfigMap: multiLineShiftConfigMap,
|
|
@@ -14986,9 +14993,9 @@ var useDashboardMetrics = ({
|
|
|
14986
14993
|
const configuredLineMetricsTable = databaseConfig?.tables?.lineMetrics ?? "line_metrics";
|
|
14987
14994
|
const schema = databaseConfig?.schema ?? "public";
|
|
14988
14995
|
const supabase = useSupabase();
|
|
14989
|
-
const [metrics2, setMetrics] = useState({ workspaceMetrics: [], lineMetrics: [] });
|
|
14996
|
+
const [metrics2, setMetrics] = useState({ workspaceMetrics: [], lineMetrics: [], selectorLineMetrics: [] });
|
|
14990
14997
|
const [metricsLineId, setMetricsLineId] = useState(lineId ?? null);
|
|
14991
|
-
const [metricsScopeKey, setMetricsScopeKey] = useState(() => buildMetricsScopeKey(lineId, lineIds, blueComparisonLineIds));
|
|
14998
|
+
const [metricsScopeKey, setMetricsScopeKey] = useState(() => buildMetricsScopeKey(lineId, lineIds, blueComparisonLineIds, selectorLineIds));
|
|
14992
14999
|
const [isLoading, setIsLoading] = useState(true);
|
|
14993
15000
|
const [error, setError] = useState(null);
|
|
14994
15001
|
const lineIdRef = useRef(lineId);
|
|
@@ -15007,6 +15014,7 @@ var useDashboardMetrics = ({
|
|
|
15007
15014
|
const configuredLineIdsRef = useRef(configuredLineIds);
|
|
15008
15015
|
const userAccessibleLineIdsRef = useRef(userAccessibleLineIds);
|
|
15009
15016
|
const explicitLineIdsRef = useRef(lineIds);
|
|
15017
|
+
const selectorLineIdsRef = useRef(selectorLineIds);
|
|
15010
15018
|
useEffect(() => {
|
|
15011
15019
|
onLineMetricsUpdateRef.current = onLineMetricsUpdate;
|
|
15012
15020
|
}, [onLineMetricsUpdate]);
|
|
@@ -15025,6 +15033,9 @@ var useDashboardMetrics = ({
|
|
|
15025
15033
|
useEffect(() => {
|
|
15026
15034
|
explicitLineIdsRef.current = lineIds;
|
|
15027
15035
|
}, [lineIds]);
|
|
15036
|
+
useEffect(() => {
|
|
15037
|
+
selectorLineIdsRef.current = selectorLineIds;
|
|
15038
|
+
}, [selectorLineIds]);
|
|
15028
15039
|
const companySpecificMetricsTable = useMemo(
|
|
15029
15040
|
() => getCompanyMetricsTableName(entityConfig.companyId, "performance_metrics"),
|
|
15030
15041
|
[entityConfig.companyId]
|
|
@@ -15033,9 +15044,10 @@ var useDashboardMetrics = ({
|
|
|
15033
15044
|
() => buildMetricsScopeKey(
|
|
15034
15045
|
lineId,
|
|
15035
15046
|
isFactoryView ? targetFactoryLineIds : void 0,
|
|
15036
|
-
normalizedBlueComparisonLineIds.length ? normalizedBlueComparisonLineIds : void 0
|
|
15047
|
+
normalizedBlueComparisonLineIds.length ? normalizedBlueComparisonLineIds : void 0,
|
|
15048
|
+
normalizedSelectorLineIds.length ? normalizedSelectorLineIds : void 0
|
|
15037
15049
|
),
|
|
15038
|
-
[isFactoryView, lineId, targetFactoryLineIds, normalizedBlueComparisonLineIds]
|
|
15050
|
+
[isFactoryView, lineId, targetFactoryLineIds, normalizedBlueComparisonLineIds, normalizedSelectorLineIds]
|
|
15039
15051
|
);
|
|
15040
15052
|
useEffect(() => {
|
|
15041
15053
|
lineIdRef.current = lineId;
|
|
@@ -15067,13 +15079,15 @@ var useDashboardMetrics = ({
|
|
|
15067
15079
|
const targetLineIdsKey = targetLineIds.slice().sort().join(",");
|
|
15068
15080
|
const effectiveBlueComparisonLineIds = normalizedBlueComparisonLineIds.length ? normalizedBlueComparisonLineIds : targetLineIds;
|
|
15069
15081
|
const blueComparisonLineIdsKey = effectiveBlueComparisonLineIds.slice().sort().join(",");
|
|
15082
|
+
const selectorLineIdsKey = normalizedSelectorLineIds.slice().sort().join(",");
|
|
15070
15083
|
const usesShiftGroups = isFactory && shiftGroups.length > 0;
|
|
15071
15084
|
const singleShiftDetails = usesShiftGroups ? null : shiftConfig ? getCurrentShift(defaultTimezone, shiftConfig) : shiftGroups.length === 1 ? { date: shiftGroups[0].date, shiftId: shiftGroups[0].shiftId } : getCurrentShift(defaultTimezone, staticShiftConfig);
|
|
15072
|
-
const fetchKey = usesShiftGroups ? `factory|${companyId || "unknown"}|${shiftGroupsKey}|blue:${blueComparisonLineIdsKey}` : isFactory ? `factory|${companyId || "unknown"}|${singleShiftDetails?.date}|${singleShiftDetails?.shiftId}|${targetLineIdsKey}|blue:${blueComparisonLineIdsKey}` : `${currentLineIdToUse}|${companyId || "unknown"}|${singleShiftDetails?.date}|${singleShiftDetails?.shiftId}|blue:${blueComparisonLineIdsKey}`;
|
|
15085
|
+
const fetchKey = usesShiftGroups ? `factory|${companyId || "unknown"}|${shiftGroupsKey}|blue:${blueComparisonLineIdsKey}|selector:${selectorLineIdsKey}` : isFactory ? `factory|${companyId || "unknown"}|${singleShiftDetails?.date}|${singleShiftDetails?.shiftId}|${targetLineIdsKey}|blue:${blueComparisonLineIdsKey}|selector:${selectorLineIdsKey}` : `${currentLineIdToUse}|${companyId || "unknown"}|${singleShiftDetails?.date}|${singleShiftDetails?.shiftId}|blue:${blueComparisonLineIdsKey}|selector:${selectorLineIdsKey}`;
|
|
15073
15086
|
const responseScopeKey = buildMetricsScopeKey(
|
|
15074
15087
|
currentLineIdToUse,
|
|
15075
15088
|
isFactory ? targetLineIds : void 0,
|
|
15076
|
-
normalizedBlueComparisonLineIds.length ? normalizedBlueComparisonLineIds : void 0
|
|
15089
|
+
normalizedBlueComparisonLineIds.length ? normalizedBlueComparisonLineIds : void 0,
|
|
15090
|
+
normalizedSelectorLineIds.length ? normalizedSelectorLineIds : void 0
|
|
15077
15091
|
);
|
|
15078
15092
|
logDebug("[useDashboardMetrics] Fetch key details:", {
|
|
15079
15093
|
isFactory,
|
|
@@ -15105,6 +15119,7 @@ var useDashboardMetrics = ({
|
|
|
15105
15119
|
workspaceMetrics: [],
|
|
15106
15120
|
blueComparisonWorkspaceMetrics: [],
|
|
15107
15121
|
lineMetrics: [],
|
|
15122
|
+
selectorLineMetrics: [],
|
|
15108
15123
|
metadata: void 0,
|
|
15109
15124
|
efficiencyLegend: DEFAULT_EFFICIENCY_LEGEND
|
|
15110
15125
|
});
|
|
@@ -15116,6 +15131,7 @@ var useDashboardMetrics = ({
|
|
|
15116
15131
|
let allWorkspaceMetrics = [];
|
|
15117
15132
|
let allBlueComparisonWorkspaceMetrics = [];
|
|
15118
15133
|
let allLineMetrics = [];
|
|
15134
|
+
let allSelectorLineMetrics = [];
|
|
15119
15135
|
let hasFlowBuffers = false;
|
|
15120
15136
|
let idleTimeVlmByLine = {};
|
|
15121
15137
|
let efficiencyLegend;
|
|
@@ -15125,7 +15141,8 @@ var useDashboardMetrics = ({
|
|
|
15125
15141
|
const buildMetricsEndpoint = (params) => {
|
|
15126
15142
|
const lineIdsParam = isFactory ? `line_ids=${params.groupLineIds.join(",")}` : `line_id=${params.groupLineIds[0]}`;
|
|
15127
15143
|
const blueComparisonParam = effectiveBlueComparisonLineIds.length ? `&blue_comparison_line_ids=${effectiveBlueComparisonLineIds.join(",")}` : "";
|
|
15128
|
-
|
|
15144
|
+
const selectorParam = normalizedSelectorLineIds.length ? `&selector_line_ids=${encodeURIComponent(normalizedSelectorLineIds.join(","))}` : "";
|
|
15145
|
+
return `/api/dashboard/metrics?${lineIdsParam}${blueComparisonParam}${selectorParam}&date=${params.date}&shift_id=${params.shiftId}&company_id=${companyId}${forceParam}${qaGreenStreakParams}`;
|
|
15129
15146
|
};
|
|
15130
15147
|
if (usesShiftGroups) {
|
|
15131
15148
|
logDebug("[useDashboardMetrics] Factory view shift groups fetch:", {
|
|
@@ -15181,6 +15198,9 @@ var useDashboardMetrics = ({
|
|
|
15181
15198
|
if (result.line_metrics) {
|
|
15182
15199
|
allLineMetrics.push(...result.line_metrics);
|
|
15183
15200
|
}
|
|
15201
|
+
if (result.selector_line_metrics) {
|
|
15202
|
+
allSelectorLineMetrics.push(...result.selector_line_metrics);
|
|
15203
|
+
}
|
|
15184
15204
|
});
|
|
15185
15205
|
if (allBlueComparisonWorkspaceMetrics.length === 0) {
|
|
15186
15206
|
allBlueComparisonWorkspaceMetrics = allWorkspaceMetrics;
|
|
@@ -15224,6 +15244,7 @@ var useDashboardMetrics = ({
|
|
|
15224
15244
|
allWorkspaceMetrics = backendData.workspace_metrics || [];
|
|
15225
15245
|
allBlueComparisonWorkspaceMetrics = backendData.blue_comparison_workspace_metrics || allWorkspaceMetrics;
|
|
15226
15246
|
allLineMetrics = backendData.line_metrics || [];
|
|
15247
|
+
allSelectorLineMetrics = backendData.selector_line_metrics || [];
|
|
15227
15248
|
hasFlowBuffers = Boolean(backendData?.metadata?.has_flow_buffers);
|
|
15228
15249
|
if (backendData?.metadata?.idle_time_vlm_by_line && typeof backendData.metadata.idle_time_vlm_by_line === "object") {
|
|
15229
15250
|
idleTimeVlmByLine = backendData.metadata.idle_time_vlm_by_line;
|
|
@@ -15255,6 +15276,7 @@ var useDashboardMetrics = ({
|
|
|
15255
15276
|
workspaceMetrics: transformedWorkspaceData,
|
|
15256
15277
|
blueComparisonWorkspaceMetrics: transformedBlueComparisonWorkspaceData.length ? transformedBlueComparisonWorkspaceData : transformedWorkspaceData,
|
|
15257
15278
|
lineMetrics: allLineMetrics || [],
|
|
15279
|
+
selectorLineMetrics: allSelectorLineMetrics || [],
|
|
15258
15280
|
metadata: { hasFlowBuffers, idleTimeVlmByLine },
|
|
15259
15281
|
efficiencyLegend: efficiencyLegend ?? DEFAULT_EFFICIENCY_LEGEND
|
|
15260
15282
|
};
|
|
@@ -15325,6 +15347,7 @@ var useDashboardMetrics = ({
|
|
|
15325
15347
|
configuredLineIds,
|
|
15326
15348
|
targetFactoryLineIds,
|
|
15327
15349
|
normalizedBlueComparisonLineIds,
|
|
15350
|
+
normalizedSelectorLineIds,
|
|
15328
15351
|
isFactoryView,
|
|
15329
15352
|
multiLineShiftConfigMap,
|
|
15330
15353
|
staticShiftConfig,
|
|
@@ -15441,7 +15464,8 @@ var useDashboardMetrics = ({
|
|
|
15441
15464
|
const isFactory = lineId === (entityConfig.factoryViewId || "factory");
|
|
15442
15465
|
if (isFactory && shiftGroups.length === 0) return null;
|
|
15443
15466
|
const shiftGroupsKeyPart = isFactory ? shiftGroups.map((g) => `${g.date}-${g.shiftId}-${g.lineIds.join("_")}`).join("|") : operationalShiftKey;
|
|
15444
|
-
|
|
15467
|
+
const selectorLineIdsKeyPart = (selectorLineIds || []).filter(Boolean).slice().sort().join(",");
|
|
15468
|
+
return `${lineId}|${entityConfig.companyId}|${shiftGroupsKeyPart}|selector:${selectorLineIdsKeyPart}`;
|
|
15445
15469
|
}, [
|
|
15446
15470
|
enabled,
|
|
15447
15471
|
supabase,
|
|
@@ -15451,7 +15475,8 @@ var useDashboardMetrics = ({
|
|
|
15451
15475
|
shiftLoading,
|
|
15452
15476
|
isTimezoneLoading,
|
|
15453
15477
|
shiftGroups,
|
|
15454
|
-
operationalShiftKey
|
|
15478
|
+
operationalShiftKey,
|
|
15479
|
+
selectorLineIds
|
|
15455
15480
|
]);
|
|
15456
15481
|
useEffect(() => {
|
|
15457
15482
|
const currentLineIdToUse = lineIdRef.current;
|
|
@@ -15488,7 +15513,7 @@ var useDashboardMetrics = ({
|
|
|
15488
15513
|
});
|
|
15489
15514
|
const targetFactoryLineIdsForSubscriptions = explicitLineIdsRef.current !== void 0 ? explicitLineIdsRef.current : currentUserAccessibleLineIds !== void 0 ? currentUserAccessibleLineIds : currentConfiguredLineIds;
|
|
15490
15515
|
const targetFactoryLineIdSet = new Set(
|
|
15491
|
-
|
|
15516
|
+
[...targetFactoryLineIdsForSubscriptions || [], ...selectorLineIdsRef.current || []].filter(Boolean)
|
|
15492
15517
|
);
|
|
15493
15518
|
currentShiftGroups.forEach((group, index) => {
|
|
15494
15519
|
const groupLineIds = group.lineIds.filter(
|
|
@@ -15658,7 +15683,10 @@ var useDashboardMetrics = ({
|
|
|
15658
15683
|
const currentShiftDetails = shiftConfig ? getCurrentShift(defaultTimezone, shiftConfig) : getCurrentShift(defaultTimezone, staticShiftConfig);
|
|
15659
15684
|
const operationalDateForSubscription = currentShiftDetails.date;
|
|
15660
15685
|
const targetLineIds = isFactory ? explicitLineIdsRef.current || currentUserAccessibleLineIds || currentConfiguredLineIds : [currentLineIdToUse];
|
|
15661
|
-
const filteredLineIds =
|
|
15686
|
+
const filteredLineIds = Array.from(/* @__PURE__ */ new Set([
|
|
15687
|
+
...targetLineIds,
|
|
15688
|
+
...selectorLineIdsRef.current || []
|
|
15689
|
+
])).filter((id3) => id3 && id3 !== factoryViewIdentifier);
|
|
15662
15690
|
if (filteredLineIds.length === 0) {
|
|
15663
15691
|
logDebug("[useDashboardMetrics] Realtime setup skipped: no line IDs after filtering", {
|
|
15664
15692
|
targetLineIds,
|
|
@@ -15765,11 +15793,12 @@ var useDashboardMetrics = ({
|
|
|
15765
15793
|
const isCurrentScopeResolved = metricsScopeKey === requestedScopeKey;
|
|
15766
15794
|
const hasLastGoodMetrics = metrics2.workspaceMetrics.length > 0 || metrics2.lineMetrics.length > 0;
|
|
15767
15795
|
const canReuseLastGoodMetrics = hasLastGoodMetrics && !isCurrentScopeResolved && (isLoading || !!error);
|
|
15768
|
-
const safeMetrics = isCurrentScopeResolved || canReuseLastGoodMetrics ? metrics2 : { workspaceMetrics: [], blueComparisonWorkspaceMetrics: [], lineMetrics: [], metadata: void 0, efficiencyLegend: DEFAULT_EFFICIENCY_LEGEND };
|
|
15796
|
+
const safeMetrics = isCurrentScopeResolved || canReuseLastGoodMetrics ? metrics2 : { workspaceMetrics: [], blueComparisonWorkspaceMetrics: [], lineMetrics: [], selectorLineMetrics: [], metadata: void 0, efficiencyLegend: DEFAULT_EFFICIENCY_LEGEND };
|
|
15769
15797
|
return {
|
|
15770
15798
|
workspaceMetrics: safeMetrics?.workspaceMetrics || [],
|
|
15771
15799
|
blueComparisonWorkspaceMetrics: safeMetrics?.blueComparisonWorkspaceMetrics || safeMetrics?.workspaceMetrics || [],
|
|
15772
15800
|
lineMetrics: safeMetrics?.lineMetrics || [],
|
|
15801
|
+
selectorLineMetrics: safeMetrics?.selectorLineMetrics || [],
|
|
15773
15802
|
efficiencyLegend: safeMetrics?.efficiencyLegend || DEFAULT_EFFICIENCY_LEGEND,
|
|
15774
15803
|
metadata: safeMetrics?.metadata,
|
|
15775
15804
|
isLoading: enabled ? isLoading || !isCurrentScopeResolved && !canReuseLastGoodMetrics : false,
|
|
@@ -39661,10 +39690,11 @@ var WorkspaceMetricCardsImpl = ({
|
|
|
39661
39690
|
}
|
|
39662
39691
|
return null;
|
|
39663
39692
|
}, [activeSku, skuAware, activeSkuId, liveSkuId, skuBreakdown]);
|
|
39664
|
-
const
|
|
39665
|
-
const
|
|
39666
|
-
const
|
|
39667
|
-
const
|
|
39693
|
+
const metricSku = displaySku;
|
|
39694
|
+
const pphValue = metricSku ? metricSku.avg_pph : workspace.avg_pph;
|
|
39695
|
+
const pphThreshold = metricSku ? metricSku.pph_threshold : workspace.pph_threshold;
|
|
39696
|
+
const cycleValue = metricSku ? metricSku.avg_cycle_time : workspace.avg_cycle_time;
|
|
39697
|
+
const cycleStandard = metricSku ? metricSku.ideal_cycle_time : workspace.ideal_cycle_time;
|
|
39668
39698
|
const displaySkuLabel = displaySku ? getSkuDisplayName(displaySku) : "";
|
|
39669
39699
|
const efficiencyValue = workspace.avg_efficiency || 0;
|
|
39670
39700
|
const efficiencyTarget = effectiveLegend.green_min;
|
|
@@ -55769,8 +55799,9 @@ var WorkspaceCycleTimeMetricCards = ({
|
|
|
55769
55799
|
}
|
|
55770
55800
|
return null;
|
|
55771
55801
|
}, [activeSku, skuAware, activeSkuId, liveSkuId, skuBreakdown]);
|
|
55772
|
-
const
|
|
55773
|
-
const
|
|
55802
|
+
const metricSku = displaySku;
|
|
55803
|
+
const cycleValue = metricSku ? metricSku.avg_cycle_time : workspace.avg_cycle_time;
|
|
55804
|
+
const cycleStandard = metricSku ? metricSku.ideal_cycle_time : workspace.ideal_cycle_time;
|
|
55774
55805
|
const displaySkuLabel = displaySku ? getSkuDisplayName(displaySku) : "";
|
|
55775
55806
|
const efficiencyValue = workspace.avg_efficiency || 0;
|
|
55776
55807
|
const efficiencyTarget = effectiveLegend.green_min;
|
|
@@ -65652,6 +65683,7 @@ var createEmptyState = () => ({
|
|
|
65652
65683
|
workspaceMetrics: [],
|
|
65653
65684
|
blueComparisonWorkspaceMetrics: [],
|
|
65654
65685
|
lineMetrics: [],
|
|
65686
|
+
selectorLineMetrics: [],
|
|
65655
65687
|
kpiTrend: null,
|
|
65656
65688
|
activeBreaks: [],
|
|
65657
65689
|
videoStreamsByWorkspaceId: {},
|
|
@@ -65665,7 +65697,7 @@ var normalizeMetadata = (metadata) => ({
|
|
|
65665
65697
|
cacheStatus: metadata?.cache_status,
|
|
65666
65698
|
warnings: metadata?.warnings ?? []
|
|
65667
65699
|
});
|
|
65668
|
-
var createResolvedScopeLookup = (resolvedScope, workspaces, blueComparisonWorkspaces) => {
|
|
65700
|
+
var createResolvedScopeLookup = (resolvedScope, workspaces, blueComparisonWorkspaces, selectorLineMetrics) => {
|
|
65669
65701
|
const lookup = /* @__PURE__ */ new Set();
|
|
65670
65702
|
const addEntry = (lineId, date, shiftId) => {
|
|
65671
65703
|
if (!lineId || !date || shiftId === void 0 || shiftId === null) return;
|
|
@@ -65674,11 +65706,13 @@ var createResolvedScopeLookup = (resolvedScope, workspaces, blueComparisonWorksp
|
|
|
65674
65706
|
resolvedScope.forEach((entry) => addEntry(entry.line_id, entry.date, entry.shift_id));
|
|
65675
65707
|
workspaces.forEach((workspace) => addEntry(workspace.line_id, workspace.date, workspace.shift_id));
|
|
65676
65708
|
blueComparisonWorkspaces.forEach((workspace) => addEntry(workspace.line_id, workspace.date, workspace.shift_id));
|
|
65709
|
+
selectorLineMetrics.forEach((lineMetric) => addEntry(lineMetric.line_id, lineMetric.date, lineMetric.shift_id));
|
|
65677
65710
|
return lookup;
|
|
65678
65711
|
};
|
|
65679
65712
|
var useLiveMonitorBootstrap = ({
|
|
65680
65713
|
lineIds,
|
|
65681
65714
|
blueComparisonLineIds,
|
|
65715
|
+
selectorLineIds,
|
|
65682
65716
|
companyId,
|
|
65683
65717
|
enabled = true,
|
|
65684
65718
|
appTimezone,
|
|
@@ -65694,6 +65728,7 @@ var useLiveMonitorBootstrap = ({
|
|
|
65694
65728
|
const effectiveTimezone = appTimezone || "Asia/Kolkata";
|
|
65695
65729
|
const rawLineIdsKey = (lineIds || []).filter(Boolean).join(",");
|
|
65696
65730
|
const rawBlueComparisonLineIdsKey = (blueComparisonLineIds || lineIds || []).filter(Boolean).join(",");
|
|
65731
|
+
const rawSelectorLineIdsKey = (selectorLineIds || []).filter(Boolean).join(",");
|
|
65697
65732
|
const normalizedLineIds = useMemo(
|
|
65698
65733
|
() => Array.from(new Set(rawLineIdsKey ? rawLineIdsKey.split(",") : [])),
|
|
65699
65734
|
[rawLineIdsKey]
|
|
@@ -65702,13 +65737,17 @@ var useLiveMonitorBootstrap = ({
|
|
|
65702
65737
|
() => Array.from(new Set(rawBlueComparisonLineIdsKey ? rawBlueComparisonLineIdsKey.split(",") : [])),
|
|
65703
65738
|
[rawBlueComparisonLineIdsKey]
|
|
65704
65739
|
);
|
|
65740
|
+
const normalizedSelectorLineIds = useMemo(
|
|
65741
|
+
() => Array.from(new Set(rawSelectorLineIdsKey ? rawSelectorLineIdsKey.split(",") : [])),
|
|
65742
|
+
[rawSelectorLineIdsKey]
|
|
65743
|
+
);
|
|
65705
65744
|
const realtimeLineIds = useMemo(
|
|
65706
|
-
() => Array.from(new Set([...normalizedLineIds, ...normalizedBlueComparisonLineIds].filter(Boolean))).sort(),
|
|
65707
|
-
[normalizedLineIds, normalizedBlueComparisonLineIds]
|
|
65745
|
+
() => Array.from(new Set([...normalizedLineIds, ...normalizedBlueComparisonLineIds, ...normalizedSelectorLineIds].filter(Boolean))).sort(),
|
|
65746
|
+
[normalizedLineIds, normalizedBlueComparisonLineIds, normalizedSelectorLineIds]
|
|
65708
65747
|
);
|
|
65709
65748
|
const requestKey = useMemo(
|
|
65710
|
-
() => `${normalizedLineIds.slice().sort().join(",")}|blue:${normalizedBlueComparisonLineIds.slice().sort().join(",")}`,
|
|
65711
|
-
[normalizedLineIds, normalizedBlueComparisonLineIds]
|
|
65749
|
+
() => `${normalizedLineIds.slice().sort().join(",")}|blue:${normalizedBlueComparisonLineIds.slice().sort().join(",")}|selector:${normalizedSelectorLineIds.slice().sort().join(",")}`,
|
|
65750
|
+
[normalizedLineIds, normalizedBlueComparisonLineIds, normalizedSelectorLineIds]
|
|
65712
65751
|
);
|
|
65713
65752
|
const realtimeLineIdsKey = useMemo(() => realtimeLineIds.join(","), [realtimeLineIds]);
|
|
65714
65753
|
const companySpecificMetricsTable = useMemo(
|
|
@@ -65740,6 +65779,9 @@ var useLiveMonitorBootstrap = ({
|
|
|
65740
65779
|
if (normalizedBlueComparisonLineIds.length) {
|
|
65741
65780
|
searchParams.set("blue_comparison_line_ids", normalizedBlueComparisonLineIds.join(","));
|
|
65742
65781
|
}
|
|
65782
|
+
if (normalizedSelectorLineIds.length) {
|
|
65783
|
+
searchParams.set("selector_line_ids", normalizedSelectorLineIds.join(","));
|
|
65784
|
+
}
|
|
65743
65785
|
if (force) {
|
|
65744
65786
|
searchParams.set("force_refresh", "true");
|
|
65745
65787
|
}
|
|
@@ -65773,6 +65815,7 @@ var useLiveMonitorBootstrap = ({
|
|
|
65773
65815
|
company_id: resolvedCompanyId,
|
|
65774
65816
|
line_ids: normalizedLineIds,
|
|
65775
65817
|
blue_comparison_line_ids: normalizedBlueComparisonLineIds,
|
|
65818
|
+
selector_line_ids: normalizedSelectorLineIds,
|
|
65776
65819
|
force_refresh: force,
|
|
65777
65820
|
pathname: typeof window !== "undefined" ? window.location.pathname : "unknown"
|
|
65778
65821
|
}
|
|
@@ -65790,6 +65833,7 @@ var useLiveMonitorBootstrap = ({
|
|
|
65790
65833
|
resolvedCompanyId,
|
|
65791
65834
|
normalizedLineIds,
|
|
65792
65835
|
normalizedBlueComparisonLineIds,
|
|
65836
|
+
normalizedSelectorLineIds,
|
|
65793
65837
|
requestKey
|
|
65794
65838
|
]);
|
|
65795
65839
|
const fetchBootstrapRef = useRef(fetchBootstrap);
|
|
@@ -65901,6 +65945,7 @@ var useLiveMonitorBootstrap = ({
|
|
|
65901
65945
|
workspaceMetrics,
|
|
65902
65946
|
blueComparisonWorkspaceMetrics: blueComparisonWorkspaceMetrics.length ? blueComparisonWorkspaceMetrics : workspaceMetrics,
|
|
65903
65947
|
lineMetrics: rawState.response.line_metrics || [],
|
|
65948
|
+
selectorLineMetrics: rawState.response.selector_line_metrics || [],
|
|
65904
65949
|
kpiTrend: rawState.response.kpi_trend || null,
|
|
65905
65950
|
activeBreaks,
|
|
65906
65951
|
videoStreamsByWorkspaceId,
|
|
@@ -65937,8 +65982,9 @@ var useLiveMonitorBootstrap = ({
|
|
|
65937
65982
|
const realtimeScopeKey = useMemo(() => Array.from(createResolvedScopeLookup(
|
|
65938
65983
|
state.resolvedScope,
|
|
65939
65984
|
state.workspaceMetrics,
|
|
65940
|
-
state.blueComparisonWorkspaceMetrics
|
|
65941
|
-
|
|
65985
|
+
state.blueComparisonWorkspaceMetrics,
|
|
65986
|
+
state.selectorLineMetrics
|
|
65987
|
+
)).sort().join("||"), [state.resolvedScope, state.workspaceMetrics, state.blueComparisonWorkspaceMetrics, state.selectorLineMetrics]);
|
|
65942
65988
|
useEffect(() => {
|
|
65943
65989
|
if (!enabled || !resolvedCompanyId || !realtimeLineIdsKey || !supabase) {
|
|
65944
65990
|
return void 0;
|
|
@@ -66044,6 +66090,7 @@ var useLiveMonitorBootstrap = ({
|
|
|
66044
66090
|
workspaceMetrics: state.workspaceMetrics,
|
|
66045
66091
|
blueComparisonWorkspaceMetrics: state.blueComparisonWorkspaceMetrics,
|
|
66046
66092
|
lineMetrics: state.lineMetrics,
|
|
66093
|
+
selectorLineMetrics: state.selectorLineMetrics,
|
|
66047
66094
|
kpiTrend: state.kpiTrend,
|
|
66048
66095
|
activeBreaks: state.activeBreaks,
|
|
66049
66096
|
videoStreamsByWorkspaceId: state.videoStreamsByWorkspaceId,
|
|
@@ -66558,6 +66605,7 @@ function HomeView({
|
|
|
66558
66605
|
workspaceMetrics: legacyWorkspaceMetrics,
|
|
66559
66606
|
blueComparisonWorkspaceMetrics: legacyMetricsBlueComparisonWorkspaceMetrics,
|
|
66560
66607
|
lineMetrics: legacyLineMetrics,
|
|
66608
|
+
selectorLineMetrics: legacySelectorLineMetrics = [],
|
|
66561
66609
|
efficiencyLegend: legacyEfficiencyLegend,
|
|
66562
66610
|
metadata: legacyMetricsMetadata,
|
|
66563
66611
|
isLoading: legacyMetricsLoading,
|
|
@@ -66568,6 +66616,7 @@ function HomeView({
|
|
|
66568
66616
|
lineId: metricsScopeLineId,
|
|
66569
66617
|
lineIds: selectedLineIds,
|
|
66570
66618
|
blueComparisonLineIds,
|
|
66619
|
+
selectorLineIds: visibleLineIds,
|
|
66571
66620
|
onLineMetricsUpdate: handleLineMetricsUpdate,
|
|
66572
66621
|
userAccessibleLineIds: visibleLineIds,
|
|
66573
66622
|
enabled: shouldEnableMetricsFetch && !isBootstrapMonitorMode
|
|
@@ -66623,6 +66672,7 @@ function HomeView({
|
|
|
66623
66672
|
const bootstrapMonitor = useLiveMonitorBootstrap({
|
|
66624
66673
|
lineIds: selectedLineIds,
|
|
66625
66674
|
blueComparisonLineIds,
|
|
66675
|
+
selectorLineIds: visibleLineIds,
|
|
66626
66676
|
companyId: userCompanyId,
|
|
66627
66677
|
enabled: shouldEnableMetricsFetch && !isLegacyMonitorMode,
|
|
66628
66678
|
appTimezone: timezone,
|
|
@@ -66633,12 +66683,32 @@ function HomeView({
|
|
|
66633
66683
|
const currentWorkspaceMetrics = isBootstrapMonitorMode ? bootstrapMonitor.workspaceMetrics : legacyWorkspaceMetrics;
|
|
66634
66684
|
const currentBlueComparisonWorkspaceMetrics = isBootstrapMonitorMode ? bootstrapMonitor.blueComparisonWorkspaceMetrics : legacyMetricsBlueComparisonWorkspaceMetrics;
|
|
66635
66685
|
const currentLineMetrics = isBootstrapMonitorMode ? bootstrapMonitor.lineMetrics : legacyLineMetrics;
|
|
66686
|
+
const currentSelectorLineMetrics = isBootstrapMonitorMode ? bootstrapMonitor.selectorLineMetrics : legacySelectorLineMetrics;
|
|
66636
66687
|
const currentEfficiencyLegend = isBootstrapMonitorMode ? bootstrapMonitor.efficiencyLegend : legacyEfficiencyLegend;
|
|
66637
66688
|
const currentMetricsMetadata = isBootstrapMonitorMode ? bootstrapMonitor.metadata : legacyMetricsMetadata;
|
|
66638
66689
|
const currentMetricsLoading = isBootstrapMonitorMode ? bootstrapMonitor.isLoading : legacyMetricsLoading;
|
|
66639
66690
|
const currentIsCurrentScopeResolved = isBootstrapMonitorMode ? bootstrapMonitor.isCurrentScopeResolved : legacyIsCurrentScopeResolved;
|
|
66640
66691
|
const currentMetricsError = isBootstrapMonitorMode ? bootstrapMonitor.error : legacyMetricsError;
|
|
66641
66692
|
const currentRefetchMetrics = isBootstrapMonitorMode ? bootstrapMonitor.refetch : refetchLegacyMetrics;
|
|
66693
|
+
const lineSelectorSignalStatusByLine = useMemo(() => {
|
|
66694
|
+
const statusByLine = /* @__PURE__ */ new Map();
|
|
66695
|
+
const legend = currentEfficiencyLegend || DEFAULT_EFFICIENCY_LEGEND;
|
|
66696
|
+
const addRows = (rows) => {
|
|
66697
|
+
(rows || []).forEach((row) => {
|
|
66698
|
+
const lineId = typeof row?.line_id === "string" ? row.line_id : "";
|
|
66699
|
+
if (!lineId || statusByLine.has(lineId)) {
|
|
66700
|
+
return;
|
|
66701
|
+
}
|
|
66702
|
+
const status = getKpiSignalStatus(row?.line_signal, legend);
|
|
66703
|
+
if (status) {
|
|
66704
|
+
statusByLine.set(lineId, status);
|
|
66705
|
+
}
|
|
66706
|
+
});
|
|
66707
|
+
};
|
|
66708
|
+
addRows(currentSelectorLineMetrics);
|
|
66709
|
+
addRows(currentLineMetrics);
|
|
66710
|
+
return statusByLine;
|
|
66711
|
+
}, [currentEfficiencyLegend, currentLineMetrics, currentSelectorLineMetrics]);
|
|
66642
66712
|
const metricsDisplayNames = useMemo(() => {
|
|
66643
66713
|
const nextDisplayNames = {};
|
|
66644
66714
|
currentWorkspaceMetrics.forEach((workspace) => {
|
|
@@ -67496,6 +67566,8 @@ function HomeView({
|
|
|
67496
67566
|
] }),
|
|
67497
67567
|
/* @__PURE__ */ jsx("div", { className: "max-h-56 space-y-0.5 overflow-y-auto pr-1", children: visibleLineIds.map((lineId) => {
|
|
67498
67568
|
const isChecked = pendingSelectedLineIds.includes(lineId);
|
|
67569
|
+
const signalStatus = lineSelectorSignalStatusByLine.get(lineId);
|
|
67570
|
+
const signalDotClass = signalStatus === "stable" ? "bg-green-500" : signalStatus === "warning" ? "bg-yellow-400" : signalStatus === "attention" ? "bg-red-500" : "";
|
|
67499
67571
|
return /* @__PURE__ */ jsxs(
|
|
67500
67572
|
"label",
|
|
67501
67573
|
{
|
|
@@ -67520,7 +67592,15 @@ function HomeView({
|
|
|
67520
67592
|
}
|
|
67521
67593
|
}
|
|
67522
67594
|
),
|
|
67523
|
-
/* @__PURE__ */ jsx("span", { className: "truncate", children: mergedLineNames[lineId] || `Line ${lineId.substring(0, 4)}` })
|
|
67595
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate", children: mergedLineNames[lineId] || `Line ${lineId.substring(0, 4)}` }),
|
|
67596
|
+
/* @__PURE__ */ jsx("span", { className: "flex h-2.5 w-2.5 flex-shrink-0 items-center justify-center", children: signalStatus ? /* @__PURE__ */ jsx(
|
|
67597
|
+
"span",
|
|
67598
|
+
{
|
|
67599
|
+
"data-testid": `line-selector-signal-dot-${lineId}`,
|
|
67600
|
+
className: `h-2 w-2 rounded-full ${signalDotClass}`,
|
|
67601
|
+
"aria-hidden": "true"
|
|
67602
|
+
}
|
|
67603
|
+
) : null })
|
|
67524
67604
|
]
|
|
67525
67605
|
},
|
|
67526
67606
|
lineId
|
|
@@ -67549,6 +67629,7 @@ function HomeView({
|
|
|
67549
67629
|
mergedLineNames,
|
|
67550
67630
|
selectedLineIds,
|
|
67551
67631
|
pendingSelectedLineIds,
|
|
67632
|
+
lineSelectorSignalStatusByLine,
|
|
67552
67633
|
visibleLineIds,
|
|
67553
67634
|
updateSelectedLineIds,
|
|
67554
67635
|
isAllLinesSelection
|
|
@@ -80105,6 +80186,8 @@ var WorkspaceDetailView = ({
|
|
|
80105
80186
|
[workspace?.sku_segments]
|
|
80106
80187
|
);
|
|
80107
80188
|
const activeSkuId = selectedSkuId;
|
|
80189
|
+
const shouldUseLiveSkuForMetricCards = !isHistoricView || Boolean(date) && date === calculatedOperationalDate && parsedShiftId !== void 0 && parsedShiftId === calculatedShiftId;
|
|
80190
|
+
const metricCardLiveSkuId = shouldUseLiveSkuForMetricCards ? liveSkuId : null;
|
|
80108
80191
|
const resolvedLineId = effectiveLineId || workspace?.line_id || cachedDetailedMetrics?.line_id || cachedOverviewMetrics?.line_id || overviewFallback?.line_id;
|
|
80109
80192
|
const { timezone: cycleTimeTimezone } = useTimezone({
|
|
80110
80193
|
lineId: resolvedLineId || void 0,
|
|
@@ -81177,7 +81260,7 @@ var WorkspaceDetailView = ({
|
|
|
81177
81260
|
skuAware: isSkuAware,
|
|
81178
81261
|
skuBreakdown: isSkuAware ? realSkuBreakdown : void 0,
|
|
81179
81262
|
activeSkuId,
|
|
81180
|
-
liveSkuId:
|
|
81263
|
+
liveSkuId: metricCardLiveSkuId
|
|
81181
81264
|
}
|
|
81182
81265
|
) : /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
81183
81266
|
WorkspaceMetricCards,
|
|
@@ -81188,7 +81271,7 @@ var WorkspaceDetailView = ({
|
|
|
81188
81271
|
skuAware: isSkuAware,
|
|
81189
81272
|
skuBreakdown: isSkuAware ? realSkuBreakdown : void 0,
|
|
81190
81273
|
activeSkuId,
|
|
81191
|
-
liveSkuId:
|
|
81274
|
+
liveSkuId: metricCardLiveSkuId
|
|
81192
81275
|
}
|
|
81193
81276
|
) })
|
|
81194
81277
|
] }),
|
|
@@ -81359,7 +81442,7 @@ var WorkspaceDetailView = ({
|
|
|
81359
81442
|
skuAware: isSkuAware,
|
|
81360
81443
|
skuBreakdown: isSkuAware ? realSkuBreakdown : void 0,
|
|
81361
81444
|
activeSkuId,
|
|
81362
|
-
liveSkuId:
|
|
81445
|
+
liveSkuId: metricCardLiveSkuId
|
|
81363
81446
|
}
|
|
81364
81447
|
) : /* @__PURE__ */ jsx("div", { className: clsx("flex min-h-0", desktopBottomSectionClass), children: /* @__PURE__ */ jsx(
|
|
81365
81448
|
WorkspaceMetricCards,
|
|
@@ -81370,7 +81453,7 @@ var WorkspaceDetailView = ({
|
|
|
81370
81453
|
skuAware: isSkuAware,
|
|
81371
81454
|
skuBreakdown: isSkuAware ? realSkuBreakdown : void 0,
|
|
81372
81455
|
activeSkuId,
|
|
81373
|
-
liveSkuId:
|
|
81456
|
+
liveSkuId: metricCardLiveSkuId
|
|
81374
81457
|
}
|
|
81375
81458
|
) })
|
|
81376
81459
|
] })
|