+
@@ -192,23 +205,55 @@ export default function ManualPrintForm({lot}: {lot: LotType}) {
//variant="underlined"
//label="Enter intials"
- {...register("initials", {required: true})}
+ {...register("initials", { required: true })}
+ />
+
+
+ {dyco[0].value === "0" && (
+
+
Enter the missing tag number.
+
+
+
+
+ )}
+
+
-
-
-
-
+
+
+
+
diff --git a/frontend/src/components/production/ocp/ManualPrinting/ManualPrintLabel.ts b/frontend/src/components/production/ocp/ManualPrinting/ManualPrintLabel.ts
index b3f9b77..25eab6f 100644
--- a/frontend/src/components/production/ocp/ManualPrinting/ManualPrintLabel.ts
+++ b/frontend/src/components/production/ocp/ManualPrinting/ManualPrintLabel.ts
@@ -1,15 +1,15 @@
-import {LotType} from "@/types/lots";
+import { LotType } from "@/types/lots";
import axios from "axios";
export const manualPrintLabels = async (lot: LotType, user: any) => {
//console.log(lot);
- const labelUrl = `/ocp/manualPrintAndFollow`;
+ const labelUrl = `/api/ocp/manualprintandfollow`;
try {
const res = await axios.post(
labelUrl,
- {line: lot.MachineLocation, printerName: lot.PrinterName},
- {headers: {Authorization: `Basic ${user?.prod}`}}
+ { line: lot.MachineLocation, printerName: lot.PrinterName },
+ { headers: { Authorization: `Basic ${user?.prod}` } }
);
if (res.data.success) {
@@ -19,7 +19,7 @@ export const manualPrintLabels = async (lot: LotType, user: any) => {
};
} else {
return {
- success: true,
+ success: false,
message: `Line ${lot.MachineDescription} encountered an error printing labels: ${res.data.message}`,
};
}
diff --git a/frontend/src/components/production/ocp/OcpLogs.tsx b/frontend/src/components/production/ocp/OcpLogs.tsx
index 0eca951..7f9b0d9 100644
--- a/frontend/src/components/production/ocp/OcpLogs.tsx
+++ b/frontend/src/components/production/ocp/OcpLogs.tsx
@@ -1,5 +1,154 @@
-import {LstCard} from "@/components/extendedUI/LstCard";
+import { LstCard } from "@/components/extendedUI/LstCard";
+import { Button } from "@/components/ui/button";
+import { Skeleton } from "@/components/ui/skeleton";
+import {
+ Table,
+ TableBody,
+ TableCell,
+ TableHead,
+ TableHeader,
+ TableRow,
+} from "@/components/ui/table";
+import { getOcpLogs } from "@/utils/querys/production/ocpLogs";
+import { useQuery } from "@tanstack/react-query";
+import axios from "axios";
+import { format } from "date-fns";
+import { Trash } from "lucide-react";
+import { toast } from "sonner";
+
+const labelLogs = [
+ { key: "message", label: "Error Message" },
+ { key: "created_at", label: "ErrorDat" },
+ { key: "clear", label: "Clear" },
+ //{key: "reprint", label: "Reprint"}, // removing the reprint button for now until repritning is working as intended
+];
export default function OcpLogs() {
- return
Ocp Logs;
+ const { data, isError, isLoading } = useQuery(getOcpLogs("4"));
+
+ const clearLog = async (log: any) => {
+ try {
+ const res = await axios.patch(`/api/logger/logs/${log.log_id}`);
+
+ if (res.data.success) {
+ toast.success(`Log message: ${log.message}, was just cleared`);
+ } else {
+ console.log(res);
+ toast.error(`There was an error clearing the message.`);
+ }
+ } catch (error) {
+ toast.error(`There was an error trying to clearing the message.`);
+ }
+ };
+ const logData = data ? data : [];
+ if (isError) {
+ return (
+
+
+ Labels for the last 2 hours
+
+
+
+ {labelLogs.map((l) => (
+ {l.label}
+ ))}
+
+
+
+
+ {Array(7)
+ .fill(0)
+ .map((_, i) => (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ))}
+
+
+
+
+ );
+ }
+
+ return (
+
+ Labels for the last 2 hours
+
+
+
+ {labelLogs.map((l) => (
+ {l.label}
+ ))}
+
+
+ {isLoading ? (
+ <>
+
+ {Array(7)
+ .fill(0)
+ .map((_, i) => (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ))}
+
+ >
+ ) : (
+
+ {logData.map((label: any) => (
+
+
+
+ {label.message}
+
+
+
+ {format(
+ label?.created_at.replace("Z", ""),
+ "M/d/yyyy hh:mm"
+ )}
+
+
+
+
+
+ ))}
+
+ )}
+
+
+ );
}
diff --git a/frontend/src/components/production/ocp/OcpPage.tsx b/frontend/src/components/production/ocp/OcpPage.tsx
index 0e56872..fbc57cc 100644
--- a/frontend/src/components/production/ocp/OcpPage.tsx
+++ b/frontend/src/components/production/ocp/OcpPage.tsx
@@ -4,6 +4,7 @@ import Lots from "./Lots";
import OcpLogs from "./OcpLogs";
import PrinterStatus from "./PrinterStatus";
import { useSettingStore } from "@/lib/store/useSettings";
+import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
export default function OCPPage() {
const { settings } = useSettingStore();
@@ -17,13 +18,25 @@ export default function OCPPage() {
diff --git a/frontend/src/utils/querys/production/labels.tsx b/frontend/src/utils/querys/production/labels.tsx
index 3ece375..8e4b72a 100644
--- a/frontend/src/utils/querys/production/labels.tsx
+++ b/frontend/src/utils/querys/production/labels.tsx
@@ -7,7 +7,7 @@ export function getlabels(hours: string) {
queryFn: () => fetchSettings(hours),
staleTime: 1000,
- //refetchInterval: 2500,
+ refetchInterval: 2 * 2000,
refetchOnWindowFocus: true,
});
}
diff --git a/frontend/src/utils/querys/production/lots.tsx b/frontend/src/utils/querys/production/lots.tsx
index 417d690..df0c558 100644
--- a/frontend/src/utils/querys/production/lots.tsx
+++ b/frontend/src/utils/querys/production/lots.tsx
@@ -7,7 +7,7 @@ export function getlots() {
queryFn: () => fetchSettings(),
staleTime: 10 * 1000,
- //refetchInterval: 10 * 1000,
+ refetchInterval: 10 * 1000,
refetchOnWindowFocus: true,
});
}
diff --git a/frontend/src/utils/querys/production/ocpLogs.tsx b/frontend/src/utils/querys/production/ocpLogs.tsx
new file mode 100644
index 0000000..e6e5d17
--- /dev/null
+++ b/frontend/src/utils/querys/production/ocpLogs.tsx
@@ -0,0 +1,22 @@
+import { queryOptions } from "@tanstack/react-query";
+import axios from "axios";
+
+export function getOcpLogs(hours: string) {
+ return queryOptions({
+ queryKey: ["ocpLogs"],
+ queryFn: () => fetchSettings(hours),
+
+ staleTime: 1000,
+ refetchInterval: 2 * 1000,
+ refetchOnWindowFocus: true,
+ });
+}
+
+const fetchSettings = async (hours: string) => {
+ const { data } = await axios.get(
+ `/api/logger/logs?service=ocp&service=rfid&level=error&level=warn&hours=${hours}`
+ );
+ // if we are not localhost ignore the devDir setting.
+ //const url: string = window.location.host.split(":")[0];
+ return data.data ?? [];
+};