From 909f1e72c21844973d7b8dea18454882628c0484 Mon Sep 17 00:00:00 2001 From: Alexander Andrews <45926661+alexander-e-andrews@users.noreply.github.com> Date: Thu, 6 Apr 2023 15:29:05 -0400 Subject: [PATCH 1/8] CEC-3863: Link azure file download (#309) Co-authored-by: Alexander Andrews --- src/components/Controls/TRexLogs/index.jsx | 24 ++++++++++++++++++---- src/services/vehiclesAPI.js | 12 +++++++++++ 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/components/Controls/TRexLogs/index.jsx b/src/components/Controls/TRexLogs/index.jsx index 165c4ed..c8967df 100644 --- a/src/components/Controls/TRexLogs/index.jsx +++ b/src/components/Controls/TRexLogs/index.jsx @@ -140,7 +140,7 @@ const TRexLogsTable = ({ vin, token, classes }) => { return pageSize * pageIndex + pageSize } const getReadPercentage = () => { - return (currentOffset * 100 / blobSize).toFixed(2); + return (currentOffset * 100 / blobSize); } const getFilteredLogs = (logs) => { return logs.filter(log => currectLogLevels[log.level] === true) @@ -182,6 +182,19 @@ const TRexLogsTable = ({ vin, token, classes }) => { return fetched } + const downloadFile = async () => { + let day = formatTwoDigit(selectedDate.getDate()) + let month = formatTwoDigit(selectedDate.getMonth() + 1)// 0 Indexed + let year = selectedDate.getFullYear() + + let result = await api.getLogFileLink({ vin, year, month, day }, token) + window.open(result['Link'], '_blank') + } + + const formatTwoDigit = (num) => { + return num < 10 ? '0' + num : '' + num + } + useEffect(() => { (async () => { try { @@ -266,11 +279,12 @@ const TRexLogsTable = ({ vin, token, classes }) => { }} /> - + + { blobSize === 0 ? `No logs for ${fromatDateForRequest(selectedDate)}` : - `Read ${getReadPercentage()}% of logs` + `Read ${getReadPercentage().toFixed(2)}% of logs` } { { align="center" value={getReadPercentage()} /> } - +

+ + diff --git a/src/services/vehiclesAPI.js b/src/services/vehiclesAPI.js index 8d38faa..80345e4 100644 --- a/src/services/vehiclesAPI.js +++ b/src/services/vehiclesAPI.js @@ -197,6 +197,18 @@ const vehiclesAPI = { .then(fetchRespHandler) .catch(errorHandler) }, + + getLogFileLink: async ({vin, year, month, day}, token) => { + const u = `${API_ENDPOINT}/vehicle/${vin}/trex-logs-link?year=${year}&month=${month}&day=${day}` + return fetch(u, { + method: "GET", + headers: Object.assign( + { "Content-Type": "application/json" }, + getAuthHeaderOptions(token) + ), + }).then(fetchRespHandler) + .catch(errorHandler) + }, }; export default vehiclesAPI; From 2fdac28b0b3095e38683133b77ae4e169cfb043f Mon Sep 17 00:00:00 2001 From: das31 <31259710+das31@users.noreply.github.com> Date: Thu, 6 Apr 2023 18:59:03 -0400 Subject: [PATCH 2/8] CEC-4066-dtc-trouble-code (#313) * first push * remove dtc column --- src/components/DTCTimeline/DTCTimeline/index.jsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/components/DTCTimeline/DTCTimeline/index.jsx b/src/components/DTCTimeline/DTCTimeline/index.jsx index 2af0b2b..13c0a6c 100644 --- a/src/components/DTCTimeline/DTCTimeline/index.jsx +++ b/src/components/DTCTimeline/DTCTimeline/index.jsx @@ -41,8 +41,12 @@ const MainForm = ({ vin }) => { label: "ECU", }, { - id: "dtc", - label: "DTC", + id: "trouble_code", + label: "Trouble Code", + }, + { + id: "status_byte", + label: "Status Code", }, { id: "epoch_usec", @@ -190,7 +194,8 @@ const MainForm = ({ vin }) => { {dtc.vin} {dtc.ecu_name} - {dtc.dtc} + {dtc.trouble_code} + {dtc.status_byte} {formatDate(dtc.epoch_usec)} ))} From 0520a4f0a82ac8ceb65fc39322cbeac3138bf9fe Mon Sep 17 00:00:00 2001 From: Eduard Voronkin <116690094+eduardvoronkin@users.noreply.github.com> Date: Thu, 6 Apr 2023 21:09:39 -0700 Subject: [PATCH 3/8] CEC-3577: reverse logs order, set default date to UTC (#311) --- src/components/Controls/TRexLogs/index.jsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/Controls/TRexLogs/index.jsx b/src/components/Controls/TRexLogs/index.jsx index c8967df..d1b44f7 100644 --- a/src/components/Controls/TRexLogs/index.jsx +++ b/src/components/Controls/TRexLogs/index.jsx @@ -128,7 +128,8 @@ const TRexLogsTable = ({ vin, token, classes }) => { const [logs, setLogs] = useState([]); const [pageIndex, setPageIndex] = useState(0); const [pageSize, setPageSize] = useState(DEFAULT_PAGE_SIZE); - const [selectedDate, setSelectedDate] = useState(new Date()); + const local_date = new Date() + const [selectedDate, setSelectedDate] = useState(new Date(local_date.getUTCFullYear(), local_date.getUTCMonth(), local_date.getUTCDate())); const [total, setTotal] = useState(0); const { setMessage } = useStatusContext(); @@ -271,7 +272,7 @@ const TRexLogsTable = ({ vin, token, classes }) => { format="yyyy/MM/dd" margin="normal" id="date-picker-inline" - label="Choose date" + label="Choose date (UTC)" value={selectedDate} onChange={handleNewDate} KeyboardButtonProps={{ @@ -295,6 +296,7 @@ const TRexLogsTable = ({ vin, token, classes }) => {

+ @@ -309,7 +311,7 @@ const TRexLogsTable = ({ vin, token, classes }) => { - {getFilteredLogs(logs).slice(-getDesiredSize(), (pageIndex === 0 ? undefined : -(pageSize * pageIndex))).map((log, i) => ( + {getFilteredLogs(logs).slice(-getDesiredSize(), (pageIndex === 0 ? undefined : -(pageSize * pageIndex))).reverse().map((log, i) => ( {log.level} {log.trex_timestamp} From 81a9673271973cd1ff5b389f79b173d1544aa020 Mon Sep 17 00:00:00 2001 From: John Wu <76966357+jwu-fisker@users.noreply.github.com> Date: Fri, 7 Apr 2023 10:34:22 -0700 Subject: [PATCH 4/8] CEC-4066 move date column (#314) --- .../DTCTimeline/DTCTimeline/index.jsx | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/components/DTCTimeline/DTCTimeline/index.jsx b/src/components/DTCTimeline/DTCTimeline/index.jsx index 13c0a6c..058b347 100644 --- a/src/components/DTCTimeline/DTCTimeline/index.jsx +++ b/src/components/DTCTimeline/DTCTimeline/index.jsx @@ -1,15 +1,15 @@ import DateFnsUtils from '@date-io/date-fns'; -import { Button, CircularProgress, Grid, TableFooter, TablePagination, TableCell, Table, TableRow, TableBody} from "@material-ui/core"; +import { Button, CircularProgress, Grid, Table, TableBody, TableCell, TableFooter, TablePagination, TableRow } from "@material-ui/core"; import { KeyboardDatePicker, MuiPickersUtilsProvider } from '@material-ui/pickers'; +import clsx from "clsx"; import React, { useEffect, useState } from "react"; import { logger } from "../../../services/monitoring"; import { DTCTimelineProvider, useDTCTimelineContext } from '../../Contexts/DTCTimelineContext'; import { useStatusContext } from "../../Contexts/StatusContext"; import { useUserContext } from "../../Contexts/UserContext"; -import { useLocalStorage } from "../../useLocalStorage"; -import clsx from "clsx"; -import TableHeaderSortable from "../../Table/HeaderSortable"; import SearchField from '../../Controls/SearchField'; +import TableHeaderSortable from "../../Table/HeaderSortable"; +import { useLocalStorage } from "../../useLocalStorage"; import useStyles from "../../useStyles"; const MainForm = ({ vin }) => { @@ -28,6 +28,10 @@ const MainForm = ({ vin }) => { const { setMessage } = useStatusContext(); const tableColumns = [ + { + id: "epoch_usec", + label: "Date", + }, { id: "id", label: "Id", @@ -48,10 +52,6 @@ const MainForm = ({ vin }) => { id: "status_byte", label: "Status Code", }, - { - id: "epoch_usec", - label: "Date", - }, ]; const handleSort = (_event, property) => { @@ -189,6 +189,7 @@ const MainForm = ({ vin }) => { {(dtcData || []).map((dtc, index) => ( + {formatDate(dtc.epoch_usec)} {dtc.id} @@ -196,7 +197,6 @@ const MainForm = ({ vin }) => { {dtc.ecu_name} {dtc.trouble_code} {dtc.status_byte} - {formatDate(dtc.epoch_usec)} ))} @@ -221,7 +221,7 @@ const MainForm = ({ vin }) => { ); - + }; const DTCTimeline = (props) => ( From c83f4dde0192eb099cf486c95981f15137ab3d55 Mon Sep 17 00:00:00 2001 From: John Wu <76966357+jwu-fisker@users.noreply.github.com> Date: Fri, 7 Apr 2023 11:36:21 -0700 Subject: [PATCH 5/8] CEC-4066 Undo change (#316) --- src/components/DTCTimeline/DTCTimeline/index.jsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/DTCTimeline/DTCTimeline/index.jsx b/src/components/DTCTimeline/DTCTimeline/index.jsx index 058b347..29eaf5b 100644 --- a/src/components/DTCTimeline/DTCTimeline/index.jsx +++ b/src/components/DTCTimeline/DTCTimeline/index.jsx @@ -28,10 +28,6 @@ const MainForm = ({ vin }) => { const { setMessage } = useStatusContext(); const tableColumns = [ - { - id: "epoch_usec", - label: "Date", - }, { id: "id", label: "Id", @@ -52,6 +48,10 @@ const MainForm = ({ vin }) => { id: "status_byte", label: "Status Code", }, + { + id: "epoch_usec", + label: "Date", + }, ]; const handleSort = (_event, property) => { @@ -189,7 +189,6 @@ const MainForm = ({ vin }) => { {(dtcData || []).map((dtc, index) => ( - {formatDate(dtc.epoch_usec)} {dtc.id} @@ -197,6 +196,7 @@ const MainForm = ({ vin }) => { {dtc.ecu_name} {dtc.trouble_code} {dtc.status_byte} + {formatDate(dtc.epoch_usec)} ))} From cfb1b7d74eaccc0045ba8f6e8f85fd3292445c2f Mon Sep 17 00:00:00 2001 From: John Wu <76966357+jwu-fisker@users.noreply.github.com> Date: Mon, 10 Apr 2023 10:59:01 -0700 Subject: [PATCH 6/8] CEC-4044 update manifest form (#312) * CEC-4044 update manifest form * Show env input if there are options --- .env.cec-euprd | 1 + .env.cec-prd | 1 + .env.dev | 1 + .env.local | 2 +- .env.prd | 1 + .env.stg | 1 + .env.template | 1 + .../Update/__snapshots__/index.test.jsx.snap | 116 ++++++++++++++++++ src/components/Manifest/Update/index.jsx | 27 +++- src/utils/key-envs.js | 35 ++++++ 10 files changed, 182 insertions(+), 4 deletions(-) create mode 100644 src/utils/key-envs.js diff --git a/.env.cec-euprd b/.env.cec-euprd index 5fb535f..59f77ea 100644 --- a/.env.cec-euprd +++ b/.env.cec-euprd @@ -8,3 +8,4 @@ REACT_APP_OTA_SERVICE_URL=https://gw.cec-euprd.fiskerinc.com/ota_update REACT_APP_SECURITY_DLL_URL=https://assets.fiskerdps.com/cloud-supplier/fisker_security_32.dll 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_ECCKEY_ENV= \ No newline at end of file diff --git a/.env.cec-prd b/.env.cec-prd index 67d8f04..5815d26 100644 --- a/.env.cec-prd +++ b/.env.cec-prd @@ -8,3 +8,4 @@ REACT_APP_OTA_SERVICE_URL=https://gw.cec-prd.fiskerinc.com/ota_update REACT_APP_SECURITY_DLL_URL=https://assets.fiskerdps.com/cloud-supplier/fisker_security_32.dll 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_ECCKEY_ENV= \ No newline at end of file diff --git a/.env.dev b/.env.dev index c2e91da..274a799 100644 --- a/.env.dev +++ b/.env.dev @@ -8,3 +8,4 @@ REACT_APP_OTA_SERVICE_URL=https://dev-gw.cloud.fiskerinc.com/ota_update REACT_APP_SECURITY_DLL_URL=https://assets.fiskerdps.com/cloud-supplier/fisker_security_32.dll REACT_APP_SECURITY_DLL_64_URL=https://assets.fiskerdps.com/cloud-supplier/fisker_security_64.dll REACT_APP_SUPERSET_URL=https://dev-superset-new.cloud.fiskerinc.com +REACT_APP_ECCKEY_ENV=stage,prod \ No newline at end of file diff --git a/.env.local b/.env.local index 3656474..8fa46ee 100644 --- a/.env.local +++ b/.env.local @@ -8,4 +8,4 @@ REACT_APP_OTA_SERVICE_URL=http://localhost/ota_update REACT_APP_SECURITY_DLL_URL=https://assets.fiskerdps.com/cloud-supplier/fisker_security_32.dll REACT_APP_SECURITY_DLL_64_URL=https://assets.fiskerdps.com/cloud-supplier/fisker_security_64.dll REACT_APP_SUPERSET_URL=https://dev-superset-new.cloud.fiskerinc.com - +REACT_APP_ECCKEY_ENV=dev,stage,prod diff --git a/.env.prd b/.env.prd index f075c03..663a705 100644 --- a/.env.prd +++ b/.env.prd @@ -8,3 +8,4 @@ REACT_APP_OTA_SERVICE_URL=https://gw.cloud.fiskerinc.com/ota_update REACT_APP_SECURITY_DLL_URL=https://assets.fiskerdps.com/cloud-supplier/fisker_security_32.dll REACT_APP_SECURITY_DLL_64_URL=https://assets.fiskerdps.com/cloud-supplier/fisker_security_64.dll REACT_APP_SUPERSET_URL=https://superset.cloud.fiskerinc.com +REACT_APP_ECCKEY_ENV=stage \ No newline at end of file diff --git a/.env.stg b/.env.stg index ad05398..7338e53 100644 --- a/.env.stg +++ b/.env.stg @@ -8,3 +8,4 @@ REACT_APP_OTA_SERVICE_URL=https://stg-gw.cloud.fiskerinc.com/ota_update REACT_APP_SECURITY_DLL_URL=https://assets.fiskerdps.com/cloud-supplier/fisker_security_32.dll REACT_APP_SECURITY_DLL_64_URL=https://assets.fiskerdps.com/cloud-supplier/fisker_security_64.dll REACT_APP_SUPERSET_URL=https://stg-superset.cloud.fiskerinc.com +REACT_APP_ECCKEY_ENV=prod \ No newline at end of file diff --git a/.env.template b/.env.template index e42e4fd..968195b 100644 --- a/.env.template +++ b/.env.template @@ -8,3 +8,4 @@ REACT_APP_OTA_SERVICE_URL=http://localhost/ota_update REACT_APP_SECURITY_DLL_URL=https://assets.fiskerdps.com/cloud-supplier/fisker_security_32.dll REACT_APP_SECURITY_DLL_64_URL=https://assets.fiskerdps.com/cloud-supplier/fisker_security_64.dll REACT_APP_SUPERSET_URL=https://dev-superset.cloud.fiskerinc.com +REACT_APP_ECCKEY_ENV=dev,stage,prod \ No newline at end of file diff --git a/src/components/Manifest/Update/__snapshots__/index.test.jsx.snap b/src/components/Manifest/Update/__snapshots__/index.test.jsx.snap index fa51235..9874fa0 100644 --- a/src/components/Manifest/Update/__snapshots__/index.test.jsx.snap +++ b/src/components/Manifest/Update/__snapshots__/index.test.jsx.snap @@ -218,6 +218,122 @@ exports[`Manifest Details Component Render 1`] = ` +
+ +
+ + + +
+
+
+ +
+ + + +
+