Merge branch 'develop' into release/0.0.3
This commit is contained in:
@@ -67,7 +67,7 @@
|
||||
"coverageThreshold": {
|
||||
"global": {
|
||||
"branches": 39,
|
||||
"functions": 45.5,
|
||||
"functions": 45,
|
||||
"lines": 50,
|
||||
"statements": 49
|
||||
}
|
||||
|
||||
@@ -76,11 +76,10 @@ export const CarUpdatesProvider = ({ children }) => {
|
||||
result = await api.getCarUpdates(search, token);
|
||||
if (result.error)
|
||||
throw new Error(`Get car updates error. ${result.message}`);
|
||||
result.data.forEach((item, i) => {
|
||||
item.msg = item.status;
|
||||
result.data.forEach((item) => {
|
||||
item.progress = 0;
|
||||
applyProgressStatus(item);
|
||||
result.data[i] = Object.assign(result.data[i], item);
|
||||
item.msg = item.status;
|
||||
applyProgressStatus(item, item);
|
||||
});
|
||||
setCarUpdates(result.data);
|
||||
if (search && search.offset === 0 && result.total) {
|
||||
@@ -120,27 +119,28 @@ export const CarUpdatesProvider = ({ children }) => {
|
||||
return 0;
|
||||
};
|
||||
|
||||
const applyProgressStatus = (item) => {
|
||||
if (validateStatusMessage(item)) {
|
||||
if (item.msg === "downloading") {
|
||||
item.progress = getDownloadProgress(item);
|
||||
const applyProgressStatus = (item, status) => {
|
||||
if (validateStatusMessage(status)) {
|
||||
if (status.msg === "downloading") {
|
||||
item.progress = getDownloadProgress(status);
|
||||
item.status = `${item.ecu || ""} downloading ${item.progress}%`.trim();
|
||||
return;
|
||||
} else if (item.msg === "package_download_complete") {
|
||||
} else if (status.msg === "package_download_complete") {
|
||||
item.progress = 100;
|
||||
item.status = `${item.ecu || ""} download complete`.trim();
|
||||
item.status = "download complete";
|
||||
return;
|
||||
} else if (item.msg === "installing") {
|
||||
item.progress = getInstallProgress(item);
|
||||
} else if (status.msg === "installing") {
|
||||
item.progress = getInstallProgress(status);
|
||||
item.status = `${item.ecu || ""} installing ${item.progress}%`.trim();
|
||||
return;
|
||||
} else if (item.msg === "package_install_complete") {
|
||||
} else if (status.msg === "package_install_complete") {
|
||||
item.progress = 100;
|
||||
item.status = `${item.ecu || ""} install complete`.trim();
|
||||
item.status = "install complete";
|
||||
return;
|
||||
}
|
||||
}
|
||||
delete item.progress;
|
||||
item.status = status.msg;
|
||||
};
|
||||
|
||||
const applyProgressStatuses = (statuses) => {
|
||||
@@ -222,28 +222,12 @@ export const CarUpdatesProvider = ({ children }) => {
|
||||
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 (
|
||||
<CarUpdatesContext.Provider
|
||||
value={{
|
||||
busy,
|
||||
carUpdates,
|
||||
totalCarUpdates,
|
||||
cancelUpdate,
|
||||
deployCarUpdates,
|
||||
deployFleetUpdates,
|
||||
getCarUpdates,
|
||||
|
||||
Reference in New Issue
Block a user