Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrated Week 2 #599

Draft
wants to merge 72 commits into
base: tp
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
45cae80
Rename check to grouping in dashboard UI
MichaelBurgess Nov 5, 2024
7c3eb12
WIP for making detections a supported resource
MichaelBurgess Nov 6, 2024
f50fb38
Add DateTimeRange Picker for Detetction Benchmark
Darkness4ever Nov 6, 2024
c685edc
Show root detection dashboards in dashboard list
MichaelBurgess Nov 6, 2024
4966a5b
Working detection benchmark with table results
MichaelBurgess Nov 6, 2024
01a911a
Add severity support
MichaelBurgess Nov 7, 2024
d74e647
dashboard input values now passed using InputValues struct
kaidaguerre Nov 8, 2024
feb7450
Add DetectionChart to panel
Darkness4ever Nov 8, 2024
da00438
dashboard inputs are now passed using InputValues struct, which also …
kaidaguerre Nov 8, 2024
f0c5587
Add execution flow
MichaelBurgess Nov 8, 2024
be87996
Fix UI crash
MichaelBurgess Nov 8, 2024
1609518
GetConnectionString returns error
kaidaguerre Nov 8, 2024
7becf6b
Add table scroll and panel alligment and sapce
Darkness4ever Nov 8, 2024
207b0ea
Add Loading Indicator for Panel Status
Darkness4ever Nov 8, 2024
767fe11
Moved summary chart
MichaelBurgess Nov 8, 2024
867bbbd
Init date range to 1d
MichaelBurgess Nov 8, 2024
66641fb
Fix date range init bug
MichaelBurgess Nov 8, 2024
8cd3c32
Fix relative time bug
MichaelBurgess Nov 8, 2024
3854249
Add tailwind css styling to DateRangePicker
Darkness4ever Nov 8, 2024
3167930
Close custom pop up when clicked outside
Darkness4ever Nov 8, 2024
cce4b7f
More filtering tweaks
MichaelBurgess Nov 8, 2024
31818ec
Add hover to preset dates and Date Picker
Darkness4ever Nov 9, 2024
4ab84bf
Highlight custom when non-preset relative unit selected
MichaelBurgess Nov 9, 2024
2204a1d
Remove animation on date button hover
Darkness4ever Nov 9, 2024
a938e71
Tweaks
MichaelBurgess Nov 9, 2024
7acc367
Show all severity cards
MichaelBurgess Nov 9, 2024
66ff891
delete test mod
kaidaguerre Nov 11, 2024
ebfc67b
fix dashboard test
pskrbasu Nov 11, 2024
5bf94f6
Add CheckGrouping story
MichaelBurgess Nov 11, 2024
5643215
Add CheckGrouping story
MichaelBurgess Nov 11, 2024
0928f96
Fix bug
MichaelBurgess Nov 11, 2024
36eaec9
Add panel type
MichaelBurgess Nov 11, 2024
57b0d33
Add Diff to Cards
Darkness4ever Nov 11, 2024
24b0fab
Diff charts
MichaelBurgess Nov 11, 2024
b7c2ffb
Fix dashboard crash in card
MichaelBurgess Nov 12, 2024
39462b9
Fix dashboard crash in card
MichaelBurgess Nov 12, 2024
0c99142
wip: snapshot diff - checkpoint initial wiring
graza-io Nov 12, 2024
238234b
Add diff to result set
Darkness4ever Nov 12, 2024
8ac0fee
Add support for chart diffing
MichaelBurgess Nov 12, 2024
0516cfd
Add diff for SingleSeries Line Chart
Darkness4ever Nov 12, 2024
82c7082
wip: snapshot diff - checkpoint
graza-io Nov 12, 2024
94963f5
wip: snapshot diff - checkpoint
graza-io Nov 12, 2024
87eefc6
Add table diffing
MichaelBurgess Nov 12, 2024
a618d3a
wip: loading snapshot changes
graza-io Nov 13, 2024
7426d76
Initial sending of diff request via web socket
MichaelBurgess Nov 13, 2024
1d4ad33
Add Diff Changes for column, area and pie
Darkness4ever Nov 13, 2024
980aec4
Increase max socket message size
MichaelBurgess Nov 13, 2024
cef8810
wip: snapshot diff - checkpoint(inserting)
graza-io Nov 13, 2024
7cd15bb
wip: started parsing diffs
graza-io Nov 13, 2024
64cca05
wip: started parsing diffs - updated to get new values in correct place
graza-io Nov 13, 2024
e5991dd
Fix card diffs to work with new format
MichaelBurgess Nov 13, 2024
f6d9c38
snapshot diffs - wip
graza-io Nov 13, 2024
a6b2ce7
Fix cards to work in new format
MichaelBurgess Nov 13, 2024
6c432eb
Add diif to CheckSummary and CheckNode
Darkness4ever Nov 13, 2024
4dfcf94
Fix aggregation logic for summary
MichaelBurgess Nov 13, 2024
2dcddc0
Logging
MichaelBurgess Nov 13, 2024
5495004
Fix benchmark summary cards
MichaelBurgess Nov 13, 2024
73c12af
Add Diff to CheckSummary
Darkness4ever Nov 13, 2024
3a3fafa
Add __diff to CheckResult
MichaelBurgess Nov 13, 2024
8922eaf
Load diff'd snapshot into UI
MichaelBurgess Nov 13, 2024
55211b7
added 'attribute' to dashboard table column
graza-io Nov 14, 2024
1773cd9
Fix bug showing dashboard list when we should not
MichaelBurgess Nov 14, 2024
3569019
Fix down to zero bug
MichaelBurgess Nov 14, 2024
1535b62
Redirect to correct path
MichaelBurgess Nov 14, 2024
41002fe
Diff for CheckPanel
Darkness4ever Nov 14, 2024
be2ffdc
Fix up number change when not in diff mode
MichaelBurgess Nov 14, 2024
fc1a682
Add SpiltSnapButton
Darkness4ever Nov 14, 2024
8a89191
Remove Diff from Snapshot header
Darkness4ever Nov 14, 2024
79fb8ef
Fixes for charts
MichaelBurgess Nov 14, 2024
1c7bc02
Fix card
MichaelBurgess Nov 14, 2024
dea0925
Styling
MichaelBurgess Nov 14, 2024
da85762
Fixes after rebase
MichaelBurgess Nov 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixes for charts
  • Loading branch information
