Skip to content

Commit

Permalink
Add download to CSV and open in new window options for benchmarks (#622)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelBurgess authored Dec 10, 2024
1 parent 4da89a0 commit a319a8b
Show file tree
Hide file tree
Showing 24 changed files with 913 additions and 535 deletions.
6 changes: 6 additions & 0 deletions internal/dashboardserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ func (s *Server) HandleDashboardEvent(ctx context.Context, event dashboardevents
changedCards := e.ChangedCards
changedCharts := e.ChangedCharts
changedDashboards := e.ChangedDashboards
changedDetections := e.ChangedDetections
changedDetectionsBenchmarks := e.ChangedDetectionBenchmarks
changedEdges := e.ChangedEdges
changedFlows := e.ChangedFlows
changedGraphs := e.ChangedGraphs
Expand All @@ -182,6 +184,8 @@ func (s *Server) HandleDashboardEvent(ctx context.Context, event dashboardevents
len(changedCards) == 0 &&
len(changedCharts) == 0 &&
len(changedDashboards) == 0 &&
len(changedDetections) == 0 &&
len(changedDetectionsBenchmarks) == 0 &&
len(changedEdges) == 0 &&
len(changedFlows) == 0 &&
len(changedGraphs) == 0 &&
Expand Down Expand Up @@ -241,6 +245,8 @@ func (s *Server) HandleDashboardEvent(ctx context.Context, event dashboardevents
changedDashboardNames = append(changedDashboardNames, getDashboardsInterestedInResourceChanges(dashboardsBeingWatched, changedDashboardNames, changedControls)...)
changedDashboardNames = append(changedDashboardNames, getDashboardsInterestedInResourceChanges(dashboardsBeingWatched, changedDashboardNames, changedCards)...)
changedDashboardNames = append(changedDashboardNames, getDashboardsInterestedInResourceChanges(dashboardsBeingWatched, changedDashboardNames, changedCharts)...)
changedDashboardNames = append(changedDashboardNames, getDashboardsInterestedInResourceChanges(dashboardsBeingWatched, changedDashboardNames, changedDetections)...)
changedDashboardNames = append(changedDashboardNames, getDashboardsInterestedInResourceChanges(dashboardsBeingWatched, changedDashboardNames, changedDetectionsBenchmarks)...)
changedDashboardNames = append(changedDashboardNames, getDashboardsInterestedInResourceChanges(dashboardsBeingWatched, changedDashboardNames, changedEdges)...)
changedDashboardNames = append(changedDashboardNames, getDashboardsInterestedInResourceChanges(dashboardsBeingWatched, changedDashboardNames, changedFlows)...)
changedDashboardNames = append(changedDashboardNames, getDashboardsInterestedInResourceChanges(dashboardsBeingWatched, changedDashboardNames, changedGraphs)...)
Expand Down
38 changes: 19 additions & 19 deletions ui/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
"dependencies": {
"@headlessui/react": "1.7.19",
"@heroicons/react": "2.2.0",
"@material-symbols/svg-300": "0.27.1",
"@material-symbols/svg-300": "0.27.2",
"@popperjs/core": "2.11.8",
"@supabase/sql-formatter": "4.0.3",
"@tanstack/react-table": "8.20.5",
"@tanstack/react-virtual": "3.10.9",
"@tanstack/react-virtual": "3.11.1",
"color-convert": "2.0.1",
"copy-to-clipboard": "3.3.3",
"dagre": "0.8.5",
Expand All @@ -31,12 +31,12 @@
"echarts-for-react": "3.0.2",
"echarts-gl": "2.0.9",
"file-saver": "2.0.5",
"framer-motion": "11.12.0",
"framer-motion": "11.13.4",
"jq-wasm": "0.0.9",
"lodash": "4.17.21",
"react": "18.3.1",
"react-cool-img": "1.2.12",
"react-day-picker": "9.4.0",
"react-day-picker": "9.4.2",
"react-dom": "18.3.1",
"react-hotkeys": "2.0.0",
"react-markdown": "9.0.1",
Expand All @@ -59,28 +59,28 @@
"devDependencies": {
"@chromatic-com/storybook": "3.2.2",
"@craco/craco": "7.1.0",
"@storybook/addon-actions": "8.4.5",
"@storybook/addon-essentials": "8.4.5",
"@storybook/addon-links": "8.4.5",
"@storybook/node-logger": "8.4.5",
"@storybook/preset-create-react-app": "8.4.5",
"@storybook/preview-api": "8.4.5",
"@storybook/react": "8.4.5",
"@storybook/react-webpack5": "8.4.5",
"@storybook/theming": "8.4.5",
"@storybook/addon-actions": "8.4.7",
"@storybook/addon-essentials": "8.4.7",
"@storybook/addon-links": "8.4.7",
"@storybook/node-logger": "8.4.7",
"@storybook/preset-create-react-app": "8.4.7",
"@storybook/preview-api": "8.4.7",
"@storybook/react": "8.4.7",
"@storybook/react-webpack5": "8.4.7",
"@storybook/theming": "8.4.7",
"@tailwindcss/forms": "0.5.9",
"@tailwindcss/line-clamp": "0.4.4",
"@tailwindcss/typography": "0.5.15",
"@testing-library/dom": "10.4.0",
"@testing-library/jest-dom": "6.6.3",
"@testing-library/react": "16.0.1",
"@testing-library/react": "16.1.0",
"@tsconfig/create-react-app": "2.0.5",
"@types/echarts": "4.9.22",
"@types/jest": "29.5.14",
"@types/lodash": "4.17.13",
"@types/node": "22.10.1",
"@types/react": "18.3.12",
"@types/react-dom": "18.3.1",
"@types/react": "18.3.14",
"@types/react-dom": "18.3.3",
"autoprefixer": "10.4.20",
"buffer": "6.0.3",
"circular-dependency-plugin": "5.2.2",
Expand All @@ -89,16 +89,16 @@
"if-node-version": "1.1.1",
"lint-staged": "15.2.10",
"npm-run-all": "4.1.5",
"prettier": "3.4.1",
"prettier": "3.4.2",
"process": "0.11.10",
"prop-types": "15.8.1",
"react-scripts": "5.0.1",
"source-map-explorer": "2.5.3",
"storybook": "8.4.5",
"storybook": "8.4.7",
"storybook-addon-react-router-v6": "2.0.15",
"storybook-dark-mode": "4.0.2",
"stream-browserify": "3.0.0",
"tailwindcss": "3.4.15",
"tailwindcss": "3.4.16",
"typescript": "4.5.5",
"vm-browserify": "1.1.2"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const TableSettings = ({ table }: { table: Table<KeyValuePairs> }) => {
<Popover className="relative">
{/*@ts-ignore*/}
<Popover.Button ref={setReferenceElement} as="div">
<Icon icon="settings" className="h-4 w-4 cursor-pointer" />
<Icon icon="data_table" className="h-4 w-4 cursor-pointer" />
</Popover.Button>
<Popover.Panel className="absolute z-10 pt-px">
{createPortal(
Expand Down
27 changes: 26 additions & 1 deletion ui/dashboard/src/components/dashboards/Table/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import {
LeafNodeDataColumn,
LeafNodeDataRow,
} from "../common";
import { Filter } from "@powerpipe/components/dashboards/grouping/common";
import { classNames } from "@powerpipe/utils/styles";
import { createPortal } from "react-dom";
import { Filter } from "@powerpipe/components/dashboards/grouping/common";
import {
flexRender,
getCoreRowModel,
Expand Down Expand Up @@ -799,12 +799,37 @@ const TableViewVirtualizedRows = ({
doRender();
}, [columns, renderTemplates, rows, virtualizedRows, templateRenderReady]);

// const tableSettingsControl = useMemo<IPanelControl | null>(() => {
// if (!table) {
// return null;
// }
// return {
// key: "table-settings",
// title: "Table settings",
// icon: "data_table",
// //component: <TableSettings table={table} />,
// action: noop,
// };
// }, [table]);

// const { enabled: panelControlsEnabled, setCustomControls } =
// usePanelControls();

// useEffect(() => {
// if (!panelControlsEnabled || !tableSettingsControl) {
// return;
// }
// setCustomControls([tableSettingsControl]);
// }, [panelControlsEnabled, tableSettingsControl, setCustomControls]);

return (
<div className="flex flex-col w-full overflow-hidden">
{filterEnabled && (
<div
className={classNames(
// "flex w-full",
"flex w-full p-4",
// filters.length ? "justify-between p-4" : "justify-end",
filters.length ? "justify-between" : "justify-end",
)}
>
Expand Down
42 changes: 25 additions & 17 deletions ui/dashboard/src/components/dashboards/grouping/Benchmark/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import Grid from "@powerpipe/components/dashboards/layout/Grid";
import Panel from "@powerpipe/components/dashboards/layout/Panel";
import PanelControls from "@powerpipe/components/dashboards/layout/Panel/PanelControls";
import useFilterConfig from "@powerpipe/hooks/useFilterConfig";
import usePanelControls from "@powerpipe/hooks/usePanelControls";
import {
BenchmarkTreeProps,
CheckDisplayGroup,
Expand All @@ -31,6 +30,10 @@ import {
import { noop } from "@powerpipe/utils/func";
import { useDashboard } from "@powerpipe/hooks/useDashboard";
import { useEffect, useMemo, useState } from "react";
import {
PanelControlsProvider,
usePanelControls,
} from "@powerpipe/hooks/usePanelControls";
import { Width } from "@powerpipe/components/dashboards/common";

const Table = getComponent("table");
Expand All @@ -46,7 +49,6 @@ type InnerCheckProps = {
grouping: CheckNode;
groupingConfig: CheckDisplayGroup[];
firstChildSummaries: CheckSummary[];
showControls: boolean;
withTitle: boolean;
};

Expand All @@ -67,29 +69,35 @@ const Benchmark = (props: InnerCheckProps) => {
}, [props.benchmark, props.grouping]);
const [referenceElement, setReferenceElement] = useState(null);
const [showBenchmarkControls, setShowBenchmarkControls] = useState(false);
const definitionWithData = useMemo(() => {
return {
...props.definition,
data: benchmarkDataTable,
};
}, [benchmarkDataTable, props.definition]);
const { panelControls: benchmarkControls, setCustomControls } =
usePanelControls(definitionWithData, props.showControls);
const {
panelControls: benchmarkControls,
showPanelControls,
setCustomControls,
setPanelData,
} = usePanelControls();

useEffect(() => {
setCustomControls([
{
key: "filter-and-group",
title: "Filter & Group",
component: <CustomizeViewSummary panelName={props.definition.name} />,
action: async () =>
dispatch({
type: DashboardActions.SHOW_CUSTOMIZE_BENCHMARK_PANEL,
panel_name: props.definition.name,
}),
component: <CustomizeViewSummary panelName={props.definition.name} />,
title: "Filter & Group",
},
]);
}, [dispatch, props.definition.name, setCustomControls]);

useEffect(() => {
if (!benchmarkDataTable) {
return;
}
setPanelData(benchmarkDataTable);
}, [benchmarkDataTable, setPanelData]);

const summaryCards = useMemo(() => {
if (!props.grouping) {
return [];
Expand Down Expand Up @@ -192,7 +200,7 @@ const Benchmark = (props: InnerCheckProps) => {
name={props.definition.name}
width={props.definition.width}
events={{
onMouseEnter: props.showControls
onMouseEnter: showPanelControls
? () => setShowBenchmarkControls(true)
: noop,
onMouseLeave: () => setShowBenchmarkControls(false),
Expand Down Expand Up @@ -246,7 +254,6 @@ const Benchmark = (props: InnerCheckProps) => {
key={summaryCard.name}
definition={cardProps}
parentType="benchmark"
showControls={false}
>
<FilterCardWrapper
cardName={summaryCard.name}
Expand Down Expand Up @@ -315,7 +322,7 @@ const BenchmarkTableView = ({
);
};

const Inner = ({ showControls, withTitle }) => {
const Inner = ({ withTitle }) => {
const {
benchmark,
definition,
Expand All @@ -336,7 +343,6 @@ const Inner = ({ showControls, withTitle }) => {
grouping={grouping}
groupingConfig={groupingConfig}
firstChildSummaries={firstChildSummaries}
showControls={showControls}
withTitle={withTitle}
/>
);
Expand Down Expand Up @@ -371,7 +377,9 @@ type BenchmarkProps = PanelDefinition & {
const BenchmarkWrapper = (props: BenchmarkProps) => {
return (
<GroupingProvider definition={props}>
<Inner showControls={props.showControls} withTitle={props.withTitle} />
<PanelControlsProvider definition={props} enabled={props.showControls}>
<Inner withTitle={props.withTitle} />
</PanelControlsProvider>
</GroupingProvider>
);
};
Expand Down

This file was deleted.

Loading

0 comments on commit a319a8b

Please sign in to comment.