CEC-377 Create multi-file updates (#71)

* Replace Deploy Package with Deploy Manifest page
Stub new controls for package files

* Add Release notes and ECU FIles to Create Manifest

* Add Release notes and ECU FIles to Create Manifest

* Oops

* Replace multi release notes with single url

* Implement multiple file uploads and progress

* Update snapshots

* Unused import

* Move file to end of form
Update progress layout
This commit is contained in:
John Wu
2021-08-09 08:54:48 -07:00
committed by GitHub
parent 5d82356991
commit 0545b54daf
19 changed files with 1533 additions and 1943 deletions

View File

@@ -1,13 +1,14 @@
import axios from 'axios';
const UPLOAD_ENDPOINT = process.env.REACT_APP_UPLOAD_SERVICE_URL || "https://gw-dev.fiskerdps.com/ota_update";
const fileField = "file";
export const getCancelToken = () => {
const token = axios.CancelToken;
return token.source();
}
export const uploadFile = (file, data, token, onProgress, cancelToken) => {
export const uploadFile = (data, token, onProgress, cancelToken) => {
const form = new FormData();
let options = {
method: "POST",
@@ -17,19 +18,23 @@ export const uploadFile = (file, data, token, onProgress, cancelToken) => {
},
cancelToken,
};
if (onProgress) {
options = {
...options,
onUploadProgress: (event) => {
onProgress(Math.min(99, Math.floor((event.loaded / event.total) * 100)));
onProgress(event.loaded / event.total);
}
}
}
for (let key in data) {
form.append(key, data[key]);
if (key !== fileField) form.append(key, data[key]);
}
form.append("file", file);
return axios.post(`${UPLOAD_ENDPOINT}/update`, form, options)
form.append(fileField, data[fileField]);
return axios.post(`${UPLOAD_ENDPOINT}/manifestfile`, form, options)
.then((response) => response.data)
.catch((error) => {
if (typeof error.response.data === "string") {