CEC-3796 - UI for creating and managing RxSWIN
This commit is contained in:
@@ -6887,7 +6887,11 @@ exports[`App Route /packages authenticated 1`] = `
|
|||||||
/>
|
/>
|
||||||
<td
|
<td
|
||||||
class="MuiTableCell-root MuiTableCell-body MuiTableCell-alignCenter"
|
class="MuiTableCell-root MuiTableCell-body MuiTableCell-alignCenter"
|
||||||
|
>
|
||||||
|
<a
|
||||||
|
href="/sums/undefined"
|
||||||
/>
|
/>
|
||||||
|
</td>
|
||||||
<td
|
<td
|
||||||
class="MuiTableCell-root MuiTableCell-body MuiTableCell-alignCenter"
|
class="MuiTableCell-root MuiTableCell-body MuiTableCell-alignCenter"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ export const CarUpdatesProvider = ({ children }) => {
|
|||||||
const [busy, setBusy] = useState(false);
|
const [busy, setBusy] = useState(false);
|
||||||
const [carUpdates, setCarUpdates] = useState([]);
|
const [carUpdates, setCarUpdates] = useState([]);
|
||||||
const [versions, setVersions] = useState([SELECT_VERSION_OBJ]);
|
const [versions, setVersions] = useState([SELECT_VERSION_OBJ]);
|
||||||
|
const [versionRxSwins, setVersionRxSwins] = useState([]);
|
||||||
const [totalCarUpdates, setTotalCarUpdates] = useState(0);
|
const [totalCarUpdates, setTotalCarUpdates] = useState(0);
|
||||||
const [delayCount, setDelayCount] = useState(0);
|
const [delayCount, setDelayCount] = useState(0);
|
||||||
let progressTimer = 0;
|
let progressTimer = 0;
|
||||||
@@ -307,6 +308,24 @@ export const CarUpdatesProvider = ({ children }) => {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getSUMSVersionRxSwins = async (sums_version, token) => {
|
||||||
|
let result;
|
||||||
|
|
||||||
|
try {
|
||||||
|
setBusy(true);
|
||||||
|
|
||||||
|
result = await api.getSUMSVersionRxSwins(sums_version, token);
|
||||||
|
if (result.error)
|
||||||
|
throw new Error(`Get software version rxswins error. ${result.message}`);
|
||||||
|
|
||||||
|
setVersionRxSwins(result.data);
|
||||||
|
} finally {
|
||||||
|
setBusy(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CarUpdatesContext.Provider
|
<CarUpdatesContext.Provider
|
||||||
value={{
|
value={{
|
||||||
@@ -325,6 +344,7 @@ export const CarUpdatesProvider = ({ children }) => {
|
|||||||
startMonitor,
|
startMonitor,
|
||||||
stopMonitor,
|
stopMonitor,
|
||||||
updateSUMSVersion,
|
updateSUMSVersion,
|
||||||
|
getSUMSVersionRxSwins,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
|
|||||||
@@ -122,6 +122,19 @@ let sumsVersions = {
|
|||||||
"data": ["2023.02.01.0.0.A", "2023.02.01.0.0.B"]
|
"data": ["2023.02.01.0.0.A", "2023.02.01.0.0.B"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let sumsVersionRxSwins = {
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
version: "2023.02.01.0.0.A",
|
||||||
|
rxswin: "testrxswin1",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
version: "2023.02.01.0.0.A",
|
||||||
|
rxswin: "testrxswin2",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
export const CarUpdatesProvider = ({ children }) => {
|
export const CarUpdatesProvider = ({ children }) => {
|
||||||
return <div data-testid="mocked-carupdatesprovider">{children}</div>;
|
return <div data-testid="mocked-carupdatesprovider">{children}</div>;
|
||||||
};
|
};
|
||||||
@@ -140,5 +153,6 @@ export const useCarUpdatesContext = () => ({
|
|||||||
stopMonitor: jest.fn(),
|
stopMonitor: jest.fn(),
|
||||||
approveUpdate: jest.fn(),
|
approveUpdate: jest.fn(),
|
||||||
getSUMSVersions: jest.fn(() => sumsVersions),
|
getSUMSVersions: jest.fn(() => sumsVersions),
|
||||||
|
getSUMSVersionRxSwins: jest.fn(() => sumsVersionRxSwins),
|
||||||
updateSUMSVersion: jest.fn(),
|
updateSUMSVersion: jest.fn(),
|
||||||
});
|
});
|
||||||
@@ -177,7 +177,9 @@ const MainForm = ({ vin, token }) => {
|
|||||||
</Link>
|
</Link>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell align="center">
|
<TableCell align="center">
|
||||||
|
<Link to={`/sums/${row.updatemanifest?.sums}`}>
|
||||||
{row.updatemanifest?.sums}
|
{row.updatemanifest?.sums}
|
||||||
|
</Link>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell align="center">
|
<TableCell align="center">
|
||||||
{row.username}
|
{row.username}
|
||||||
|
|||||||
@@ -447,7 +447,11 @@ const MainForm = () => {
|
|||||||
<TableCell align="center">
|
<TableCell align="center">
|
||||||
{formatManifestType(row.manifest_type)}
|
{formatManifestType(row.manifest_type)}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell align="center">{row.sums}</TableCell>
|
<TableCell align="center">
|
||||||
|
<Link to={`/sums/${row.sums}`}>
|
||||||
|
{row.sums}
|
||||||
|
</Link>
|
||||||
|
</TableCell>
|
||||||
<TableCell align="center">
|
<TableCell align="center">
|
||||||
{formatType(row.type)}
|
{formatType(row.type)}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ const SMSSend = React.lazy(() => import("../SMS/Send"));
|
|||||||
const SuppliersList = React.lazy(() => import("../Suppliers/List"));
|
const SuppliersList = React.lazy(() => import("../Suppliers/List"));
|
||||||
const SupplierDetails = React.lazy(() => import("../Suppliers/Details"));
|
const SupplierDetails = React.lazy(() => import("../Suppliers/Details"));
|
||||||
const Datascope = React.lazy(() => import("../Dashboard"));
|
const Datascope = React.lazy(() => import("../Dashboard"));
|
||||||
|
const SumsRxSwin = React.lazy(() => import("../SUMS"));
|
||||||
const DashboardCustom = React.lazy(() => import("../DashboardCustom"));
|
const DashboardCustom = React.lazy(() => import("../DashboardCustom"));
|
||||||
|
|
||||||
const SiteRoutes = () => {
|
const SiteRoutes = () => {
|
||||||
@@ -305,6 +306,15 @@ const SiteRoutes = () => {
|
|||||||
rolesPerGroup={Permissions.FiskerMagnaRead}
|
rolesPerGroup={Permissions.FiskerMagnaRead}
|
||||||
providers={providers}
|
providers={providers}
|
||||||
/>
|
/>
|
||||||
|
<AuthRoute
|
||||||
|
path="/sums/:sums_version"
|
||||||
|
render={() => <SumsRxSwin />}
|
||||||
|
type={TYPES.PROTECTED}
|
||||||
|
token={token}
|
||||||
|
groups={groups}
|
||||||
|
rolesPerGroup={Permissions.FiskerMagnaCreate}
|
||||||
|
providers={providers}
|
||||||
|
/>
|
||||||
<PageNotFound />
|
<PageNotFound />
|
||||||
</Switch>
|
</Switch>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
|
|||||||
102
src/components/SUMS/index.jsx
Normal file
102
src/components/SUMS/index.jsx
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
import {
|
||||||
|
Table,
|
||||||
|
TableBody,
|
||||||
|
TableCell,
|
||||||
|
TableFooter,
|
||||||
|
TablePagination,
|
||||||
|
TableRow,
|
||||||
|
} from "@material-ui/core";
|
||||||
|
import { logger } from "../../services/monitoring";
|
||||||
|
import React, { useEffect, useState } from "react";
|
||||||
|
import { useParams } from "react-router";
|
||||||
|
import {
|
||||||
|
CarUpdatesProvider,
|
||||||
|
useCarUpdatesContext
|
||||||
|
} from "../Contexts/CarUpdatesContext";
|
||||||
|
import { useUserContext } from "../Contexts/UserContext";
|
||||||
|
import TableHeaderSortable from "../Table/HeaderSortable";
|
||||||
|
import useStyles from "../useStyles";
|
||||||
|
|
||||||
|
const tableColumns = [
|
||||||
|
{
|
||||||
|
id: "sums_version",
|
||||||
|
label: "SUMS Version",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "sums_rxswin",
|
||||||
|
label: "RXSwin Version",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const MainForm = () => {
|
||||||
|
const { sums_version } = useParams();
|
||||||
|
const classes = useStyles();
|
||||||
|
const [orderBy, setOrderBy] = useState("id");
|
||||||
|
const [order, setOrder] = useState("desc");
|
||||||
|
const {
|
||||||
|
getSUMSVersionRxSwins,
|
||||||
|
stopMonitor,
|
||||||
|
} = useCarUpdatesContext();
|
||||||
|
const [versionRxSwins, setVersionRxSwins] = useState([]);
|
||||||
|
const {
|
||||||
|
token: {
|
||||||
|
idToken: { jwtToken: token },
|
||||||
|
},
|
||||||
|
} = useUserContext();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
(async () => {
|
||||||
|
try {
|
||||||
|
if (!sums_version || !token) return;
|
||||||
|
stopMonitor();
|
||||||
|
await getSUMSVersionRxSwins(
|
||||||
|
sums_version,
|
||||||
|
token
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
setVersionRxSwins(e.message);
|
||||||
|
logger.warn(e.stack);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [sums_version, token]);
|
||||||
|
|
||||||
|
const handleSort = (event, property) => {
|
||||||
|
try {
|
||||||
|
if (property === orderBy) {
|
||||||
|
if (order === "asc") {
|
||||||
|
setOrder("desc");
|
||||||
|
} else {
|
||||||
|
setOrder("asc");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
setOrderBy(property);
|
||||||
|
setOrder("asc");
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
logger.warn(e.stack);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Table>
|
||||||
|
<TableHeaderSortable
|
||||||
|
classes={classes}
|
||||||
|
orderBy={orderBy}
|
||||||
|
order={order}
|
||||||
|
columnData={tableColumns}
|
||||||
|
onSortRequest={handleSort}
|
||||||
|
/>
|
||||||
|
<TableBody>
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const SumsRxSwin = () => (
|
||||||
|
<CarUpdatesProvider>
|
||||||
|
<MainForm />
|
||||||
|
</CarUpdatesProvider>
|
||||||
|
);
|
||||||
|
|
||||||
|
export default SumsRxSwin;
|
||||||
@@ -122,6 +122,18 @@ const updatesAPI = {
|
|||||||
})
|
})
|
||||||
.then(fetchRespHandler)
|
.then(fetchRespHandler)
|
||||||
.catch(errorHandler);
|
.catch(errorHandler);
|
||||||
|
},
|
||||||
|
|
||||||
|
getSUMSVersionRxSwins: async (sums_version, token) => {
|
||||||
|
return fetch(`${API_ENDPOINT}/manifest/sums/${sums_version}/rxswins`, {
|
||||||
|
method: "GET",
|
||||||
|
headers: Object.assign(
|
||||||
|
{ "Content-Type": "application/json" },
|
||||||
|
getAuthHeaderOptions(token)
|
||||||
|
),
|
||||||
|
})
|
||||||
|
.then(fetchRespHandler)
|
||||||
|
.catch(errorHandler);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user