diff --git a/.env.cec-euprd b/.env.cec-euprd index 0bcb8e9..7b9dcef 100644 --- a/.env.cec-euprd +++ b/.env.cec-euprd @@ -9,10 +9,11 @@ REACT_APP_SECURITY_DLL_URL=https://assets.fiskerdps.com/cloud-supplier/fisker_se REACT_APP_SECURITY_DLL_64_URL=https://assets.fiskerdps.com/cloud-supplier/fisker_security_64.dll REACT_APP_SUPERSET_URL=https://superset.cec-euprd.fiskerinc.com REACT_APP_ROLE_CREATE=e92f2b3e-1b80-42e5-9483-8ae648224dc6 -REACT_APP_ROLE_READ_ONLY=9af2d8c0-c26d-4d6d-bbd1-ac53cbd37ebc +REACT_APP_ROLE_READ_ONLY=ae5123e3-7a6a-4ca9-947b-a0f184f82cbd REACT_APP_ROLE_DELETE=bfd1cccc-213a-4f31-b3d1-6e685976aec8 REACT_APP_ROLE_GENERATE_CERTIFICATE=9af2d8c0-c26d-4d6d-bbd1-ac53cbd37ebc REACT_APP_ROLE_MANUFACTURE=3412e11a-a2d1-4355-be3e-ef9aa5065b69 REACT_APP_ROLE_SUPPLIER_APPROVER=a6c9805e-80b2-42b2-bfbb-9df52e5504d8 REACT_APP_ROLE_MANIFEST_MIGRATION=42798c8a-9fa7-4fb4-82c0-9582cabe364f REACT_APP_ECCKEY_ENV= +REACT_APP_HOME_MAP_DEFAULT_LOCATION={"lat":49.8327,"lng":9.8816,"zoom":4.5} diff --git a/.env.cec-prd b/.env.cec-prd index 54ea7a8..d30b7e4 100644 --- a/.env.cec-prd +++ b/.env.cec-prd @@ -9,10 +9,11 @@ REACT_APP_SECURITY_DLL_URL=https://assets.fiskerdps.com/cloud-supplier/fisker_se REACT_APP_SECURITY_DLL_64_URL=https://assets.fiskerdps.com/cloud-supplier/fisker_security_64.dll REACT_APP_SUPERSET_URL=https://superset.cec-prd.fiskerinc.com REACT_APP_ROLE_CREATE=e92f2b3e-1b80-42e5-9483-8ae648224dc6 -REACT_APP_ROLE_READ_ONLY=9af2d8c0-c26d-4d6d-bbd1-ac53cbd37ebc +REACT_APP_ROLE_READ_ONLY=ae5123e3-7a6a-4ca9-947b-a0f184f82cbd REACT_APP_ROLE_DELETE=bfd1cccc-213a-4f31-b3d1-6e685976aec8 REACT_APP_ROLE_GENERATE_CERTIFICATE=9af2d8c0-c26d-4d6d-bbd1-ac53cbd37ebc REACT_APP_ROLE_MANUFACTURE=3412e11a-a2d1-4355-be3e-ef9aa5065b69 REACT_APP_ROLE_SUPPLIER_APPROVER=a6c9805e-80b2-42b2-bfbb-9df52e5504d8 REACT_APP_ROLE_MANIFEST_MIGRATION=42798c8a-9fa7-4fb4-82c0-9582cabe364f REACT_APP_ECCKEY_ENV= +REACT_APP_HOME_MAP_DEFAULT_LOCATION={"lat":37.0902,"lng":-95.7129,"zoom":4.5} diff --git a/.env.dev b/.env.dev index e08c37a..a04f46a 100644 --- a/.env.dev +++ b/.env.dev @@ -16,3 +16,4 @@ REACT_APP_ROLE_MANUFACTURE=3412e11a-a2d1-4355-be3e-ef9aa5065b69 REACT_APP_ROLE_SUPPLIER_APPROVER=a6c9805e-80b2-42b2-bfbb-9df52e5504d8 REACT_APP_ROLE_MANIFEST_MIGRATION=42798c8a-9fa7-4fb4-82c0-9582cabe364f REACT_APP_ECCKEY_ENV=stage,prod +REACT_APP_HOME_MAP_DEFAULT_LOCATION={"lat":37.0902,"lng":-95.7129,"zoom":4.5} diff --git a/.env.local b/.env.local index 71f52ab..788b410 100644 --- a/.env.local +++ b/.env.local @@ -16,3 +16,4 @@ REACT_APP_ROLE_MANUFACTURE=3412e11a-a2d1-4355-be3e-ef9aa5065b69 REACT_APP_ROLE_SUPPLIER_APPROVER=a6c9805e-80b2-42b2-bfbb-9df52e5504d8 REACT_APP_ROLE_MANIFEST_MIGRATION=42798c8a-9fa7-4fb4-82c0-9582cabe364f REACT_APP_ECCKEY_ENV=dev,stage,prod +REACT_APP_HOME_MAP_DEFAULT_LOCATION={"lat":37.0902,"lng":-95.7129,"zoom":4.5} diff --git a/.env.prd b/.env.prd index 4174e96..f812b2a 100644 --- a/.env.prd +++ b/.env.prd @@ -16,3 +16,4 @@ REACT_APP_ROLE_MANUFACTURE=3412e11a-a2d1-4355-be3e-ef9aa5065b69 REACT_APP_ROLE_SUPPLIER_APPROVER=a6c9805e-80b2-42b2-bfbb-9df52e5504d8 REACT_APP_ROLE_MANIFEST_MIGRATION=42798c8a-9fa7-4fb4-82c0-9582cabe364f REACT_APP_ECCKEY_ENV=stage +REACT_APP_HOME_MAP_DEFAULT_LOCATION={"lat":37.0902,"lng":-95.7129,"zoom":4.5} diff --git a/.env.stg b/.env.stg index 8bb96c4..702381f 100644 --- a/.env.stg +++ b/.env.stg @@ -16,3 +16,4 @@ REACT_APP_ROLE_MANUFACTURE=3412e11a-a2d1-4355-be3e-ef9aa5065b69 REACT_APP_ROLE_SUPPLIER_APPROVER=a6c9805e-80b2-42b2-bfbb-9df52e5504d8 REACT_APP_ROLE_MANIFEST_MIGRATION=42798c8a-9fa7-4fb4-82c0-9582cabe364f REACT_APP_ECCKEY_ENV=prod +REACT_APP_HOME_MAP_DEFAULT_LOCATION={"lat":37.0902,"lng":-95.7129,"zoom":4.5} diff --git a/.env.template b/.env.template index 1cdf893..517bef2 100644 --- a/.env.template +++ b/.env.template @@ -16,3 +16,4 @@ REACT_APP_ROLE_MANUFACTURE=3412e11a-a2d1-4355-be3e-ef9aa5065b69 REACT_APP_ROLE_SUPPLIER_APPROVER=a6c9805e-80b2-42b2-bfbb-9df52e5504d8 REACT_APP_ROLE_MANIFEST_MIGRATION=42798c8a-9fa7-4fb4-82c0-9582cabe364f REACT_APP_ECCKEY_ENV=dev,stage,prod +REACT_APP_HOME_MAP_DEFAULT_LOCATION={"lat":37.0902,"lng":-95.7129,"zoom":4.5} diff --git a/src/components/App/__snapshots__/App.test.js.snap b/src/components/App/__snapshots__/App.test.js.snap index 909fc68..9795528 100644 --- a/src/components/App/__snapshots__/App.test.js.snap +++ b/src/components/App/__snapshots__/App.test.js.snap @@ -475,6 +475,79 @@ exports[`App Route / authenticated 1`] = `
+
+ +
+ + + +
+
+
+ +
+ + + +
+
({ .fn() .mockResolvedValue({ // tests only pass without mocking the data here + // '3FAFP13P71R199267': [], // '3FAFP13P31R199430': [[16.891136999999986, 26.832352999999955], [56.891136999999986, 66.832352999999955], [26.891136999999986, 36.832352999999955]], // '3FAFP13P71R199060': [[36.891136999999986, 46.832352999999955], [76.891136999999986, 16.832352999999955]], }), diff --git a/src/components/Layouts/SideMenu.jsx b/src/components/Layouts/SideMenu.jsx index f0d24cf..408cb76 100644 --- a/src/components/Layouts/SideMenu.jsx +++ b/src/components/Layouts/SideMenu.jsx @@ -9,10 +9,10 @@ import HomeIcon from "@material-ui/icons/Home"; import SettingsInputCompositeIcon from "@material-ui/icons/SettingsInputComposite"; import { default as React, useEffect, useState } from "react"; +import { getCustomDashboardSubmenu } from "../../services/customDashboards"; import { hasRole, Permissions } from "../../utils/roles"; import { useUserContext } from "../Contexts/UserContext"; import { ExpandableSideMenuItem, MenuItem } from "./MenuItem"; -import { getCustomDashboardSubmenu } from "../../services/customDashboards" const menuData = [ { @@ -67,7 +67,7 @@ const menuData = [ { label: "Certificate", to: "/tools/certificates/add", - rolesPerProvider: Permissions.FiskerCertificate, + rolesPerProvider: Permissions.FiskerMagnaCertificate, }, { label: "Security.dll", diff --git a/src/components/Manifest/List/index.jsx b/src/components/Manifest/List/index.jsx index eca560c..e41d28f 100644 --- a/src/components/Manifest/List/index.jsx +++ b/src/components/Manifest/List/index.jsx @@ -195,7 +195,7 @@ const MainForm = () => { ), }); } - if (hasRole(groups, Permissions.FiskerRead, providers)) { + if (hasRole(groups, Permissions.FiskerCreate, providers)) { actions.push({ tip: `Update "${row.name} ${row.version}"`, link: `/package-update/${row.id}`, diff --git a/src/components/VehicleMap/index.jsx b/src/components/VehicleMap/index.jsx index 2c9dbc7..27ecae3 100644 --- a/src/components/VehicleMap/index.jsx +++ b/src/components/VehicleMap/index.jsx @@ -6,11 +6,13 @@ import useStyles from "../useStyles"; import GrayMarkerIcon from "../../assets/gray-marker.png"; import GreenMarkerIcon from "../../assets/green-marker.png"; +import { DropDownList } from "../Controls/DropDownList"; import { logger } from "../../services/monitoring"; import { ValidateLocationData } from "../../utils/locations"; import { useUserContext } from "../Contexts/UserContext"; import { useVehicleContext, VehicleProvider } from "../Contexts/VehicleContext"; import { VehiclePopUp } from "./popup"; +import zoomLocations from './zoomLocations.json'; const Component = () => { const classes = useStyles(); @@ -60,17 +62,10 @@ const Component = () => { }; const centerAroundMarkers = (points) => { - // if (markers == null) { - // markers = [] - // } - // const coord = markers.reduce((coord, marker) => { - // coord[0] += marker[0] / markers.length; - // coord[1] += marker[1] / markers.length; - // return coord; - // }, [0, 0]) - - setCenter([37.0902, -95.7129]); - setZoom(4.5); + let defaultLocationJSON = process.env.REACT_APP_HOME_MAP_DEFAULT_LOCATION; + let defaultLocation = JSON.parse(defaultLocationJSON) + setCenter([defaultLocation.lat, defaultLocation.lng]); + setZoom(defaultLocation.zoom); }; useEffect(() => { @@ -109,6 +104,12 @@ const Component = () => { setSelectedVIN(vin); }; + const focusMap = (e) => { + let zoomLocation = JSON.parse(e.target.value) + setCenter(zoomLocation.center); + setZoom(zoomLocation.zoom) + } + const retrieveAndStoreCarState = (vin) => { getState(token, vin).then((results) => { setCarState({ ...results.data, vin: vin }); @@ -143,55 +144,58 @@ const Component = () => { } return ( - - - - {markers.map((marker) => ( - - -
-

- {marker[2]} -

- -
-
-
- ))} - - {carState ? ( - + + + - ) : null} - + + {markers.map((marker) => ( + + +
+

+ {marker[2]} +

+ +
+
+
+ ))} + + {carState ? ( + + ) : null} +
+ ); }; diff --git a/src/components/VehicleMap/zoomLocations.json b/src/components/VehicleMap/zoomLocations.json new file mode 100644 index 0000000..6c502c8 --- /dev/null +++ b/src/components/VehicleMap/zoomLocations.json @@ -0,0 +1,26 @@ +[ + { + "value": "{ \"center\": [37.0902, -95.7129], \"zoom\": 4.5 }", + "label": "North America" + }, + { + "value": "{ \"center\": [33.8463, -118.0461], \"zoom\": 10 }", + "label": "- La Palma" + }, + { + "value": "{ \"center\": [33.8847, -118.4109], \"zoom\": 10 }", + "label": "- Manhattan Beach" + }, + { + "value": "{ \"center\": [37.7749, -122.4194], \"zoom\": 10 }", + "label": "- San Francisco" + }, + { + "value": "{ \"center\": [49.8327, 9.8816], \"zoom\": 4.5 }", + "label": "Europe" + }, + { + "value": "{ \"center\": [47.0707, 15.4395], \"zoom\": 10 }", + "label": "- Graz" + } +] \ No newline at end of file diff --git a/src/components/VehiclePathsMap/index.jsx b/src/components/VehiclePathsMap/index.jsx index 97f7961..62449ee 100644 --- a/src/components/VehiclePathsMap/index.jsx +++ b/src/components/VehiclePathsMap/index.jsx @@ -60,15 +60,18 @@ const ComponentVehiclePathsMap = (props) => { // validate each location for (let vinLocations of resultArray) { - let path = [] - path[0] = vinLocations[0] - path[1] = [] - for (let location of vinLocations[1]) { - if (ValidateLocationVehiclePathsData(location) !== false) { - path[1].push(location); + // if there are points for the vin; skip if empty points array + if (vinLocations[0] && vinLocations[1] && vinLocations[1][0]) { + let path = [] + path[0] = vinLocations[0] + path[1] = [] + for (let location of vinLocations[1]) { + if (ValidateLocationVehiclePathsData(location) !== false) { + path[1].push(location); + } } + points.push(path) } - points.push(path) } setMarkers(points); diff --git a/src/utils/roles.js b/src/utils/roles.js index 4875da4..69f1d18 100644 --- a/src/utils/roles.js +++ b/src/utils/roles.js @@ -77,7 +77,7 @@ export const Permissions = { [Providers.MAGNA]: [Roles.MAGNAGROUP], }, FiskerTools: { - [Providers.FISKER]: [Roles.APPROVESUPPLIERS, Roles.CERTIFICATES], + [Providers.FISKER]: [Roles.CERTIFICATES, Roles.CREATE], [Providers.FISKER_QA]: [Roles.MANUFACTURE], [Providers.MAGNA]: [Roles.MAGNAGROUP], }, diff --git a/src/utils/roles.test.js b/src/utils/roles.test.js index 3ed5719..c4198ac 100644 --- a/src/utils/roles.test.js +++ b/src/utils/roles.test.js @@ -56,7 +56,7 @@ describe("Roles Helper", () => { it("Check FiskerTools permission", () => { expect( hasRole([Roles.APPROVESUPPLIERS], Permissions.FiskerTools, [Providers.FISKER]) - ).toEqual(true); + ).toEqual(false); expect( hasRole([Roles.CERTIFICATES], Permissions.FiskerTools, [Providers.FISKER]) ).toEqual(true);