CEC-2601 Revert progress changes (#208)
* CEC-2601 Revert progress changes * update
This commit is contained in:
@@ -67,7 +67,7 @@
|
|||||||
"coverageThreshold": {
|
"coverageThreshold": {
|
||||||
"global": {
|
"global": {
|
||||||
"branches": 39,
|
"branches": 39,
|
||||||
"functions": 45.5,
|
"functions": 45,
|
||||||
"lines": 50,
|
"lines": 50,
|
||||||
"statements": 49
|
"statements": 49
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,11 +76,10 @@ export const CarUpdatesProvider = ({ children }) => {
|
|||||||
result = await api.getCarUpdates(search, token);
|
result = await api.getCarUpdates(search, token);
|
||||||
if (result.error)
|
if (result.error)
|
||||||
throw new Error(`Get car updates error. ${result.message}`);
|
throw new Error(`Get car updates error. ${result.message}`);
|
||||||
result.data.forEach((item, i) => {
|
result.data.forEach((item) => {
|
||||||
item.msg = item.status;
|
|
||||||
item.progress = 0;
|
item.progress = 0;
|
||||||
applyProgressStatus(item);
|
item.msg = item.status;
|
||||||
result.data[i] = Object.assign(result.data[i], item);
|
applyProgressStatus(item, item);
|
||||||
});
|
});
|
||||||
setCarUpdates(result.data);
|
setCarUpdates(result.data);
|
||||||
if (search && search.offset === 0 && result.total) {
|
if (search && search.offset === 0 && result.total) {
|
||||||
@@ -120,27 +119,28 @@ export const CarUpdatesProvider = ({ children }) => {
|
|||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
const applyProgressStatus = (item) => {
|
const applyProgressStatus = (item, status) => {
|
||||||
if (validateStatusMessage(item)) {
|
if (validateStatusMessage(status)) {
|
||||||
if (item.msg === "downloading") {
|
if (status.msg === "downloading") {
|
||||||
item.progress = getDownloadProgress(item);
|
item.progress = getDownloadProgress(status);
|
||||||
item.status = `${item.ecu || ""} downloading ${item.progress}%`.trim();
|
item.status = `${item.ecu || ""} downloading ${item.progress}%`.trim();
|
||||||
return;
|
return;
|
||||||
} else if (item.msg === "package_download_complete") {
|
} else if (status.msg === "package_download_complete") {
|
||||||
item.progress = 100;
|
item.progress = 100;
|
||||||
item.status = `${item.ecu || ""} download complete`.trim();
|
item.status = "download complete";
|
||||||
return;
|
return;
|
||||||
} else if (item.msg === "installing") {
|
} else if (status.msg === "installing") {
|
||||||
item.progress = getInstallProgress(item);
|
item.progress = getInstallProgress(status);
|
||||||
item.status = `${item.ecu || ""} installing ${item.progress}%`.trim();
|
item.status = `${item.ecu || ""} installing ${item.progress}%`.trim();
|
||||||
return;
|
return;
|
||||||
} else if (item.msg === "package_install_complete") {
|
} else if (status.msg === "package_install_complete") {
|
||||||
item.progress = 100;
|
item.progress = 100;
|
||||||
item.status = `${item.ecu || ""} install complete`.trim();
|
item.status = "install complete";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete item.progress;
|
delete item.progress;
|
||||||
|
item.status = status.msg;
|
||||||
};
|
};
|
||||||
|
|
||||||
const applyProgressStatuses = (statuses) => {
|
const applyProgressStatuses = (statuses) => {
|
||||||
@@ -222,28 +222,12 @@ export const CarUpdatesProvider = ({ children }) => {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
const cancelUpdate = async (id, token) => {
|
|
||||||
let result;
|
|
||||||
|
|
||||||
try {
|
|
||||||
setBusy(true);
|
|
||||||
result = await api.cancelCarUpdate(id, token);
|
|
||||||
if (result.error)
|
|
||||||
throw new Error(`Cancel car update error. ${result.message}`);
|
|
||||||
} finally {
|
|
||||||
setBusy(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CarUpdatesContext.Provider
|
<CarUpdatesContext.Provider
|
||||||
value={{
|
value={{
|
||||||
busy,
|
busy,
|
||||||
carUpdates,
|
carUpdates,
|
||||||
totalCarUpdates,
|
totalCarUpdates,
|
||||||
cancelUpdate,
|
|
||||||
deployCarUpdates,
|
deployCarUpdates,
|
||||||
deployFleetUpdates,
|
deployFleetUpdates,
|
||||||
getCarUpdates,
|
getCarUpdates,
|
||||||
|
|||||||
Reference in New Issue
Block a user