feature/IO-2742-redis - Checkpoint, Redis fully implemented.
Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
@@ -214,7 +214,9 @@ export function App({ bodyshop, checkUserSession, currentUser, online, setOnline
|
||||
path="/tech/*"
|
||||
element={
|
||||
<ErrorBoundary>
|
||||
<PrivateRoute isAuthorized={currentUser.authorized} />
|
||||
<SocketProvider bodyshop={bodyshop}>
|
||||
<PrivateRoute isAuthorized={currentUser.authorized} />
|
||||
</SocketProvider>
|
||||
</ErrorBoundary>
|
||||
}
|
||||
>
|
||||
|
||||
@@ -1,62 +1,77 @@
|
||||
import { SyncOutlined } from "@ant-design/icons";
|
||||
import { Button, Card, Form, Input, Table } from "antd";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import React, { useEffect, useState, useContext } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
import { pageLimit } from "../../utils/config";
|
||||
import SocketContext from "../../contexts/SocketIO/socketContext.jsx"; // Import SocketContext
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
//currentUser: selectCurrentUser
|
||||
bodyshop: selectBodyshop
|
||||
});
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
//setUserLanguage: language => dispatch(setUserLanguage(language))
|
||||
});
|
||||
export default connect(mapStateToProps)(DmsAllocationsSummaryAp);
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(DmsAllocationsSummaryAp);
|
||||
|
||||
export function DmsAllocationsSummaryAp({ socket, bodyshop, billids, title }) {
|
||||
export function DmsAllocationsSummaryAp({ bodyshop, billids, title }) {
|
||||
const { t } = useTranslation();
|
||||
const [allocationsSummary, setAllocationsSummary] = useState([]);
|
||||
const { socket } = useContext(SocketContext);
|
||||
|
||||
useEffect(() => {
|
||||
socket.on("ap-export-success", (billid) => {
|
||||
if (!socket) return;
|
||||
|
||||
const handleSuccess = async (billid) => {
|
||||
setAllocationsSummary((allocationsSummary) =>
|
||||
allocationsSummary.map((a) => {
|
||||
if (a.billid !== billid) return a;
|
||||
return { ...a, status: "Successful" };
|
||||
})
|
||||
);
|
||||
});
|
||||
socket.on("ap-export-failure", ({ billid, error }) => {
|
||||
allocationsSummary.map((a) => {
|
||||
if (a.billid !== billid) return a;
|
||||
return { ...a, status: error };
|
||||
});
|
||||
});
|
||||
|
||||
if (socket.disconnected) socket.connect();
|
||||
return () => {
|
||||
socket.removeListener("ap-export-success");
|
||||
socket.removeListener("ap-export-failure");
|
||||
//socket.disconnect();
|
||||
try {
|
||||
await new Promise((resolve, reject) => {
|
||||
socket.emit("clear-dms-session", (response) => {
|
||||
if (response && response.status === "ok") {
|
||||
resolve();
|
||||
} else {
|
||||
reject(new Error("Failed to clear DMS session"));
|
||||
}
|
||||
});
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Failed to clear DMS session", error);
|
||||
}
|
||||
};
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
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-failure", handleFailure);
|
||||
|
||||
return () => {
|
||||
socket.off("ap-export-success", handleSuccess);
|
||||
socket.off("ap-export-failure", handleFailure);
|
||||
};
|
||||
}, [socket]);
|
||||
|
||||
useEffect(() => {
|
||||
if (socket.connected) {
|
||||
if (socket && socket.connected) {
|
||||
socket.emit("pbs-calculate-allocations-ap", billids, (ack) => {
|
||||
setAllocationsSummary(ack);
|
||||
|
||||
socket.allocationsSummary = ack;
|
||||
});
|
||||
}
|
||||
}, [socket, socket.connected, billids]);
|
||||
console.log(allocationsSummary);
|
||||
|
||||
const columns = [
|
||||
{
|
||||
title: t("general.labels.status"),
|
||||
@@ -68,35 +83,40 @@ export function DmsAllocationsSummaryAp({ socket, bodyshop, billids, title }) {
|
||||
dataIndex: ["Posting", "Reference"],
|
||||
key: "reference"
|
||||
},
|
||||
|
||||
{
|
||||
title: t("jobs.fields.dms.lines"),
|
||||
dataIndex: "Lines",
|
||||
key: "Lines",
|
||||
render: (text, record) => (
|
||||
<table style={{ tableLayout: "auto", width: "100%" }}>
|
||||
<tr>
|
||||
<th>{t("bills.fields.invoice_number")}</th>
|
||||
<th>{t("bodyshop.fields.dms.dms_acctnumber")}</th>
|
||||
<th>{t("jobs.fields.dms.amount")}</th>
|
||||
</tr>
|
||||
{record.Posting.Lines.map((l, idx) => (
|
||||
<tr key={idx}>
|
||||
<td>{l.InvoiceNumber}</td>
|
||||
<td>{l.Account}</td>
|
||||
<td>{l.Amount}</td>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{t("bills.fields.invoice_number")}</th>
|
||||
<th>{t("bodyshop.fields.dms.dms_acctnumber")}</th>
|
||||
<th>{t("jobs.fields.dms.amount")}</th>
|
||||
</tr>
|
||||
))}
|
||||
</thead>
|
||||
<tbody>
|
||||
{record.Posting.Lines.map((l, idx) => (
|
||||
<tr key={idx}>
|
||||
<td>{l.InvoiceNumber}</td>
|
||||
<td>{l.Account}</td>
|
||||
<td>{l.Amount}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
)
|
||||
}
|
||||
];
|
||||
|
||||
const handleFinish = async (values) => {
|
||||
socket.emit(`pbs-export-ap`, {
|
||||
billids,
|
||||
txEnvelope: values
|
||||
});
|
||||
if (socket) {
|
||||
socket.emit("pbs-export-ap", {
|
||||
billids,
|
||||
txEnvelope: values
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -105,7 +125,9 @@ export function DmsAllocationsSummaryAp({ socket, bodyshop, billids, title }) {
|
||||
extra={
|
||||
<Button
|
||||
onClick={() => {
|
||||
socket.emit("pbs-calculate-allocations-ap", billids, (ack) => setAllocationsSummary(ack));
|
||||
if (socket) {
|
||||
socket.emit("pbs-calculate-allocations-ap", billids, (ack) => setAllocationsSummary(ack));
|
||||
}
|
||||
}}
|
||||
>
|
||||
<SyncOutlined />
|
||||
@@ -124,12 +146,7 @@ export function DmsAllocationsSummaryAp({ socket, bodyshop, billids, title }) {
|
||||
name="journal"
|
||||
label={t("jobs.fields.dms.journal")}
|
||||
initialValue={bodyshop.cdk_configuration && bodyshop.cdk_configuration.default_journal}
|
||||
rules={[
|
||||
{
|
||||
required: true
|
||||
//message: t("general.validation.required"),
|
||||
}
|
||||
]}
|
||||
rules={[{ required: true }]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
|
||||
@@ -4,11 +4,8 @@ import React from "react";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { setBreadcrumbs, setSelectedHeader } from "../../redux/application/application.actions";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop
|
||||
});
|
||||
const mapStateToProps = createStructuredSelector({});
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
setBreadcrumbs: (breadcrumbs) => dispatch(setBreadcrumbs(breadcrumbs)),
|
||||
@@ -17,7 +14,7 @@ const mapDispatchToProps = (dispatch) => ({
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(DmsLogEvents);
|
||||
|
||||
export function DmsLogEvents({ socket, logs, bodyshop }) {
|
||||
export function DmsLogEvents({ logs }) {
|
||||
return (
|
||||
<Timeline
|
||||
pending
|
||||
|
||||
@@ -37,6 +37,7 @@ function ProductionBoardKanbanContainer({ bodyshop, currentUser }) {
|
||||
onError: (error) => console.error(`Error fetching Kanban settings: ${error.message}`)
|
||||
});
|
||||
|
||||
// This provides us the current version of the Lanes from the Redux store
|
||||
// const currentReducerData = useSelector((state) => (state.trello.lanes ? state.trello : {}));
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Button, Card, Col, notification, Row, Select, Space } from "antd";
|
||||
import React, { useEffect, useRef, useState, useContext } from "react";
|
||||
import React, { useContext, useEffect, useRef, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { useLocation, useNavigate } from "react-router-dom";
|
||||
@@ -7,13 +7,10 @@ import { createStructuredSelector } from "reselect";
|
||||
import DmsAllocationsSummaryApComponent from "../../components/dms-allocations-summary-ap/dms-allocations-summary-ap.component";
|
||||
import DmsLogEvents from "../../components/dms-log-events/dms-log-events.component";
|
||||
import { setBreadcrumbs, setSelectedHeader } from "../../redux/application/application.actions";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
import InstanceRenderManager from "../../utils/instanceRenderMgr";
|
||||
import SocketContext from "../../contexts/SocketIO/socketContext";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop
|
||||
});
|
||||
const mapStateToProps = createStructuredSelector({});
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
setBreadcrumbs: (breadcrumbs) => dispatch(setBreadcrumbs(breadcrumbs)),
|
||||
@@ -22,7 +19,7 @@ const mapDispatchToProps = (dispatch) => ({
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(DmsContainer);
|
||||
|
||||
export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader }) {
|
||||
export function DmsContainer({ setBreadcrumbs, setSelectedHeader }) {
|
||||
const { t } = useTranslation();
|
||||
const { socket } = useContext(SocketContext);
|
||||
const [logLevel, setLogLevel] = useState("DEBUG");
|
||||
@@ -124,29 +121,23 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader }) {
|
||||
<Select.Option key="ERROR">ERROR</Select.Option>
|
||||
</Select>
|
||||
<Button onClick={() => setLogs([])}>Clear Logs</Button>
|
||||
{/*<Button*/}
|
||||
{/* onClick={() => {*/}
|
||||
{/* setLogs([]);*/}
|
||||
{/* socket.disconnect();*/}
|
||||
{/* socket.connect();*/}
|
||||
{/* }}*/}
|
||||
{/*>*/}
|
||||
{/* Reconnect*/}
|
||||
{/*</Button>*/}
|
||||
<Button
|
||||
onClick={() => {
|
||||
setLogs([]);
|
||||
if (socket) {
|
||||
socket.emit("clear-dms-session");
|
||||
}
|
||||
}}
|
||||
>
|
||||
Clear Session
|
||||
</Button>
|
||||
</Space>
|
||||
}
|
||||
>
|
||||
<DmsLogEvents socket={socket} logs={logs} />
|
||||
<DmsLogEvents logs={logs} />
|
||||
</Card>
|
||||
</div>
|
||||
</Col>
|
||||
</Row>
|
||||
);
|
||||
}
|
||||
|
||||
export const determineDmsType = (bodyshop) => {
|
||||
if (bodyshop.cdk_dealerid) return "cdk";
|
||||
else {
|
||||
return "pbs";
|
||||
}
|
||||
};
|
||||
|
||||
@@ -104,7 +104,7 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse
|
||||
setLogs((logs) => [...logs, payload]);
|
||||
};
|
||||
|
||||
const handleExportSuccess = (payload) => {
|
||||
const handleExportSuccess = async (payload) => {
|
||||
notification.success({
|
||||
message: t("jobs.successes.exported")
|
||||
});
|
||||
@@ -113,6 +113,21 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse
|
||||
operation: AuditTrailMapping.jobexported(),
|
||||
type: "jobexported"
|
||||
});
|
||||
|
||||
try {
|
||||
await new Promise((resolve, reject) => {
|
||||
socket.emit("clear-dms-session", (response) => {
|
||||
if (response && response.status === "ok") {
|
||||
resolve();
|
||||
} else {
|
||||
reject(new Error("Failed to clear DMS session"));
|
||||
}
|
||||
});
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Failed to clear DMS session", error);
|
||||
}
|
||||
|
||||
history("/manage/accounting/receivables");
|
||||
};
|
||||
|
||||
@@ -186,20 +201,21 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse
|
||||
<Select.Option key="WARNING">WARNING</Select.Option>
|
||||
<Select.Option key="ERROR">ERROR</Select.Option>
|
||||
</Select>
|
||||
<Button onClick={() => setLogs([])}>Clear Logs</Button>
|
||||
{/*<Button*/}
|
||||
{/* onClick={() => {*/}
|
||||
{/* setLogs([]);*/}
|
||||
{/* socket.disconnect();*/}
|
||||
{/* socket.connect();*/}
|
||||
{/* }}*/}
|
||||
{/*>*/}
|
||||
{/* Reconnect*/}
|
||||
{/*</Button>*/}
|
||||
4<Button onClick={() => setLogs([])}>Clear Logs</Button>
|
||||
<Button
|
||||
onClick={() => {
|
||||
setLogs([]);
|
||||
if (socket) {
|
||||
socket.emit("clear-dms-session");
|
||||
}
|
||||
}}
|
||||
>
|
||||
Clear Session
|
||||
</Button>
|
||||
</Space>
|
||||
}
|
||||
>
|
||||
<DmsLogEvents socket={socket} logs={logs} />
|
||||
<DmsLogEvents logs={logs} />
|
||||
</Card>
|
||||
</div>
|
||||
</Col>
|
||||
|
||||
Reference in New Issue
Block a user