perf(format): code format
This commit is contained in:
@@ -21,7 +21,12 @@ import {
|
||||
} from "mantine-datatable"
|
||||
import { useEffect, useMemo, useState } from "react"
|
||||
import * as XLSX from "xlsx-js-style"
|
||||
import { DimensionType, GroupedData, MetricColumn, dimensionOpts } from "./config"
|
||||
import {
|
||||
DimensionType,
|
||||
GroupedData,
|
||||
MetricColumn,
|
||||
dimensionOpts,
|
||||
} from "./config"
|
||||
|
||||
function emptyGroupedData(): GroupedData {
|
||||
return {
|
||||
@@ -42,8 +47,12 @@ export default function WorkloadMetricsTable(props: {
|
||||
}) {
|
||||
const { title, sheetName, fileName, metrics, fetchData } = props
|
||||
|
||||
const [startDate, setStartDate] = useState(dayjs().subtract(1, "day").format("YYYY-MM-DD"))
|
||||
const [endDate, setEndDate] = useState(dayjs().subtract(1, "day").format("YYYY-MM-DD"))
|
||||
const [startDate, setStartDate] = useState(
|
||||
dayjs().subtract(1, "day").format("YYYY-MM-DD")
|
||||
)
|
||||
const [endDate, setEndDate] = useState(
|
||||
dayjs().subtract(1, "day").format("YYYY-MM-DD")
|
||||
)
|
||||
const [dimension, setDimension] = useState<DimensionType>("all")
|
||||
const [data, setData] = useState<GroupedData>(emptyGroupedData())
|
||||
const [loading, setLoading] = useState(false)
|
||||
@@ -152,14 +161,18 @@ export default function WorkloadMetricsTable(props: {
|
||||
{ accessor: "user_name", title: "用户名", width: 120 },
|
||||
{ accessor: "group_name", title: "用户组", width: 160 },
|
||||
],
|
||||
order_by_group_name: [{ accessor: "group_name", title: "用户组", width: 180 }],
|
||||
order_by_group_name: [
|
||||
{ accessor: "group_name", title: "用户组", width: 180 },
|
||||
],
|
||||
order_by_project_name: [
|
||||
{ accessor: "project_name", title: "项目名称", width: 220 },
|
||||
],
|
||||
order_by_project_type: [
|
||||
{ accessor: "project_type", title: "项目类型", width: 220 },
|
||||
],
|
||||
order_by_user_name: [{ accessor: "user_name", title: "用户名", width: 180 }],
|
||||
order_by_user_name: [
|
||||
{ accessor: "user_name", title: "用户名", width: 180 },
|
||||
],
|
||||
}
|
||||
return allCols[dimension]
|
||||
}, [dimension])
|
||||
@@ -319,7 +332,11 @@ export default function WorkloadMetricsTable(props: {
|
||||
</SimpleGrid>
|
||||
</Paper>
|
||||
|
||||
<Paper withBorder p="sm" radius="sm" style={{ flex: 1, minHeight: 0, display: "flex" }}>
|
||||
<Paper
|
||||
withBorder
|
||||
p="sm"
|
||||
radius="sm"
|
||||
style={{ flex: 1, minHeight: 0, display: "flex" }}>
|
||||
<DataTable<any>
|
||||
withTableBorder
|
||||
withRowBorders
|
||||
@@ -327,7 +344,7 @@ export default function WorkloadMetricsTable(props: {
|
||||
records={sortedRecords}
|
||||
columns={columns}
|
||||
noRecordsText="暂无数据"
|
||||
rowKey={rowKey as any}
|
||||
idAccessor={rowKey as any}
|
||||
scrollAreaProps={{ type: "auto" }}
|
||||
style={{ width: "100%" }}
|
||||
sortStatus={sortStatus}
|
||||
|
||||
Reference in New Issue
Block a user