From 131c97fa7b6eab5d65fb9ce0841060c8f29c274f Mon Sep 17 00:00:00 2001 From: arpanetus Date: Fri, 14 Oct 2022 19:35:58 +0600 Subject: [PATCH 1/2] CEC-2587 Add edge_mask field (#217) --- .../Table/__snapshots__/index.test.jsx.snap | 32 +++++++++++++++++++ src/components/CANFilter/Table/index.jsx | 10 ++++++ src/components/CANFilter/Update/index.jsx | 1 + .../__snapshots__/CANFiltersTab.test.jsx.snap | 32 +++++++++++++++++++ .../Table/__snapshots__/index.test.jsx.snap | 32 +++++++++++++++++++ .../Fleets/Status/CANFilters/Table/index.jsx | 6 ++++ .../__snapshots__/CANFiltersTab.test.jsx.snap | 32 +++++++++++++++++++ src/utils/strings.js | 13 ++++++++ 8 files changed, 158 insertions(+) create mode 100644 src/utils/strings.js diff --git a/src/components/CANFilter/Table/__snapshots__/index.test.jsx.snap b/src/components/CANFilter/Table/__snapshots__/index.test.jsx.snap index 7c01ca1..00fb3e3 100644 --- a/src/components/CANFilter/Table/__snapshots__/index.test.jsx.snap +++ b/src/components/CANFilter/Table/__snapshots__/index.test.jsx.snap @@ -172,6 +172,29 @@ exports[`CANFiltersTable Render 1`] = ` + + + Edge mask + + + + @@ -263,6 +289,9 @@ exports[`CANFiltersTable Render 1`] = ` href="/fleet/undefined" /> + @@ -323,6 +352,9 @@ exports[`CANFiltersTable Render 1`] = ` href="/fleet/undefined" /> + diff --git a/src/components/CANFilter/Table/index.jsx b/src/components/CANFilter/Table/index.jsx index 55d985d..9068090 100644 --- a/src/components/CANFilter/Table/index.jsx +++ b/src/components/CANFilter/Table/index.jsx @@ -29,6 +29,7 @@ import SearchField from "../../Controls/SearchField"; import { logger } from "../../../services/monitoring"; import { Roles, hasRole } from "../../../utils/roles"; import {useLocalStorage} from "../../useLocalStorage"; +import {trimIfMoreThan} from "../../../utils/strings"; const tableColumns = [ { @@ -43,6 +44,10 @@ const tableColumns = [ id: "fleet", label: "Fleet" }, + { + id: "edge_mask", + label: "Edge mask" + }, { id: "", label: "Actions" @@ -121,6 +126,10 @@ const MainForm = ({ vin }) => { }; const Actions = (row) => { + if(row.fleet != null) { + return + } + let actions = []; if (hasRole([Roles.CREATE], groups)) { actions.push({ @@ -187,6 +196,7 @@ const MainForm = ({ vin }) => { {row.fleet} + {trimIfMoreThan(row.edge_mask, 15, "...")} {Actions(row)} ))} diff --git a/src/components/CANFilter/Update/index.jsx b/src/components/CANFilter/Update/index.jsx index 8b17515..5e3226b 100644 --- a/src/components/CANFilter/Update/index.jsx +++ b/src/components/CANFilter/Update/index.jsx @@ -24,6 +24,7 @@ const MainForm = () => { const vin = queries.get("vin") ?? "" const canID = queries.get("can_id") ?? "" const interval = queries.get("interval") ?? "" + // const edge_mask = queries.get("edge_mask") ?? "" useEffect(() => { setTitle("Update CAN Filter"); diff --git a/src/components/Cars/Status/__snapshots__/CANFiltersTab.test.jsx.snap b/src/components/Cars/Status/__snapshots__/CANFiltersTab.test.jsx.snap index bf2a936..da44961 100644 --- a/src/components/Cars/Status/__snapshots__/CANFiltersTab.test.jsx.snap +++ b/src/components/Cars/Status/__snapshots__/CANFiltersTab.test.jsx.snap @@ -171,6 +171,29 @@ exports[`CANFiltersTab Render 1`] = ` + + + Edge mask + + + + @@ -262,6 +288,9 @@ exports[`CANFiltersTab Render 1`] = ` href="/fleet/undefined" /> + @@ -322,6 +351,9 @@ exports[`CANFiltersTab Render 1`] = ` href="/fleet/undefined" /> + diff --git a/src/components/Fleets/Status/CANFilters/Table/__snapshots__/index.test.jsx.snap b/src/components/Fleets/Status/CANFilters/Table/__snapshots__/index.test.jsx.snap index 6632c33..6baadf0 100644 --- a/src/components/Fleets/Status/CANFilters/Table/__snapshots__/index.test.jsx.snap +++ b/src/components/Fleets/Status/CANFilters/Table/__snapshots__/index.test.jsx.snap @@ -150,6 +150,29 @@ exports[`FleetCANFiltersTable Render 1`] = ` + + + Edge mask + + + 789 + @@ -227,6 +253,9 @@ exports[`FleetCANFiltersTable Render 1`] = ` > 1000 + @@ -280,6 +309,9 @@ exports[`FleetCANFiltersTable Render 1`] = ` > 1 + diff --git a/src/components/Fleets/Status/CANFilters/Table/index.jsx b/src/components/Fleets/Status/CANFilters/Table/index.jsx index 07c51cf..e9eb631 100644 --- a/src/components/Fleets/Status/CANFilters/Table/index.jsx +++ b/src/components/Fleets/Status/CANFilters/Table/index.jsx @@ -24,6 +24,7 @@ import SearchField from "../../../../Controls/SearchField"; import { logger } from "../../../../../services/monitoring"; import { Roles, hasRole } from "../../../../../utils/roles"; import {useLocalStorage} from "../../../../useLocalStorage"; +import {trimIfMoreThan} from "../../../../../utils/strings" const tableColumns = [ { @@ -34,6 +35,10 @@ const tableColumns = [ id: "interval", label: "Interval (ms)" }, + { + id: "edge_mask", + label: "Edge mask" + }, { id: "", label: "Actions" @@ -173,6 +178,7 @@ const MainForm = ({ name }) => { {row.can_id} {row.interval} + {trimIfMoreThan(row.edge_mask, 15, "...")} {Actions(row)} ))} diff --git a/src/components/Fleets/Status/__snapshots__/CANFiltersTab.test.jsx.snap b/src/components/Fleets/Status/__snapshots__/CANFiltersTab.test.jsx.snap index 392115a..27c2794 100644 --- a/src/components/Fleets/Status/__snapshots__/CANFiltersTab.test.jsx.snap +++ b/src/components/Fleets/Status/__snapshots__/CANFiltersTab.test.jsx.snap @@ -149,6 +149,29 @@ exports[`CANFiltersTab Render 1`] = ` + + + Edge mask + + + 789 + @@ -226,6 +252,9 @@ exports[`CANFiltersTab Render 1`] = ` > 1000 + @@ -279,6 +308,9 @@ exports[`CANFiltersTab Render 1`] = ` > 1 + diff --git a/src/utils/strings.js b/src/utils/strings.js new file mode 100644 index 0000000..38df487 --- /dev/null +++ b/src/utils/strings.js @@ -0,0 +1,13 @@ +export function trimIfMoreThan(maybeString, maxLength = 20, sfx = "") { + if (typeof maybeString == "string" && maybeString !== "") { + let toAppSfx = sfx + let toTrimLnth = maxLength - toAppSfx.length + if (maybeString.length <= maxLength) { + toAppSfx = "" + toTrimLnth = maxLength + } + return maybeString.substring(0, toTrimLnth) + toAppSfx + } + + return "" +} \ No newline at end of file From d9b7793eb516db8220dcbba62f81ca7fb0f35688 Mon Sep 17 00:00:00 2001 From: arpanetus Date: Fri, 14 Oct 2022 19:42:06 +0600 Subject: [PATCH 2/2] CEC-2640 Update online car filter to also include online HMIs (#220) --- src/components/Cars/List/index.jsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/components/Cars/List/index.jsx b/src/components/Cars/List/index.jsx index 69e5d18..0dbc101 100644 --- a/src/components/Cars/List/index.jsx +++ b/src/components/Cars/List/index.jsx @@ -16,6 +16,7 @@ const MainForm = () => { const classes = useStyles(); const [search, setSearch] = useState(""); const [online, setOnline] = useState(false); + const [onlineHMI, setOnlineHMI] = useState(false); const { setTitle, setSitePath } = useStatusContext(); const { token: { @@ -31,6 +32,10 @@ const MainForm = () => { setOnline(event.target.checked); } + const handleOnlineHMI = (event) => { + setOnlineHMI(event.target.checked); + } + useEffect(() => { setTitle("Vehicles"); setSitePath([]); @@ -58,6 +63,14 @@ const MainForm = () => { /> } label="Only online" /> + + + } label="Only online HMI" /> + @@ -66,7 +79,7 @@ const MainForm = () => { classes={classes} token={token} multiSelect={false} - search={{ search, online: online? true : null}} + search={{ search, online: online? true : null, online_hmi: onlineHMI? true : null }} /> );