Reorganize app pages (#73)
* Update layout and menus * Add breadcrumbs Add menu icons Add ECU drop down * Implement submenu Update download progress * revamped dashboard section - failing app.test.js * Clean up Co-authored-by: Drew Taylor <dtaylor@fiskerinc.com>
This commit is contained in:
@@ -76,15 +76,17 @@ export const CarUpdatesProvider = ({ children }) => {
|
||||
};
|
||||
|
||||
const applyProgressStatus = (item, status) => {
|
||||
if (status.msg === "DONE") {
|
||||
if (status.msg === "package_download_complete") {
|
||||
delete item.progress;
|
||||
item.status = "downloaded";
|
||||
} else if (status.msg === "downloading" && status.total > 0) {
|
||||
let progress = Math.floor((100 * status.bytes) / status.total);
|
||||
} else if (status.msg === "downloading" && status.package_total > 0) {
|
||||
let progress = Math.floor(
|
||||
(100 * status.package_current) / status.package_total
|
||||
);
|
||||
if (progress > 99) progress = 0;
|
||||
item.progress = progress;
|
||||
item.status = `downloading ${progress}%`;
|
||||
} else if (status.error > 0) {
|
||||
} else if (status.error > 0 || status.msg === "download_error") {
|
||||
item.status = "download error";
|
||||
} else {
|
||||
item.status = "downloading";
|
||||
|
||||
@@ -117,6 +117,16 @@ export const ManifestsProvider = ({ children }) => {
|
||||
}
|
||||
};
|
||||
|
||||
const checkExistingManifest = async (data, token) => {
|
||||
const check = {
|
||||
name: data.name,
|
||||
version: data.version,
|
||||
};
|
||||
const { data: result } = await api.getManifests(check, token);
|
||||
if (result.length > 0)
|
||||
throw new Error(`Update ${data.name} ${data.version} already exists`);
|
||||
};
|
||||
|
||||
const createManifest = async (data, token) => {
|
||||
let result;
|
||||
|
||||
@@ -125,7 +135,8 @@ export const ManifestsProvider = ({ children }) => {
|
||||
validateManifest(data, token);
|
||||
setUploadedFiles(data.files);
|
||||
|
||||
result = await api.createManifest(data, token);
|
||||
await checkExistingManifest(data, token);
|
||||
if (result !== null) result = await api.createManifest(data, token);
|
||||
if (result.error)
|
||||
throw new Error(`Create manifest error. ${result.message}`);
|
||||
|
||||
|
||||
@@ -5,14 +5,17 @@ const StatusContext = React.createContext();
|
||||
export const StatusProvider = ({ children }) => {
|
||||
const [message, setMessage] = useState(null);
|
||||
const [title, setTitle] = useState("");
|
||||
const [sitePath, setSitePath] = useState([]);
|
||||
|
||||
return (
|
||||
<StatusContext.Provider
|
||||
value={{
|
||||
message,
|
||||
setMessage,
|
||||
title,
|
||||
sitePath,
|
||||
setMessage,
|
||||
setTitle,
|
||||
setSitePath,
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
|
||||
Reference in New Issue
Block a user