Skip to content

Commit 6277360

Browse files
authored
vis: deduplicate node radius options (#1643)
1 parent 3718211 commit 6277360

File tree

6 files changed

+45
-45
lines changed

6 files changed

+45
-45
lines changed

packages/ott-vis-panel/src/components/CorePanel.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ const CoreData: React.FC<Props> = ({ options, data, width, height }) => {
7474
height={height}
7575
width={width}
7676
systemState={systemState}
77+
{...options.nodes}
7778
{...options.tree}
7879
/>
7980
);
@@ -83,13 +84,14 @@ const CoreData: React.FC<Props> = ({ options, data, width, height }) => {
8384
height={height}
8485
width={width}
8586
systemState={systemState}
87+
{...options.nodes}
8688
{...options.topology}
8789
/>
8890
);
8991
} else {
9092
return <div>Invalid view</div>;
9193
}
92-
}, [options.view, options.tree, options.topology, height, width, systemState]);
94+
}, [options.view, options.nodes, options.tree, options.topology, height, width, systemState]);
9395

9496
const [readEvents, setReadEvents] = useState(0);
9597

packages/ott-vis-panel/src/components/TreeDisplay.tsx

+2-4
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,18 @@ import {
1313
} from "treeutils";
1414
import { useD3Zoom } from "chartutils";
1515
import { dedupeMonoliths } from "aggregate";
16+
import type { NodeRadiusOptions } from "types";
1617

1718
interface TreeDisplayProps extends TreeDisplayStyleProps {
1819
systemState: SystemState;
1920
width: number;
2021
height: number;
2122
}
2223

