@optifye/dashboard-core 6.11.44 → 6.11.45
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 +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +184 -155
- package/dist/index.mjs +184 -155
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -66,6 +66,7 @@ interface WorkspaceMetrics {
|
|
|
66
66
|
workspace_name: string;
|
|
67
67
|
action_count: number;
|
|
68
68
|
pph: number;
|
|
69
|
+
pph_threshold?: number;
|
|
69
70
|
performance_score: 0 | 1 | 2;
|
|
70
71
|
avg_cycle_time: number;
|
|
71
72
|
ideal_cycle_time?: number;
|
|
@@ -5556,6 +5557,11 @@ declare const workspaceService: {
|
|
|
5556
5557
|
lineIds?: string[];
|
|
5557
5558
|
force?: boolean;
|
|
5558
5559
|
}): Promise<Record<string, WorkspaceVideoStream>>;
|
|
5560
|
+
primeWorkspaceVideoStreamsCache(params: {
|
|
5561
|
+
streams: Record<string, WorkspaceVideoStream>;
|
|
5562
|
+
workspaceIds?: string[];
|
|
5563
|
+
lineIds?: string[];
|
|
5564
|
+
}): void;
|
|
5559
5565
|
getWorkspaceCameraIps(params: {
|
|
5560
5566
|
workspaceIds?: string[];
|
|
5561
5567
|
lineIds?: string[];
|
package/dist/index.d.ts
CHANGED
|
@@ -66,6 +66,7 @@ interface WorkspaceMetrics {
|
|
|
66
66
|
workspace_name: string;
|
|
67
67
|
action_count: number;
|
|
68
68
|
pph: number;
|
|
69
|
+
pph_threshold?: number;
|
|
69
70
|
performance_score: 0 | 1 | 2;
|
|
70
71
|
avg_cycle_time: number;
|
|
71
72
|
ideal_cycle_time?: number;
|
|
@@ -5556,6 +5557,11 @@ declare const workspaceService: {
|
|
|
5556
5557
|
lineIds?: string[];
|
|
5557
5558
|
force?: boolean;
|
|
5558
5559
|
}): Promise<Record<string, WorkspaceVideoStream>>;
|
|
5560
|
+
primeWorkspaceVideoStreamsCache(params: {
|
|
5561
|
+
streams: Record<string, WorkspaceVideoStream>;
|
|
5562
|
+
workspaceIds?: string[];
|
|
5563
|
+
lineIds?: string[];
|
|
5564
|
+
}): void;
|
|
5559
5565
|
getWorkspaceCameraIps(params: {
|
|
5560
5566
|
workspaceIds?: string[];
|
|
5561
5567
|
lineIds?: string[];
|
package/dist/index.js
CHANGED
|
@@ -5117,6 +5117,27 @@ var workspaceService = {
|
|
|
5117
5117
|
this._workspaceVideoStreamsInFlight.set(cacheKey, fetchPromise);
|
|
5118
5118
|
return fetchPromise;
|
|
5119
5119
|
},
|
|
5120
|
+
primeWorkspaceVideoStreamsCache(params) {
|
|
5121
|
+
const streams = params.streams || {};
|
|
5122
|
+
const workspaceIds = (params.workspaceIds || []).filter(Boolean);
|
|
5123
|
+
const lineIds = (params.lineIds || []).filter(Boolean);
|
|
5124
|
+
if (!Object.keys(streams).length || !workspaceIds.length && !lineIds.length) {
|
|
5125
|
+
return;
|
|
5126
|
+
}
|
|
5127
|
+
const timestamp = Date.now();
|
|
5128
|
+
const entry = {
|
|
5129
|
+
streams,
|
|
5130
|
+
timestamp
|
|
5131
|
+
};
|
|
5132
|
+
if (workspaceIds.length) {
|
|
5133
|
+
const workspaceKey = workspaceIds.slice().sort().join(",");
|
|
5134
|
+
this._workspaceVideoStreamsCache.set(`workspaces:${workspaceKey}`, entry);
|
|
5135
|
+
}
|
|
5136
|
+
if (lineIds.length) {
|
|
5137
|
+
const lineKey = lineIds.slice().sort().join(",");
|
|
5138
|
+
this._workspaceVideoStreamsCache.set(`lines:${lineKey}`, entry);
|
|
5139
|
+
}
|
|
5140
|
+
},
|
|
5120
5141
|
async getWorkspaceCameraIps(params) {
|
|
5121
5142
|
const workspaceIds = (params.workspaceIds || []).filter(Boolean);
|
|
5122
5143
|
const lineIds = (params.lineIds || []).filter(Boolean);
|
|
@@ -11988,8 +12009,8 @@ var useOperationalShiftKey = ({
|
|
|
11988
12009
|
};
|
|
11989
12010
|
|
|
11990
12011
|
// src/lib/stores/workspaceMetricsStore.ts
|
|
11991
|
-
var OVERVIEW_TTL_MS =
|
|
11992
|
-
var DETAILED_TTL_MS =
|
|
12012
|
+
var OVERVIEW_TTL_MS = 12e4;
|
|
12013
|
+
var DETAILED_TTL_MS = 12e4;
|
|
11993
12014
|
var overviewByKey = /* @__PURE__ */ new Map();
|
|
11994
12015
|
var detailedByKey = /* @__PURE__ */ new Map();
|
|
11995
12016
|
var latestOverviewByWorkspace = /* @__PURE__ */ new Map();
|
|
@@ -13485,6 +13506,109 @@ function getEfficiencyTextColorClasses(efficiency, legend = DEFAULT_EFFICIENCY_L
|
|
|
13485
13506
|
}
|
|
13486
13507
|
}
|
|
13487
13508
|
|
|
13509
|
+
// src/lib/utils/monitorWorkspaceMetrics.ts
|
|
13510
|
+
var sortWorkspaceMetrics = (left, right) => {
|
|
13511
|
+
if (left.line_id !== right.line_id) {
|
|
13512
|
+
return left.line_id.localeCompare(right.line_id);
|
|
13513
|
+
}
|
|
13514
|
+
return left.workspace_name.localeCompare(right.workspace_name, void 0, { numeric: true });
|
|
13515
|
+
};
|
|
13516
|
+
var buildLineMetricsById = (lineMetrics) => (lineMetrics || []).reduce((acc, lineMetric) => {
|
|
13517
|
+
const lineId = lineMetric?.line_id;
|
|
13518
|
+
if (!lineId) {
|
|
13519
|
+
return acc;
|
|
13520
|
+
}
|
|
13521
|
+
acc[lineId] = { total_workspaces: lineMetric?.total_workspaces };
|
|
13522
|
+
return acc;
|
|
13523
|
+
}, {});
|
|
13524
|
+
var transformMonitorWorkspaceMetrics = ({
|
|
13525
|
+
rows,
|
|
13526
|
+
companyId,
|
|
13527
|
+
workspaceConfig,
|
|
13528
|
+
appTimezone,
|
|
13529
|
+
lineMetrics,
|
|
13530
|
+
resolveShiftConfig,
|
|
13531
|
+
shouldOverrideShiftType,
|
|
13532
|
+
fallbackShiftConfig = null
|
|
13533
|
+
}) => {
|
|
13534
|
+
const effectiveWorkspaceConfig = workspaceConfig || DEFAULT_WORKSPACE_CONFIG;
|
|
13535
|
+
const detailTimezone = appTimezone || "Asia/Kolkata";
|
|
13536
|
+
const lineMetricsById = buildLineMetricsById(lineMetrics);
|
|
13537
|
+
return (rows || []).map((item) => {
|
|
13538
|
+
const lineId = String(item?.line_id || "");
|
|
13539
|
+
const lineShiftConfig = resolveShiftConfig?.(lineId) || fallbackShiftConfig || void 0;
|
|
13540
|
+
const detailedMetrics = toWorkspaceDetailedMetrics({
|
|
13541
|
+
data: item,
|
|
13542
|
+
companyId,
|
|
13543
|
+
workspaceConfig: effectiveWorkspaceConfig,
|
|
13544
|
+
shiftConfig: lineShiftConfig,
|
|
13545
|
+
appTimezone: detailTimezone,
|
|
13546
|
+
lineMetricsById,
|
|
13547
|
+
overrideShiftType: shouldOverrideShiftType?.(lineId) ?? false
|
|
13548
|
+
});
|
|
13549
|
+
if (detailedMetrics) {
|
|
13550
|
+
workspaceMetricsStore.setDetailed(detailedMetrics);
|
|
13551
|
+
}
|
|
13552
|
+
const idleTimeValue = typeof item.idle_time === "number" ? item.idle_time : Number(item.idle_time);
|
|
13553
|
+
const idleTimeSeconds = Number.isFinite(idleTimeValue) ? idleTimeValue : void 0;
|
|
13554
|
+
const pphThresholdValue = typeof item.pph_threshold === "number" ? item.pph_threshold : Number(item.pph_threshold);
|
|
13555
|
+
const actionFamily = normalizeActionFamily({
|
|
13556
|
+
actionFamily: item.action_family,
|
|
13557
|
+
actionType: item.action_type,
|
|
13558
|
+
actionName: item.action_name
|
|
13559
|
+
});
|
|
13560
|
+
const actionType = actionFamily === "assembly" || actionFamily === "output" ? actionFamily : null;
|
|
13561
|
+
const metric = {
|
|
13562
|
+
company_id: item.company_id || companyId,
|
|
13563
|
+
line_id: lineId,
|
|
13564
|
+
shift_id: item.shift_id,
|
|
13565
|
+
date: item.date,
|
|
13566
|
+
workspace_uuid: item.workspace_id,
|
|
13567
|
+
workspace_name: item.workspace_name,
|
|
13568
|
+
displayName: item.workspace_display_name || item.display_name || void 0,
|
|
13569
|
+
action_count: item.total_output || 0,
|
|
13570
|
+
pph: item.avg_pph || 0,
|
|
13571
|
+
pph_threshold: Number.isFinite(pphThresholdValue) ? pphThresholdValue : void 0,
|
|
13572
|
+
performance_score: item.performance_score || 0,
|
|
13573
|
+
avg_cycle_time: item.avg_cycle_time || 0,
|
|
13574
|
+
ideal_cycle_time: item.ideal_cycle_time || void 0,
|
|
13575
|
+
trend: item.trend_score === 1 ? 2 : 0,
|
|
13576
|
+
predicted_output: item.ideal_output || 0,
|
|
13577
|
+
efficiency: item.efficiency || 0,
|
|
13578
|
+
action_threshold: item.total_day_output || 0,
|
|
13579
|
+
monitoring_mode: item.monitoring_mode ?? void 0,
|
|
13580
|
+
idle_time: idleTimeSeconds,
|
|
13581
|
+
idle_time_hourly: item.idle_time_hourly ?? null,
|
|
13582
|
+
shift_start: item.shift_start ?? void 0,
|
|
13583
|
+
shift_end: item.shift_end ?? void 0,
|
|
13584
|
+
assembly_enabled: item.assembly_enabled ?? false,
|
|
13585
|
+
video_grid_metric_mode: normalizeVideoGridMetricMode(
|
|
13586
|
+
item.video_grid_metric_mode,
|
|
13587
|
+
item.assembly_enabled ?? false
|
|
13588
|
+
),
|
|
13589
|
+
action_type: actionType,
|
|
13590
|
+
action_family: actionFamily,
|
|
13591
|
+
action_display_name: getActionDisplayName({
|
|
13592
|
+
displayName: item.action_display_name,
|
|
13593
|
+
actionFamily: item.action_family,
|
|
13594
|
+
actionType: item.action_type,
|
|
13595
|
+
actionName: item.action_name
|
|
13596
|
+
}),
|
|
13597
|
+
recent_flow_percent: item.recent_flow_percent ?? null,
|
|
13598
|
+
recent_flow_window_minutes: item.recent_flow_window_minutes ?? null,
|
|
13599
|
+
recent_flow_effective_end_at: item.recent_flow_effective_end_at ?? null,
|
|
13600
|
+
recent_flow_computed_at: item.recent_flow_computed_at ?? null,
|
|
13601
|
+
scheduled_break_active: item.scheduled_break_active ?? false,
|
|
13602
|
+
incoming_wip_current: item.incoming_wip_current ?? null,
|
|
13603
|
+
incoming_wip_effective_at: item.incoming_wip_effective_at ?? null,
|
|
13604
|
+
incoming_wip_buffer_name: item.incoming_wip_buffer_name ?? null,
|
|
13605
|
+
show_exclamation: item.show_exclamation ?? void 0
|
|
13606
|
+
};
|
|
13607
|
+
workspaceMetricsStore.setOverview(metric);
|
|
13608
|
+
return metric;
|
|
13609
|
+
}).sort(sortWorkspaceMetrics);
|
|
13610
|
+
};
|
|
13611
|
+
|
|
13488
13612
|
// src/lib/hooks/useDashboardMetrics.ts
|
|
13489
13613
|
var DEBUG_DASHBOARD_LOGS = process.env.NEXT_PUBLIC_DEBUG_DASHBOARD === "true";
|
|
13490
13614
|
var REALTIME_REFRESH_DEBOUNCE_MS = 1500;
|
|
@@ -13802,89 +13926,16 @@ var useDashboardMetrics = ({
|
|
|
13802
13926
|
}
|
|
13803
13927
|
efficiencyLegend = parseEfficiencyLegend(backendData?.efficiency_legend) ?? DEFAULT_EFFICIENCY_LEGEND;
|
|
13804
13928
|
}
|
|
13805
|
-
const lineMetricsById = (allLineMetrics || []).reduce(
|
|
13806
|
-
(acc, line) => {
|
|
13807
|
-
const lineId2 = line?.line_id;
|
|
13808
|
-
if (lineId2) {
|
|
13809
|
-
acc[lineId2] = { total_workspaces: line?.total_workspaces };
|
|
13810
|
-
}
|
|
13811
|
-
return acc;
|
|
13812
|
-
},
|
|
13813
|
-
{}
|
|
13814
|
-
);
|
|
13815
13929
|
const detailTimezone = appTimezone || "Asia/Kolkata";
|
|
13816
|
-
|
|
13817
|
-
|
|
13818
|
-
|
|
13819
|
-
|
|
13820
|
-
|
|
13821
|
-
|
|
13822
|
-
|
|
13823
|
-
|
|
13824
|
-
|
|
13825
|
-
overrideShiftType: Boolean(lineShiftConfig)
|
|
13826
|
-
});
|
|
13827
|
-
if (detailedMetrics) {
|
|
13828
|
-
workspaceMetricsStore.setDetailed(detailedMetrics);
|
|
13829
|
-
}
|
|
13830
|
-
});
|
|
13831
|
-
const transformedWorkspaceData = allWorkspaceMetrics.map((item) => {
|
|
13832
|
-
const idleTimeValue = typeof item.idle_time === "number" ? item.idle_time : Number(item.idle_time);
|
|
13833
|
-
const idleTimeSeconds = Number.isFinite(idleTimeValue) ? idleTimeValue : void 0;
|
|
13834
|
-
const actionFamily = normalizeActionFamily({
|
|
13835
|
-
actionFamily: item.action_family,
|
|
13836
|
-
actionType: item.action_type,
|
|
13837
|
-
actionName: item.action_name
|
|
13838
|
-
});
|
|
13839
|
-
const actionType = actionFamily === "assembly" || actionFamily === "output" ? actionFamily : null;
|
|
13840
|
-
return {
|
|
13841
|
-
company_id: item.company_id || companyId,
|
|
13842
|
-
line_id: item.line_id,
|
|
13843
|
-
shift_id: item.shift_id,
|
|
13844
|
-
date: item.date,
|
|
13845
|
-
workspace_uuid: item.workspace_id,
|
|
13846
|
-
workspace_name: item.workspace_name,
|
|
13847
|
-
displayName: item.workspace_display_name || item.display_name || void 0,
|
|
13848
|
-
action_count: item.total_output || 0,
|
|
13849
|
-
pph: item.avg_pph || 0,
|
|
13850
|
-
performance_score: item.performance_score || 0,
|
|
13851
|
-
avg_cycle_time: item.avg_cycle_time || 0,
|
|
13852
|
-
trend: item.trend_score === 1 ? 2 : 0,
|
|
13853
|
-
predicted_output: item.ideal_output || 0,
|
|
13854
|
-
efficiency: item.efficiency || 0,
|
|
13855
|
-
action_threshold: item.total_day_output || 0,
|
|
13856
|
-
show_exclamation: item.show_exclamation ?? void 0,
|
|
13857
|
-
monitoring_mode: item.monitoring_mode ?? void 0,
|
|
13858
|
-
idle_time: idleTimeSeconds,
|
|
13859
|
-
assembly_enabled: item.assembly_enabled ?? false,
|
|
13860
|
-
video_grid_metric_mode: normalizeVideoGridMetricMode(
|
|
13861
|
-
item.video_grid_metric_mode,
|
|
13862
|
-
item.assembly_enabled ?? false
|
|
13863
|
-
),
|
|
13864
|
-
action_type: actionType,
|
|
13865
|
-
action_family: actionFamily,
|
|
13866
|
-
action_display_name: getActionDisplayName({
|
|
13867
|
-
displayName: item.action_display_name,
|
|
13868
|
-
actionFamily: item.action_family,
|
|
13869
|
-
actionType: item.action_type,
|
|
13870
|
-
actionName: item.action_name
|
|
13871
|
-
}),
|
|
13872
|
-
recent_flow_percent: item.recent_flow_percent ?? null,
|
|
13873
|
-
recent_flow_window_minutes: item.recent_flow_window_minutes ?? null,
|
|
13874
|
-
recent_flow_effective_end_at: item.recent_flow_effective_end_at ?? null,
|
|
13875
|
-
recent_flow_computed_at: item.recent_flow_computed_at ?? null,
|
|
13876
|
-
incoming_wip_current: item.incoming_wip_current ?? null,
|
|
13877
|
-
incoming_wip_effective_at: item.incoming_wip_effective_at ?? null,
|
|
13878
|
-
incoming_wip_buffer_name: item.incoming_wip_buffer_name ?? null
|
|
13879
|
-
};
|
|
13880
|
-
}).sort((a, b) => {
|
|
13881
|
-
if (a.line_id !== b.line_id) return a.line_id.localeCompare(b.line_id);
|
|
13882
|
-
const wsNumA = parseInt(a.workspace_name?.replace(/[^0-9]/g, "") || "0");
|
|
13883
|
-
const wsNumB = parseInt(b.workspace_name?.replace(/[^0-9]/g, "") || "0");
|
|
13884
|
-
return wsNumA - wsNumB;
|
|
13885
|
-
});
|
|
13886
|
-
transformedWorkspaceData.forEach((metric) => {
|
|
13887
|
-
workspaceMetricsStore.setOverview(metric);
|
|
13930
|
+
const transformedWorkspaceData = transformMonitorWorkspaceMetrics({
|
|
13931
|
+
rows: allWorkspaceMetrics,
|
|
13932
|
+
companyId: companyId || "",
|
|
13933
|
+
workspaceConfig: effectiveWorkspaceConfig,
|
|
13934
|
+
appTimezone: detailTimezone,
|
|
13935
|
+
lineMetrics: allLineMetrics,
|
|
13936
|
+
resolveShiftConfig: (metricLineId) => isFactoryView ? multiLineShiftConfigMap.get(metricLineId) || staticShiftConfig : shiftConfig || staticShiftConfig,
|
|
13937
|
+
shouldOverrideShiftType: (metricLineId) => isFactoryView ? Boolean(multiLineShiftConfigMap.get(metricLineId)) : Boolean(shiftConfig),
|
|
13938
|
+
fallbackShiftConfig: staticShiftConfig
|
|
13888
13939
|
});
|
|
13889
13940
|
const newMetricsState = {
|
|
13890
13941
|
workspaceMetrics: transformedWorkspaceData,
|
|
@@ -60844,67 +60895,6 @@ var HelpView = ({
|
|
|
60844
60895
|
};
|
|
60845
60896
|
var AuthenticatedHelpView = withAuth(HelpView);
|
|
60846
60897
|
var HelpView_default = HelpView;
|
|
60847
|
-
var sortWorkspaceMetrics = (left, right) => {
|
|
60848
|
-
if (left.line_id !== right.line_id) {
|
|
60849
|
-
return left.line_id.localeCompare(right.line_id);
|
|
60850
|
-
}
|
|
60851
|
-
return left.workspace_name.localeCompare(right.workspace_name, void 0, { numeric: true });
|
|
60852
|
-
};
|
|
60853
|
-
var transformWorkspaceMetrics = (rows) => (rows || []).map((item) => {
|
|
60854
|
-
const actionFamily = normalizeActionFamily({
|
|
60855
|
-
actionFamily: item.action_family,
|
|
60856
|
-
actionType: item.action_type,
|
|
60857
|
-
actionName: item.action_name
|
|
60858
|
-
});
|
|
60859
|
-
const actionType = actionFamily === "assembly" || actionFamily === "output" ? actionFamily : null;
|
|
60860
|
-
const metric = {
|
|
60861
|
-
company_id: item.company_id || "",
|
|
60862
|
-
line_id: item.line_id,
|
|
60863
|
-
shift_id: item.shift_id,
|
|
60864
|
-
date: item.date,
|
|
60865
|
-
workspace_uuid: item.workspace_id,
|
|
60866
|
-
workspace_name: item.workspace_name,
|
|
60867
|
-
displayName: item.workspace_display_name || item.display_name || void 0,
|
|
60868
|
-
action_count: item.total_output || 0,
|
|
60869
|
-
pph: item.avg_pph || 0,
|
|
60870
|
-
performance_score: item.performance_score || 0,
|
|
60871
|
-
avg_cycle_time: item.avg_cycle_time || 0,
|
|
60872
|
-
ideal_cycle_time: item.ideal_cycle_time || void 0,
|
|
60873
|
-
trend: item.trend_score === 1 ? 2 : 0,
|
|
60874
|
-
predicted_output: item.ideal_output || 0,
|
|
60875
|
-
efficiency: item.efficiency || 0,
|
|
60876
|
-
action_threshold: item.total_day_output || 0,
|
|
60877
|
-
monitoring_mode: item.monitoring_mode ?? void 0,
|
|
60878
|
-
idle_time: typeof item.idle_time === "number" ? item.idle_time : Number(item.idle_time),
|
|
60879
|
-
idle_time_hourly: item.idle_time_hourly ?? null,
|
|
60880
|
-
shift_start: item.shift_start ?? void 0,
|
|
60881
|
-
shift_end: item.shift_end ?? void 0,
|
|
60882
|
-
assembly_enabled: item.assembly_enabled ?? false,
|
|
60883
|
-
video_grid_metric_mode: normalizeVideoGridMetricMode(
|
|
60884
|
-
item.video_grid_metric_mode,
|
|
60885
|
-
item.assembly_enabled ?? false
|
|
60886
|
-
),
|
|
60887
|
-
action_type: actionType,
|
|
60888
|
-
action_family: actionFamily,
|
|
60889
|
-
action_display_name: getActionDisplayName({
|
|
60890
|
-
displayName: item.action_display_name,
|
|
60891
|
-
actionFamily: item.action_family,
|
|
60892
|
-
actionType: item.action_type,
|
|
60893
|
-
actionName: item.action_name
|
|
60894
|
-
}),
|
|
60895
|
-
recent_flow_percent: item.recent_flow_percent ?? null,
|
|
60896
|
-
recent_flow_window_minutes: item.recent_flow_window_minutes ?? null,
|
|
60897
|
-
recent_flow_effective_end_at: item.recent_flow_effective_end_at ?? null,
|
|
60898
|
-
recent_flow_computed_at: item.recent_flow_computed_at ?? null,
|
|
60899
|
-
scheduled_break_active: item.scheduled_break_active ?? false,
|
|
60900
|
-
incoming_wip_current: item.incoming_wip_current ?? null,
|
|
60901
|
-
incoming_wip_effective_at: item.incoming_wip_effective_at ?? null,
|
|
60902
|
-
incoming_wip_buffer_name: item.incoming_wip_buffer_name ?? null,
|
|
60903
|
-
show_exclamation: item.show_exclamation ?? void 0
|
|
60904
|
-
};
|
|
60905
|
-
workspaceMetricsStore.setOverview(metric);
|
|
60906
|
-
return metric;
|
|
60907
|
-
}).sort(sortWorkspaceMetrics);
|
|
60908
60898
|
var transformActiveBreaks = (activeBreaksByLine) => {
|
|
60909
60899
|
if (!activeBreaksByLine) return [];
|
|
60910
60900
|
return Object.values(activeBreaksByLine).flat().map((item) => ({
|
|
@@ -60945,12 +60935,18 @@ var normalizeMetadata = (metadata) => ({
|
|
|
60945
60935
|
var useLiveMonitorBootstrap = ({
|
|
60946
60936
|
lineIds,
|
|
60947
60937
|
companyId,
|
|
60948
|
-
enabled = true
|
|
60938
|
+
enabled = true,
|
|
60939
|
+
appTimezone,
|
|
60940
|
+
workspaceConfig,
|
|
60941
|
+
fallbackShiftConfig,
|
|
60942
|
+
lineShiftConfigs
|
|
60949
60943
|
}) => {
|
|
60950
60944
|
const supabase = useSupabase();
|
|
60951
60945
|
const entityConfig = useEntityConfig();
|
|
60952
60946
|
const { hydrateFromBackend } = useIdleTimeVlmConfig();
|
|
60953
60947
|
const resolvedCompanyId = companyId || entityConfig?.companyId;
|
|
60948
|
+
const effectiveWorkspaceConfig = workspaceConfig || DEFAULT_WORKSPACE_CONFIG;
|
|
60949
|
+
const effectiveTimezone = appTimezone || "Asia/Kolkata";
|
|
60954
60950
|
const rawLineIdsKey = (lineIds || []).filter(Boolean).join(",");
|
|
60955
60951
|
const normalizedLineIds = React143.useMemo(
|
|
60956
60952
|
() => Array.from(new Set(rawLineIdsKey ? rawLineIdsKey.split(",") : [])),
|
|
@@ -60991,12 +60987,28 @@ var useLiveMonitorBootstrap = ({
|
|
|
60991
60987
|
if (requestId !== activeRequestIdRef.current) {
|
|
60992
60988
|
return;
|
|
60993
60989
|
}
|
|
60994
|
-
const workspaceMetrics =
|
|
60990
|
+
const workspaceMetrics = transformMonitorWorkspaceMetrics({
|
|
60991
|
+
rows: response.workspace_metrics || [],
|
|
60992
|
+
companyId: resolvedCompanyId,
|
|
60993
|
+
workspaceConfig: effectiveWorkspaceConfig,
|
|
60994
|
+
appTimezone: effectiveTimezone,
|
|
60995
|
+
lineMetrics: response.line_metrics || [],
|
|
60996
|
+
resolveShiftConfig: (lineId) => lineShiftConfigs?.get(lineId) || fallbackShiftConfig,
|
|
60997
|
+
shouldOverrideShiftType: (lineId) => Boolean(lineShiftConfigs?.get(lineId)),
|
|
60998
|
+
fallbackShiftConfig
|
|
60999
|
+
});
|
|
60995
61000
|
const activeBreaks = transformActiveBreaks(response.active_breaks_by_line);
|
|
60996
61001
|
const metadata = normalizeMetadata(response.metadata);
|
|
61002
|
+
const workspaceIds = workspaceMetrics.map((metric) => metric.workspace_uuid).filter((workspaceId) => Boolean(workspaceId));
|
|
61003
|
+
const videoStreamsByWorkspaceId = response.video_streams_by_workspace_id || {};
|
|
60997
61004
|
if (metadata.idleTimeVlmByLine) {
|
|
60998
61005
|
hydrateFromBackend(metadata.idleTimeVlmByLine);
|
|
60999
61006
|
}
|
|
61007
|
+
workspaceService.primeWorkspaceVideoStreamsCache({
|
|
61008
|
+
streams: videoStreamsByWorkspaceId,
|
|
61009
|
+
workspaceIds,
|
|
61010
|
+
lineIds: normalizedLineIds
|
|
61011
|
+
});
|
|
61000
61012
|
setState({
|
|
61001
61013
|
requestKey,
|
|
61002
61014
|
resolvedScope: response.resolved_scope || [],
|
|
@@ -61006,7 +61018,7 @@ var useLiveMonitorBootstrap = ({
|
|
|
61006
61018
|
lineMetrics: response.line_metrics || [],
|
|
61007
61019
|
kpiTrend: response.kpi_trend || null,
|
|
61008
61020
|
activeBreaks,
|
|
61009
|
-
videoStreamsByWorkspaceId
|
|
61021
|
+
videoStreamsByWorkspaceId,
|
|
61010
61022
|
efficiencyLegend: response.efficiency_legend || null,
|
|
61011
61023
|
metadata
|
|
61012
61024
|
});
|
|
@@ -61020,7 +61032,18 @@ var useLiveMonitorBootstrap = ({
|
|
|
61020
61032
|
setIsLoading(false);
|
|
61021
61033
|
}
|
|
61022
61034
|
}
|
|
61023
|
-
}, [
|
|
61035
|
+
}, [
|
|
61036
|
+
enabled,
|
|
61037
|
+
supabase,
|
|
61038
|
+
resolvedCompanyId,
|
|
61039
|
+
normalizedLineIds,
|
|
61040
|
+
requestKey,
|
|
61041
|
+
hydrateFromBackend,
|
|
61042
|
+
effectiveWorkspaceConfig,
|
|
61043
|
+
effectiveTimezone,
|
|
61044
|
+
lineShiftConfigs,
|
|
61045
|
+
fallbackShiftConfig
|
|
61046
|
+
]);
|
|
61024
61047
|
React143.useEffect(() => {
|
|
61025
61048
|
if (!enabled) {
|
|
61026
61049
|
setIsLoading(false);
|
|
@@ -61580,7 +61603,11 @@ function HomeView({
|
|
|
61580
61603
|
const bootstrapMonitor = useLiveMonitorBootstrap({
|
|
61581
61604
|
lineIds: selectedLineIds,
|
|
61582
61605
|
companyId: userCompanyId,
|
|
61583
|
-
enabled: shouldEnableMetricsFetch && !isLegacyMonitorMode
|
|
61606
|
+
enabled: shouldEnableMetricsFetch && !isLegacyMonitorMode,
|
|
61607
|
+
appTimezone: timezone,
|
|
61608
|
+
workspaceConfig: dashboardConfig?.workspaceConfig,
|
|
61609
|
+
fallbackShiftConfig: dashboardConfig?.shiftConfig,
|
|
61610
|
+
lineShiftConfigs
|
|
61584
61611
|
});
|
|
61585
61612
|
const currentWorkspaceMetrics = isBootstrapMonitorMode ? bootstrapMonitor.workspaceMetrics : legacyWorkspaceMetrics;
|
|
61586
61613
|
const currentLineMetrics = isBootstrapMonitorMode ? bootstrapMonitor.lineMetrics : legacyLineMetrics;
|
|
@@ -62784,7 +62811,7 @@ var buildLineInfoSnapshot = (lineDetails, metrics2) => {
|
|
|
62784
62811
|
}
|
|
62785
62812
|
};
|
|
62786
62813
|
};
|
|
62787
|
-
var
|
|
62814
|
+
var transformWorkspaceMetrics = (workspaceData, lineId, companyId, queryDate, queryShiftId) => (workspaceData || []).map((item) => ({
|
|
62788
62815
|
company_id: item.company_id || companyId,
|
|
62789
62816
|
line_id: item.line_id || lineId,
|
|
62790
62817
|
shift_id: item.shift_id ?? queryShiftId,
|
|
@@ -62932,7 +62959,7 @@ var useLineDetailPageData = ({
|
|
|
62932
62959
|
setDetailResponse(nextDetail);
|
|
62933
62960
|
const metrics3 = transformLineMetrics(lineId, nextDetail, queryDate, queryShiftId);
|
|
62934
62961
|
const lineDetails2 = transformLineDetails(lineId, nextDetail);
|
|
62935
|
-
const workspaces2 =
|
|
62962
|
+
const workspaces2 = transformWorkspaceMetrics(
|
|
62936
62963
|
nextDetail.workspace_metrics || [],
|
|
62937
62964
|
lineId,
|
|
62938
62965
|
companyId,
|
|
@@ -63022,7 +63049,7 @@ var useLineDetailPageData = ({
|
|
|
63022
63049
|
[detailResponse, lineId]
|
|
63023
63050
|
);
|
|
63024
63051
|
const workspaces = React143.useMemo(
|
|
63025
|
-
() => detailResponse && companyId ?
|
|
63052
|
+
() => detailResponse && companyId ? transformWorkspaceMetrics(detailResponse.workspace_metrics || [], lineId, companyId, queryDate, queryShiftId) : [],
|
|
63026
63053
|
[detailResponse, companyId, lineId, queryDate, queryShiftId]
|
|
63027
63054
|
);
|
|
63028
63055
|
const lineInfo = React143.useMemo(() => buildLineInfoSnapshot(lineDetails, metrics2), [lineDetails, metrics2]);
|
|
@@ -72090,6 +72117,8 @@ var WorkspaceDetailView = ({
|
|
|
72090
72117
|
const totalActions = Number(cachedOverviewMetrics.action_count || 0);
|
|
72091
72118
|
const targetOutput = Number(cachedOverviewMetrics.action_threshold || 0);
|
|
72092
72119
|
const idealOutput = Number(cachedOverviewMetrics.predicted_output ?? targetOutput ?? 0);
|
|
72120
|
+
const pphThreshold = Number(cachedOverviewMetrics.pph_threshold || 0);
|
|
72121
|
+
const idealCycleTime = Number(cachedOverviewMetrics.ideal_cycle_time || 0);
|
|
72093
72122
|
return {
|
|
72094
72123
|
line_id: cachedOverviewMetrics.line_id,
|
|
72095
72124
|
line_name: "",
|
|
@@ -72108,11 +72137,11 @@ var WorkspaceDetailView = ({
|
|
|
72108
72137
|
shift_start: shiftDefinition?.startTime || "",
|
|
72109
72138
|
shift_end: shiftDefinition?.endTime || "",
|
|
72110
72139
|
shift_type: shiftType,
|
|
72111
|
-
pph_threshold:
|
|
72140
|
+
pph_threshold: pphThreshold,
|
|
72112
72141
|
target_output: targetOutput,
|
|
72113
72142
|
avg_pph: Number(cachedOverviewMetrics.pph || 0),
|
|
72114
72143
|
avg_cycle_time: avgCycleTime,
|
|
72115
|
-
ideal_cycle_time:
|
|
72144
|
+
ideal_cycle_time: idealCycleTime,
|
|
72116
72145
|
avg_efficiency: Number(cachedOverviewMetrics.efficiency || 0),
|
|
72117
72146
|
total_actions: totalActions,
|
|
72118
72147
|
hourly_action_counts: [],
|
package/dist/index.mjs
CHANGED
|
@@ -5088,6 +5088,27 @@ var workspaceService = {
|
|
|
5088
5088
|
this._workspaceVideoStreamsInFlight.set(cacheKey, fetchPromise);
|
|
5089
5089
|
return fetchPromise;
|
|
5090
5090
|
},
|
|
5091
|
+
primeWorkspaceVideoStreamsCache(params) {
|
|
5092
|
+
const streams = params.streams || {};
|
|
5093
|
+
const workspaceIds = (params.workspaceIds || []).filter(Boolean);
|
|
5094
|
+
const lineIds = (params.lineIds || []).filter(Boolean);
|
|
5095
|
+
if (!Object.keys(streams).length || !workspaceIds.length && !lineIds.length) {
|
|
5096
|
+
return;
|
|
5097
|
+
}
|
|
5098
|
+
const timestamp = Date.now();
|
|
5099
|
+
const entry = {
|
|
5100
|
+
streams,
|
|
5101
|
+
timestamp
|
|
5102
|
+
};
|
|
5103
|
+
if (workspaceIds.length) {
|
|
5104
|
+
const workspaceKey = workspaceIds.slice().sort().join(",");
|
|
5105
|
+
this._workspaceVideoStreamsCache.set(`workspaces:${workspaceKey}`, entry);
|
|
5106
|
+
}
|
|
5107
|
+
if (lineIds.length) {
|
|
5108
|
+
const lineKey = lineIds.slice().sort().join(",");
|
|
5109
|
+
this._workspaceVideoStreamsCache.set(`lines:${lineKey}`, entry);
|
|
5110
|
+
}
|
|
5111
|
+
},
|
|
5091
5112
|
async getWorkspaceCameraIps(params) {
|
|
5092
5113
|
const workspaceIds = (params.workspaceIds || []).filter(Boolean);
|
|
5093
5114
|
const lineIds = (params.lineIds || []).filter(Boolean);
|
|
@@ -11959,8 +11980,8 @@ var useOperationalShiftKey = ({
|
|
|
11959
11980
|
};
|
|
11960
11981
|
|
|
11961
11982
|
// src/lib/stores/workspaceMetricsStore.ts
|
|
11962
|
-
var OVERVIEW_TTL_MS =
|
|
11963
|
-
var DETAILED_TTL_MS =
|
|
11983
|
+
var OVERVIEW_TTL_MS = 12e4;
|
|
11984
|
+
var DETAILED_TTL_MS = 12e4;
|
|
11964
11985
|
var overviewByKey = /* @__PURE__ */ new Map();
|
|
11965
11986
|
var detailedByKey = /* @__PURE__ */ new Map();
|
|
11966
11987
|
var latestOverviewByWorkspace = /* @__PURE__ */ new Map();
|
|
@@ -13456,6 +13477,109 @@ function getEfficiencyTextColorClasses(efficiency, legend = DEFAULT_EFFICIENCY_L
|
|
|
13456
13477
|
}
|
|
13457
13478
|
}
|
|
13458
13479
|
|
|
13480
|
+
// src/lib/utils/monitorWorkspaceMetrics.ts
|
|
13481
|
+
var sortWorkspaceMetrics = (left, right) => {
|
|
13482
|
+
if (left.line_id !== right.line_id) {
|
|
13483
|
+
return left.line_id.localeCompare(right.line_id);
|
|
13484
|
+
}
|
|
13485
|
+
return left.workspace_name.localeCompare(right.workspace_name, void 0, { numeric: true });
|
|
13486
|
+
};
|
|
13487
|
+
var buildLineMetricsById = (lineMetrics) => (lineMetrics || []).reduce((acc, lineMetric) => {
|
|
13488
|
+
const lineId = lineMetric?.line_id;
|
|
13489
|
+
if (!lineId) {
|
|
13490
|
+
return acc;
|
|
13491
|
+
}
|
|
13492
|
+
acc[lineId] = { total_workspaces: lineMetric?.total_workspaces };
|
|
13493
|
+
return acc;
|
|
13494
|
+
}, {});
|
|
13495
|
+
var transformMonitorWorkspaceMetrics = ({
|
|
13496
|
+
rows,
|
|
13497
|
+
companyId,
|
|
13498
|
+
workspaceConfig,
|
|
13499
|
+
appTimezone,
|
|
13500
|
+
lineMetrics,
|
|
13501
|
+
resolveShiftConfig,
|
|
13502
|
+
shouldOverrideShiftType,
|
|
13503
|
+
fallbackShiftConfig = null
|
|
13504
|
+
}) => {
|
|
13505
|
+
const effectiveWorkspaceConfig = workspaceConfig || DEFAULT_WORKSPACE_CONFIG;
|
|
13506
|
+
const detailTimezone = appTimezone || "Asia/Kolkata";
|
|
13507
|
+
const lineMetricsById = buildLineMetricsById(lineMetrics);
|
|
13508
|
+
return (rows || []).map((item) => {
|
|
13509
|
+
const lineId = String(item?.line_id || "");
|
|
13510
|
+
const lineShiftConfig = resolveShiftConfig?.(lineId) || fallbackShiftConfig || void 0;
|
|
13511
|
+
const detailedMetrics = toWorkspaceDetailedMetrics({
|
|
13512
|
+
data: item,
|
|
13513
|
+
companyId,
|
|
13514
|
+
workspaceConfig: effectiveWorkspaceConfig,
|
|
13515
|
+
shiftConfig: lineShiftConfig,
|
|
13516
|
+
appTimezone: detailTimezone,
|
|
13517
|
+
lineMetricsById,
|
|
13518
|
+
overrideShiftType: shouldOverrideShiftType?.(lineId) ?? false
|
|
13519
|
+
});
|
|
13520
|
+
if (detailedMetrics) {
|
|
13521
|
+
workspaceMetricsStore.setDetailed(detailedMetrics);
|
|
13522
|
+
}
|
|
13523
|
+
const idleTimeValue = typeof item.idle_time === "number" ? item.idle_time : Number(item.idle_time);
|
|
13524
|
+
const idleTimeSeconds = Number.isFinite(idleTimeValue) ? idleTimeValue : void 0;
|
|
13525
|
+
const pphThresholdValue = typeof item.pph_threshold === "number" ? item.pph_threshold : Number(item.pph_threshold);
|
|
13526
|
+
const actionFamily = normalizeActionFamily({
|
|
13527
|
+
actionFamily: item.action_family,
|
|
13528
|
+
actionType: item.action_type,
|
|
13529
|
+
actionName: item.action_name
|
|
13530
|
+
});
|
|
13531
|
+
const actionType = actionFamily === "assembly" || actionFamily === "output" ? actionFamily : null;
|
|
13532
|
+
const metric = {
|
|
13533
|
+
company_id: item.company_id || companyId,
|
|
13534
|
+
line_id: lineId,
|
|
13535
|
+
shift_id: item.shift_id,
|
|
13536
|
+
date: item.date,
|
|
13537
|
+
workspace_uuid: item.workspace_id,
|
|
13538
|
+
workspace_name: item.workspace_name,
|
|
13539
|
+
displayName: item.workspace_display_name || item.display_name || void 0,
|
|
13540
|
+
action_count: item.total_output || 0,
|
|
13541
|
+
pph: item.avg_pph || 0,
|
|
13542
|
+
pph_threshold: Number.isFinite(pphThresholdValue) ? pphThresholdValue : void 0,
|
|
13543
|
+
performance_score: item.performance_score || 0,
|
|
13544
|
+
avg_cycle_time: item.avg_cycle_time || 0,
|
|
13545
|
+
ideal_cycle_time: item.ideal_cycle_time || void 0,
|
|
13546
|
+
trend: item.trend_score === 1 ? 2 : 0,
|
|
13547
|
+
predicted_output: item.ideal_output || 0,
|
|
13548
|
+
efficiency: item.efficiency || 0,
|
|
13549
|
+
action_threshold: item.total_day_output || 0,
|
|
13550
|
+
monitoring_mode: item.monitoring_mode ?? void 0,
|
|
13551
|
+
idle_time: idleTimeSeconds,
|
|
13552
|
+
idle_time_hourly: item.idle_time_hourly ?? null,
|
|
13553
|
+
shift_start: item.shift_start ?? void 0,
|
|
13554
|
+
shift_end: item.shift_end ?? void 0,
|
|
13555
|
+
assembly_enabled: item.assembly_enabled ?? false,
|
|
13556
|
+
video_grid_metric_mode: normalizeVideoGridMetricMode(
|
|
13557
|
+
item.video_grid_metric_mode,
|
|
13558
|
+
item.assembly_enabled ?? false
|
|
13559
|
+
),
|
|
13560
|
+
action_type: actionType,
|
|
13561
|
+
action_family: actionFamily,
|
|
13562
|
+
action_display_name: getActionDisplayName({
|
|
13563
|
+
displayName: item.action_display_name,
|
|
13564
|
+
actionFamily: item.action_family,
|
|
13565
|
+
actionType: item.action_type,
|
|
13566
|
+
actionName: item.action_name
|
|
13567
|
+
}),
|
|
13568
|
+
recent_flow_percent: item.recent_flow_percent ?? null,
|
|
13569
|
+
recent_flow_window_minutes: item.recent_flow_window_minutes ?? null,
|
|
13570
|
+
recent_flow_effective_end_at: item.recent_flow_effective_end_at ?? null,
|
|
13571
|
+
recent_flow_computed_at: item.recent_flow_computed_at ?? null,
|
|
13572
|
+
scheduled_break_active: item.scheduled_break_active ?? false,
|
|
13573
|
+
incoming_wip_current: item.incoming_wip_current ?? null,
|
|
13574
|
+
incoming_wip_effective_at: item.incoming_wip_effective_at ?? null,
|
|
13575
|
+
incoming_wip_buffer_name: item.incoming_wip_buffer_name ?? null,
|
|
13576
|
+
show_exclamation: item.show_exclamation ?? void 0
|
|
13577
|
+
};
|
|
13578
|
+
workspaceMetricsStore.setOverview(metric);
|
|
13579
|
+
return metric;
|
|
13580
|
+
}).sort(sortWorkspaceMetrics);
|
|
13581
|
+
};
|
|
13582
|
+
|
|
13459
13583
|
// src/lib/hooks/useDashboardMetrics.ts
|
|
13460
13584
|
var DEBUG_DASHBOARD_LOGS = process.env.NEXT_PUBLIC_DEBUG_DASHBOARD === "true";
|
|
13461
13585
|
var REALTIME_REFRESH_DEBOUNCE_MS = 1500;
|
|
@@ -13773,89 +13897,16 @@ var useDashboardMetrics = ({
|
|
|
13773
13897
|
}
|
|
13774
13898
|
efficiencyLegend = parseEfficiencyLegend(backendData?.efficiency_legend) ?? DEFAULT_EFFICIENCY_LEGEND;
|
|
13775
13899
|
}
|
|
13776
|
-
const lineMetricsById = (allLineMetrics || []).reduce(
|
|
13777
|
-
(acc, line) => {
|
|
13778
|
-
const lineId2 = line?.line_id;
|
|
13779
|
-
if (lineId2) {
|
|
13780
|
-
acc[lineId2] = { total_workspaces: line?.total_workspaces };
|
|
13781
|
-
}
|
|
13782
|
-
return acc;
|
|
13783
|
-
},
|
|
13784
|
-
{}
|
|
13785
|
-
);
|
|
13786
13900
|
const detailTimezone = appTimezone || "Asia/Kolkata";
|
|
13787
|
-
|
|
13788
|
-
|
|
13789
|
-
|
|
13790
|
-
|
|
13791
|
-
|
|
13792
|
-
|
|
13793
|
-
|
|
13794
|
-
|
|
13795
|
-
|
|
13796
|
-
overrideShiftType: Boolean(lineShiftConfig)
|
|
13797
|
-
});
|
|
13798
|
-
if (detailedMetrics) {
|
|
13799
|
-
workspaceMetricsStore.setDetailed(detailedMetrics);
|
|
13800
|
-
}
|
|
13801
|
-
});
|
|
13802
|
-
const transformedWorkspaceData = allWorkspaceMetrics.map((item) => {
|
|
13803
|
-
const idleTimeValue = typeof item.idle_time === "number" ? item.idle_time : Number(item.idle_time);
|
|
13804
|
-
const idleTimeSeconds = Number.isFinite(idleTimeValue) ? idleTimeValue : void 0;
|
|
13805
|
-
const actionFamily = normalizeActionFamily({
|
|
13806
|
-
actionFamily: item.action_family,
|
|
13807
|
-
actionType: item.action_type,
|
|
13808
|
-
actionName: item.action_name
|
|
13809
|
-
});
|
|
13810
|
-
const actionType = actionFamily === "assembly" || actionFamily === "output" ? actionFamily : null;
|
|
13811
|
-
return {
|
|
13812
|
-
company_id: item.company_id || companyId,
|
|
13813
|
-
line_id: item.line_id,
|
|
13814
|
-
shift_id: item.shift_id,
|
|
13815
|
-
date: item.date,
|
|
13816
|
-
workspace_uuid: item.workspace_id,
|
|
13817
|
-
workspace_name: item.workspace_name,
|
|
13818
|
-
displayName: item.workspace_display_name || item.display_name || void 0,
|
|
13819
|
-
action_count: item.total_output || 0,
|
|
13820
|
-
pph: item.avg_pph || 0,
|
|
13821
|
-
performance_score: item.performance_score || 0,
|
|
13822
|
-
avg_cycle_time: item.avg_cycle_time || 0,
|
|
13823
|
-
trend: item.trend_score === 1 ? 2 : 0,
|
|
13824
|
-
predicted_output: item.ideal_output || 0,
|
|
13825
|
-
efficiency: item.efficiency || 0,
|
|
13826
|
-
action_threshold: item.total_day_output || 0,
|
|
13827
|
-
show_exclamation: item.show_exclamation ?? void 0,
|
|
13828
|
-
monitoring_mode: item.monitoring_mode ?? void 0,
|
|
13829
|
-
idle_time: idleTimeSeconds,
|
|
13830
|
-
assembly_enabled: item.assembly_enabled ?? false,
|
|
13831
|
-
video_grid_metric_mode: normalizeVideoGridMetricMode(
|
|
13832
|
-
item.video_grid_metric_mode,
|
|
13833
|
-
item.assembly_enabled ?? false
|
|
13834
|
-
),
|
|
13835
|
-
action_type: actionType,
|
|
13836
|
-
action_family: actionFamily,
|
|
13837
|
-
action_display_name: getActionDisplayName({
|
|
13838
|
-
displayName: item.action_display_name,
|
|
13839
|
-
actionFamily: item.action_family,
|
|
13840
|
-
actionType: item.action_type,
|
|
13841
|
-
actionName: item.action_name
|
|
13842
|
-
}),
|
|
13843
|
-
recent_flow_percent: item.recent_flow_percent ?? null,
|
|
13844
|
-
recent_flow_window_minutes: item.recent_flow_window_minutes ?? null,
|
|
13845
|
-
recent_flow_effective_end_at: item.recent_flow_effective_end_at ?? null,
|
|
13846
|
-
recent_flow_computed_at: item.recent_flow_computed_at ?? null,
|
|
13847
|
-
incoming_wip_current: item.incoming_wip_current ?? null,
|
|
13848
|
-
incoming_wip_effective_at: item.incoming_wip_effective_at ?? null,
|
|
13849
|
-
incoming_wip_buffer_name: item.incoming_wip_buffer_name ?? null
|
|
13850
|
-
};
|
|
13851
|
-
}).sort((a, b) => {
|
|
13852
|
-
if (a.line_id !== b.line_id) return a.line_id.localeCompare(b.line_id);
|
|
13853
|
-
const wsNumA = parseInt(a.workspace_name?.replace(/[^0-9]/g, "") || "0");
|
|
13854
|
-
const wsNumB = parseInt(b.workspace_name?.replace(/[^0-9]/g, "") || "0");
|
|
13855
|
-
return wsNumA - wsNumB;
|
|
13856
|
-
});
|
|
13857
|
-
transformedWorkspaceData.forEach((metric) => {
|
|
13858
|
-
workspaceMetricsStore.setOverview(metric);
|
|
13901
|
+
const transformedWorkspaceData = transformMonitorWorkspaceMetrics({
|
|
13902
|
+
rows: allWorkspaceMetrics,
|
|
13903
|
+
companyId: companyId || "",
|
|
13904
|
+
workspaceConfig: effectiveWorkspaceConfig,
|
|
13905
|
+
appTimezone: detailTimezone,
|
|
13906
|
+
lineMetrics: allLineMetrics,
|
|
13907
|
+
resolveShiftConfig: (metricLineId) => isFactoryView ? multiLineShiftConfigMap.get(metricLineId) || staticShiftConfig : shiftConfig || staticShiftConfig,
|
|
13908
|
+
shouldOverrideShiftType: (metricLineId) => isFactoryView ? Boolean(multiLineShiftConfigMap.get(metricLineId)) : Boolean(shiftConfig),
|
|
13909
|
+
fallbackShiftConfig: staticShiftConfig
|
|
13859
13910
|
});
|
|
13860
13911
|
const newMetricsState = {
|
|
13861
13912
|
workspaceMetrics: transformedWorkspaceData,
|
|
@@ -60815,67 +60866,6 @@ var HelpView = ({
|
|
|
60815
60866
|
};
|
|
60816
60867
|
var AuthenticatedHelpView = withAuth(HelpView);
|
|
60817
60868
|
var HelpView_default = HelpView;
|
|
60818
|
-
var sortWorkspaceMetrics = (left, right) => {
|
|
60819
|
-
if (left.line_id !== right.line_id) {
|
|
60820
|
-
return left.line_id.localeCompare(right.line_id);
|
|
60821
|
-
}
|
|
60822
|
-
return left.workspace_name.localeCompare(right.workspace_name, void 0, { numeric: true });
|
|
60823
|
-
};
|
|
60824
|
-
var transformWorkspaceMetrics = (rows) => (rows || []).map((item) => {
|
|
60825
|
-
const actionFamily = normalizeActionFamily({
|
|
60826
|
-
actionFamily: item.action_family,
|
|
60827
|
-
actionType: item.action_type,
|
|
60828
|
-
actionName: item.action_name
|
|
60829
|
-
});
|
|
60830
|
-
const actionType = actionFamily === "assembly" || actionFamily === "output" ? actionFamily : null;
|
|
60831
|
-
const metric = {
|
|
60832
|
-
company_id: item.company_id || "",
|
|
60833
|
-
line_id: item.line_id,
|
|
60834
|
-
shift_id: item.shift_id,
|
|
60835
|
-
date: item.date,
|
|
60836
|
-
workspace_uuid: item.workspace_id,
|
|
60837
|
-
workspace_name: item.workspace_name,
|
|
60838
|
-
displayName: item.workspace_display_name || item.display_name || void 0,
|
|
60839
|
-
action_count: item.total_output || 0,
|
|
60840
|
-
pph: item.avg_pph || 0,
|
|
60841
|
-
performance_score: item.performance_score || 0,
|
|
60842
|
-
avg_cycle_time: item.avg_cycle_time || 0,
|
|
60843
|
-
ideal_cycle_time: item.ideal_cycle_time || void 0,
|
|
60844
|
-
trend: item.trend_score === 1 ? 2 : 0,
|
|
60845
|
-
predicted_output: item.ideal_output || 0,
|
|
60846
|
-
efficiency: item.efficiency || 0,
|
|
60847
|
-
action_threshold: item.total_day_output || 0,
|
|
60848
|
-
monitoring_mode: item.monitoring_mode ?? void 0,
|
|
60849
|
-
idle_time: typeof item.idle_time === "number" ? item.idle_time : Number(item.idle_time),
|
|
60850
|
-
idle_time_hourly: item.idle_time_hourly ?? null,
|
|
60851
|
-
shift_start: item.shift_start ?? void 0,
|
|
60852
|
-
shift_end: item.shift_end ?? void 0,
|
|
60853
|
-
assembly_enabled: item.assembly_enabled ?? false,
|
|
60854
|
-
video_grid_metric_mode: normalizeVideoGridMetricMode(
|
|
60855
|
-
item.video_grid_metric_mode,
|
|
60856
|
-
item.assembly_enabled ?? false
|
|
60857
|
-
),
|
|
60858
|
-
action_type: actionType,
|
|
60859
|
-
action_family: actionFamily,
|
|
60860
|
-
action_display_name: getActionDisplayName({
|
|
60861
|
-
displayName: item.action_display_name,
|
|
60862
|
-
actionFamily: item.action_family,
|
|
60863
|
-
actionType: item.action_type,
|
|
60864
|
-
actionName: item.action_name
|
|
60865
|
-
}),
|
|
60866
|
-
recent_flow_percent: item.recent_flow_percent ?? null,
|
|
60867
|
-
recent_flow_window_minutes: item.recent_flow_window_minutes ?? null,
|
|
60868
|
-
recent_flow_effective_end_at: item.recent_flow_effective_end_at ?? null,
|
|
60869
|
-
recent_flow_computed_at: item.recent_flow_computed_at ?? null,
|
|
60870
|
-
scheduled_break_active: item.scheduled_break_active ?? false,
|
|
60871
|
-
incoming_wip_current: item.incoming_wip_current ?? null,
|
|
60872
|
-
incoming_wip_effective_at: item.incoming_wip_effective_at ?? null,
|
|
60873
|
-
incoming_wip_buffer_name: item.incoming_wip_buffer_name ?? null,
|
|
60874
|
-
show_exclamation: item.show_exclamation ?? void 0
|
|
60875
|
-
};
|
|
60876
|
-
workspaceMetricsStore.setOverview(metric);
|
|
60877
|
-
return metric;
|
|
60878
|
-
}).sort(sortWorkspaceMetrics);
|
|
60879
60869
|
var transformActiveBreaks = (activeBreaksByLine) => {
|
|
60880
60870
|
if (!activeBreaksByLine) return [];
|
|
60881
60871
|
return Object.values(activeBreaksByLine).flat().map((item) => ({
|
|
@@ -60916,12 +60906,18 @@ var normalizeMetadata = (metadata) => ({
|
|
|
60916
60906
|
var useLiveMonitorBootstrap = ({
|
|
60917
60907
|
lineIds,
|
|
60918
60908
|
companyId,
|
|
60919
|
-
enabled = true
|
|
60909
|
+
enabled = true,
|
|
60910
|
+
appTimezone,
|
|
60911
|
+
workspaceConfig,
|
|
60912
|
+
fallbackShiftConfig,
|
|
60913
|
+
lineShiftConfigs
|
|
60920
60914
|
}) => {
|
|
60921
60915
|
const supabase = useSupabase();
|
|
60922
60916
|
const entityConfig = useEntityConfig();
|
|
60923
60917
|
const { hydrateFromBackend } = useIdleTimeVlmConfig();
|
|
60924
60918
|
const resolvedCompanyId = companyId || entityConfig?.companyId;
|
|
60919
|
+
const effectiveWorkspaceConfig = workspaceConfig || DEFAULT_WORKSPACE_CONFIG;
|
|
60920
|
+
const effectiveTimezone = appTimezone || "Asia/Kolkata";
|
|
60925
60921
|
const rawLineIdsKey = (lineIds || []).filter(Boolean).join(",");
|
|
60926
60922
|
const normalizedLineIds = useMemo(
|
|
60927
60923
|
() => Array.from(new Set(rawLineIdsKey ? rawLineIdsKey.split(",") : [])),
|
|
@@ -60962,12 +60958,28 @@ var useLiveMonitorBootstrap = ({
|
|
|
60962
60958
|
if (requestId !== activeRequestIdRef.current) {
|
|
60963
60959
|
return;
|
|
60964
60960
|
}
|
|
60965
|
-
const workspaceMetrics =
|
|
60961
|
+
const workspaceMetrics = transformMonitorWorkspaceMetrics({
|
|
60962
|
+
rows: response.workspace_metrics || [],
|
|
60963
|
+
companyId: resolvedCompanyId,
|
|
60964
|
+
workspaceConfig: effectiveWorkspaceConfig,
|
|
60965
|
+
appTimezone: effectiveTimezone,
|
|
60966
|
+
lineMetrics: response.line_metrics || [],
|
|
60967
|
+
resolveShiftConfig: (lineId) => lineShiftConfigs?.get(lineId) || fallbackShiftConfig,
|
|
60968
|
+
shouldOverrideShiftType: (lineId) => Boolean(lineShiftConfigs?.get(lineId)),
|
|
60969
|
+
fallbackShiftConfig
|
|
60970
|
+
});
|
|
60966
60971
|
const activeBreaks = transformActiveBreaks(response.active_breaks_by_line);
|
|
60967
60972
|
const metadata = normalizeMetadata(response.metadata);
|
|
60973
|
+
const workspaceIds = workspaceMetrics.map((metric) => metric.workspace_uuid).filter((workspaceId) => Boolean(workspaceId));
|
|
60974
|
+
const videoStreamsByWorkspaceId = response.video_streams_by_workspace_id || {};
|
|
60968
60975
|
if (metadata.idleTimeVlmByLine) {
|
|
60969
60976
|
hydrateFromBackend(metadata.idleTimeVlmByLine);
|
|
60970
60977
|
}
|
|
60978
|
+
workspaceService.primeWorkspaceVideoStreamsCache({
|
|
60979
|
+
streams: videoStreamsByWorkspaceId,
|
|
60980
|
+
workspaceIds,
|
|
60981
|
+
lineIds: normalizedLineIds
|
|
60982
|
+
});
|
|
60971
60983
|
setState({
|
|
60972
60984
|
requestKey,
|
|
60973
60985
|
resolvedScope: response.resolved_scope || [],
|
|
@@ -60977,7 +60989,7 @@ var useLiveMonitorBootstrap = ({
|
|
|
60977
60989
|
lineMetrics: response.line_metrics || [],
|
|
60978
60990
|
kpiTrend: response.kpi_trend || null,
|
|
60979
60991
|
activeBreaks,
|
|
60980
|
-
videoStreamsByWorkspaceId
|
|
60992
|
+
videoStreamsByWorkspaceId,
|
|
60981
60993
|
efficiencyLegend: response.efficiency_legend || null,
|
|
60982
60994
|
metadata
|
|
60983
60995
|
});
|
|
@@ -60991,7 +61003,18 @@ var useLiveMonitorBootstrap = ({
|
|
|
60991
61003
|
setIsLoading(false);
|
|
60992
61004
|
}
|
|
60993
61005
|
}
|
|
60994
|
-
}, [
|
|
61006
|
+
}, [
|
|
61007
|
+
enabled,
|
|
61008
|
+
supabase,
|
|
61009
|
+
resolvedCompanyId,
|
|
61010
|
+
normalizedLineIds,
|
|
61011
|
+
requestKey,
|
|
61012
|
+
hydrateFromBackend,
|
|
61013
|
+
effectiveWorkspaceConfig,
|
|
61014
|
+
effectiveTimezone,
|
|
61015
|
+
lineShiftConfigs,
|
|
61016
|
+
fallbackShiftConfig
|
|
61017
|
+
]);
|
|
60995
61018
|
useEffect(() => {
|
|
60996
61019
|
if (!enabled) {
|
|
60997
61020
|
setIsLoading(false);
|
|
@@ -61551,7 +61574,11 @@ function HomeView({
|
|
|
61551
61574
|
const bootstrapMonitor = useLiveMonitorBootstrap({
|
|
61552
61575
|
lineIds: selectedLineIds,
|
|
61553
61576
|
companyId: userCompanyId,
|
|
61554
|
-
enabled: shouldEnableMetricsFetch && !isLegacyMonitorMode
|
|
61577
|
+
enabled: shouldEnableMetricsFetch && !isLegacyMonitorMode,
|
|
61578
|
+
appTimezone: timezone,
|
|
61579
|
+
workspaceConfig: dashboardConfig?.workspaceConfig,
|
|
61580
|
+
fallbackShiftConfig: dashboardConfig?.shiftConfig,
|
|
61581
|
+
lineShiftConfigs
|
|
61555
61582
|
});
|
|
61556
61583
|
const currentWorkspaceMetrics = isBootstrapMonitorMode ? bootstrapMonitor.workspaceMetrics : legacyWorkspaceMetrics;
|
|
61557
61584
|
const currentLineMetrics = isBootstrapMonitorMode ? bootstrapMonitor.lineMetrics : legacyLineMetrics;
|
|
@@ -62755,7 +62782,7 @@ var buildLineInfoSnapshot = (lineDetails, metrics2) => {
|
|
|
62755
62782
|
}
|
|
62756
62783
|
};
|
|
62757
62784
|
};
|
|
62758
|
-
var
|
|
62785
|
+
var transformWorkspaceMetrics = (workspaceData, lineId, companyId, queryDate, queryShiftId) => (workspaceData || []).map((item) => ({
|
|
62759
62786
|
company_id: item.company_id || companyId,
|
|
62760
62787
|
line_id: item.line_id || lineId,
|
|
62761
62788
|
shift_id: item.shift_id ?? queryShiftId,
|
|
@@ -62903,7 +62930,7 @@ var useLineDetailPageData = ({
|
|
|
62903
62930
|
setDetailResponse(nextDetail);
|
|
62904
62931
|
const metrics3 = transformLineMetrics(lineId, nextDetail, queryDate, queryShiftId);
|
|
62905
62932
|
const lineDetails2 = transformLineDetails(lineId, nextDetail);
|
|
62906
|
-
const workspaces2 =
|
|
62933
|
+
const workspaces2 = transformWorkspaceMetrics(
|
|
62907
62934
|
nextDetail.workspace_metrics || [],
|
|
62908
62935
|
lineId,
|
|
62909
62936
|
companyId,
|
|
@@ -62993,7 +63020,7 @@ var useLineDetailPageData = ({
|
|
|
62993
63020
|
[detailResponse, lineId]
|
|
62994
63021
|
);
|
|
62995
63022
|
const workspaces = useMemo(
|
|
62996
|
-
() => detailResponse && companyId ?
|
|
63023
|
+
() => detailResponse && companyId ? transformWorkspaceMetrics(detailResponse.workspace_metrics || [], lineId, companyId, queryDate, queryShiftId) : [],
|
|
62997
63024
|
[detailResponse, companyId, lineId, queryDate, queryShiftId]
|
|
62998
63025
|
);
|
|
62999
63026
|
const lineInfo = useMemo(() => buildLineInfoSnapshot(lineDetails, metrics2), [lineDetails, metrics2]);
|
|
@@ -72061,6 +72088,8 @@ var WorkspaceDetailView = ({
|
|
|
72061
72088
|
const totalActions = Number(cachedOverviewMetrics.action_count || 0);
|
|
72062
72089
|
const targetOutput = Number(cachedOverviewMetrics.action_threshold || 0);
|
|
72063
72090
|
const idealOutput = Number(cachedOverviewMetrics.predicted_output ?? targetOutput ?? 0);
|
|
72091
|
+
const pphThreshold = Number(cachedOverviewMetrics.pph_threshold || 0);
|
|
72092
|
+
const idealCycleTime = Number(cachedOverviewMetrics.ideal_cycle_time || 0);
|
|
72064
72093
|
return {
|
|
72065
72094
|
line_id: cachedOverviewMetrics.line_id,
|
|
72066
72095
|
line_name: "",
|
|
@@ -72079,11 +72108,11 @@ var WorkspaceDetailView = ({
|
|
|
72079
72108
|
shift_start: shiftDefinition?.startTime || "",
|
|
72080
72109
|
shift_end: shiftDefinition?.endTime || "",
|
|
72081
72110
|
shift_type: shiftType,
|
|
72082
|
-
pph_threshold:
|
|
72111
|
+
pph_threshold: pphThreshold,
|
|
72083
72112
|
target_output: targetOutput,
|
|
72084
72113
|
avg_pph: Number(cachedOverviewMetrics.pph || 0),
|
|
72085
72114
|
avg_cycle_time: avgCycleTime,
|
|
72086
|
-
ideal_cycle_time:
|
|
72115
|
+
ideal_cycle_time: idealCycleTime,
|
|
72087
72116
|
avg_efficiency: Number(cachedOverviewMetrics.efficiency || 0),
|
|
72088
72117
|
total_actions: totalActions,
|
|
72089
72118
|
hourly_action_counts: [],
|