mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-02 05:10:35 +08:00
feat: dashboard layout is updated from widgets (#1207)
This commit is contained in:
parent
642c6c5920
commit
d863c2781a
@ -74,24 +74,31 @@ function GridGraph(): JSX.Element {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return data.layout
|
|
||||||
.filter((_, index) => widgets[index])
|
return widgets.map((widget, index) => {
|
||||||
.map((e, index) => ({
|
const allLayouts = data?.layout;
|
||||||
...e,
|
const lastLayout = (data?.layout || [])[(allLayouts?.length || 0) - 1];
|
||||||
Component: (): JSX.Element => {
|
|
||||||
if (widgets[index]) {
|
const currentLayout = (allLayouts || [])[index] || {
|
||||||
return (
|
h: lastLayout.h,
|
||||||
<Graph
|
i: (lastLayout.i + 1).toString(),
|
||||||
name={e.i + index}
|
w: lastLayout.w,
|
||||||
isDeleted={isDeleted}
|
x: (lastLayout.x % 2) * 6,
|
||||||
widget={widgets[index]}
|
y: lastLayout.y,
|
||||||
yAxisUnit={widgets[index].yAxisUnit}
|
};
|
||||||
/>
|
|
||||||
);
|
return {
|
||||||
}
|
...currentLayout,
|
||||||
return <div />;
|
Component: (): JSX.Element => (
|
||||||
},
|
<Graph
|
||||||
}));
|
name={widget.id + index}
|
||||||
|
isDeleted={isDeleted}
|
||||||
|
widget={widget}
|
||||||
|
yAxisUnit={widget.yAxisUnit}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
};
|
||||||
|
});
|
||||||
}, [widgets, data.layout]);
|
}, [widgets, data.layout]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -217,6 +224,8 @@ function GridGraph(): JSX.Element {
|
|||||||
return <Spinner height="40vh" size="large" tip="Loading..." />;
|
return <Spinner height="40vh" size="large" tip="Loading..." />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log({ layouts });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{saveLayout && (
|
{saveLayout && (
|
||||||
@ -255,7 +264,7 @@ function GridGraph(): JSX.Element {
|
|||||||
<CardContainer
|
<CardContainer
|
||||||
isQueryType={isQueryType}
|
isQueryType={isQueryType}
|
||||||
isDarkMode={isDarkMode}
|
isDarkMode={isDarkMode}
|
||||||
key={rest.i}
|
key={rest.i + JSON.stringify(widget)}
|
||||||
data-grid={rest}
|
data-grid={rest}
|
||||||
>
|
>
|
||||||
<Card isDarkMode={isDarkMode} isQueryType={isQueryType}>
|
<Card isDarkMode={isDarkMode} isQueryType={isQueryType}>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user