CEC-5182: fix missing parameters (#476)
This commit is contained in:
@@ -33,6 +33,10 @@ const validateDeployFleetUpdates = (data) => {
|
||||
};
|
||||
|
||||
export function downloadPercent(status) {
|
||||
if (!status) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (status.status === "install_succeeded") {
|
||||
return 100;
|
||||
}
|
||||
@@ -45,6 +49,10 @@ export function downloadPercent(status) {
|
||||
}
|
||||
|
||||
export function installPercent(status) {
|
||||
if (!status) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (status.total_files === 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ export const FleetProvider = ({ children }) => {
|
||||
token
|
||||
)
|
||||
.then((result) => {
|
||||
if (!Array.isArray(result.statuses)) {
|
||||
if (!Array.isArray(result?.statuses)) {
|
||||
return Promise.reject();
|
||||
}
|
||||
return result;
|
||||
@@ -169,7 +169,9 @@ export const FleetProvider = ({ children }) => {
|
||||
.catch(() => {
|
||||
return Promise.reject();
|
||||
});
|
||||
|
||||
let pivot = result.statuses?.length ? result.statuses.length - 1 : 0;
|
||||
|
||||
setFleetVehicles((fleetVehicles) => fleetVehicles.map((vehicle) => {
|
||||
result.statuses.find((status, i) => {
|
||||
if (vehicle.car_update_id !== status.car_update_id) {
|
||||
@@ -178,7 +180,7 @@ export const FleetProvider = ({ children }) => {
|
||||
|
||||
switch (status.msg) {
|
||||
case "downloading":
|
||||
vehicle.car_update_progress = downloadPercent();
|
||||
vehicle.car_update_progress = downloadPercent(status);
|
||||
vehicle.car_update_status = `${status.ecu} downloading ${vehicle.car_update_progress}%`.trim();
|
||||
break;
|
||||
case "package_download_complete":
|
||||
@@ -186,7 +188,7 @@ export const FleetProvider = ({ children }) => {
|
||||
vehicle.car_update_status = `download complete`;
|
||||
break;
|
||||
case "installing":
|
||||
vehicle.car_update_progress = installPercent();
|
||||
vehicle.car_update_progress = installPercent(status);
|
||||
vehicle.car_update_status = `${status.ecu} installing ${vehicle.car_update_progress}%`.trim();
|
||||
break;
|
||||
case "package_install_complete":
|
||||
|
||||
Reference in New Issue
Block a user