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