feature/IO-3357-Reynolds-and-Reynolds-DMS-API-Integration - Expanded Logs / Formatting change

This commit is contained in:
Dave
2025-11-12 17:01:54 -05:00
parent 556cd993b9
commit 90f653c0b7
13 changed files with 444 additions and 254 deletions

View File

@@ -1,4 +1,3 @@
// DmsContainer updated
import { useQuery } from "@apollo/client";
import { Button, Card, Col, Result, Row, Select, Space } from "antd";
import queryString from "query-string";
@@ -55,6 +54,9 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse
const history = useNavigate();
const [logs, setLogs] = useState([]);
const search = queryString.parse(useLocation().search);
const [detailsOpen, setDetailsOpen] = useState(false); // false => button shows "Expand All"
const [detailsNonce, setDetailsNonce] = useState(0); // forces child to react to toggles
const { jobId } = search;
const notification = useNotification();
const {
@@ -77,9 +79,14 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse
fetchPolicy: "network-only",
nextFetchPolicy: "network-only"
});
const logsRef = useRef(null);
// NEW: RR “open RO limit” UX hold
const toggleDetailsAll = () => {
setDetailsOpen((v) => !v);
setDetailsNonce((n) => n + 1);
};
const [rrOpenRoLimit, setRrOpenRoLimit] = useState(false);
const clearRrOpenRoLimit = () => setRrOpenRoLimit(false);
@@ -166,7 +173,16 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse
notification.error({ message: err.message });
};
const handleLogEvent = (payload) => setLogs((prev) => [...prev, payload]);
const handleLogEvent = (payload = {}) => {
const normalized = {
timestamp: payload.timestamp ? new Date(payload.timestamp) : payload.ts ? new Date(payload.ts) : new Date(),
level: (payload.level || "INFO").toUpperCase(),
message: payload.message || payload.msg || "",
// show details regardless of property name
meta: payload.meta ?? payload.ctx ?? payload.details ?? null
};
setLogs((prev) => [...prev, normalized]);
};
// FINAL step only (emitted by server after rr-finalize-repair-order)
const handleExportSuccess = (payload) => {
@@ -379,7 +395,6 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse
value={logLevel}
onChange={(value) => {
setLogLevel(value);
// Send to the active socket type
if (dms === "rr" || Fortellis.treatment === "on") {
wsssocket.emit("set-log-level", value);
} else {
@@ -392,6 +407,7 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse
<Select.Option key="WARN">WARN</Select.Option>
<Select.Option key="ERROR">ERROR</Select.Option>
</Select>
<Button onClick={toggleDetailsAll}>{detailsOpen ? "Collapse All" : "Expand All"}</Button>
<Button onClick={() => setLogs([])}>Clear Logs</Button>
<Button
onClick={() => {
@@ -409,7 +425,7 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse
</Space>
}
>
<DmsLogEvents socket={socket} logs={logs} />
<DmsLogEvents logs={logs} detailsOpen={detailsOpen} detailsNonce={detailsNonce} />
</Card>
</div>
</Col>