mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-05 06:40:37 +08:00

* feat: dashboard panel grouping initial setup * feat: added panel map to the dashboard response and subsequent types for the same * feat: added panel map to the dashboard response and subsequent types for the same * feat: added settings modal * feat: handle panel collapse and open changes * feat: handle creating panel map when dashboard layout changes * feat: handle creating panel map when dashboard layout changes * feat: refactor code * feat: handle multiple collapsable rows * fix: type issues * feat: handle row collapse button and scroll * feat: handle y axis movement for rows * feat: handle delete row * feat: handle settings name change * feat: disable collapse/uncollapse when dashboard loading to avoid async states * feat: decrease the height of the grouping row * fix: row height management * fix: handle empty row case * feat: remove resize handle from the row * feat: handle re-arrangement of panels * feat: increase height of default new widget * feat: added safety checks
35 lines
945 B
TypeScript
35 lines
945 B
TypeScript
import { Layout } from 'react-grid-layout';
|
|
import { Dashboard, Widgets } from 'types/api/dashboard/getAll';
|
|
|
|
export const getPreviousWidgets = (
|
|
selectedDashboard: Dashboard,
|
|
selectedWidgetIndex: number,
|
|
): Widgets[] =>
|
|
(selectedDashboard.data.widgets?.slice(
|
|
0,
|
|
selectedWidgetIndex || 0,
|
|
) as Widgets[]) || [];
|
|
|
|
export const getNextWidgets = (
|
|
selectedDashboard: Dashboard,
|
|
selectedWidgetIndex: number,
|
|
): Widgets[] =>
|
|
(selectedDashboard.data.widgets?.slice(
|
|
(selectedWidgetIndex || 0) + 1, // this is never undefined
|
|
selectedDashboard.data.widgets?.length,
|
|
) as Widgets[]) || [];
|
|
|
|
export const getSelectedWidgetIndex = (
|
|
selectedDashboard: Dashboard,
|
|
widgetId: string | null,
|
|
): number =>
|
|
selectedDashboard.data.widgets?.findIndex((e) => e.id === widgetId) || 0;
|
|
|
|
export const sortLayout = (layout: Layout[]): Layout[] =>
|
|
[...layout].sort((a, b) => {
|
|
if (a.y === b.y) {
|
|
return a.x - b.x;
|
|
}
|
|
return a.y - b.y;
|
|
});
|