@optifye/dashboard-core 6.5.7 → 6.5.8

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 CHANGED
@@ -32,6 +32,7 @@ interface LineInfo {
32
32
  underperforming_workspace_names: string[];
33
33
  underperforming_workspace_uuids: string[];
34
34
  output_array: number[];
35
+ output_hourly?: Record<string, number[]>;
35
36
  line_threshold: number;
36
37
  threshold_pph?: number;
37
38
  shift_start?: string;
package/dist/index.d.ts CHANGED
@@ -32,6 +32,7 @@ interface LineInfo {
32
32
  underperforming_workspace_names: string[];
33
33
  underperforming_workspace_uuids: string[];
34
34
  output_array: number[];
35
+ output_hourly?: Record<string, number[]>;
35
36
  line_threshold: number;
36
37
  threshold_pph?: number;
37
38
  shift_start?: string;
package/dist/index.js CHANGED
@@ -24939,11 +24939,25 @@ var LinePdfGenerator = ({
24939
24939
  doc.setTextColor(70, 70, 70);
24940
24940
  doc.text("Hourly Output Overview", 20, 135);
24941
24941
  doc.setTextColor(0, 0, 0);
24942
- const getHourlyTimeRanges = (startTimeStr) => {
24942
+ const getHourlyTimeRanges = (startTimeStr, endTimeStr) => {
24943
24943
  const [hours, minutes] = startTimeStr.split(":");
24944
24944
  const startHour = parseInt(hours);
24945
24945
  const startMinute = parseInt(minutes || "0");
24946
- const SHIFT_DURATION = 11;
24946
+ let SHIFT_DURATION = 11;
24947
+ if (endTimeStr) {
24948
+ const [endHours, endMinutes] = endTimeStr.split(":");
24949
+ const endHour = parseInt(endHours);
24950
+ const endMinute = parseInt(endMinutes || "0");
24951
+ let duration = endHour - startHour;
24952
+ if (duration <= 0) {
24953
+ duration += 24;
24954
+ }
24955
+ const minuteDiff = endMinute - startMinute;
24956
+ if (minuteDiff !== 0) {
24957
+ duration += minuteDiff / 60;
24958
+ }
24959
+ SHIFT_DURATION = Math.round(duration);
24960
+ }
24947
24961
  return Array.from({ length: SHIFT_DURATION }, (_, i) => {
24948
24962
  const hourStartTime = /* @__PURE__ */ new Date();
24949
24963
  hourStartTime.setHours(startHour);
@@ -24964,12 +24978,35 @@ var LinePdfGenerator = ({
24964
24978
  return `${formatTime3(hourStartTime)} - ${formatTime3(hourEndTime)}`;
24965
24979
  });
24966
24980
  };
24967
- const hourlyTimeRanges = lineInfo.metrics.shift_start ? getHourlyTimeRanges(lineInfo.metrics.shift_start) : [];
24968
- const targetOutputPerHour = Math.round(lineInfo.metrics.line_threshold / 11);
24969
- const hourlyActualOutput = Array.from({ length: 11 }, (_, i) => {
24970
- const proportionalOutput = Math.round(lineInfo.metrics.current_output / 11 * (0.85 + Math.random() * 0.3));
24971
- return Math.max(0, proportionalOutput);
24972
- });
24981
+ const hourlyTimeRanges = lineInfo.metrics.shift_start ? getHourlyTimeRanges(lineInfo.metrics.shift_start, lineInfo.metrics.shift_end) : [];
24982
+ const shiftDuration = hourlyTimeRanges.length || 11;
24983
+ const targetOutputPerHour = Math.round(lineInfo.metrics.line_threshold / shiftDuration);
24984
+ let hourlyActualOutput = [];
24985
+ if (lineInfo.metrics.output_hourly && Object.keys(lineInfo.metrics.output_hourly).length > 0) {
24986
+ const startHour = parseInt(lineInfo.metrics.shift_start?.split(":")[0] || "6");
24987
+ const expectedHours = [];
24988
+ for (let i = 0; i < shiftDuration; i++) {
24989
+ expectedHours.push((startHour + i) % 24);
24990
+ }
24991
+ hourlyActualOutput = expectedHours.map((hour) => {
24992
+ const hourData = lineInfo.metrics.output_hourly[hour.toString()];
24993
+ if (hourData && Array.isArray(hourData)) {
24994
+ return hourData.reduce((sum, val) => sum + (val || 0), 0);
24995
+ }
24996
+ return 0;
24997
+ });
24998
+ } else if (lineInfo.metrics.output_array && lineInfo.metrics.output_array.length > 0) {
24999
+ hourlyActualOutput = lineInfo.metrics.output_array.reduce((acc, val, i) => {
25000
+ const hourIndex = Math.floor(i / 60);
25001
+ if (!acc[hourIndex]) acc[hourIndex] = 0;
25002
+ acc[hourIndex] += val;
25003
+ return acc;
25004
+ }, []);
25005
+ } else {
25006
+ hourlyActualOutput = Array.from({ length: shiftDuration }, () => {
25007
+ return Math.round(lineInfo.metrics.current_output / shiftDuration);
25008
+ });
25009
+ }
24973
25010
  doc.setFontSize(11);
24974
25011
  doc.setFont("helvetica", "bold");
24975
25012
  doc.setFillColor(245, 245, 245);
@@ -29357,10 +29394,11 @@ var HealthStatusGrid = ({
29357
29394
  };
29358
29395
  var ISTTimer2 = ISTTimer_default;
29359
29396
  var DashboardHeader = React19.memo(({ lineTitle, className = "", headerControls }) => {
29397
+ const dashboardConfig = useDashboardConfig();
29360
29398
  const getShiftName = () => {
29361
- const now2 = /* @__PURE__ */ new Date();
29362
- const currentHour = now2.getHours();
29363
- return currentHour >= 6 && currentHour < 18 ? "Day" : "Night";
29399
+ const timezone = dashboardConfig.dateTimeConfig?.defaultTimezone || "Asia/Kolkata";
29400
+ const currentShift = getCurrentShift(timezone, dashboardConfig.shiftConfig);
29401
+ return currentShift.shiftId === 0 ? "Day" : "Night";
29364
29402
  };
29365
29403
  const getShiftIcon = () => {
29366
29404
  const shift = getShiftName();
@@ -34093,6 +34131,7 @@ var KPIDetailView = ({
34093
34131
  underperforming_workspace_names: metrics2.underperforming_workspace_names || [],
34094
34132
  underperforming_workspace_uuids: metrics2.underperforming_workspace_uuids || [],
34095
34133
  output_array: metrics2.output_array || [],
34134
+ output_hourly: metrics2.output_hourly,
34096
34135
  line_threshold: metrics2.line_threshold ?? 0,
34097
34136
  threshold_pph: metrics2.threshold_pph ?? 0,
34098
34137
  shift_start: metrics2.shift_start || "06:00",
package/dist/index.mjs CHANGED
@@ -24909,11 +24909,25 @@ var LinePdfGenerator = ({
24909
24909
  doc.setTextColor(70, 70, 70);
24910
24910
  doc.text("Hourly Output Overview", 20, 135);
24911
24911
  doc.setTextColor(0, 0, 0);
24912
- const getHourlyTimeRanges = (startTimeStr) => {
24912
+ const getHourlyTimeRanges = (startTimeStr, endTimeStr) => {
24913
24913
  const [hours, minutes] = startTimeStr.split(":");
24914
24914
  const startHour = parseInt(hours);
24915
24915
  const startMinute = parseInt(minutes || "0");
24916
- const SHIFT_DURATION = 11;
24916
+ let SHIFT_DURATION = 11;
24917
+ if (endTimeStr) {
24918
+ const [endHours, endMinutes] = endTimeStr.split(":");
24919
+ const endHour = parseInt(endHours);
24920
+ const endMinute = parseInt(endMinutes || "0");
24921
+ let duration = endHour - startHour;
24922
+ if (duration <= 0) {
24923
+ duration += 24;
24924
+ }
24925
+ const minuteDiff = endMinute - startMinute;
24926
+ if (minuteDiff !== 0) {
24927
+ duration += minuteDiff / 60;
24928
+ }
24929
+ SHIFT_DURATION = Math.round(duration);
24930
+ }
24917
24931
  return Array.from({ length: SHIFT_DURATION }, (_, i) => {
24918
24932
  const hourStartTime = /* @__PURE__ */ new Date();
24919
24933
  hourStartTime.setHours(startHour);
@@ -24934,12 +24948,35 @@ var LinePdfGenerator = ({
24934
24948
  return `${formatTime3(hourStartTime)} - ${formatTime3(hourEndTime)}`;
24935
24949
  });
24936
24950
  };
24937
- const hourlyTimeRanges = lineInfo.metrics.shift_start ? getHourlyTimeRanges(lineInfo.metrics.shift_start) : [];
24938
- const targetOutputPerHour = Math.round(lineInfo.metrics.line_threshold / 11);
24939
- const hourlyActualOutput = Array.from({ length: 11 }, (_, i) => {
24940
- const proportionalOutput = Math.round(lineInfo.metrics.current_output / 11 * (0.85 + Math.random() * 0.3));
24941
- return Math.max(0, proportionalOutput);
24942
- });
24951
+ const hourlyTimeRanges = lineInfo.metrics.shift_start ? getHourlyTimeRanges(lineInfo.metrics.shift_start, lineInfo.metrics.shift_end) : [];
24952
+ const shiftDuration = hourlyTimeRanges.length || 11;
24953
+ const targetOutputPerHour = Math.round(lineInfo.metrics.line_threshold / shiftDuration);
24954
+ let hourlyActualOutput = [];
24955
+ if (lineInfo.metrics.output_hourly && Object.keys(lineInfo.metrics.output_hourly).length > 0) {
24956
+ const startHour = parseInt(lineInfo.metrics.shift_start?.split(":")[0] || "6");
24957
+ const expectedHours = [];
24958
+ for (let i = 0; i < shiftDuration; i++) {
24959
+ expectedHours.push((startHour + i) % 24);
24960
+ }
24961
+ hourlyActualOutput = expectedHours.map((hour) => {
24962
+ const hourData = lineInfo.metrics.output_hourly[hour.toString()];
24963
+ if (hourData && Array.isArray(hourData)) {
24964
+ return hourData.reduce((sum, val) => sum + (val || 0), 0);
24965
+ }
24966
+ return 0;
24967
+ });
24968
+ } else if (lineInfo.metrics.output_array && lineInfo.metrics.output_array.length > 0) {
24969
+ hourlyActualOutput = lineInfo.metrics.output_array.reduce((acc, val, i) => {
24970
+ const hourIndex = Math.floor(i / 60);
24971
+ if (!acc[hourIndex]) acc[hourIndex] = 0;
24972
+ acc[hourIndex] += val;
24973
+ return acc;
24974
+ }, []);
24975
+ } else {
24976
+ hourlyActualOutput = Array.from({ length: shiftDuration }, () => {
24977
+ return Math.round(lineInfo.metrics.current_output / shiftDuration);
24978
+ });
24979
+ }
24943
24980
  doc.setFontSize(11);
24944
24981
  doc.setFont("helvetica", "bold");
24945
24982
  doc.setFillColor(245, 245, 245);
@@ -29327,10 +29364,11 @@ var HealthStatusGrid = ({
29327
29364
  };
29328
29365
  var ISTTimer2 = ISTTimer_default;
29329
29366
  var DashboardHeader = memo(({ lineTitle, className = "", headerControls }) => {
29367
+ const dashboardConfig = useDashboardConfig();
29330
29368
  const getShiftName = () => {
29331
- const now2 = /* @__PURE__ */ new Date();
29332
- const currentHour = now2.getHours();
29333
- return currentHour >= 6 && currentHour < 18 ? "Day" : "Night";
29369
+ const timezone = dashboardConfig.dateTimeConfig?.defaultTimezone || "Asia/Kolkata";
29370
+ const currentShift = getCurrentShift(timezone, dashboardConfig.shiftConfig);
29371
+ return currentShift.shiftId === 0 ? "Day" : "Night";
29334
29372
  };
29335
29373
  const getShiftIcon = () => {
29336
29374
  const shift = getShiftName();
@@ -34063,6 +34101,7 @@ var KPIDetailView = ({
34063
34101
  underperforming_workspace_names: metrics2.underperforming_workspace_names || [],
34064
34102
  underperforming_workspace_uuids: metrics2.underperforming_workspace_uuids || [],
34065
34103
  output_array: metrics2.output_array || [],
34104
+ output_hourly: metrics2.output_hourly,
34066
34105
  line_threshold: metrics2.line_threshold ?? 0,
34067
34106
  threshold_pph: metrics2.threshold_pph ?? 0,
34068
34107
  shift_start: metrics2.shift_start || "06:00",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optifye/dashboard-core",
3
- "version": "6.5.7",
3
+ "version": "6.5.8",
4
4
  "description": "Reusable UI & logic for Optifye dashboard",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",