Skip to content

Commit

Permalink
fix: sort by logs
Browse files Browse the repository at this point in the history
  • Loading branch information
jacovinus committed Jan 18, 2024
1 parent 4a915fd commit 199d4b2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default function CardinalityTotals({ isLoading }) {

const sortByProperty = useCallback(
(column: string) => {

const numberCols = [
"series_created",
"series_dropped",
Expand Down Expand Up @@ -72,8 +73,8 @@ export default function CardinalityTotals({ isLoading }) {
{totals?.length ? (
totals?.map((total, key) => (
<TotalsRow
key={key}
isLoading={isLoading}
key={key}
headers={PROCESS_HEADERS}
total={total}
/>
Expand Down
6 changes: 3 additions & 3 deletions packages/main/plugins/Cardinality/TotalsPanel/TotalsRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { type Total } from "../api/types";
import { CellFormatter, getCellData } from "./helper";
import { type MaintainanceActions } from "./types";
import { UndoCardinalityDialog } from "../CardinalityDialog";
import { Tooltip } from "@mui/material";


export function TotalsRow({
headers,
Expand All @@ -24,14 +24,14 @@ export function TotalsRow({
))}

<div className="cell">
<Tooltip title="undo action">

<UndoCardinalityDialog
id={total.id}
query={total.query}
isLoading={isLoading}
undoAction={() => handleUndoFingerprints(total.id)}
/>
</Tooltip>

</div>
</div>
);
Expand Down
21 changes: 17 additions & 4 deletions packages/main/plugins/Cardinality/TotalsPanel/array_helper.mts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,15 @@ if (!Array.prototype.sortColByString) {
): T[] {
if (sort === "asc") {
return this.sort((a, b) => {
const colA = a[col].toUpperCase(); // ignore upper and lowercase
const colB = b[col].toUpperCase(); // ignore upper and lowercase
let colA: string, colB: string;
if (Array.isArray(a[col])) {
colA = a[col]?.join("").toUpperCase();
colB = b[col]?.join("").toUpperCase();
} else {
colA = a[col].toUpperCase(); // ignore upper and lowercase
colB = b[col].toUpperCase(); // ignore upper and lowercase
}

if (colA < colB) {
return -1;
}
Expand All @@ -42,8 +49,14 @@ if (!Array.prototype.sortColByString) {
}

return this.sort((a, b) => {
const colA = a[col].toUpperCase(); // ignore upper and lowercase
const colB = b[col].toUpperCase(); // ignore upper and lowercase
let colA: string, colB: string;
if (Array.isArray(a[col])) {
colA = a[col]?.join("").toUpperCase();
colB = b[col]?.join("").toUpperCase();
} else {
colA = a[col].toUpperCase(); // ignore upper and lowercase
colB = b[col].toUpperCase(); // ignore upper and lowercase
}
if (colB < colA) {
return -1;
}
Expand Down

0 comments on commit 199d4b2

Please sign in to comment.