@optifye/dashboard-core 6.1.5 → 6.1.6
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 +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +31 -7
- package/dist/index.mjs +31 -7
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1547,7 +1547,7 @@ var workspaceService = {
|
|
|
1547
1547
|
const config = _getDashboardConfigInstance();
|
|
1548
1548
|
const dbConfig = config?.databaseConfig;
|
|
1549
1549
|
const workspacesTable = getTable3(dbConfig, "workspaces");
|
|
1550
|
-
const { data, error } = await supabase.from(workspacesTable).select("id, line_id, workspace_id, action_id, action_pph_threshold, action_cycle_time, action_total_day_output").eq("line_id", lineId).order("workspace_id", { ascending: true });
|
|
1550
|
+
const { data, error } = await supabase.from(workspacesTable).select("id, line_id, workspace_id, action_id, action_pph_threshold, action_cycle_time, action_total_day_output, enable").eq("line_id", lineId).order("workspace_id", { ascending: true });
|
|
1551
1551
|
if (error) {
|
|
1552
1552
|
console.error(`Error fetching workspaces from ${workspacesTable}:`, error);
|
|
1553
1553
|
throw error;
|
|
@@ -1568,7 +1568,7 @@ var workspaceService = {
|
|
|
1568
1568
|
const dbConfig = config?.databaseConfig;
|
|
1569
1569
|
const workspacesTable = getTable3(dbConfig, "workspaces");
|
|
1570
1570
|
console.log("\u{1F504} Using workspaces table:", workspacesTable);
|
|
1571
|
-
let query = supabase.from(workspacesTable).select("workspace_id, display_name, line_id");
|
|
1571
|
+
let query = supabase.from(workspacesTable).select("workspace_id, display_name, line_id, enable");
|
|
1572
1572
|
console.log("\u{1F504} Supabase query created, about to add filters...");
|
|
1573
1573
|
if (lineId) {
|
|
1574
1574
|
query = query.eq("line_id", lineId);
|
|
@@ -1587,10 +1587,10 @@ var workspaceService = {
|
|
|
1587
1587
|
console.log("Raw workspace data from Supabase:", data);
|
|
1588
1588
|
const displayNamesMap = /* @__PURE__ */ new Map();
|
|
1589
1589
|
(data || []).forEach((workspace) => {
|
|
1590
|
-
if (workspace.workspace_id && workspace.display_name) {
|
|
1590
|
+
if (workspace.workspace_id && workspace.display_name && workspace.enable === true) {
|
|
1591
1591
|
const displayName = workspace.display_name.trim();
|
|
1592
1592
|
displayNamesMap.set(workspace.workspace_id, displayName);
|
|
1593
|
-
console.log(`\u2705 Mapped: ${workspace.workspace_id} -> ${displayName}`);
|
|
1593
|
+
console.log(`\u2705 Mapped: ${workspace.workspace_id} -> ${displayName} (enabled: ${workspace.enable})`);
|
|
1594
1594
|
}
|
|
1595
1595
|
});
|
|
1596
1596
|
console.log("Final display names map:", Array.from(displayNamesMap.entries()));
|
|
@@ -3726,6 +3726,14 @@ var useLineWorkspaceMetrics = (lineId, options) => {
|
|
|
3726
3726
|
queryShiftId,
|
|
3727
3727
|
metricsTable
|
|
3728
3728
|
});
|
|
3729
|
+
const workspaces2 = await workspaceService.getWorkspaces(lineId);
|
|
3730
|
+
const enabledWorkspaceIds = workspaces2.filter((ws) => ws.enable === true).map((ws) => ws.id);
|
|
3731
|
+
if (enabledWorkspaceIds.length === 0) {
|
|
3732
|
+
setWorkspaces([]);
|
|
3733
|
+
setInitialized(true);
|
|
3734
|
+
setLoading(false);
|
|
3735
|
+
return;
|
|
3736
|
+
}
|
|
3729
3737
|
const { data, error: fetchError } = await supabase.from(metricsTable).select(`
|
|
3730
3738
|
workspace_name,
|
|
3731
3739
|
total_output,
|
|
@@ -3737,7 +3745,7 @@ var useLineWorkspaceMetrics = (lineId, options) => {
|
|
|
3737
3745
|
trend_score,
|
|
3738
3746
|
line_id,
|
|
3739
3747
|
total_day_output
|
|
3740
|
-
`).eq("date", queryDate).eq("shift_id", queryShiftId).eq("line_id", lineId).order("workspace_name", { ascending: true });
|
|
3748
|
+
`).eq("date", queryDate).eq("shift_id", queryShiftId).eq("line_id", lineId).in("workspace_id", enabledWorkspaceIds).order("workspace_name", { ascending: true });
|
|
3741
3749
|
if (fetchError) throw fetchError;
|
|
3742
3750
|
const transformedData = (data || []).map((item) => ({
|
|
3743
3751
|
company_id: entityConfig.companyId || "unknown",
|
|
@@ -4191,7 +4199,22 @@ var useDashboardMetrics = ({ onLineMetricsUpdate, lineId }) => {
|
|
|
4191
4199
|
throw new Error("No target line IDs available for fetching metrics.");
|
|
4192
4200
|
}
|
|
4193
4201
|
const isFactoryView = currentLineIdToUse === (entityConfig.factoryViewId || "factory");
|
|
4194
|
-
let
|
|
4202
|
+
let enabledWorkspaceIds = [];
|
|
4203
|
+
for (const targetLineId of targetLineIds) {
|
|
4204
|
+
const workspaces = await workspaceService.getWorkspaces(targetLineId);
|
|
4205
|
+
const enabledIds = workspaces.filter((ws) => ws.enable === true).map((ws) => ws.id);
|
|
4206
|
+
enabledWorkspaceIds.push(...enabledIds);
|
|
4207
|
+
}
|
|
4208
|
+
if (enabledWorkspaceIds.length === 0) {
|
|
4209
|
+
const newMetricsState2 = {
|
|
4210
|
+
workspaceMetrics: [],
|
|
4211
|
+
lineMetrics: []
|
|
4212
|
+
};
|
|
4213
|
+
setMetrics(newMetricsState2);
|
|
4214
|
+
setCache(currentLineIdToUse, newMetricsState2);
|
|
4215
|
+
return;
|
|
4216
|
+
}
|
|
4217
|
+
let workspaceQuery = supabase.from(companySpecificMetricsTable).select("company_id,line_id,shift_id,date,workspace_id,workspace_name,total_output,avg_pph,performance_score,avg_cycle_time,trend_score,ideal_output,efficiency,total_day_output").eq("date", operationalDate).eq("shift_id", currentShiftDetails.shiftId).in("workspace_id", enabledWorkspaceIds);
|
|
4195
4218
|
if (!isFactoryView) {
|
|
4196
4219
|
workspaceQuery = workspaceQuery.in("line_id", targetLineIds);
|
|
4197
4220
|
}
|
|
@@ -32656,12 +32679,13 @@ var TargetsView = ({
|
|
|
32656
32679
|
}
|
|
32657
32680
|
try {
|
|
32658
32681
|
const workspacesData = await workspaceService.getWorkspaces(lineId);
|
|
32682
|
+
const enabledWorkspaces = workspacesData.filter((ws) => ws.enable === true);
|
|
32659
32683
|
const actionThresholds = await workspaceService.getActionThresholds(
|
|
32660
32684
|
lineId,
|
|
32661
32685
|
currentDate,
|
|
32662
32686
|
selectedShift
|
|
32663
32687
|
);
|
|
32664
|
-
const mappedWorkspaces =
|
|
32688
|
+
const mappedWorkspaces = enabledWorkspaces.map((ws) => {
|
|
32665
32689
|
const threshold = actionThresholds.find((t) => t.workspace_id === ws.id);
|
|
32666
32690
|
return {
|
|
32667
32691
|
id: ws.id,
|
package/dist/index.mjs
CHANGED
|
@@ -1518,7 +1518,7 @@ var workspaceService = {
|
|
|
1518
1518
|
const config = _getDashboardConfigInstance();
|
|
1519
1519
|
const dbConfig = config?.databaseConfig;
|
|
1520
1520
|
const workspacesTable = getTable3(dbConfig, "workspaces");
|
|
1521
|
-
const { data, error } = await supabase.from(workspacesTable).select("id, line_id, workspace_id, action_id, action_pph_threshold, action_cycle_time, action_total_day_output").eq("line_id", lineId).order("workspace_id", { ascending: true });
|
|
1521
|
+
const { data, error } = await supabase.from(workspacesTable).select("id, line_id, workspace_id, action_id, action_pph_threshold, action_cycle_time, action_total_day_output, enable").eq("line_id", lineId).order("workspace_id", { ascending: true });
|
|
1522
1522
|
if (error) {
|
|
1523
1523
|
console.error(`Error fetching workspaces from ${workspacesTable}:`, error);
|
|
1524
1524
|
throw error;
|
|
@@ -1539,7 +1539,7 @@ var workspaceService = {
|
|
|
1539
1539
|
const dbConfig = config?.databaseConfig;
|
|
1540
1540
|
const workspacesTable = getTable3(dbConfig, "workspaces");
|
|
1541
1541
|
console.log("\u{1F504} Using workspaces table:", workspacesTable);
|
|
1542
|
-
let query = supabase.from(workspacesTable).select("workspace_id, display_name, line_id");
|
|
1542
|
+
let query = supabase.from(workspacesTable).select("workspace_id, display_name, line_id, enable");
|
|
1543
1543
|
console.log("\u{1F504} Supabase query created, about to add filters...");
|
|
1544
1544
|
if (lineId) {
|
|
1545
1545
|
query = query.eq("line_id", lineId);
|
|
@@ -1558,10 +1558,10 @@ var workspaceService = {
|
|
|
1558
1558
|
console.log("Raw workspace data from Supabase:", data);
|
|
1559
1559
|
const displayNamesMap = /* @__PURE__ */ new Map();
|
|
1560
1560
|
(data || []).forEach((workspace) => {
|
|
1561
|
-
if (workspace.workspace_id && workspace.display_name) {
|
|
1561
|
+
if (workspace.workspace_id && workspace.display_name && workspace.enable === true) {
|
|
1562
1562
|
const displayName = workspace.display_name.trim();
|
|
1563
1563
|
displayNamesMap.set(workspace.workspace_id, displayName);
|
|
1564
|
-
console.log(`\u2705 Mapped: ${workspace.workspace_id} -> ${displayName}`);
|
|
1564
|
+
console.log(`\u2705 Mapped: ${workspace.workspace_id} -> ${displayName} (enabled: ${workspace.enable})`);
|
|
1565
1565
|
}
|
|
1566
1566
|
});
|
|
1567
1567
|
console.log("Final display names map:", Array.from(displayNamesMap.entries()));
|
|
@@ -3697,6 +3697,14 @@ var useLineWorkspaceMetrics = (lineId, options) => {
|
|
|
3697
3697
|
queryShiftId,
|
|
3698
3698
|
metricsTable
|
|
3699
3699
|
});
|
|
3700
|
+
const workspaces2 = await workspaceService.getWorkspaces(lineId);
|
|
3701
|
+
const enabledWorkspaceIds = workspaces2.filter((ws) => ws.enable === true).map((ws) => ws.id);
|
|
3702
|
+
if (enabledWorkspaceIds.length === 0) {
|
|
3703
|
+
setWorkspaces([]);
|
|
3704
|
+
setInitialized(true);
|
|
3705
|
+
setLoading(false);
|
|
3706
|
+
return;
|
|
3707
|
+
}
|
|
3700
3708
|
const { data, error: fetchError } = await supabase.from(metricsTable).select(`
|
|
3701
3709
|
workspace_name,
|
|
3702
3710
|
total_output,
|
|
@@ -3708,7 +3716,7 @@ var useLineWorkspaceMetrics = (lineId, options) => {
|
|
|
3708
3716
|
trend_score,
|
|
3709
3717
|
line_id,
|
|
3710
3718
|
total_day_output
|
|
3711
|
-
`).eq("date", queryDate).eq("shift_id", queryShiftId).eq("line_id", lineId).order("workspace_name", { ascending: true });
|
|
3719
|
+
`).eq("date", queryDate).eq("shift_id", queryShiftId).eq("line_id", lineId).in("workspace_id", enabledWorkspaceIds).order("workspace_name", { ascending: true });
|
|
3712
3720
|
if (fetchError) throw fetchError;
|
|
3713
3721
|
const transformedData = (data || []).map((item) => ({
|
|
3714
3722
|
company_id: entityConfig.companyId || "unknown",
|
|
@@ -4162,7 +4170,22 @@ var useDashboardMetrics = ({ onLineMetricsUpdate, lineId }) => {
|
|
|
4162
4170
|
throw new Error("No target line IDs available for fetching metrics.");
|
|
4163
4171
|
}
|
|
4164
4172
|
const isFactoryView = currentLineIdToUse === (entityConfig.factoryViewId || "factory");
|
|
4165
|
-
let
|
|
4173
|
+
let enabledWorkspaceIds = [];
|
|
4174
|
+
for (const targetLineId of targetLineIds) {
|
|
4175
|
+
const workspaces = await workspaceService.getWorkspaces(targetLineId);
|
|
4176
|
+
const enabledIds = workspaces.filter((ws) => ws.enable === true).map((ws) => ws.id);
|
|
4177
|
+
enabledWorkspaceIds.push(...enabledIds);
|
|
4178
|
+
}
|
|
4179
|
+
if (enabledWorkspaceIds.length === 0) {
|
|
4180
|
+
const newMetricsState2 = {
|
|
4181
|
+
workspaceMetrics: [],
|
|
4182
|
+
lineMetrics: []
|
|
4183
|
+
};
|
|
4184
|
+
setMetrics(newMetricsState2);
|
|
4185
|
+
setCache(currentLineIdToUse, newMetricsState2);
|
|
4186
|
+
return;
|
|
4187
|
+
}
|
|
4188
|
+
let workspaceQuery = supabase.from(companySpecificMetricsTable).select("company_id,line_id,shift_id,date,workspace_id,workspace_name,total_output,avg_pph,performance_score,avg_cycle_time,trend_score,ideal_output,efficiency,total_day_output").eq("date", operationalDate).eq("shift_id", currentShiftDetails.shiftId).in("workspace_id", enabledWorkspaceIds);
|
|
4166
4189
|
if (!isFactoryView) {
|
|
4167
4190
|
workspaceQuery = workspaceQuery.in("line_id", targetLineIds);
|
|
4168
4191
|
}
|
|
@@ -32627,12 +32650,13 @@ var TargetsView = ({
|
|
|
32627
32650
|
}
|
|
32628
32651
|
try {
|
|
32629
32652
|
const workspacesData = await workspaceService.getWorkspaces(lineId);
|
|
32653
|
+
const enabledWorkspaces = workspacesData.filter((ws) => ws.enable === true);
|
|
32630
32654
|
const actionThresholds = await workspaceService.getActionThresholds(
|
|
32631
32655
|
lineId,
|
|
32632
32656
|
currentDate,
|
|
32633
32657
|
selectedShift
|
|
32634
32658
|
);
|
|
32635
|
-
const mappedWorkspaces =
|
|
32659
|
+
const mappedWorkspaces = enabledWorkspaces.map((ws) => {
|
|
32636
32660
|
const threshold = actionThresholds.find((t) => t.workspace_id === ws.id);
|
|
32637
32661
|
return {
|
|
32638
32662
|
id: ws.id,
|