small ts fixes
This commit is contained in:
@@ -5,7 +5,8 @@ interface ToolTipProps {
|
|||||||
active?: boolean,
|
active?: boolean,
|
||||||
payload?: object,
|
payload?: object,
|
||||||
unit?: string
|
unit?: string
|
||||||
};
|
}
|
||||||
|
|
||||||
const defaultProps = {
|
const defaultProps = {
|
||||||
active: false,
|
active: false,
|
||||||
payload: {},
|
payload: {},
|
||||||
@@ -13,12 +14,16 @@ const defaultProps = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
interface ChartProps {
|
interface ChartProps {
|
||||||
data: [{}],
|
data: [{
|
||||||
|
time: string,
|
||||||
|
}],
|
||||||
color: string,
|
color: string,
|
||||||
unit: string,
|
unit: string,
|
||||||
dataCollections?: {},
|
dataCollections?: any,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function CustomizedTooltip(props: ToolTipProps) {
|
function CustomizedTooltip(props: ToolTipProps) {
|
||||||
const { active, payload, unit } = props;
|
const { active, payload, unit } = props;
|
||||||
if (active && payload && payload[0]) {
|
if (active && payload && payload[0]) {
|
||||||
@@ -40,15 +45,11 @@ export default function Chart({ data, color, unit, dataCollections }: ChartProps
|
|||||||
return timeFormat("%I:%M")(new Date(tick));
|
return timeFormat("%I:%M")(new Date(tick));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let ticks = data.map((item) => item?.time);
|
||||||
if (dataCollections) {
|
if (dataCollections) {
|
||||||
var ticks = dataCollections[0].data?.map(function (collection) {
|
ticks = dataCollections[0].data?.map((collection) => collection?.time);
|
||||||
return collection?.time;
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
var ticks = data.map(function (item) {
|
|
||||||
return item?.time;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<LineChart width={1200} height={400} data={data}>
|
<LineChart width={1200} height={400} data={data}>
|
||||||
<XAxis
|
<XAxis
|
||||||
@@ -90,3 +91,7 @@ export default function Chart({ data, color, unit, dataCollections }: ChartProps
|
|||||||
</LineChart>
|
</LineChart>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Chart.defaultProps = {
|
||||||
|
dataCollections: [],
|
||||||
|
};
|
||||||
|
|||||||
@@ -2,6 +2,28 @@ import React from "react";
|
|||||||
import { timeFormat } from "d3-time-format";
|
import { timeFormat } from "d3-time-format";
|
||||||
import { Table, } from "antd";
|
import { Table, } from "antd";
|
||||||
import Linkify from "react-linkify";
|
import Linkify from "react-linkify";
|
||||||
|
import { SortOrder } from "antd/lib/table/interface";
|
||||||
|
|
||||||
|
function renderColumnLevel(text, entry) {
|
||||||
|
let color = 'black';
|
||||||
|
|
||||||
|
if (entry.level === "warning") {
|
||||||
|
color = "orange";
|
||||||
|
} else if (entry.level === 'error') {
|
||||||
|
color = "red";
|
||||||
|
}
|
||||||
|
|
||||||
|
const style = {
|
||||||
|
color,
|
||||||
|
};
|
||||||
|
return <div style={style}>{text}</div>;
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderMessage(text, entry) {
|
||||||
|
return (
|
||||||
|
<Linkify>{text}</Linkify>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
export default function LogTable({ logs, pageSize }) {
|
export default function LogTable({ logs, pageSize }) {
|
||||||
const columns = [
|
const columns = [
|
||||||
@@ -33,8 +55,8 @@ export default function LogTable({ logs, pageSize }) {
|
|||||||
render: (timestamp) =>
|
render: (timestamp) =>
|
||||||
timeFormat("%H:%M:%S %m/%d/%Y")(new Date(timestamp)),
|
timeFormat("%H:%M:%S %m/%d/%Y")(new Date(timestamp)),
|
||||||
sorter: (a, b) => new Date(a.time).getTime() - new Date(b.time).getTime(),
|
sorter: (a, b) => new Date(a.time).getTime() - new Date(b.time).getTime(),
|
||||||
sortDirections: ["descend", "ascend"],
|
sortDirections: ["descend", "ascend"] as SortOrder[],
|
||||||
defaultSortOrder: "descend",
|
defaultSortOrder: "descend" as SortOrder,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Message",
|
title: "Message",
|
||||||
@@ -57,23 +79,3 @@ export default function LogTable({ logs, pageSize }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderColumnLevel(text, entry) {
|
|
||||||
let color = 'black';
|
|
||||||
|
|
||||||
if (entry.level === "warning") {
|
|
||||||
color = "orange";
|
|
||||||
} else if (entry.level === 'error') {
|
|
||||||
color = "red";
|
|
||||||
}
|
|
||||||
|
|
||||||
const style = {
|
|
||||||
color,
|
|
||||||
};
|
|
||||||
return <div style={style}>{text}</div>;
|
|
||||||
}
|
|
||||||
|
|
||||||
function renderMessage(text, entry) {
|
|
||||||
return (
|
|
||||||
<Linkify>{text}</Linkify>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user