feature/IO-2924-Refactor-Production-Board-For-Sockets - Checkpoint
Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
@@ -20,7 +20,7 @@ export function DmsAllocationsSummaryAp({ bodyshop, billids, title }) {
|
|||||||
const { socket } = useContext(SocketContext);
|
const { socket } = useContext(SocketContext);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!socket) return;
|
if (!socket || !socket.connected) return;
|
||||||
|
|
||||||
const handleSuccess = async (billid) => {
|
const handleSuccess = async (billid) => {
|
||||||
setAllocationsSummary((allocationsSummary) =>
|
setAllocationsSummary((allocationsSummary) =>
|
||||||
@@ -45,21 +45,10 @@ export function DmsAllocationsSummaryAp({ bodyshop, billids, title }) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleFailure = ({ billid, error }) => {
|
|
||||||
setAllocationsSummary((allocationsSummary) =>
|
|
||||||
allocationsSummary.map((a) => {
|
|
||||||
if (a.billid !== billid) return a;
|
|
||||||
return { ...a, status: error };
|
|
||||||
})
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
socket.on("ap-export-success", handleSuccess);
|
socket.on("ap-export-success", handleSuccess);
|
||||||
socket.on("ap-export-failure", handleFailure);
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
socket.off("ap-export-success", handleSuccess);
|
socket.off("ap-export-success", handleSuccess);
|
||||||
socket.off("ap-export-failure", handleFailure);
|
|
||||||
};
|
};
|
||||||
}, [socket]);
|
}, [socket]);
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export function DmsAllocationsSummary({ socket, bodyshop, jobId, title }) {
|
|||||||
const [allocationsSummary, setAllocationsSummary] = useState([]);
|
const [allocationsSummary, setAllocationsSummary] = useState([]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (socket.connected) {
|
if (socket && socket.connected) {
|
||||||
socket.emit("cdk-calculate-allocations", jobId, (ack) => {
|
socket.emit("cdk-calculate-allocations", jobId, (ack) => {
|
||||||
setAllocationsSummary(ack);
|
setAllocationsSummary(ack);
|
||||||
socket.allocationsSummary = ack;
|
socket.allocationsSummary = ack;
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ export function DmsContainer({ setBreadcrumbs, setSelectedHeader }) {
|
|||||||
{
|
{
|
||||||
timestamp: new Date(),
|
timestamp: new Date(),
|
||||||
level: "WARNING",
|
level: "WARNING",
|
||||||
message: "Reconnected to CDK Export Service"
|
message: "Reconnected to DMS Export Service"
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse
|
|||||||
{
|
{
|
||||||
timestamp: new Date(),
|
timestamp: new Date(),
|
||||||
level: "WARNING",
|
level: "WARNING",
|
||||||
message: "Reconnected to CDK Export Service"
|
message: "Reconnected to DMS Export Service"
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
@@ -201,7 +201,7 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse
|
|||||||
<Select.Option key="WARNING">WARNING</Select.Option>
|
<Select.Option key="WARNING">WARNING</Select.Option>
|
||||||
<Select.Option key="ERROR">ERROR</Select.Option>
|
<Select.Option key="ERROR">ERROR</Select.Option>
|
||||||
</Select>
|
</Select>
|
||||||
4<Button onClick={() => setLogs([])}>Clear Logs</Button>
|
<Button onClick={() => setLogs([])}>Clear Logs</Button>
|
||||||
<Button
|
<Button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setLogs([]);
|
setLogs([]);
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import UpdateAlert from "../../components/update-alert/update-alert.component";
|
|||||||
import InstanceRenderManager from "../../utils/instanceRenderMgr.js";
|
import InstanceRenderManager from "../../utils/instanceRenderMgr.js";
|
||||||
import "./manage.page.styles.scss";
|
import "./manage.page.styles.scss";
|
||||||
import SocketContext from "../../contexts/SocketIO/socketContext.jsx";
|
import SocketContext from "../../contexts/SocketIO/socketContext.jsx";
|
||||||
|
import { requestForToken } from "../../firebase/firebase.utils.js";
|
||||||
|
|
||||||
const JobsPage = lazy(() => import("../jobs/jobs.page"));
|
const JobsPage = lazy(() => import("../jobs/jobs.page"));
|
||||||
|
|
||||||
@@ -112,6 +113,17 @@ export function Manage({ conflict, bodyshop }) {
|
|||||||
const [chatVisible] = useState(false);
|
const [chatVisible] = useState(false);
|
||||||
const { socket, clientId } = useContext(SocketContext);
|
const { socket, clientId } = useContext(SocketContext);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const widgetId = InstanceRenderManager({
|
||||||
|
imex: "IABVNO4scRKY11XBQkNr",
|
||||||
|
rome: "mQdqARMzkZRUVugJ6TdS"
|
||||||
|
});
|
||||||
|
window.noticeable.render("widget", widgetId);
|
||||||
|
requestForToken().catch((error) => {
|
||||||
|
console.error(`Unable to request for token.`, error);
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
document.title = InstanceRenderManager({
|
document.title = InstanceRenderManager({
|
||||||
imex: t("titles.imexonline"),
|
imex: t("titles.imexonline"),
|
||||||
|
|||||||
@@ -38,7 +38,9 @@ const SOCKETIO_CORS_ORIGIN = [
|
|||||||
"https://www.test.promanager.web-est.com",
|
"https://www.test.promanager.web-est.com",
|
||||||
"https://test.promanager.web-est.com",
|
"https://test.promanager.web-est.com",
|
||||||
"https://www.promanager.web-est.com",
|
"https://www.promanager.web-est.com",
|
||||||
"https://www.promanager.web-est.com"
|
"https://www.promanager.web-est.com",
|
||||||
|
"https://old.imex.online",
|
||||||
|
"https://www.old.imex.online"
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -60,12 +60,11 @@ async function registerSocketEvents(socket) {
|
|||||||
// CDK-specific socket events
|
// CDK-specific socket events
|
||||||
function registerCdkEvents(socket) {
|
function registerCdkEvents(socket) {
|
||||||
socket.on("cdk-export-job", (jobid) => CdkJobExport(socket, jobid));
|
socket.on("cdk-export-job", (jobid) => CdkJobExport(socket, jobid));
|
||||||
|
|
||||||
socket.on("cdk-selected-customer", async (selectedCustomerId) => {
|
socket.on("cdk-selected-customer", async (selectedCustomerId) => {
|
||||||
await createLogEvent(socket, "DEBUG", `User selected customer ID ${selectedCustomerId}`);
|
await createLogEvent(socket, "DEBUG", `User selected customer ID ${selectedCustomerId}`);
|
||||||
CdkSelectedCustomer(socket, selectedCustomerId).catch((err) =>
|
CdkSelectedCustomer(socket, selectedCustomerId);
|
||||||
console.error(`Error in cdk-selected-customer: ${err}`)
|
await setSessionData(socket.id, "selectedCustomerId ", selectedCustomerId);
|
||||||
);
|
|
||||||
await setSessionData(socket.id, "selectedCustomer", selectedCustomerId);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("cdk-get-makes", async (cdk_dealerid, callback) => {
|
socket.on("cdk-get-makes", async (cdk_dealerid, callback) => {
|
||||||
@@ -73,16 +72,15 @@ function registerCdkEvents(socket) {
|
|||||||
const makes = await CdkGetMakes(socket, cdk_dealerid);
|
const makes = await CdkGetMakes(socket, cdk_dealerid);
|
||||||
callback(makes);
|
callback(makes);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await createLogEvent(socket, "ERROR", `Error in cdk-get-makes WS call. ${JSON.stringify(error)}`);
|
await createLogEvent(socket, "ERROR", `Error in cdk-get-makes WS call. ${JSON.stringify(error, null, 2)}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("cdk-calculate-allocations", async (jobid, callback) => {
|
socket.on("cdk-calculate-allocations", async (jobid, callback) => {
|
||||||
const allocations = await CdkCalculateAllocations(socket, jobid);
|
const allocations = await CdkCalculateAllocations(socket, jobid);
|
||||||
await createLogEvent(socket, "DEBUG", `Allocations calculated.`);
|
await createLogEvent(socket, "DEBUG", `Allocations calculated.`);
|
||||||
await createLogEvent(socket, "TRACE", `Allocations details: ${JSON.stringify(allocations)}`);
|
await createLogEvent(socket, "TRACE", `Allocations details: ${JSON.stringify(allocations, null, 2)}`);
|
||||||
callback(allocations);
|
callback(allocations);
|
||||||
await setSessionData(socket.id, "cdk_allocations", allocations);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,18 +89,18 @@ function registerPbsArEvents(socket) {
|
|||||||
socket.on("pbs-calculate-allocations", async (jobid, callback) => {
|
socket.on("pbs-calculate-allocations", async (jobid, callback) => {
|
||||||
const allocations = await CdkCalculateAllocations(socket, jobid);
|
const allocations = await CdkCalculateAllocations(socket, jobid);
|
||||||
await createLogEvent(socket, "DEBUG", `PBS AR allocations calculated.`);
|
await createLogEvent(socket, "DEBUG", `PBS AR allocations calculated.`);
|
||||||
await createLogEvent(socket, "TRACE", `Allocations details: ${JSON.stringify(allocations)}`);
|
await createLogEvent(socket, "TRACE", `Allocations details: ${JSON.stringify(allocations, null, 2)}`);
|
||||||
callback(allocations);
|
callback(allocations);
|
||||||
await setSessionData(socket.id, "pbs_allocations", allocations);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("pbs-export-job", (jobid) => PbsExportJob(socket, jobid));
|
socket.on("pbs-export-job", (jobid) => PbsExportJob(socket, jobid));
|
||||||
|
|
||||||
socket.on("pbs-selected-customer", async (selectedCustomerId) => {
|
socket.on("pbs-selected-customer", async (selectedCustomerId) => {
|
||||||
await createLogEvent(socket, "DEBUG", `PBS AR selected customer ID ${selectedCustomerId}`);
|
await createLogEvent(socket, "DEBUG", `PBS AR selected customer ID ${selectedCustomerId}`);
|
||||||
PbsSelectedCustomer(socket, selectedCustomerId).catch((err) =>
|
PbsSelectedCustomer(socket, selectedCustomerId).catch((err) =>
|
||||||
console.error(`Error in pbs-selected-customer: ${err}`)
|
console.error(`Error in pbs-selected-customer: ${err}`)
|
||||||
);
|
);
|
||||||
await setSessionData(socket.id, "selectedCustomer", selectedCustomerId);
|
await setSessionData(socket.id, "selectedCustomerId", selectedCustomerId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,13 +109,13 @@ function registerPbsApEvents(socket) {
|
|||||||
socket.on("pbs-calculate-allocations-ap", async (billids, callback) => {
|
socket.on("pbs-calculate-allocations-ap", async (billids, callback) => {
|
||||||
const allocations = await PbsCalculateAllocationsAp(socket, billids);
|
const allocations = await PbsCalculateAllocationsAp(socket, billids);
|
||||||
await createLogEvent(socket, "DEBUG", `PBS AP allocations calculated.`);
|
await createLogEvent(socket, "DEBUG", `PBS AP allocations calculated.`);
|
||||||
await createLogEvent(socket, "TRACE", `Allocations details: ${JSON.stringify(allocations)}`);
|
await createLogEvent(socket, "TRACE", `Allocations details: ${JSON.stringify(allocations, null, 2)}`);
|
||||||
callback(allocations);
|
callback(allocations);
|
||||||
await setSessionData(socket.id, "pbs_ap_allocations", allocations);
|
await setSessionData(socket.id, "pbs_ap_allocations", allocations);
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("pbs-export-ap", async ({ billids, txEnvelope }) => {
|
socket.on("pbs-export-ap", async ({ billids, txEnvelope }) => {
|
||||||
await setSessionData(socket.id, "pbs_txEnvelope", txEnvelope);
|
await setSessionData(socket.id, "txEnvelope", txEnvelope);
|
||||||
PbsExportAp(socket, {
|
PbsExportAp(socket, {
|
||||||
billids,
|
billids,
|
||||||
txEnvelope
|
txEnvelope
|
||||||
|
|||||||
Reference in New Issue
Block a user