MichaelBurgess committed Nov 28, 2024
commit 79fb8ef4a47dd290876df27df3e8407170800e79
2 changes: 1 addition & 1 deletion ui/dashboard/src/components/SpiltSnapButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ const SplitButton: React.FC<SplitButtonProps> = ({ className }) => {
</NeutralButton>
)}

{(isSnapshot || isLive || dataMode == DashboardDataModeDiff) && (
{(isSnapshot || dataMode == DashboardDataModeDiff) && (
<NeutralButton
type="button"
className="inline-flex items-center space-x-2 shadow-none rounded-r-none"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ SingleSeriesDiff.args = {
data: {
columns: [
{ name: "Type", data_type: "TEXT" },
{ name: "_diff", data_type: "INT8" },
{ name: "__diff", data_type: "INT8" },
{ name: "Count_diff", data_type: "INT8" },
{ name: "Count", data_type: "INT8" },
],
Expand All @@ -333,7 +333,7 @@ SingleTimeSeriesDiff.args = {
{ name: "time", data_type: "TIMESTAMP" },
{ name: "Count", data_type: "INT8" },
{ name: "Count_diff", data_type: "INT8" },
{ name: "_diff", data_type: "TEXT" },
{ name: "__diff", data_type: "TEXT" },
],
rows: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ SingleSeriesDiff.args = {
data: {
columns: [
{ name: "Type", data_type: "TEXT" },
{ name: "_diff", data_type: "INT8" },
{ name: "__diff", data_type: "INT8" },
{ name: "Count_diff", data_type: "INT8" },
{ name: "Count", data_type: "INT8" },
],
Expand All @@ -320,7 +320,7 @@ MultiSeriesGroupedDiff.args = {
{ name: "Women_diff", data_type: "INT8" },
{ name: "Children", data_type: "INT8" },
{ name: "Children_diff", data_type: "INT8" },
{ name: "_diff", data_type: "INT8" },
{ name: "__diff", data_type: "INT8" },
],
rows: [
{
Expand Down
124 changes: 94 additions & 30 deletions ui/dashboard/src/components/dashboards/charts/Chart/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,18 @@ import { injectSearchPathPrefix } from "@powerpipe/utils/url";
import { registerComponent } from "@powerpipe/components/dashboards";
import { useDashboard } from "@powerpipe/hooks/useDashboard";
import { useNavigate } from "react-router-dom";
import { isDiffColumn, parseDiffColumn } from "@powerpipe/utils/data";
import {
isDiffColumn,
parseDiffColumn,
tableRowDiffColumn,
} from "@powerpipe/utils/data";

const getThemeColorsWithPointOverrides = (
type: ChartType = "column",
series: any[],
seriesOverrides: ChartSeries | undefined,
dataset: any[][],
themeColorValues
themeColorValues,
) => {
if (isEmpty(themeColorValues)) {
return [];
Expand All @@ -55,7 +59,7 @@ const getThemeColorsWithPointOverrides = (
newThemeColors.push(
themeColorValues.charts[
(rowIndex - 1) % themeColorValues.charts.length
]
],
);
}
}
Expand All @@ -70,7 +74,7 @@ const getThemeColorsWithPointOverrides = (
if (pointOverride && pointOverride.color) {
newThemeColors[dataRowIndex] = getColorOverride(
pointOverride.color,
themeColorValues
themeColorValues,
);
}
});
Expand All @@ -86,7 +90,7 @@ const getThemeColorsWithPointOverrides = (
newThemeColors.push(
themeColorValues.charts[
seriesIndex % themeColorValues.charts.length
]
],
);
}
}
Expand Down Expand Up @@ -165,7 +169,7 @@ const getCommonBaseOptionsForChartType = (
shouldBeTimeSeries: boolean,
series: any[],
seriesOverrides: ChartSeries | undefined,
themeColors
themeColors,
) => {
switch (type) {
case "bar":
Expand All @@ -175,7 +179,7 @@ const getCommonBaseOptionsForChartType = (
series,
seriesOverrides,
dataset,
themeColors
themeColors,
),
legend: {
show: series ? series.length > 1 : false,
Expand Down Expand Up @@ -219,7 +223,7 @@ const getCommonBaseOptionsForChartType = (
series,
seriesOverrides,
dataset,
themeColors
themeColors,
),
legend: {
show: series ? series.length > 1 : false,
Expand Down Expand Up @@ -269,7 +273,7 @@ const getCommonBaseOptionsForChartType = (
series,
seriesOverrides,
dataset,
themeColors
themeColors,
),
legend: {
show: series ? series.length > 1 : false,
Expand Down Expand Up @@ -316,7 +320,7 @@ const getCommonBaseOptionsForChartType = (
series,
seriesOverrides,
dataset,
themeColors
themeColors,
),
legend: {
show: false,
Expand All @@ -332,7 +336,7 @@ const getCommonBaseOptionsForChartType = (
series,
seriesOverrides,
dataset,
themeColors
themeColors,
),
legend: {
show: false,
Expand All @@ -349,7 +353,7 @@ const getCommonBaseOptionsForChartType = (
const getOptionOverridesForChartType = (
type: ChartType = "column",
properties: ChartProperties | undefined,
shouldBeTimeSeries: boolean
shouldBeTimeSeries: boolean,
) => {
if (!properties) {
return {};
Expand Down Expand Up @@ -536,7 +540,7 @@ const getSeriesForChartType = (
transform: ChartTransform,
shouldBeTimeSeries: boolean,
themeColors,
dataset
dataset,
) => {
if (!data) {
return [];
Expand All @@ -551,17 +555,20 @@ const getSeriesForChartType = (
? rowSeriesLabels
: data.columns
.slice(1)
.filter((col) => col.name !== "_diff")
.filter((col) => col.name !== "__diff")
.map((col) => col.name);
const seriesNamesWithoutDiffColumns = seriesNames.filter(
(s) => !isDiffColumn(s)
(s) => !isDiffColumn(s),
);
const seriesLength = seriesNames.length;
const hasDiffCol = !!data.columns.find((col) => col.name === "_diff");
const hasDiffCol = !!data.columns.find((col) => col.name === "__diff");

console.log({ data, hasDiffCol });

for (let seriesIndex = 0; seriesIndex < seriesLength; seriesIndex++) {
let seriesName = seriesNames[seriesIndex];
const diff = parseDiffColumn(seriesName);
console.log(diff);
let seriesColor = "auto";
const seriesMapSettings = {
index: seriesIndex,
Expand Down Expand Up @@ -636,6 +643,8 @@ const getSeriesForChartType = (
// Set base color
const baseColor = seriesMapSettings.color;

console.log(seriesMapSettings);

// Define the colors
const lightColor = lightenColor(baseColor, 0.3);
// const darkColor = darkenColor(baseColor, 0.2);
Expand Down Expand Up @@ -896,7 +905,7 @@ function lightenColor(color, amount) {
return rgbToHex(
Math.min(255, r + amount * 255),
Math.min(255, g + amount * 255),
Math.min(255, b + amount * 255)
Math.min(255, b + amount * 255),
);
}

Expand All @@ -905,7 +914,7 @@ function darkenColor(color, amount) {
return rgbToHex(
Math.max(0, r - amount * 255),
Math.max(0, g - amount * 255),
Math.max(0, b - amount * 255)
Math.max(0, b - amount * 255),
);
}

Expand All @@ -920,7 +929,7 @@ function rgbToHex(r, g, b) {

const adjustGridConfig = (
config: EChartsOption,
properties: ChartProperties | undefined
properties: ChartProperties | undefined,
) => {
let newConfig = { ...config };
if (!!newConfig?.xAxis?.name) {
Expand Down Expand Up @@ -953,23 +962,78 @@ const adjustGridConfig = (
return newConfig;
};

const injectDiffColumns = (data: LeafNodeData) => {
const diffSeriesToAdd = {};
let newColumns = [...data.columns];
for (const row of data.rows) {
const keys = Object.keys(row);
for (const key of keys) {
if (key === "__diff" || key.endsWith("_diff") || !!diffSeriesToAdd[key]) {
continue;
}
const diff = tableRowDiffColumn(row, key);
if (
diff.hasDiffColumn &&
!data.columns.find((c) => c.name === `${key}_diff`)
) {
diffSeriesToAdd[`${key}_diff`] = key;
}

// if (hasDiffCol(key)) const series = seriesWithDiffs[key] || [];
// series.push(row[key]);
// seriesWithDiffs[key] = series;
}
}

console.log(diffSeriesToAdd);

const diffCol = newColumns.find((c) => c.name === "__diff");
for (const diffSeries of Object.keys(diffSeriesToAdd)) {
const matchingColumnIndex = newColumns.findIndex(
(c) => c.name === diffSeriesToAdd[diffSeries],
);
const matchingColumn = newColumns.find(
(c) => c.name === diffSeriesToAdd[diffSeries],
);
if (!matchingColumn) {
continue;
}
newColumns = [
...newColumns.slice(0, matchingColumnIndex),
{ ...matchingColumn, name: `${matchingColumn.name}_diff` },
matchingColumn,
...newColumns.slice(matchingColumnIndex + 1),
];
}

if (!diffCol) {
newColumns = [...newColumns, { name: "__diff" }];
}

return { columns: newColumns, rows: data.rows };
};

const buildChartOptions = (props: ChartProps, themeColors: any) => {
const updatedData = injectDiffColumns(props.data);
// props.data = updatedData;

const { dataset, rowSeriesLabels, transform } = buildChartDataset(
props.data,
props.properties
updatedData,
props.properties,
);
console.log({ updatedData, dataset });
const treatAsTimeSeries = ["timestamp", "timestamptz", "date"].includes(
props.data?.columns[0].data_type.toLowerCase() || ""
updatedData?.columns[0].data_type.toLowerCase() || "",
);
const series = getSeriesForChartType(
props.display_type || "column",
props.data,
updatedData,
props.properties,
rowSeriesLabels,
transform,
treatAsTimeSeries,
themeColors,
dataset
dataset,
);
const config = merge(
getCommonBaseOptions(),
Expand All @@ -980,19 +1044,19 @@ const buildChartOptions = (props: ChartProps, themeColors: any) => {
treatAsTimeSeries,
series,
props.properties?.series,
themeColors
themeColors,
),
getOptionOverridesForChartType(
props.display_type || "column",
props.properties,
treatAsTimeSeries
treatAsTimeSeries,
),
{ series },
{
dataset: {
source: dataset,
},
}
},
);
return adjustGridConfig(config, props.properties);
};
Expand All @@ -1007,7 +1071,7 @@ const handleClick = async (
params: any,
navigate,
renderTemplates,
searchPathPrefix
searchPathPrefix,
) => {
const componentType = params.componentType;
if (componentType !== "series") {
Expand All @@ -1022,12 +1086,12 @@ const handleClick = async (
}
const renderedResults = await renderTemplates(
{ graph_node: params.data.href as string },
[params.data]
[params.data],
);
let rowRenderResult = renderedResults[0];
const withSearchPathPrefix = injectSearchPathPrefix(
rowRenderResult.graph_node.result,
searchPathPrefix
searchPathPrefix,
);
navigate(withSearchPathPrefix);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,6 @@ SingleSeriesDiff.args = {
data: {
columns: [
{ name: "Type", data_type: "TEXT" },
{ name: "_diff", data_type: "INT8" },
{ name: "Count_diff", data_type: "INT8" },
{ name: "Count", data_type: "INT8" },
],
rows: [
Expand All @@ -336,7 +334,7 @@ MultiSeriesStackedWithDiff.args = {
data: {
columns: [
{ name: "Country", data_type: "TEXT" },
{ name: "_diff", data_type: "TEXT" },
{ name: "__diff", data_type: "TEXT" },
{ name: "Men", data_type: "INT8" },
{ name: "Men_diff", data_type: "INT8" },
{ name: "Women", data_type: "INT8" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ SingleSeriesDiff.args = {
data: {
columns: [
{ name: "Type", data_type: "TEXT" },
{ name: "_diff", data_type: "INT8" },
{ name: "__diff", data_type: "INT8" },
{ name: "Count_diff", data_type: "INT8" },
{ name: "Count", data_type: "INT8" },
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ SingleSeriesDiff.args = {
data: {
columns: [
{ name: "Type", data_type: "TEXT" },
{ name: "_diff", data_type: "INT8" },
{ name: "__diff", data_type: "INT8" },
{ name: "Count_diff", data_type: "INT8" },
{ name: "Count", data_type: "INT8" },
],
Expand Down
Loading