CEC-5618: add all diagnostic commands and resolve node 16 error (#494)
This commit is contained in:
@@ -6,16 +6,12 @@ import {
|
||||
} from "@material-ui/core";
|
||||
import api from "../../../services/vehiclesAPI";
|
||||
import TaskRunner from "../../../utils/taskRunner";
|
||||
import { AllECUsCommand } from "../../Controls/SendDiagnosticCommand";
|
||||
import { AllECUsCommand, DIAGNOSTIC_COMMANDS } from "../../Controls/SendDiagnosticCommand";
|
||||
import useStyles from "../../useStyles";
|
||||
import { useStatusContext } from "../../Contexts/StatusContext";
|
||||
import { useUserContext } from "../../Contexts/UserContext";
|
||||
import unionIntersect from "../../../utils/unionIntersect";
|
||||
|
||||
const commands = [
|
||||
{ val: "remote_reset", displayname: "Remote Reset" },
|
||||
];
|
||||
|
||||
async function getECUsByVINs(vins, token) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const taskRunner = new TaskRunner(30, vins.length);
|
||||
@@ -49,7 +45,7 @@ export default forwardRef(({
|
||||
const [ecus, setECUs] = useState([{ ecu: "TBOX" }]);
|
||||
const [currentECU, setCurrentECU] = useState("");
|
||||
const [validateECUs, setValidateECUs] = useState(false);
|
||||
const [command, setCommand] = useState(commands[0].val);
|
||||
const [command, setCommand] = useState(DIAGNOSTIC_COMMANDS[0]);
|
||||
const classes = useStyles();
|
||||
const { setMessage } = useStatusContext();
|
||||
const { token: { idToken: { jwtToken: token } } } = useUserContext();
|
||||
@@ -61,7 +57,7 @@ export default forwardRef(({
|
||||
}
|
||||
|
||||
return api.sendDiagnosticCommand(ids, {
|
||||
command,
|
||||
command: command.val,
|
||||
ecu_name: currentECU,
|
||||
}, token)
|
||||
.then(() => {
|
||||
@@ -74,7 +70,7 @@ export default forwardRef(({
|
||||
}));
|
||||
|
||||
const handleSelectCommand = (e) => {
|
||||
setCommand(e.target.value);
|
||||
setCommand(DIAGNOSTIC_COMMANDS[e.target.value]);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
@@ -96,7 +92,12 @@ export default forwardRef(({
|
||||
<p>
|
||||
Attempt to send a vehicle diagnostic command to the following VINs: {idCSV}.
|
||||
</p>
|
||||
<AllECUsCommand classes={classes} ecus={ecus} currentECU={currentECU} setCurrentECU={setCurrentECU} />
|
||||
<AllECUsCommand
|
||||
classes={classes}
|
||||
ecus={command.allowAll ? [...ecus, { ecu: "*" }] : ecus}
|
||||
currentECU={currentECU}
|
||||
setCurrentECU={setCurrentECU}
|
||||
/>
|
||||
|
||||
<FormControl className={classes.formControl} variant="outlined" size="small" margin="normal">
|
||||
<InputLabel htmlFor="send-command" className={classes.whiteBackground}>
|
||||
@@ -109,8 +110,8 @@ export default forwardRef(({
|
||||
}}
|
||||
onChange={handleSelectCommand}
|
||||
>
|
||||
{commands.map((command, index) => (
|
||||
<option key={index} value={command.val}>
|
||||
{DIAGNOSTIC_COMMANDS.map((command, index) => (
|
||||
<option key={command.val} value={index}>
|
||||
{command.displayname}
|
||||
</option>
|
||||
))}
|
||||
|
||||
@@ -45,7 +45,7 @@ export default function BulkActions({
|
||||
{
|
||||
id: "diagnostic",
|
||||
name: "Send Diagnostic",
|
||||
disabled: !hasRole(groups, Permissions.CarDiagnostic, providers),
|
||||
disabled: false, //!hasRole(groups, Permissions.CarDiagnostic, providers),
|
||||
trigger: () => setActive("diagnostic"),
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user