Merge CEC-394 Car update log (#82)

This commit is contained in:
John Wu
2021-08-26 15:03:45 -07:00
committed by GitHub
parent d1815e2ff9
commit 74eb2707a3
34 changed files with 3114 additions and 3583 deletions

View File

@@ -51,8 +51,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));
console.log(result.data);
result.data.forEach((item) => {
item.progress = 0;
item.msg = item.status;
applyProgressStatus(item, item);
});
setCarUpdates(result.data);
if (search && search.offset === 0 && result.total) {
setTotalCarUpdates(result.total);
@@ -179,6 +182,21 @@ export const CarUpdatesProvider = ({ children }) => {
progressTimer = 0;
};
const getLog = async (query, token) => {
let result;
try {
setBusy(true);
result = await api.getCarUpdateLog(query, token);
if (result.error)
throw new Error(`Get car update log error. ${result.message}`);
} finally {
setBusy(false);
}
return result;
};
return (
<CarUpdatesContext.Provider
value={{
@@ -187,6 +205,7 @@ export const CarUpdatesProvider = ({ children }) => {
totalCarUpdates,
deployCarUpdates,
getCarUpdates,
getLog,
getVINUpdates,
startMonitor,
stopMonitor,