mirror of
https://github.com/woodchen-ink/certimate.git
synced 2025-07-18 17:31:55 +08:00
feat(ui): show errmsg if table loaded error
This commit is contained in:
parent
3a2baba746
commit
d1dbbae101
@ -129,7 +129,7 @@ const WorkflowRuns = ({ className, style, workflowId }: WorkflowRunsProps) => {
|
|||||||
const [page, setPage] = useState<number>(1);
|
const [page, setPage] = useState<number>(1);
|
||||||
const [pageSize, setPageSize] = useState<number>(10);
|
const [pageSize, setPageSize] = useState<number>(10);
|
||||||
|
|
||||||
const { loading } = useRequest(
|
const { loading, loadedError } = useRequest(
|
||||||
() => {
|
() => {
|
||||||
return listWorkflowRuns({
|
return listWorkflowRuns({
|
||||||
workflowId: workflowId,
|
workflowId: workflowId,
|
||||||
@ -150,6 +150,8 @@ const WorkflowRuns = ({ className, style, workflowId }: WorkflowRunsProps) => {
|
|||||||
|
|
||||||
console.error(err);
|
console.error(err);
|
||||||
notificationApi.error({ message: t("common.text.request_error"), description: getErrMsg(err) });
|
notificationApi.error({ message: t("common.text.request_error"), description: getErrMsg(err) });
|
||||||
|
|
||||||
|
throw err;
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -164,7 +166,7 @@ const WorkflowRuns = ({ className, style, workflowId }: WorkflowRunsProps) => {
|
|||||||
dataSource={tableData}
|
dataSource={tableData}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
locale={{
|
locale={{
|
||||||
emptyText: <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />,
|
emptyText: <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description={loadedError ? getErrMsg(loadedError) : undefined} />,
|
||||||
}}
|
}}
|
||||||
pagination={{
|
pagination={{
|
||||||
current: page,
|
current: page,
|
||||||
|
@ -130,7 +130,7 @@ const AccessList = () => {
|
|||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const { loading, run: refreshTableData } = useRequest(
|
const { loading, run: refreshData } = useRequest(
|
||||||
() => {
|
() => {
|
||||||
const startIndex = (page - 1) * pageSize;
|
const startIndex = (page - 1) * pageSize;
|
||||||
const endIndex = startIndex + pageSize;
|
const endIndex = startIndex + pageSize;
|
||||||
@ -157,7 +157,7 @@ const AccessList = () => {
|
|||||||
// TODO: 有关联数据的不允许被删除
|
// TODO: 有关联数据的不允许被删除
|
||||||
try {
|
try {
|
||||||
await deleteAccess(data);
|
await deleteAccess(data);
|
||||||
refreshTableData();
|
refreshData();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
notificationApi.error({ message: t("common.text.request_error"), description: getErrMsg(err) });
|
notificationApi.error({ message: t("common.text.request_error"), description: getErrMsg(err) });
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useNavigate, useSearchParams } from "react-router-dom";
|
import { useNavigate, useSearchParams } from "react-router-dom";
|
||||||
import { DeleteOutlined as DeleteOutlinedIcon, SelectOutlined as SelectOutlinedIcon } from "@ant-design/icons";
|
import { DeleteOutlined as DeleteOutlinedIcon, SelectOutlined as SelectOutlinedIcon, WarningOutlined as WarningOutlinedIcon } from "@ant-design/icons";
|
||||||
import { PageHeader } from "@ant-design/pro-components";
|
import { PageHeader } from "@ant-design/pro-components";
|
||||||
import { useRequest } from "ahooks";
|
import { useRequest } from "ahooks";
|
||||||
import { Button, Divider, Empty, Menu, type MenuProps, Modal, Radio, Space, Table, type TableProps, Tooltip, Typography, notification, theme } from "antd";
|
import { Button, Divider, Empty, Menu, type MenuProps, Modal, Radio, Space, Table, type TableProps, Tooltip, Typography, notification, theme } from "antd";
|
||||||
@ -188,7 +188,11 @@ const CertificateList = () => {
|
|||||||
const [page, setPage] = useState<number>(() => parseInt(+searchParams.get("page")! + "") || 1);
|
const [page, setPage] = useState<number>(() => parseInt(+searchParams.get("page")! + "") || 1);
|
||||||
const [pageSize, setPageSize] = useState<number>(() => parseInt(+searchParams.get("perPage")! + "") || 10);
|
const [pageSize, setPageSize] = useState<number>(() => parseInt(+searchParams.get("perPage")! + "") || 10);
|
||||||
|
|
||||||
const { loading, run: refreshTableData } = useRequest(
|
const {
|
||||||
|
loading,
|
||||||
|
error: loadedError,
|
||||||
|
run: refreshData,
|
||||||
|
} = useRequest(
|
||||||
() => {
|
() => {
|
||||||
return listCertificate({
|
return listCertificate({
|
||||||
page: page,
|
page: page,
|
||||||
@ -209,6 +213,8 @@ const CertificateList = () => {
|
|||||||
|
|
||||||
console.error(err);
|
console.error(err);
|
||||||
notificationApi.error({ message: t("common.text.request_error"), description: getErrMsg(err) });
|
notificationApi.error({ message: t("common.text.request_error"), description: getErrMsg(err) });
|
||||||
|
|
||||||
|
throw err;
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -222,7 +228,7 @@ const CertificateList = () => {
|
|||||||
const resp = await removeCertificate(certificate);
|
const resp = await removeCertificate(certificate);
|
||||||
if (resp) {
|
if (resp) {
|
||||||
setTableData((prev) => prev.filter((item) => item.id !== certificate.id));
|
setTableData((prev) => prev.filter((item) => item.id !== certificate.id));
|
||||||
refreshTableData();
|
refreshData();
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
@ -244,7 +250,7 @@ const CertificateList = () => {
|
|||||||
dataSource={tableData}
|
dataSource={tableData}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
locale={{
|
locale={{
|
||||||
emptyText: <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description={t("certificate.nodata")} />,
|
emptyText: <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description={loadedError ? getErrMsg(loadedError) : t("certificate.nodata")} />,
|
||||||
}}
|
}}
|
||||||
pagination={{
|
pagination={{
|
||||||
current: page,
|
current: page,
|
||||||
|
@ -66,6 +66,8 @@ const Dashboard = () => {
|
|||||||
|
|
||||||
console.error(err);
|
console.error(err);
|
||||||
notificationApi.error({ message: t("common.text.request_error"), description: getErrMsg(err) });
|
notificationApi.error({ message: t("common.text.request_error"), description: getErrMsg(err) });
|
||||||
|
|
||||||
|
throw err;
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -176,6 +178,8 @@ const Dashboard = () => {
|
|||||||
|
|
||||||
console.error(err);
|
console.error(err);
|
||||||
notificationApi.error({ message: t("common.text.request_error"), description: getErrMsg(err) });
|
notificationApi.error({ message: t("common.text.request_error"), description: getErrMsg(err) });
|
||||||
|
|
||||||
|
throw err;
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -20,6 +20,7 @@ import {
|
|||||||
type MenuProps,
|
type MenuProps,
|
||||||
Modal,
|
Modal,
|
||||||
Radio,
|
Radio,
|
||||||
|
Result,
|
||||||
Space,
|
Space,
|
||||||
Switch,
|
Switch,
|
||||||
Table,
|
Table,
|
||||||
@ -240,7 +241,11 @@ const WorkflowList = () => {
|
|||||||
const [page, setPage] = useState<number>(() => parseInt(+searchParams.get("page")! + "") || 1);
|
const [page, setPage] = useState<number>(() => parseInt(+searchParams.get("page")! + "") || 1);
|
||||||
const [pageSize, setPageSize] = useState<number>(() => parseInt(+searchParams.get("perPage")! + "") || 10);
|
const [pageSize, setPageSize] = useState<number>(() => parseInt(+searchParams.get("perPage")! + "") || 10);
|
||||||
|
|
||||||
const { loading, run: refreshTableData } = useRequest(
|
const {
|
||||||
|
loading,
|
||||||
|
error: loadedError,
|
||||||
|
run: refreshData,
|
||||||
|
} = useRequest(
|
||||||
() => {
|
() => {
|
||||||
return listWorkflow({
|
return listWorkflow({
|
||||||
page: page,
|
page: page,
|
||||||
@ -261,6 +266,8 @@ const WorkflowList = () => {
|
|||||||
|
|
||||||
console.error(err);
|
console.error(err);
|
||||||
notificationApi.error({ message: t("common.text.request_error"), description: getErrMsg(err) });
|
notificationApi.error({ message: t("common.text.request_error"), description: getErrMsg(err) });
|
||||||
|
|
||||||
|
throw err;
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -305,7 +312,7 @@ const WorkflowList = () => {
|
|||||||
const resp = await removeWorkflow(workflow);
|
const resp = await removeWorkflow(workflow);
|
||||||
if (resp) {
|
if (resp) {
|
||||||
setTableData((prev) => prev.filter((item) => item.id !== workflow.id));
|
setTableData((prev) => prev.filter((item) => item.id !== workflow.id));
|
||||||
refreshTableData();
|
refreshData();
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
@ -342,7 +349,7 @@ const WorkflowList = () => {
|
|||||||
dataSource={tableData}
|
dataSource={tableData}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
locale={{
|
locale={{
|
||||||
emptyText: <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description={t("workflow.nodata")} />,
|
emptyText: <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description={loadedError ? getErrMsg(loadedError) : t("workflow.nodata")} />,
|
||||||
}}
|
}}
|
||||||
pagination={{
|
pagination={{
|
||||||
current: page,
|
current: page,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user