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:
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user