CEC-4541: Force Config push (#355)
This commit is contained in:
committed by
GitHub
parent
f2377d9ed7
commit
a5f32151b2
@@ -11428,6 +11428,43 @@ exports[`App Route /vehicle-status authenticated 1`] = `
|
||||
/>
|
||||
</svg>
|
||||
</a>
|
||||
<label
|
||||
class="MuiFormControlLabel-root"
|
||||
>
|
||||
<span
|
||||
aria-disabled="false"
|
||||
class="MuiButtonBase-root MuiIconButton-root PrivateSwitchBase-root-0 MuiCheckbox-root MuiCheckbox-colorSecondary MuiIconButton-colorSecondary"
|
||||
>
|
||||
<span
|
||||
class="MuiIconButton-label"
|
||||
>
|
||||
<input
|
||||
class="PrivateSwitchBase-input-0"
|
||||
data-indeterminate="false"
|
||||
type="checkbox"
|
||||
value=""
|
||||
/>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="MuiSvgIcon-root"
|
||||
focusable="false"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
d="M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z"
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
<span
|
||||
class="MuiTouchRipple-root"
|
||||
/>
|
||||
</span>
|
||||
<span
|
||||
class="MuiTypography-root MuiFormControlLabel-label MuiTypography-body1"
|
||||
>
|
||||
FORCE CONFIG PUSH
|
||||
</span>
|
||||
</label>
|
||||
<a
|
||||
class=""
|
||||
href="/vehicle-status/FISKER123"
|
||||
|
||||
@@ -168,6 +168,43 @@ exports[`VehicleDetailsTab Render 1`] = `
|
||||
/>
|
||||
</svg>
|
||||
</a>
|
||||
<label
|
||||
class="MuiFormControlLabel-root"
|
||||
>
|
||||
<span
|
||||
aria-disabled="false"
|
||||
class="MuiButtonBase-root MuiIconButton-root PrivateSwitchBase-root-0 MuiCheckbox-root MuiCheckbox-colorSecondary MuiIconButton-colorSecondary"
|
||||
>
|
||||
<span
|
||||
class="MuiIconButton-label"
|
||||
>
|
||||
<input
|
||||
class="PrivateSwitchBase-input-0"
|
||||
data-indeterminate="false"
|
||||
type="checkbox"
|
||||
value=""
|
||||
/>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="MuiSvgIcon-root"
|
||||
focusable="false"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
d="M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z"
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
<span
|
||||
class="MuiTouchRipple-root"
|
||||
/>
|
||||
</span>
|
||||
<span
|
||||
class="MuiTypography-root MuiFormControlLabel-label MuiTypography-body1"
|
||||
>
|
||||
FORCE CONFIG PUSH
|
||||
</span>
|
||||
</label>
|
||||
<a
|
||||
class=""
|
||||
href="/"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Grid, Tooltip } from "@material-ui/core";
|
||||
import { Grid, Tooltip, Checkbox, FormControlLabel } from "@material-ui/core";
|
||||
import DeleteIcon from "@material-ui/icons/Delete";
|
||||
import EditIcon from "@material-ui/icons/Edit";
|
||||
import UploadIcon from '@mui/icons-material/Upload';
|
||||
@@ -27,6 +27,7 @@ const MainForm = ({ vin }) => {
|
||||
const [redirect, setRedirect] = useState(null);
|
||||
const [showDeleteModal, setShowDeleteModal] = useState(false);
|
||||
const [showUploadConfigModal, setShowUploadConfigModal] = useState(false);
|
||||
const [forced, setForced] = useState(false);
|
||||
const {
|
||||
token: {
|
||||
idToken: { jwtToken: token },
|
||||
@@ -37,6 +38,10 @@ const MainForm = ({ vin }) => {
|
||||
|
||||
const showDebugMask = (process.env.REACT_APP_ENABLE_DEBUGMASK === "1");
|
||||
|
||||
const onForcedChange = (event) => {
|
||||
setForced(event.target.checked);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
try {
|
||||
@@ -63,7 +68,7 @@ const MainForm = ({ vin }) => {
|
||||
|
||||
const onUploadConfig = async () => {
|
||||
try {
|
||||
await uploadConfig(vin, token);
|
||||
await uploadConfig(vin, forced, token);
|
||||
setMessage(`Config Uploaded ${vin}`);
|
||||
} catch (e) {
|
||||
setMessage(e.message);
|
||||
@@ -159,6 +164,15 @@ const MainForm = ({ vin }) => {
|
||||
providers={providers}
|
||||
rolesPerProvider={Permissions.FiskerCreate}
|
||||
>
|
||||
<FormControlLabel
|
||||
label="FORCE CONFIG PUSH"
|
||||
control={
|
||||
<Checkbox
|
||||
checked={forced}
|
||||
onChange={onForcedChange}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
<Tooltip key={`push-config-${vin}`} title={`Push Config "${vin}"`}>
|
||||
<Link to="#" onClick={() => setShowUploadConfigModal(true)}>
|
||||
<UploadIcon aria-label={`Push Config "${vin}"`} />
|
||||
|
||||
@@ -176,6 +176,43 @@ exports[`DetailsTab Render 1`] = `
|
||||
/>
|
||||
</svg>
|
||||
</a>
|
||||
<label
|
||||
class="MuiFormControlLabel-root"
|
||||
>
|
||||
<span
|
||||
aria-disabled="false"
|
||||
class="MuiButtonBase-root MuiIconButton-root PrivateSwitchBase-root-0 MuiCheckbox-root MuiCheckbox-colorSecondary MuiIconButton-colorSecondary"
|
||||
>
|
||||
<span
|
||||
class="MuiIconButton-label"
|
||||
>
|
||||
<input
|
||||
class="PrivateSwitchBase-input-0"
|
||||
data-indeterminate="false"
|
||||
type="checkbox"
|
||||
value=""
|
||||
/>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="MuiSvgIcon-root"
|
||||
focusable="false"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
d="M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z"
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
<span
|
||||
class="MuiTouchRipple-root"
|
||||
/>
|
||||
</span>
|
||||
<span
|
||||
class="MuiTypography-root MuiFormControlLabel-label MuiTypography-body1"
|
||||
>
|
||||
FORCE CONFIG PUSH
|
||||
</span>
|
||||
</label>
|
||||
<a
|
||||
class=""
|
||||
href="/testroute/TESTVIN1234567890"
|
||||
|
||||
@@ -357,6 +357,43 @@ exports[`CarStatus Render 1`] = `
|
||||
/>
|
||||
</svg>
|
||||
</a>
|
||||
<label
|
||||
class="MuiFormControlLabel-root"
|
||||
>
|
||||
<span
|
||||
aria-disabled="false"
|
||||
class="MuiButtonBase-root MuiIconButton-root PrivateSwitchBase-root-0 MuiCheckbox-root MuiCheckbox-colorSecondary MuiIconButton-colorSecondary"
|
||||
>
|
||||
<span
|
||||
class="MuiIconButton-label"
|
||||
>
|
||||
<input
|
||||
class="PrivateSwitchBase-input-0"
|
||||
data-indeterminate="false"
|
||||
type="checkbox"
|
||||
value=""
|
||||
/>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="MuiSvgIcon-root"
|
||||
focusable="false"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
d="M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z"
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
<span
|
||||
class="MuiTouchRipple-root"
|
||||
/>
|
||||
</span>
|
||||
<span
|
||||
class="MuiTypography-root MuiFormControlLabel-label MuiTypography-body1"
|
||||
>
|
||||
FORCE CONFIG PUSH
|
||||
</span>
|
||||
</label>
|
||||
<a
|
||||
class=""
|
||||
href="/"
|
||||
|
||||
@@ -200,12 +200,12 @@ export const VehicleProvider = ({ children }) => {
|
||||
}
|
||||
};
|
||||
|
||||
const uploadConfig = async (vin, token) => {
|
||||
const uploadConfig = async (vin, forced, token) => {
|
||||
try {
|
||||
setBusy(true);
|
||||
validateVIN(vin);
|
||||
|
||||
const result = await api.updateConfig(vin, token);
|
||||
const result = await api.updateConfig(vin, forced, token);
|
||||
if (result.error)
|
||||
throw new Error(`Update vehicle error. ${result.message}`);
|
||||
return result;
|
||||
|
||||
@@ -173,8 +173,8 @@ const vehiclesAPI = {
|
||||
.then(fetchRespHandler)
|
||||
.catch(errorHandler),
|
||||
|
||||
updateConfig: async (vin, token) =>
|
||||
fetch(`${API_ENDPOINT}/car_config/${vin}`, {
|
||||
updateConfig: async (vin, forced, token) =>
|
||||
fetch(`${API_ENDPOINT}/car_config/${vin}?forced=${forced}`, {
|
||||
method: "POST",
|
||||
headers: Object.assign(
|
||||
{ "Content-Type": "application/json" },
|
||||
|
||||
Reference in New Issue
Block a user