CEC-2611 Show HMI online status (#205)

* CEC-2611 Show HMI online status
Update car update progress to show ECU
Refresh car details car updates tab

* clean up
This commit is contained in:
John Wu
2022-09-28 18:00:31 -07:00
committed by GitHub
parent 63e2d2b18f
commit 231df333b0
9 changed files with 214 additions and 96 deletions

View File

@@ -76,10 +76,11 @@ 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) => {
item.progress = 0;
result.data.forEach((item, i) => {
item.msg = item.status;
applyProgressStatus(item, item);
item.progress = 0;
applyProgressStatus(item);
result.data[i] = Object.assign(result.data[i], item);
});
setCarUpdates(result.data);
if (search && search.offset === 0 && result.total) {
@@ -119,28 +120,27 @@ export const CarUpdatesProvider = ({ children }) => {
return 0;
};
const applyProgressStatus = (item, status) => {
if (validateStatusMessage(status)) {
if (status.msg === "downloading") {
item.progress = getDownloadProgress(status);
const applyProgressStatus = (item) => {
if (validateStatusMessage(item)) {
if (item.msg === "downloading") {
item.progress = getDownloadProgress(item);
item.status = `${item.ecu || ""} downloading ${item.progress}%`.trim();
return;
} else if (status.msg === "package_download_complete") {
} else if (item.msg === "package_download_complete") {
item.progress = 100;
item.status = "download complete";
item.status = `${item.ecu || ""} download complete`.trim();
return;
} else if (status.msg === "installing") {
item.progress = getInstallProgress(status);
} else if (item.msg === "installing") {
item.progress = getInstallProgress(item);
item.status = `${item.ecu || ""} installing ${item.progress}%`.trim();
return;
} else if (status.msg === "package_install_complete") {
} else if (item.msg === "package_install_complete") {
item.progress = 100;
item.status = "install complete";
item.status = `${item.ecu || ""} install complete`.trim();
return;
}
}
delete item.progress;
item.status = status.msg;
};
const applyProgressStatuses = (statuses) => {