Merge pull request #524 from Fisker-Inc/CEC-6008
CEC-6008 - Map flashpack numbers to OS numbers, and display in the UI
This commit is contained in:
@@ -34,6 +34,7 @@ export const VehicleProvider = ({ children }) => {
|
||||
const [totalFlashpacks, setTotalFlashpacks] = useState(0);
|
||||
const [flashpackECUMappings, setFlashpackECUMappings] = useState([])
|
||||
const [totalFlashpackECUMappings, setTotalFlashpackECUMappings] = useState(0)
|
||||
const [osVersions, setOSVersions] = useState([{ "value": "", "label": "None" }])
|
||||
|
||||
const addConnections = async (cars, token) => {
|
||||
try {
|
||||
@@ -331,7 +332,7 @@ export const VehicleProvider = ({ children }) => {
|
||||
}
|
||||
};
|
||||
|
||||
const addFlashpackVersion = async (model, trim, year, flashpack, carFlashpackVersions, token) => {
|
||||
const addFlashpackVersion = async (model, trim, year, flashpack, osVersion, carFlashpackVersions, token) => {
|
||||
try {
|
||||
setBusy(true);
|
||||
|
||||
@@ -340,6 +341,7 @@ export const VehicleProvider = ({ children }) => {
|
||||
"car_trim": trim,
|
||||
"car_year": year,
|
||||
"flashpack": flashpack,
|
||||
"os_version": osVersion,
|
||||
"ecu_versions": carFlashpackVersions,
|
||||
}
|
||||
|
||||
@@ -424,6 +426,30 @@ export const VehicleProvider = ({ children }) => {
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
};
|
||||
|
||||
const getOSVersions = async (token) => {
|
||||
try {
|
||||
setBusy(true);
|
||||
|
||||
const result = await api.getOSVersions(token);
|
||||
if (result.error) {
|
||||
throw new Error(`Get OS versions error. ${result.message}`);
|
||||
}
|
||||
|
||||
var data = [{ "value": "", "label": "None" }]
|
||||
|
||||
for (let i = 0; i < result.data.length; i++) {
|
||||
data.push({
|
||||
"value": result.data[i],
|
||||
"label": result.data[i]
|
||||
});
|
||||
}
|
||||
|
||||
setOSVersions(data);
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -466,6 +492,8 @@ export const VehicleProvider = ({ children }) => {
|
||||
deleteFlashpackVersion,
|
||||
deleteFlashpackVersionECUMapping,
|
||||
getCarFlashpackVersionInfo,
|
||||
osVersions,
|
||||
getOSVersions,
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
|
||||
@@ -91,11 +91,6 @@ exports[`FlashpackAdd Render 1`] = `
|
||||
class="MuiSelect-root MuiSelect-select MuiSelect-outlined MuiInputBase-input MuiOutlinedInput-input"
|
||||
required=""
|
||||
>
|
||||
<option
|
||||
value="Base"
|
||||
>
|
||||
Base
|
||||
</option>
|
||||
<option
|
||||
value="Sport"
|
||||
>
|
||||
@@ -244,6 +239,50 @@ exports[`FlashpackAdd Render 1`] = `
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="MuiFormControl-root MuiFormControl-marginNormal MuiFormControl-fullWidth"
|
||||
>
|
||||
<label
|
||||
class="MuiFormLabel-root MuiInputLabel-root makeStyles-whiteBackground-0 MuiInputLabel-formControl MuiInputLabel-animated MuiInputLabel-outlined"
|
||||
data-shrink="false"
|
||||
>
|
||||
OS Version
|
||||
</label>
|
||||
<div
|
||||
class="MuiInputBase-root MuiOutlinedInput-root MuiInputBase-formControl"
|
||||
required=""
|
||||
>
|
||||
<select
|
||||
aria-invalid="false"
|
||||
class="MuiSelect-root MuiSelect-select MuiSelect-outlined MuiInputBase-input MuiOutlinedInput-input"
|
||||
required=""
|
||||
/>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="MuiSvgIcon-root MuiSelect-icon MuiSelect-iconOutlined"
|
||||
focusable="false"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
d="M7 10l5 5 5-5z"
|
||||
/>
|
||||
</svg>
|
||||
<fieldset
|
||||
aria-hidden="true"
|
||||
class="PrivateNotchedOutline-root-0 MuiOutlinedInput-notchedOutline"
|
||||
style="padding-left: 8px;"
|
||||
>
|
||||
<legend
|
||||
class="PrivateNotchedOutline-legend-0"
|
||||
style="width: 0.01px;"
|
||||
>
|
||||
<span>
|
||||
|
||||
</span>
|
||||
</legend>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="container"
|
||||
>
|
||||
|
||||
@@ -27,14 +27,17 @@ const MainForm = () => {
|
||||
const [redirect, setRedirect] = useState(null);
|
||||
const { setMessage, setTitle, setSitePath } = useStatusContext();
|
||||
const [carModel, setCarModel] = useLocalStorage("FLASHPACK_ADD_MODEL", "Ocean");
|
||||
const [carTrim, setCarTrim] = useLocalStorage("FLASHPACK_ADD_TRIM", "Base");
|
||||
const [carTrim, setCarTrim] = useLocalStorage("FLASHPACK_ADD_TRIM", "Sport");
|
||||
const [carYear, setCarYear] = useLocalStorage("FLASHPACK_ADD_YEAR", 2024);
|
||||
const [trims, setTrims] = useLocalStorage("FLASHPACK_ADD_TRIMS", modelsTrimsYears.oceanTrims);
|
||||
const [years, setYears] = useLocalStorage("FLASHPACK_ADD_YEARS", modelsTrimsYears.oceanYears);
|
||||
const [flashpack, setFlashpack] = useState();
|
||||
const [flashpack, setFlashpack] = useState("");
|
||||
const [osVersion, setOSVersion] = useState("");
|
||||
const [mappingInputs, setMappingInputs] = useState([{ ecuName: "", ecuVersion: "" }]);
|
||||
const {
|
||||
addFlashpackVersion,
|
||||
getOSVersions,
|
||||
osVersions,
|
||||
busy,
|
||||
} = useVehicleContext();
|
||||
|
||||
@@ -56,6 +59,19 @@ const MainForm = () => {
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
try {
|
||||
if (!token) return;
|
||||
await getOSVersions(token);
|
||||
} catch (e) {
|
||||
setMessage(e.message);
|
||||
logger.warn(e.stack);
|
||||
}
|
||||
})();
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [token]);
|
||||
|
||||
const onCarModelChange = (event) => {
|
||||
let newModel = event.target.value
|
||||
|
||||
@@ -87,6 +103,10 @@ const MainForm = () => {
|
||||
setFlashpack(event.target.value);
|
||||
}
|
||||
|
||||
const onOSVersionChange = (event) => {
|
||||
setOSVersion(event.target.value);
|
||||
}
|
||||
|
||||
const onSubmit = async (event) => {
|
||||
try {
|
||||
event.preventDefault();
|
||||
@@ -100,7 +120,7 @@ const MainForm = () => {
|
||||
})
|
||||
}
|
||||
|
||||
const result = await addFlashpackVersion(carModel, carTrim, parseInt(carYear), flashpack, carFlashpackVersions, token);
|
||||
const result = await addFlashpackVersion(carModel, carTrim, parseInt(carYear), flashpack, osVersion, carFlashpackVersions, token);
|
||||
if (!result || result.error) return;
|
||||
|
||||
setMessage(`Added ${carYear} ${carModel} ${carTrim} ${flashpack}`);
|
||||
@@ -157,6 +177,7 @@ const MainForm = () => {
|
||||
onChange={onFlashpackChange}
|
||||
type="number"
|
||||
/>
|
||||
<DropDownList fullWidth required label="OS Version" data={osVersions} classes={classes} onChange={onOSVersionChange} value={osVersion} />
|
||||
<div className="container">
|
||||
{mappingInputs.map((item, index) => (
|
||||
<div className="input_container" key={index}>
|
||||
|
||||
@@ -79,11 +79,6 @@ exports[`Flashpack Render 1`] = `
|
||||
aria-invalid="false"
|
||||
class="MuiSelect-root MuiSelect-select MuiSelect-outlined MuiInputBase-input MuiOutlinedInput-input"
|
||||
>
|
||||
<option
|
||||
value="Base"
|
||||
>
|
||||
Base
|
||||
</option>
|
||||
<option
|
||||
value="Sport"
|
||||
>
|
||||
@@ -245,6 +240,29 @@ exports[`Flashpack Render 1`] = `
|
||||
</svg>
|
||||
</span>
|
||||
</th>
|
||||
<th
|
||||
class="MuiTableCell-root MuiTableCell-head MuiTableCell-alignCenter"
|
||||
scope="col"
|
||||
>
|
||||
<span
|
||||
aria-disabled="false"
|
||||
class="MuiButtonBase-root MuiTableSortLabel-root"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
Part of OS Version
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="MuiSvgIcon-root MuiTableSortLabel-icon MuiTableSortLabel-iconDirectionAsc"
|
||||
focusable="false"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
d="M20 12l-1.41-1.41L13 16.17V4h-2v12.17l-5.58-5.59L4 12l8 8 8-8z"
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
</th>
|
||||
<th
|
||||
class="MuiTableCell-root MuiTableCell-head MuiTableCell-alignCenter"
|
||||
scope="col"
|
||||
|
||||
@@ -30,6 +30,10 @@ const tableColumns = [
|
||||
id: "flashpack",
|
||||
label: "Flashpack Number",
|
||||
},
|
||||
{
|
||||
id: "os_version",
|
||||
label: "Part of OS Version",
|
||||
},
|
||||
{
|
||||
id: "car_model",
|
||||
label: "Model",
|
||||
@@ -58,7 +62,7 @@ const MainForm = () => {
|
||||
const [showDeleteModal, setShowDeleteModal] = useState(false);
|
||||
const [rowToDelete, setRowToDelete] = useState({});
|
||||
const [model, setModel] = useLocalStorage("FLASHPACKS_MODEL", "Ocean");
|
||||
const [trim, setTrim] = useLocalStorage("FLASHPACKS_TRIM", "Base");
|
||||
const [trim, setTrim] = useLocalStorage("FLASHPACKS_TRIM", "Sport");
|
||||
const [year, setYear] = useLocalStorage("FLASHPACKS_YEAR", 2024);
|
||||
const [trims, setTrims] = useLocalStorage("FLASHPACKS_TRIMS", modelsTrimsYears.oceanTrims);
|
||||
const [years, setYears] = useLocalStorage("FLASHPACKS_YEARS", modelsTrimsYears.oceanYears);
|
||||
@@ -210,6 +214,9 @@ const MainForm = () => {
|
||||
{row.flashpack}
|
||||
</Link>
|
||||
</TableCell>
|
||||
<TableCell align="center">
|
||||
{row.os_version}
|
||||
</TableCell>
|
||||
<TableCell align="center">
|
||||
{row.car_model}
|
||||
</TableCell>
|
||||
@@ -245,7 +252,7 @@ const MainForm = () => {
|
||||
) : (
|
||||
<TablePagination
|
||||
rowsPerPageOptions={[5, 10, 25, 100]}
|
||||
colSpan={5}
|
||||
colSpan={6}
|
||||
count={totalFlashpacks}
|
||||
rowsPerPage={pageSize}
|
||||
page={pageIndex}
|
||||
|
||||
@@ -6,10 +6,6 @@
|
||||
}
|
||||
],
|
||||
"oceanTrims": [
|
||||
{
|
||||
"value": "Base",
|
||||
"label": "Base"
|
||||
},
|
||||
{
|
||||
"value": "Sport",
|
||||
"label": "Sport"
|
||||
|
||||
@@ -360,6 +360,17 @@ const vehiclesAPI = {
|
||||
}).then(fetchRespHandler)
|
||||
.catch(errorHandler)
|
||||
},
|
||||
|
||||
getOSVersions: async (token) => {
|
||||
return fetch(`${API_ENDPOINT}/manifests_active_os_versions`, {
|
||||
method: "GET",
|
||||
headers: Object.assign(
|
||||
{ "Content-Type": "application/json" },
|
||||
getAuthHeaderOptions(token)
|
||||
),
|
||||
}).then(fetchRespHandler)
|
||||
.catch(errorHandler)
|
||||
},
|
||||
};
|
||||
|
||||
export default vehiclesAPI;
|
||||
|
||||
Reference in New Issue
Block a user