Skip to content

Commit

Permalink
Use floating filter to make filtering more visible (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
juberti authored May 6, 2024
1 parent 89b64e0 commit 5d2fbf7
Showing 1 changed file with 33 additions and 4 deletions.
37 changes: 33 additions & 4 deletions website/src/utils/DataGridDefinitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ export const TotalTimeDefinition = {
// Set-up all of our column definitions that will be used in the Data Grid
const headerClass = "font-bold";

function milliSecParser(text: string) {
return parseFloat(text) / 1000;
}
function milliSecFormatter(value: number) {
return (value * 1000).toString();
}

// Model column
const columnModel = {
field: "model",
Expand All @@ -66,6 +73,10 @@ const columnModel = {
//TODO: Make this ~200 on mobile screen size by default
minWidth: 160,
// tooltipField: "output"
filterParams: {
filterOptions: ["contains"],
maxNumConditions: 4,
},
};

const columnProvider = {
Expand All @@ -75,6 +86,10 @@ const columnProvider = {
headerClass: headerClass,
minWidth: 130,
maxWidth: 200,
filterParams: {
filterOptions: ["contains"],
maxNumConditions: 4,
},
};

// TTFT column
Expand All @@ -87,6 +102,12 @@ const columnTTFT = {
maxWidth: 120,
valueFormatter: (p: ValueFormatterParam) =>
p.value < 1.0 ? p.value.toFixed(3) * 1000 + "ms" : p.value.toFixed(2) + "s",
filterParams: {
filterOptions: ["lessThanOrEqual"],
maxNumConditions: 1,
numberParser: milliSecParser,
numberFormatter: milliSecFormatter,
},
};

// TPS column
Expand All @@ -98,6 +119,10 @@ const columnTPS = {
minWidth: 0,
maxWidth: 120,
valueFormatter: (p: ValueFormatterParam) => p.value.toFixed(2),
filterParams: {
filterOptions: ["greaterThanOrEqual"],
maxNumConditions: 1,
},
};

// Total Time column
Expand All @@ -115,6 +140,12 @@ const columnTotalTime = {
valueFormatter: (p: ValueFormatterParam) =>
p.value < 1.0 ? p.value.toFixed(3) * 1000 + "ms" : p.value.toFixed(2) + "s",
sort: "asc",
filterParams: {
filterOptions: ["lessThanOrEqual"],
maxNumConditions: 1,
numberParser: milliSecParser,
numberFormatter: milliSecFormatter,
},
};

export const gridOptionsBase = {
Expand All @@ -126,10 +157,8 @@ export const gridOptionsBase = {
defaultColDef: {
suppressMovable: true,
filter: true,
filterParams: {
filterOptions: ["contains"],
maxNumConditions: 4,
},
floatingFilter: true,
suppressHeaderMenuButton: true,
// minWidth: 80,
},
domLayout: "autoHeight",
Expand Down

0 comments on commit 5d2fbf7

Please sign in to comment.