Change main UI layout and add VINs to add and upload forms (#16)

* Add new upload update package form
Add new add vehicle form
Add new side menu layout
Add new toolbar layout
Update and add unit tests

* Enable add get and add vehicles

* Integration issues with ota_update service

* Update get vehicle JSON format

* Fix related unit test
Add release notes field

* Add StatusContext to display error and status messages
This commit is contained in:
John Wu
2021-03-11 12:53:29 -08:00
committed by GitHub
parent 39e779dc1d
commit 2e1f4a7a7c
31 changed files with 2666 additions and 377 deletions

View File

@@ -11,7 +11,7 @@ export const getCancelToken = () => {
return issuedCancelToken;
}
export const uploadFile = async (file, token, onProgress, cancelToken) => {
export const uploadFile = async (file, data, token, onProgress, cancelToken) => {
if (!uploadFileDelay) return uploadFileResponse;
onProgress(50);
await delay(10000);

View File

@@ -0,0 +1,17 @@
const data = [
{ vin: "3C4PDCBG0ET127145" },
{ vin: "1G1FP87S3GN100062" },
{ vin: "1HGCG325XYA062256" },
{ vin: "1J4GZ78YXWC160024" },
{ vin: "2C3CCAAG8CH222800" },
{ vin: "KNADM4A39C6028108" },
{ vin: "1G11C5SL9FF153507" },
];
const vehiclesAPI = {
getVehicles: async (search, token) => { return { data: { data } }; },
addVehicle: async (vehicle, token) => { data.push(vehicle); },
};
export default vehiclesAPI;

View File

@@ -7,7 +7,7 @@ export const getCancelToken = () => {
return token.source();
}
export const uploadFile = (file, token, onProgress, cancelToken) => {
export const uploadFile = (file, data, token, onProgress, cancelToken) => {
const form = new FormData();
let options = {
method: "POST",
@@ -24,7 +24,10 @@ export const uploadFile = (file, token, onProgress, cancelToken) => {
onProgress(Math.min(99, Math.floor((event.loaded / event.total) * 100)));
}
}
}
form.append('file', file);
return axios.post(UPLOAD_ENDPOINT, form, options);
}
for (let key in data) {
form.append(key, data[key]);
}
form.append("file", file);
return axios.post(`${UPLOAD_ENDPOINT}/upload`, form, options);
};

20
src/services/vehicles.js Normal file
View File

@@ -0,0 +1,20 @@
import axios from 'axios';
const API_ENDPOINT = process.env.REACT_APP_UPLOAD_SERVICE_URL || "https://gw-dev.fiskerdps.com/ota_update";
const getOptions = (token) => ({
headers: {
"Authorization": `Bearer ${token}`,
},
});
const vehiclesAPI = {
getVehicles: async (search, token) => {
return axios.get(`${API_ENDPOINT}/vehicles`, getOptions(token));
},
addVehicle: async (vehicle, token) => {
return axios.post(`${API_ENDPOINT}/vehicle`, vehicle, getOptions(token));
}
};
export default vehiclesAPI;