mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-10-12 08:21:28 +08:00
feat: add functionality to export dashboard as json from listing page
This commit is contained in:
parent
e3caa6a8f5
commit
8d1c4491b7
@ -27,6 +27,8 @@ import { AxiosError } from 'axios';
|
|||||||
import cx from 'classnames';
|
import cx from 'classnames';
|
||||||
import { ENTITY_VERSION_V4 } from 'constants/app';
|
import { ENTITY_VERSION_V4 } from 'constants/app';
|
||||||
import ROUTES from 'constants/routes';
|
import ROUTES from 'constants/routes';
|
||||||
|
import { sanitizeDashboardData } from 'container/NewDashboard/DashboardDescription';
|
||||||
|
import { downloadObjectAsJson } from 'container/NewDashboard/DashboardDescription/utils';
|
||||||
import { Base64Icons } from 'container/NewDashboard/DashboardSettings/General/utils';
|
import { Base64Icons } from 'container/NewDashboard/DashboardSettings/General/utils';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { useGetAllDashboard } from 'hooks/dashboard/useGetAllDashboard';
|
import { useGetAllDashboard } from 'hooks/dashboard/useGetAllDashboard';
|
||||||
@ -44,6 +46,7 @@ import {
|
|||||||
EllipsisVertical,
|
EllipsisVertical,
|
||||||
Expand,
|
Expand,
|
||||||
ExternalLink,
|
ExternalLink,
|
||||||
|
FileJson,
|
||||||
Github,
|
Github,
|
||||||
HdmiPort,
|
HdmiPort,
|
||||||
LayoutGrid,
|
LayoutGrid,
|
||||||
@ -450,6 +453,23 @@ function DashboardsList(): JSX.Element {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleJsonExport = (event: React.MouseEvent<HTMLElement>): void => {
|
||||||
|
event.stopPropagation();
|
||||||
|
event.preventDefault();
|
||||||
|
const selectedDashboardData = dashboards?.find(
|
||||||
|
(d) => d.uuid === dashboard.id,
|
||||||
|
);
|
||||||
|
if (selectedDashboardData) {
|
||||||
|
downloadObjectAsJson(
|
||||||
|
sanitizeDashboardData({
|
||||||
|
...selectedDashboardData.data,
|
||||||
|
uuid: selectedDashboardData.uuid,
|
||||||
|
}),
|
||||||
|
dashboard.name,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="dashboard-list-item" onClick={onClickHandler}>
|
<div className="dashboard-list-item" onClick={onClickHandler}>
|
||||||
<div className="title-with-action">
|
<div className="title-with-action">
|
||||||
@ -523,6 +543,14 @@ function DashboardsList(): JSX.Element {
|
|||||||
>
|
>
|
||||||
Copy Link
|
Copy Link
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button
|
||||||
|
type="text"
|
||||||
|
className="action-btn"
|
||||||
|
icon={<FileJson size={12} />}
|
||||||
|
onClick={handleJsonExport}
|
||||||
|
>
|
||||||
|
Export JSON
|
||||||
|
</Button>
|
||||||
</section>
|
</section>
|
||||||
<section className="section-2">
|
<section className="section-2">
|
||||||
<DeleteButton
|
<DeleteButton
|
||||||
|
@ -65,7 +65,7 @@ interface DashboardDescriptionProps {
|
|||||||
handle: FullScreenHandle;
|
handle: FullScreenHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
function sanitizeDashboardData(
|
export function sanitizeDashboardData(
|
||||||
selectedData: DashboardData,
|
selectedData: DashboardData,
|
||||||
): Omit<DashboardData, 'uuid'> {
|
): Omit<DashboardData, 'uuid'> {
|
||||||
if (!selectedData?.variables) {
|
if (!selectedData?.variables) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user