Skip to content

Commit

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

const sortByProperty = useCallback(
(column: string) => {
const numberCols = [];
const numberCols = [
"series_created",
"series_dropped",
"to_sec",
"from_sec",
"created_sec",
];

const columnName = column.split(" ").join("_").toLocaleLowerCase();

setTotals((prev) => {
let prevCols = [...prev];
if (numberCols.includes(column)) {
return prevCols.sortColByNumber(column, sort);
if (numberCols.includes(columnName)) {
return prevCols.sortColByNumber(columnName, sort);
}
return prevCols.sortColByString(column, sort);
return prevCols.sortColByString(columnName, sort);
});

setSort((prev) => (prev === "asc" ? "desc" : "asc"));
},
[totals]
);

return (
<div className={cx(TotalRowStyle(theme))}>
<div
Expand All @@ -50,7 +59,11 @@ export default function CardinalityTotals({ isLoading }) {
<div className="table">
<div className="table-header">
{PROCESS_HEADERS?.map((header) => (
<div key={header} className="cell">
<div
key={header}
onClick={() => sortByProperty(header)}
className="cell"
>
{header}
</div>
))}
Expand Down
1 change: 0 additions & 1 deletion packages/main/plugins/Cardinality/TotalsPanel/helper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ const TYPES = (type: string) => {
};

export function TypeRenderer({ type, children }) {
console.log(type);

return <span style={{ color: TYPES(type) }}>{children}</span>;
}
12 changes: 6 additions & 6 deletions packages/main/plugins/Cardinality/api/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ export const totalsMock: MaintainanceItem[] = [
query: "{a=\"b\"}",
type: "delete",
status: "running",
created_sec: 1704359839,
from_sec: 1704240000,
to_sec: 1704326400,
created_sec: 1704359849,
from_sec: 1704240010,
to_sec: 1704326420,
series_dropped: 150,
series_created: 0,
logs: [
Expand Down Expand Up @@ -39,9 +39,9 @@ export const totalsMock: MaintainanceItem[] = [
query: "{__name=\"server\",type=\"clickhouse\",level=\"info\"}",
type: "delete",
status: "running",
created_sec: 1704359839,
from_sec: 1704240000,
to_sec: 1704326400,
created_sec: 1704359859,
from_sec: 1704240020,
to_sec: 1704326415,
series_dropped: 150,
series_created: 0,
logs: [
Expand Down

0 comments on commit 4a915fd

Please sign in to comment.