|
@@ -3,6 +3,7 @@ import { useMemo, useState } from "react";
|
|
import { DataGrid, GridColDef } from "@mui/x-data-grid";
|
|
import { DataGrid, GridColDef } from "@mui/x-data-grid";
|
|
import { truncateStr } from "@/utils/truncate-str";
|
|
import { truncateStr } from "@/utils/truncate-str";
|
|
import parseTraffic from "@/utils/parse-traffic";
|
|
import parseTraffic from "@/utils/parse-traffic";
|
|
|
|
+import { sortWithUnit, sortStringTime } from "@/utils/custom-comparator";
|
|
|
|
|
|
interface Props {
|
|
interface Props {
|
|
connections: IConnectionsItem[];
|
|
connections: IConnectionsItem[];
|
|
@@ -24,6 +25,7 @@ export const ConnectionTable = (props: Props) => {
|
|
width: 88,
|
|
width: 88,
|
|
align: "right",
|
|
align: "right",
|
|
headerAlign: "right",
|
|
headerAlign: "right",
|
|
|
|
+ sortComparator: sortWithUnit,
|
|
},
|
|
},
|
|
{
|
|
{
|
|
field: "upload",
|
|
field: "upload",
|
|
@@ -31,6 +33,7 @@ export const ConnectionTable = (props: Props) => {
|
|
width: 88,
|
|
width: 88,
|
|
align: "right",
|
|
align: "right",
|
|
headerAlign: "right",
|
|
headerAlign: "right",
|
|
|
|
+ sortComparator: sortWithUnit,
|
|
},
|
|
},
|
|
{
|
|
{
|
|
field: "dlSpeed",
|
|
field: "dlSpeed",
|
|
@@ -38,6 +41,7 @@ export const ConnectionTable = (props: Props) => {
|
|
width: 88,
|
|
width: 88,
|
|
align: "right",
|
|
align: "right",
|
|
headerAlign: "right",
|
|
headerAlign: "right",
|
|
|
|
+ sortComparator: sortWithUnit,
|
|
},
|
|
},
|
|
{
|
|
{
|
|
field: "ulSpeed",
|
|
field: "ulSpeed",
|
|
@@ -45,6 +49,7 @@ export const ConnectionTable = (props: Props) => {
|
|
width: 88,
|
|
width: 88,
|
|
align: "right",
|
|
align: "right",
|
|
headerAlign: "right",
|
|
headerAlign: "right",
|
|
|
|
+ sortComparator: sortWithUnit,
|
|
},
|
|
},
|
|
{ field: "chains", headerName: "Chains", flex: 360, minWidth: 360 },
|
|
{ field: "chains", headerName: "Chains", flex: 360, minWidth: 360 },
|
|
{ field: "rule", headerName: "Rule", flex: 300, minWidth: 250 },
|
|
{ field: "rule", headerName: "Rule", flex: 300, minWidth: 250 },
|
|
@@ -56,6 +61,7 @@ export const ConnectionTable = (props: Props) => {
|
|
minWidth: 100,
|
|
minWidth: 100,
|
|
align: "right",
|
|
align: "right",
|
|
headerAlign: "right",
|
|
headerAlign: "right",
|
|
|
|
+ sortComparator: sortStringTime,
|
|
},
|
|
},
|
|
{ field: "source", headerName: "Source", flex: 200, minWidth: 130 },
|
|
{ field: "source", headerName: "Source", flex: 200, minWidth: 130 },
|
|
{
|
|
{
|
|
@@ -72,7 +78,6 @@ export const ConnectionTable = (props: Props) => {
|
|
const { metadata, rulePayload } = each;
|
|
const { metadata, rulePayload } = each;
|
|
const chains = [...each.chains].reverse().join(" / ");
|
|
const chains = [...each.chains].reverse().join(" / ");
|
|
const rule = rulePayload ? `${each.rule}(${rulePayload})` : each.rule;
|
|
const rule = rulePayload ? `${each.rule}(${rulePayload})` : each.rule;
|
|
-
|
|
|
|
return {
|
|
return {
|
|
id: each.id,
|
|
id: each.id,
|
|
host: metadata.host
|
|
host: metadata.host
|