23-
export interface TreeDisplayStyleProps {
24+
export interface TreeDisplayStyleProps extends NodeRadiusOptions {
2425
horizontal?: boolean;
2526
b2mLinkStyle?: "smooth" | "step";
2627
b2mSpacing?: number;
27-
baseNodeRadius?: number;
28-
balancerNodeRadius?: number;
29-
clientNodeRadius?: number;
3028
balancerGroupStyle?: "stacked" | "region-packed";
3129
}
3230

packages/ott-vis-panel/src/components/views/TopologyView.tsx

+6-4
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,15 @@ import { useColorProvider } from "colors";
1919
import { useD3Zoom } from "chartutils";
2020
import { dedupeItems } from "aggregate";
2121
import { useEventBus, type BusEvent } from "eventbus";
22+
import type { NodeRadiusOptions } from "types";
2223

2324
interface TopologyViewProps extends TopologyViewStyleProps {
2425
systemState: SystemState;
2526
width: number;
2627
height: number;
2728
}
2829

29-
export interface TopologyViewStyleProps {
30-
baseNodeRadius: number;
31-
clientNodeRadius: number;
30+
export interface TopologyViewStyleProps extends NodeRadiusOptions {
3231
subtreePadding: number;
3332
}
3433

@@ -68,6 +67,7 @@ export const TopologyView: React.FC<TopologyViewProps> = ({
6867
width,
6968
height,
7069
baseNodeRadius = 20,
70+
balancerNodeRadius = 20,
7171
clientNodeRadius = 8,
7272
subtreePadding = 60,
7373
}) => {
@@ -87,11 +87,13 @@ export const TopologyView: React.FC<TopologyViewProps> = ({
8787
(group: string): number => {
8888
if (group === "client") {
8989
return clientNodeRadius;
90+
} else if (group === "balancer") {
91+
return balancerNodeRadius;
9092
} else {
9193
return baseNodeRadius;
9294
}
9395
},
94-
[baseNodeRadius, clientNodeRadius]
96+
[baseNodeRadius, balancerNodeRadius, clientNodeRadius]
9597
);
9698

9799
useEffect(() => {

packages/ott-vis-panel/src/module.ts

+21-35
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,27 @@ export const plugin = new PanelPlugin<CoreOptions>(CorePanel).setPanelOptions(bu
3535
name: "Use Sample Data",
3636
description: "Use sample data instead of querying the datasource",
3737
})
38+
.addNumberInput({
39+
path: "nodes.baseNodeRadius",
40+
name: "Base Node Radius",
41+
description: "Set the radius of the nodes.",
42+
defaultValue: 20,
43+
showIf: config => config.view === "tree" || config.view === "topology",
44+
})
45+
.addNumberInput({
46+
path: "nodes.balancerNodeRadius",
47+
name: "Balancer Node Radius",
48+
description: "Set the radius of the balancer nodes",
49+
defaultValue: 30,
50+
showIf: config => config.view === "tree" || config.view === "topology",
51+
})
52+
.addNumberInput({
53+
path: "nodes.clientNodeRadius",
54+
name: "Client Node Radius",
55+
description: "Set the radius of the client nodes",
56+
defaultValue: 8,
57+
showIf: config => config.view === "tree" || config.view === "topology",
58+
})
3859
.addBooleanSwitch({
3960
path: "tree.horizontal",
4061
name: "Horizontal",
@@ -67,41 +88,6 @@ export const plugin = new PanelPlugin<CoreOptions>(CorePanel).setPanelOptions(bu
6788
defaultValue: 300,
6889
showIf: config => config.view === "tree",
6990
})
70-
.addNumberInput({
71-
path: "tree.baseNodeRadius",
72-
name: "Base Node Radius",
73-
description: "Set the radius of the nodes in the tree view",
74-
defaultValue: 20,
75-
showIf: config => config.view === "tree",
76-
})
77-
.addNumberInput({
78-
path: "topology.baseNodeRadius",
79-
name: "Base Node Radius",
80-
description: "Set the radius of the nodes in the topology view",
81-
defaultValue: 20,
82-
showIf: config => config.view === "topology",
83-
})
84-
.addNumberInput({
85-
path: "tree.balancerNodeRadius",
86-
name: "Tree Balancer Node Radius",
87-
description: "Set the radius of the balancer nodes in the tree view",
88-
defaultValue: 30,
89-
showIf: config => config.view === "tree",
90-
})
91-
.addNumberInput({
92-
path: "tree.clientNodeRadius",
93-
name: "Client Node Radius",
94-
description: "Set the radius of the client nodes in the tree view",
95-
defaultValue: 8,
96-
showIf: config => config.view === "tree",
97-
})
98-
.addNumberInput({
99-
path: "topology.clientNodeRadius",
100-
name: "Client Node Radius",
101-
description: "Set the radius of the client nodes in the topology view",
102-
defaultValue: 8,
103-
showIf: config => config.view === "topology",
104-
})
10591
.addSelect({
10692
path: "tree.balancerGroupStyle",
10793
name: "Tree Balancer Group Style",

packages/ott-vis-panel/src/types.ts

+7
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,11 @@ export interface CoreOptions {
77

88
tree: TreeDisplayStyleProps;
99
topology: TopologyViewStyleProps;
10+
nodes: NodeRadiusOptions;
11+
}
12+
13+
export interface NodeRadiusOptions {
14+
baseNodeRadius?: number;
15+
balancerNodeRadius?: number;
16+
clientNodeRadius?: number;
1017
}

packages/ott-vis/provisioning/dashboards/topology-dash.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434
},
3535
"id": 1,
3636
"options": {
37+
"nodes": {
38+
"balancerNodeRadius": 20,
39+
"baseNodeRadius": 20,
40+
"clientNodeRadius": 8
41+
},
3742
"topology": {
3843
"baseNodeRadius": 20,
3944
"clientNodeRadius": 8
@@ -85,6 +90,6 @@
8590
"timezone": "",
8691
"title": "Just TopologyView",
8792
"uid": "e3771ad0-95f0-4be2-932d-259323694d10",
88-
"version": 3,
93+
"version": 16,
8994
"weekStart": ""
9095
}

0 commit comments

Comments
 (0)